public class Polygon2d extends java.lang.Object implements Renderable
TRANSLUCENT, TWO_DIMENSIONAL
Constructor and Description |
---|
Polygon2d() |
Polygon2d(double[] coords) |
Polygon2d(Point2d[] pnts) |
Modifier and Type | Method and Description |
---|---|
Vertex2d |
addVertex(double x,
double y) |
void |
appendVertex(Vertex2d vtx) |
void |
clear() |
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
boolean |
epsilonEquals(Polygon2d poly,
double eps)
Returns true if this polygon is equal to another polygon within a
prescribed tolerance eps.
|
boolean |
equals(Polygon2d poly)
Returns true if this polygon is equal to another polygon.
|
void |
getBounds(Point2d minValues,
Point2d maxValues) |
void |
getCentroid(Point2d pnt) |
Vertex2d |
getFirstVertex() |
Vertex2d |
getLastVertex() |
double |
getMaxCoordinate() |
int |
getRenderHints()
Returns a bit code giving rendering hints about this renderable.
|
RenderProps |
getRenderProps()
Returns the render properities for this object.
|
void |
getSelection(java.util.LinkedList<java.lang.Object> list,
int qid)
Append to
list the component (or components) associated with
the qid -th selection query issued by this component's render
method. |
java.util.ListIterator |
getVertices() |
void |
inverseTransform(AffineTransform2dBase X)
Applies an inverse affine transformation to the vertices of this polygon.
|
boolean |
isConsistent() |
boolean |
isEmpty() |
boolean |
isSelectable()
Returns true if this object is in fact selectable.
|
int |
numSelectionQueriesNeeded()
If this selectable manages its own selection (by issuing selection
queries within its
render method), then this method should
return the maximum number of selection queries that will be
required. |
int |
numVertices() |
void |
prependVertex(Vertex2d vtx) |
void |
prerender(RenderList list)
Prepare for rendering, and potentially add itself to a list to be drawn
by a GLRenderer.
|
void |
render(GLRenderer renderer,
int flags)
Render this object using Open GL via the JOGL.
|
void |
render(GLRenderer renderer,
RenderProps props,
int flags) |
void |
scan(ReaderTokenizer rtok) |
void |
set(double[] coords,
int numVertices) |
void |
set(Point2d[] pnts,
int numVertices) |
void |
set(Polygon2d poly) |
void |
setRenderProps(RenderProps props)
Assigns a new set of render properties to this object.
|
void |
shiftVertices(int n) |
java.lang.String |
toString() |
java.lang.String |
toString(NumberFormat fmt) |
java.lang.String |
toString(java.lang.String fmtStr) |
void |
transform(AffineTransform2dBase X)
Applies a affine transformation to the vertices of this polygon.
|
void |
updateBounds(Point2d minValues,
Point2d maxValues) |
void |
updateBounds(Point3d pmin,
Point3d pmax)
Update the minimum and maximum points for this object.
|
public Polygon2d()
public Polygon2d(double[] coords)
public Polygon2d(Point2d[] pnts)
public java.util.ListIterator getVertices()
public int numVertices()
public double getMaxCoordinate()
public Vertex2d addVertex(double x, double y)
public void appendVertex(Vertex2d vtx)
public void prependVertex(Vertex2d vtx)
public boolean isEmpty()
public Vertex2d getLastVertex()
public Vertex2d getFirstVertex()
public void clear()
public void getCentroid(Point2d pnt)
public void set(Polygon2d poly)
public void set(double[] coords, int numVertices)
public void set(Point2d[] pnts, int numVertices)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String fmtStr)
public java.lang.String toString(NumberFormat fmt)
public void scan(ReaderTokenizer rtok) throws java.io.IOException
java.io.IOException
public boolean epsilonEquals(Polygon2d poly, double eps)
poly
- polygon to be compared witheps
- tolerance valueepsilonEquals(maspack.geometry.Polygon2d, double)
public boolean equals(Polygon2d poly)
poly
- polygon to be compared withepsilonEquals(maspack.geometry.Polygon2d, double)
public void shiftVertices(int n)
public boolean isConsistent()
public void transform(AffineTransform2dBase X)
X
- affine transformationpublic void inverseTransform(AffineTransform2dBase X)
X
- affine transformationpublic void prerender(RenderList list)
GLRenderable
prerender
in interface GLRenderable
public void updateBounds(Point3d pmin, Point3d pmax)
GLRenderable
updateBounds
in interface GLRenderable
pmin
- minimum pointpmax
- maximum pointpublic void render(GLRenderer renderer, int flags)
GLRenderable
render
in interface GLRenderable
renderer
- renderer object which is used to perform the rendering. Provides pointers
to GL and GLU, along with helper functions.flags
- supplies flags that may be used to control different
aspects of the rendering. Flags are defined in GLRenderer
and currently include
GLRenderer.SELECTED
,
GLRenderer.VERTEX_COLORING
,
GLRenderer.HSV_COLOR_INTERPOLATION
,
GLRenderer.SORT_FACES
, and
GLRenderer.CLEAR_MESH_DISPLAY_LISTS
.public void render(GLRenderer renderer, RenderProps props, int flags)
public int getRenderHints()
GLRenderable
TRANSLUCENT
.getRenderHints
in interface GLRenderable
public RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
public void setRenderProps(RenderProps props)
HasRenderProps
null
will remove render properties from this object.setRenderProps
in interface HasRenderProps
props
- new render properties for this objectpublic RenderProps getRenderProps()
HasRenderProps
getRenderProps
in interface HasRenderProps
public boolean isSelectable()
GLSelectable
isSelectable
in interface GLSelectable
public int numSelectionQueriesNeeded()
GLSelectable
render
method), then this method should
return the maximum number of selection queries that will be
required. Otherwise, this method should return -1.numSelectionQueriesNeeded
in interface GLSelectable
public void getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
GLSelectable
list
the component (or components) associated with
the qid
-th selection query issued by this component's render
method. This will only be called if this component manages its own
selection (i.e., the number nums
returned by GLSelectable.numSelectionQueriesNeeded()
is positive), and qid
will in
turn be a number between 0 and nums
-1.getSelection
in interface GLSelectable
list
- selected objects are appended to the end of this listqid
- index of the selection query