Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  2. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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?
  3. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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.
  4. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    When the value returned by the getID() method changes.
  5. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  6. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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]...
  7. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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
  8. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  9. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    Which step(s) are you having problems with?
    Post the new code you have
    and post the questions you have about the listed steps.
  10. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    Many of the steps the program needs to do were listed in post#15
  11. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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....
  12. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  13. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  14. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  15. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  16. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
  17. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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. ...
  18. Replies
    36
    Views
    2,703

    Re: draw 4 different polygons.

    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...
Results 1 to 18 of 18