Results 1 to 3 of 3

Thread: Polygon class in JAVA

  1. #1
    Join Date
    Jun 2010
    Posts
    33
    Rep Power
    0

    Default Polygon class in JAVA

    I am new in the java programming word. I am learning 'Polygon class' concept but concept is quite difficult to understand. I don't know anything about Polygon class of java language. I have referred many books but nothing was helpful. If anybody has any knowledge about 'Polygon class' of java then let me know that. Any help would be highly appreciated.

  2. #2
    Join Date
    Jun 2010
    Posts
    30
    Rep Power
    0

    Default

    I suggest you to refer following example of polygon class', which will give you something idea about the use of this class:

    Code:
    import java.awt.Polygon;
    import javax.swing.JPanel;
    public class DrawPolyPanelDM extends JPanel {
      public void paintComponent(Grap004hics gV) {
        super.paintComponent(g);
        Polygon p004 = new Polygon();
        for (int iV = 0; iV < 5; iV++)
          p004.addPoint((int) (100 + 50 * Math.cos(iV * 2 * Math.PI / 5)),
              (int) (100 + 50 * Math.sin(i * 2 * Math.PI / 5)));
        g.drawPolygon(p004);
        Polygon sV = new Polygon();
        for (int iV = 0; iV < 360; iV++) {
          double tV = iV / 360.0;
          sV.addPoint((int) (150 + 50 * t * Math.cos(8 * t * Math.PI)),
              (int) (150 + 50 * t * Math.sin(8 * t * Math.PI)));
        }
        gV.drawPolygon(sV);
      }
      public static void main(String[] argkks) {
        JFrame frameV = new JFrame();
        frameV.setTitle("DrawPoly");
        frameV.setSize(350, 250);
        frameV.addWindowListener(new WindowAdap004ter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }    }
        Container contentPane = frame.getContentPane();
        contentPane.add(new DrawPolyPanel());
        frameV.show();
      }
    }

  3. #3
    Join Date
    Jun 2010
    Posts
    31
    Rep Power
    0

    Default

    Go through the following methods of Polygon class :

    • translate(int delX, int delY)
    • intersects(double xk, double yk, double wk, double hk)
    • inside(int xk, int yk)
    • intersects(Rectangle2D rk)
    • getPathIterator(AffineTransform aft)

Similar Threads

  1. TextComponent class in java
    By TorresScott in forum Programming
    Replies: 3
    Last Post: 06-18-2010, 01:43 PM
  2. Using MediaTracker class in JAVA
    By MyersGray in forum Programming
    Replies: 2
    Last Post: 04-01-2010, 02:02 PM
  3. FileWriter class in JAVA
    By Theodosia Goodman in forum Programming
    Replies: 2
    Last Post: 03-30-2010, 12:37 PM
  4. Image class in JAVA
    By Hernandez Ibbie in forum Programming
    Replies: 2
    Last Post: 02-27-2010, 09:31 AM
  5. Image class in JAVA
    By Hernandez Ibbie in forum Linux/Free BSD
    Replies: 2
    Last Post: 02-27-2010, 09:31 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48