Java GUI programming strategy?

Java for beginners.

Hi, I do not have much experience in GUI programming. So, I'm after a few tips on how to tackle this next project. I hope I can explain myself well enough.

plan
(source: mobilehomeservicesltd.com )

(see photo above as a reference) This GUI aspect of my program will be a two-dimensional bird's-eye view of a static caravan and a veranda / balcony made with basic shapes. Therefore, as a rule, the caravan will be represented by a rectangle (just a rectangle, ignore the completed diagram). Sometimes static caravans have shaped facades, which will be represented by a polygon, rather than a straight rectangular one. Everything on a scale depends on user input, since all caravans have their own individual dimensions.

After the caravan part is in place, I need to draw another polyangular window surrounding the caravan, representing the balcony / veranda, all on a scale. Understand yet ?? Good. Here comes part of the problem (for me anyway).

On the polyangular window representing the balcony, I should be able to draw lines to represent the flooring that will be nailed as a surface (as in the diagram above). Now, since the caravan can have a shaped facade, the flooring must match the shape of the caravan. In other words, if the caravan has an oval or angled front, the flooring must be trimmed to follow this shape.

Don't get bored with too much detail. The idea is to allow the user to decide whether they want to install the flooring so that it moves in the same direction as the caravan, or against it. As soon as the user decides, I will try to calculate from the drawing (how this will be done on a scale) how many full slabs will be needed to create this veranda (among other elements).

Now my knowledge is limited in the graphical interface, but I have to deal with panels and drawing lines, rectangles, multi-angles, etc. My original idea was to manually draw a caravan using the g.drawLine method, the same with the veranda, and then my calculations are based on pixel counting to calculate all the different components.

Am I struggling to do this, or is it something relatively easy to program? Is there a better way to do this that I should look before trying this?

+4
source share
1 answer

What you want to do is achievable, but this is not an easy task. But don't let this slow you down.

You need to start by understanding how to draw in Swing. Take a look at

You will also want to get to know Swing in general.

The basic concept with scaling is assigning weight to a pixel. The larger the distance the pixel is responsible for, the smaller your image will become

+6
source

Source: https://habr.com/ru/post/1435504/


All Articles