Class ElementPolygon

java.lang.Object
org.opensourcephysics.display3d.simple3d.Element
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
  • 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 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)
    • 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