org.opensourcephysics.display3d.simple3d
Class ElementPolygon

java.lang.Object
  extended by org.opensourcephysics.display3d.simple3d.Element
      extended by org.opensourcephysics.display3d.simple3d.ElementPolygon
All Implemented Interfaces:
Element, ElementPolygon, InteractionSource

public class ElementPolygon
extends Element
implements ElementPolygon

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
protected  org.opensourcephysics.display3d.simple3d.Object3D[] closedObject
           
protected  org.opensourcephysics.display3d.simple3d.Object3D[] lineObjects
           
 
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
ElementPolygon()
           
 
Method Summary
 double[][] getData()
          Gets (a copy of) the data of the points for the polygon
 void getExtrema(double[] min, double[] max)
          Returns the extreme points of a box that contains the element.
static XML.ObjectLoader getLoader()
          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 screen
 boolean isClosed()
          Gets whether the polygon is closed
 void setClosed(boolean closed)
          Sets whether the polygon is closed
 void 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 Detail

lineObjects

protected org.opensourcephysics.display3d.simple3d.Object3D[] lineObjects

closedObject

protected org.opensourcephysics.display3d.simple3d.Object3D[] closedObject
Constructor Detail

ElementPolygon

public ElementPolygon()
Method Detail

setClosed

public void setClosed(boolean closed)
Description copied from interface: ElementPolygon
Sets whether the polygon is closed

Specified by:
setClosed in interface ElementPolygon
Parameters:
closed - boolean

isClosed

public boolean isClosed()
Description copied from interface: ElementPolygon
Gets whether the polygon is closed

Specified by:
isClosed in interface ElementPolygon
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 interface ElementPolygon
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 interface ElementPolygon
Parameters:
xArray - double[] the double[nPoints] array with the X coordinates
yArray - double[] the double[nPoints] array with the Y coordinates
zArray - 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 interface ElementPolygon
Returns:
double[][] the double[nPoints][3] array with the data

getExtrema

public void getExtrema(double[] min,
                       double[] max)
Description copied from class: Element
Returns the extreme points of a box that contains the element.

Parameters:
min - double[] A previously allocated double[3] array that will hold the minimum point
max - double[] A previously allocated double[3] array that will hold the maximum point

getTargetHit

protected InteractionTarget getTargetHit(int x,
                                         int y)
Description copied from class: Element
Gets the target that is under the (x,y) position of the screen

Overrides:
getTargetHit in class Element
Parameters:
x - int
y - int
Returns:
InteractionTarget

getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load object data.

Returns:
the XML.ObjectLoader