Java Doc for Polygon.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.Polygon

Polygon
public class Polygon implements Shape,java.io.Serializable(Code)
The Polygon class encapsulates a description of a closed, two-dimensional region within a coordinate space. This region is bounded by an arbitrary number of line segments, each of which is one side of the polygon. Internally, a polygon comprises of a list of (x,y) coordinate pairs, where each pair defines a vertex of the polygon, and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of (x,y) points are joined by a line segment that closes the polygon. This Polygon is defined with an even-odd winding rule. See java.awt.geom.PathIterator.WIND_EVEN_ODD WIND_EVEN_ODD for a definition of the even-odd winding rule. This class's hit-testing methods, which include the contains, intersects and inside methods, use the insideness definition described in the Shape class comments.
version:
   1.26, 07/24/98
author:
   Sami Shaio
See Also:   Shape
author:
   Herb Jellinek
since:
   1.0

Inner Class :class PolygonPathIterator implements PathIterator

Field Summary
protected  Rectanglebounds
     The bounds of this Polygon .
public  intnpoints
     The total number of points.
public  intxpoints
     The array of X coordinates.
public  intypoints
     The array of Y coordinates.

Constructor Summary
public  Polygon()
     Creates an empty polygon.
public  Polygon(int xpoints, int ypoints, int npoints)
     Constructs and initializes a Polygon from the specified parameters.

Method Summary
public  voidaddPoint(int x, int y)
     Appends the specified coordinates to this Polygon.
 voidcalculateBounds(int xpoints, int ypoints, int npoints)
    
public  booleancontains(Point p)
     Determines whether the specified Point is inside this Polygon.
public  booleancontains(int x, int y)
     Determines whether the specified coordinates are inside this Polygon.
public  booleancontains(double x, double y)
    
public  booleancontains(Point2D p)
    
public  booleancontains(double x, double y, double w, double h)
    
public  booleancontains(Rectangle2D r)
    
public  RectanglegetBoundingBox()
     Returns the bounds of this Polygon.
public  RectanglegetBounds()
     Gets the bounding box of this Polygon.
public  Rectangle2DgetBounds2D()
    
public  PathIteratorgetPathIterator(AffineTransform at)
     Returns an iterator object that iterates along the boundary of this Polygon and provides access to the geometry of the outline of this Polygon.
public  PathIteratorgetPathIterator(AffineTransform at, double flatness)
     Returns an iterator object that iterates along the boundary of the Shape and provides access to the geometry of the outline of the Shape.
public  booleaninside(int x, int y)
     Determines whether the specified coordinates are contained in this Polygon.
public  booleanintersects(double x, double y, double w, double h)
    
public  booleanintersects(Rectangle2D r)
    
public  voidinvalidate()
     Invalidates or flushes any internally-cached data that depends on the vertex coordinates of this Polygon.
public  voidreset()
     Resets this Polygon object to an empty polygon.
public  voidtranslate(int deltaX, int deltaY)
     Translates the vertices of the Polygon by deltaX along the x axis and by deltaY along the y axis.
 voidupdateBounds(int x, int y)
    

Field Detail
bounds
protected Rectangle bounds(Code)
The bounds of this Polygon . This value can be null.
See Also:   Polygon.getBoundingBox()
See Also:   Polygon.getBounds()
since:
   1.0



npoints
public int npoints(Code)
The total number of points. The value of npoints represents the number of valid points in this Polygon and might be less than the number of elements in Polygon.xpoints xpoints or Polygon.ypoints ypoints . This value can be NULL.
See Also:   Polygon.addPoint(int,int)
since:
   1.0



xpoints
public int xpoints(Code)
The array of X coordinates. The number of elements in this array might be more than the number of X coordinates in this Polygon. The extra elements allow new points to be added to this Polygon without re-creating this array. The value of Polygon.npoints npoints is equal to the number of valid points in this Polygon.
See Also:   Polygon.addPoint(int,int)
since:
   1.0



ypoints
public int ypoints(Code)
The array of Y coordinates. The number of elements in this array might be more than the number of Y coordinates in this Polygon. The extra elements allow new points to be added to this Polygon without re-creating this array. The value of npoints is equal to the number of valid points in this Polygon.
See Also:   Polygon.addPoint(int,int)
since:
   1.0




Constructor Detail
Polygon
public Polygon()(Code)
Creates an empty polygon.
since:
   1.0



Polygon
public Polygon(int xpoints, int ypoints, int npoints)(Code)
Constructs and initializes a Polygon from the specified parameters.
Parameters:
  xpoints - an array of X coordinates
Parameters:
  ypoints - an array of Y coordinates
Parameters:
  npoints - the total number of points in the Polygon
exception:
  NegativeArraySizeException - if the value ofnpoints is negative.
exception:
  IndexOutOfBoundsException - if npoints isgreater than the length of xpointsor the length of ypoints.
exception:
  NullPointerException - if xpoints orypoints is null.
since:
   1.0




Method Detail
addPoint
public void addPoint(int x, int y)(Code)
Appends the specified coordinates to this Polygon.

If an operation that calculates the bounding box of this Polygon has already been performed, such as getBounds or contains, then this method updates the bounding box.
Parameters:
  x - the specified X coordinate
Parameters:
  y - the specified Y coordinate
See Also:   java.awt.Polygon.getBounds
See Also:   java.awt.Polygon.contains
since:
   1.0




calculateBounds
void calculateBounds(int xpoints, int ypoints, int npoints)(Code)



contains
public boolean contains(Point p)(Code)
Determines whether the specified Point is inside this Polygon.
Parameters:
  p - the specified Point to be tested true if the Polygon contains thePoint; false otherwise.
See Also:   Polygon.contains(double,double)
since:
   1.0



contains
public boolean contains(int x, int y)(Code)
Determines whether the specified coordinates are inside this Polygon.


Parameters:
  x - the specified X coordinate to be tested
Parameters:
  y - the specified Y coordinate to be tested true if this Polygon containsthe specified coordinates (x,y) ; false otherwise.
See Also:   Polygon.contains(double,double)
since:
   1.1




contains
public boolean contains(double x, double y)(Code)

since:
   1.2



contains
public boolean contains(Point2D p)(Code)

since:
   1.2



contains
public boolean contains(double x, double y, double w, double h)(Code)

since:
   1.2



contains
public boolean contains(Rectangle2D r)(Code)

since:
   1.2



getBoundingBox
public Rectangle getBoundingBox()(Code)
Returns the bounds of this Polygon. the bounds of this Polygon.
since:
   1.0



getBounds
public Rectangle getBounds()(Code)
Gets the bounding box of this Polygon. The bounding box is the smallest Rectangle whose sides are parallel to the x and y axes of the coordinate space, and can completely contain the Polygon. a Rectangle that defines the bounds of this Polygon.
since:
   1.1



getBounds2D
public Rectangle2D getBounds2D()(Code)

since:
   1.2



getPathIterator
public PathIterator getPathIterator(AffineTransform at)(Code)
Returns an iterator object that iterates along the boundary of this Polygon and provides access to the geometry of the outline of this Polygon. An optional AffineTransform can be specified so that the coordinates returned in the iteration are transformed accordingly.
Parameters:
  at - an optional AffineTransform to be applied to thecoordinates as they are returned in the iteration, or null if untransformed coordinates are desired a PathIterator object that provides access to thegeometry of this Polygon.
since:
   1.2



getPathIterator
public PathIterator getPathIterator(AffineTransform at, double flatness)(Code)
Returns an iterator object that iterates along the boundary of the Shape and provides access to the geometry of the outline of the Shape. Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator. Since polygons are already flat, the flatness parameter is ignored. An optional AffineTransform can be specified in which case the coordinates returned in the iteration are transformed accordingly.
Parameters:
  at - an optional AffineTransform to be applied to thecoordinates as they are returned in the iteration, or null if untransformed coordinates are desired
Parameters:
  flatness - the maximum amount that the control pointsfor a given curve can vary from colinear before a subdividedcurve is replaced by a straight line connecting the endpoints. Since polygons are already flat theflatness parameter is ignored. a PathIterator object that provides access to theShape object's geometry.
since:
   1.2



inside
public boolean inside(int x, int y)(Code)
Determines whether the specified coordinates are contained in this Polygon.
Parameters:
  x - the specified X coordinate to be tested
Parameters:
  y - the specified Y coordinate to be tested true if this Polygon containsthe specified coordinates (x,y) ; false otherwise.
See Also:   Polygon.contains(double,double)
since:
   1.0



intersects
public boolean intersects(double x, double y, double w, double h)(Code)

since:
   1.2



intersects
public boolean intersects(Rectangle2D r)(Code)

since:
   1.2



invalidate
public void invalidate()(Code)
Invalidates or flushes any internally-cached data that depends on the vertex coordinates of this Polygon. This method should be called after any direct manipulation of the coordinates in the xpoints or ypoints arrays to avoid inconsistent results from methods such as getBounds or contains that might cache data from earlier computations relating to the vertex coordinates.
See Also:   java.awt.Polygon.getBounds
since:
   1.4



reset
public void reset()(Code)
Resets this Polygon object to an empty polygon. The coordinate arrays and the data in them are left untouched but the number of points is reset to zero to mark the old vertex data as invalid and to start accumulating new vertex data at the beginning. All internally-cached data relating to the old vertices are discarded. Note that since the coordinate arrays from before the reset are reused, creating a new empty Polygon might be more memory efficient than resetting the current one if the number of vertices in the new polygon data is significantly smaller than the number of vertices in the data from before the reset.
See Also:   java.awt.Polygon.invalidate
since:
   1.4



translate
public void translate(int deltaX, int deltaY)(Code)
Translates the vertices of the Polygon by deltaX along the x axis and by deltaY along the y axis.
Parameters:
  deltaX - the amount to translate along the X axis
Parameters:
  deltaY - the amount to translate along the Y axis
since:
   1.1



updateBounds
void updateBounds(int x, int y)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.