If it is too complicated now to separate the x,y pairs into separate Polygons based on their id, put all of the x,y points into one Polygon object. Change the loop in the paintComponent() method...
Type: Posts; User: Norm
If it is too complicated now to separate the x,y pairs into separate Polygons based on their id, put all of the x,y points into one Polygon object. Change the loop in the paintComponent() method...
Please explain.
What variable contains a reference to the collection?
What do you mean by "save"? Write it to disk file or put it into a database?
You need an int variable that keeps track of the id of the POINTS. It should start at 1 to match the id of the first POINTS in the POLYGON collection.
When the value returned by the getID() method changes.
The x an y arrays should be defined the same size as the POLYGON collection.This is copied from your code:
int n = POLYGON.size() ;
int[] x = new int[n];
int[] y = new int[n];
Now look at...
Outside the loop: Define two arrays for the x and y values and an index to use with them.
Inside the loop: assign the current POINT's x and y values in the arrays and increment the index:
x[index]...
I suggested a technique in post#15. Try to do the steps listed there one at a time.
I've shown the first step. Now work on the second, third, etc
The posted code does NOT follow the steps listed in post #15.
The first step was: Define array to hold Polygons
The code to do that was shown in post #17.
In the code in post #22, the array is...
Which step(s) are you having problems with?
Post the new code you have
and post the questions you have about the listed steps.
Many of the steps the program needs to do were listed in post#15
I just posted pseudo code for one way to solve your problem.
Look at the lines of pseudo code, one at a time and if you don't understand how to do that step, please ask a question about that step....
What are the steps to make 4 Polygons from the points contained in the POLYGON container?
Here is one way it could be done:
Define array to hold Polygons
Initialize ptr to the above array to 0...
What line did the error happen on?
Before trying to write any more code, you need to stop and do some design work on what the code needs to do. The posted code does not do what I think the...
How many points are there for each polygon? How do you find those points in the POLYGON collection? Count them as they are added to the arrays used to build the Polygon object and use that count...
Please explain what the problem is.
Where does the code call the drawPolygon() method to draw a polygon?
There are two versions of the method. You need to write some code that uses one of them...
Where is the call to the draw method for drawing the polygon?
If you want to draw 4 different polygons, where are the 4 containers that hold the points for the polygons? It looks like all the...
What happens if you call drawPolygon() for each polygon you want drawn?
I only see one call to drawPolygon() in the posted code. Because of the poor formatting I can't tell if there are any loops. ...
Can you explain the problem you are having?
If you are getting any errors, please copy the full text and paste it here.
Please Edit your post and wrap your code with
<YOUR CODE HERE>
to...