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, targetSizeFields 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 polygonvoidgetExtrema(double[] min, double[] max) static XML.ObjectLoaderReturns an XML.ObjectLoader to save and load object data.protected InteractionTargetgetTargetHit(int x, int y) Gets the target that is under the (x,y) position of the screenbooleanisClosed()Gets whether the polygon is closedvoidsetClosed(boolean closed) Sets whether the polygon is closedvoidsetData(double[][] data) Sets the data for the points of the polygon.voidsetData(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, toSpaceFrameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, toSpaceFrameMethods 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:ElementPolygonSets whether the polygon is closed- Specified by:
setClosedin interfaceElementPolygon- Parameters:
closed- boolean
-
isClosed
public boolean isClosed()Description copied from interface:ElementPolygonGets whether the polygon is closed- Specified by:
isClosedin 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:
setDatain 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:ElementPolygonSets 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:
setDatain 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:
getDatain interfaceElementPolygon- Returns:
- double[][] the double[nPoints][3] array with the data
-
getExtrema
public void getExtrema(double[] min, double[] max) -
getTargetHit
Description copied from class:ElementGets the target that is under the (x,y) position of the screen- Overrides:
getTargetHitin classElement- Parameters:
x- inty- int- Returns:
- InteractionTarget
-
getLoader
Returns an XML.ObjectLoader to save and load object data.- Returns:
- the XML.ObjectLoader
-