Class ElementPolygon
java.lang.Object
org.opensourcephysics.display3d.simple3d.Element
org.opensourcephysics.display3d.simple3d.ElementPolygon
- All Implemented Interfaces:
Element
,ElementPolygon
,InteractionSource
Title: ElementPolygon
Description: A Polygon using the painter's algorithm
- Version:
- March 2005
- Author:
- Francisco Esquembre
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensourcephysics.display3d.core.ElementPolygon
ElementPolygon.ElementPolygonLoader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.opensourcephysics.display3d.simple3d.Object3D[]
protected org.opensourcephysics.display3d.simple3d.Object3D[]
Fields inherited from class org.opensourcephysics.display3d.simple3d.Element
targetPosition, targetSize
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]
getData()
Gets (a copy of) the data of the points for the polygonvoid
getExtrema
(double[] min, double[] max) static XML.ObjectLoader
Returns an XML.ObjectLoader to save and load object data.protected InteractionTarget
getTargetHit
(int x, int y) Gets the target that is under the (x,y) position of the screenboolean
isClosed()
Gets whether the polygon is closedvoid
setClosed
(boolean closed) Sets whether the polygon is closedvoid
setData
(double[][] data) Sets the data for the points of the polygon.void
setData
(double[] xArray, double[] yArray, double[] zArray) Sets the data for the points of the polygon.Methods inherited from class org.opensourcephysics.display3d.simple3d.Element
addInteractionListener, getAxesMode, getDrawingPanel3D, getHotSpotBodyCoordinates, getInteractionTarget, getName, getSizeX, getSizeY, getSizeZ, getStyle, getTransformation, getX, getY, getZ, isReallyVisible, isVisible, loadUnmutableObjects, removeInteractionListener, setName, setSizeX, setSizeXYZ, setSizeXYZ, setSizeY, setSizeZ, setTransformation, setVisible, setX, setXYZ, setXYZ, setY, setZ, toBodyFrame, toSpaceFrame
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display3d.core.Element
getDrawingPanel3D, getName, getSizeX, getSizeY, getSizeZ, getStyle, getTransformation, getX, getY, getZ, isVisible, loadUnmutableObjects, setName, setSizeX, setSizeXYZ, setSizeXYZ, setSizeY, setSizeZ, setTransformation, setVisible, setX, setXYZ, setXYZ, setY, setZ, toBodyFrame, toSpaceFrame
Methods inherited from interface org.opensourcephysics.display3d.core.interaction.InteractionSource
addInteractionListener, getInteractionTarget, removeInteractionListener
-
Field Details
-
lineObjects
protected org.opensourcephysics.display3d.simple3d.Object3D[] lineObjects -
closedObject
protected org.opensourcephysics.display3d.simple3d.Object3D[] closedObject
-
-
Constructor Details
-
ElementPolygon
public ElementPolygon()
-
-
Method Details
-
setClosed
public void setClosed(boolean closed) Description copied from interface:ElementPolygon
Sets whether the polygon is closed- Specified by:
setClosed
in interfaceElementPolygon
- Parameters:
closed
- boolean
-
isClosed
public boolean isClosed()Description copied from interface:ElementPolygon
Gets whether the polygon is closed- Specified by:
isClosed
in interfaceElementPolygon
- Returns:
- boolean
-
setData
public void setData(double[][] data) Sets the data for the points of the polygon. Each entry in the data array corresponds to one vertex. If the polygon is closed, the last point will be connected to the first one and the interior will be filled (unless the fill color of the style is set to null). The data array is copied, so subsequence changes to the original array do not affect the polygon, until this setData() methos is invoked.- Specified by:
setData
in interfaceElementPolygon
- Parameters:
data
- double[][] the double[nPoints][3] array with the data
-
setData
public void setData(double[] xArray, double[] yArray, double[] zArray) Description copied from interface:ElementPolygon
Sets the data for the points of the polygon. Each entry in the data array corresponds to one vertex. If the polygon is closed, the last point will be connected to the first one and the interior will be filled (unless the fill color of the style is set to null). The data array is copied, so subsequence changes to the original array do not affect the polygon, until the setData() method is invoked. If the arrays have different lengths, the last element of the shortest array is repeated to match the longest array.- Specified by:
setData
in interfaceElementPolygon
- Parameters:
xArray
- double[] the double[nPoints] array with the X coordinatesyArray
- double[] the double[nPoints] array with the Y coordinateszArray
- double[] the double[nPoints] array with the Z coordinates
-
getData
public double[][] getData()Gets (a copy of) the data of the points for the polygon- Specified by:
getData
in interfaceElementPolygon
- Returns:
- double[][] the double[nPoints][3] array with the data
-
getExtrema
public void getExtrema(double[] min, double[] max) -
getTargetHit
Description copied from class:Element
Gets the target that is under the (x,y) position of the screen- Overrides:
getTargetHit
in classElement
- Parameters:
x
- inty
- int- Returns:
- InteractionTarget
-
getLoader
Returns an XML.ObjectLoader to save and load object data.- Returns:
- the XML.ObjectLoader
-