站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

EqualPolygon (Tab Control) - NetBeans API Javadoc (Current Development Version)

org.netbeans.swing.tabcontrol 1.8

org.netbeans.swing.tabcontrol.plaf
Class EqualPolygon

java.lang.Object
  extended by java.awt.Polygon
      extended by org.netbeans.swing.tabcontrol.plaf.EqualPolygon
All Implemented Interfaces:
Shape, Serializable

public final class EqualPolygon
extends Polygon

A Polygon which implements a proper equals/hashcode contract. In order to optimize drag and drop repainting, it is necessary that the Shape objects returned by getTabIndication() be able to be compared properly.

To ease migration of older code, this class also implements a couple methods of GeneralPath, which was used before. These methods just delegate to addPoint(), so the full functionality of GeneralPath is not replicated (specifically, a polygon must be contiguous and closed).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Polygon
bounds, npoints, xpoints, ypoints
 
Constructor Summary
EqualPolygon()
          Creates a new instance of EqualGeneralPath
EqualPolygon(int[] x, int[] y)
          Non copy constructor based on fixed arrays.
EqualPolygon(int[] x, int[] y, int n)
          Copy constructor will copy the xpoints/ypoints arrays so the caller can later modify them without changing the polygon constructor here.
EqualPolygon(Polygon p)
          Copy constructor - takes either another EqualPolygon or a Polygon.
EqualPolygon(Rectangle r)
          Convenience constructor which takes a Rectangle
 
Method Summary
 Object clone()
          Creates a new EqualPolygon using the copy constructor - the resulting polygon may be modified without affecting the original.
 boolean equals(Object o)
          Returns true if the argument is a Polygon (does not need to be EqualPolygon) and its point arrays and number of points matches.
 int hashCode()
          Computes a hashCode based on the points arrays.
 void lineTo(int x, int y)
          Delegates to Polygon.addPoint().
 void moveTo(int x, int y)
          Delegates to Polygon.addPoint().
 String toString()
          Overridden to produce a meaningful result.
 
Methods inherited from class java.awt.Polygon
addPoint, contains, contains, contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, invalidate, reset, translate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EqualPolygon

public EqualPolygon()
Creates a new instance of EqualGeneralPath


EqualPolygon

public EqualPolygon(int[] x,
                    int[] y,
                    int n)
Copy constructor will copy the xpoints/ypoints arrays so the caller can later modify them without changing the polygon constructor here.


EqualPolygon

public EqualPolygon(Polygon p)
Copy constructor - takes either another EqualPolygon or a Polygon. Copies the points arrays of the original polygon, so the passed polygon may be modified without affecting the instance constructed here.

Parameters:
p -

EqualPolygon

public EqualPolygon(Rectangle r)
Convenience constructor which takes a Rectangle


EqualPolygon

public EqualPolygon(int[] x,
                    int[] y)
Non copy constructor based on fixed arrays. Takes the point count parameter fromx.length.

Method Detail

moveTo

public void moveTo(int x,
                   int y)
Delegates to Polygon.addPoint().

Parameters:
x - x coordinate
y - y coordinate

lineTo

public void lineTo(int x,
                   int y)
Delegates to Polygon.addPoint().

Parameters:
x - x coordinate
y - y coordinate

clone

public Object clone()
Creates a new EqualPolygon using the copy constructor - the resulting polygon may be modified without affecting the original.

Overrides:
clone in class Object
Returns:
A new instance of EqualPolygon with the same point values

toString

public String toString()
Overridden to produce a meaningful result.

Overrides:
toString in class Object
Returns:
A string representation of the EqualPolygon

hashCode

public int hashCode()
Computes a hashCode based on the points arrays.

Overrides:
hashCode in class Object
Returns:
The hash code

equals

public boolean equals(Object o)
Returns true if the argument is a Polygon (does not need to be EqualPolygon) and its point arrays and number of points matches.

Overrides:
equals in class Object
Parameters:
o - Another polygon
Returns:
whether or not they are equal

org.netbeans.swing.tabcontrol 1.8

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.