java.lang.Object
org.opensourcephysics.display3d.simple3d.Element
All Implemented Interfaces:
Element, InteractionSource
Direct Known Subclasses:
AbstractTile, ElementCircle, ElementImage, ElementPoints, ElementPolygon, ElementSegment, ElementSpring, ElementText, ElementTrail, Group

public abstract class Element extends Object implements Element

Title: Element

Interaction: An Element includes the following targets:

  • TARGET_POSITION : Allows the element to be repositioned
  • TARGET_SIZE : Allows the element to be resized
The actual position (and implementation) of the target depends on the element.

Copyright: Open Source Physics project

Version:
June 2005
Author:
Francisco Esquembre
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.opensourcephysics.display3d.core.Element

    Element.Loader
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final InteractionTarget
     
    protected final InteractionTarget
     

    Fields inherited from interface org.opensourcephysics.display3d.core.Element

    TARGET_POSITION, TARGET_SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the specified interaction listener to receive interaction events to any of its targets from this source.
    protected int
     
    Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.
    protected double[]
    Returns the body coordinates of the specified hotspot
    Gives access to one of the targets of this source.
    final String
    Gets the name of the element
    final double
    Get the size along the X axis
    final double
    Get the size along the Y axis
    final double
    Get the size along the Z axis
    final Style
    Gets the style of the element
    getTargetHit(int x, int y)
    Gets the target that is under the (x,y) position of the screen
    Returns a clone of the element transformation
    final double
    Get the X coordinate of the element
    final double
    Get the Y coordinate of the element
    final double
    Get the Z coordinate of the element
    protected final boolean
    Returns the real visibility status of the element, which will be false if it belongs to an invisible group
    final boolean
    Whether the element is visible
    void
    Loads unmutable objects of the Element, such as the style, as well as perform any extra implementation-specific initialization.
    void
    Removes the specified interaction listener
    void
    setName(String aName)
    Gives a name to the element.
    void
    setSizeX(double sizeX)
    Set the size along the X axis
    void
    setSizeXYZ(double[] size)
    Sets the size of the element.
    void
    setSizeXYZ(double sizeX, double sizeY, double sizeZ)
    Set the size along the X, Y and Z axes
    void
    setSizeY(double sizeY)
    Set the size along the Y axis
    void
    setSizeZ(double sizeZ)
    Set the size along the Z axis
    void
    Sets the internal transformation of the element, that is, the transformation that converts the standard XYZ axes to the body's internal reference axes.
    void
    setVisible(boolean _visible)
    Sets the visibility of the element
    void
    setX(double x)
    Set the X coordinate of the element
    void
    setXYZ(double[] pos)
    Sets the coordinates of the element.
    void
    setXYZ(double x, double y, double z)
    Set the X, Y, and Z coordinates of the element
    void
    setY(double y)
    Set the Y coordinate of the element
    void
    setZ(double z)
    Set the Z coordinate of the element
    double[]
    toBodyFrame(double[] vector)
    This method converts a double[3] vector from the space's frame to the body's frame.
    double[]
    toSpaceFrame(double[] vector)
    This method transforms a double[3] vector from the body's frame to the space's frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Element

      public Element()
  • Method Details

    • getDrawingPanel3D

      public final DrawingPanel3D getDrawingPanel3D()
      Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.
      Specified by:
      getDrawingPanel3D in interface Element
      Returns:
      DrawingPanel3D
    • getAxesMode

      protected int getAxesMode()
    • setName

      public void setName(String aName)
      Description copied from interface: Element
      Gives a name to the element. Naming an element is optional, but the element may use its name to identify itself in XML files, for instance.
      Specified by:
      setName in interface Element
      Parameters:
      aName - String
    • getName

      public final String getName()
      Description copied from interface: Element
      Gets the name of the element
      Specified by:
      getName in interface Element
      Returns:
      String the name
    • setX

      public void setX(double x)
      Description copied from interface: Element
      Set the X coordinate of the element
      Specified by:
      setX in interface Element
      Parameters:
      x - double
    • getX

      public final double getX()
      Description copied from interface: Element
      Get the X coordinate of the element
      Specified by:
      getX in interface Element
      Returns:
      double
    • setY

      public void setY(double y)
      Description copied from interface: Element
      Set the Y coordinate of the element
      Specified by:
      setY in interface Element
      Parameters:
      y - double
    • getY

      public final double getY()
      Description copied from interface: Element
      Get the Y coordinate of the element
      Specified by:
      getY in interface Element
      Returns:
      double
    • setZ

      public void setZ(double z)
      Description copied from interface: Element
      Set the Z coordinate of the element
      Specified by:
      setZ in interface Element
      Parameters:
      z - double
    • getZ

      public final double getZ()
      Description copied from interface: Element
      Get the Z coordinate of the element
      Specified by:
      getZ in interface Element
      Returns:
      double
    • setXYZ

      public void setXYZ(double x, double y, double z)
      Description copied from interface: Element
      Set the X, Y, and Z coordinates of the element
      Specified by:
      setXYZ in interface Element
      Parameters:
      x - double
      y - double
      z - double
    • setXYZ

      public void setXYZ(double[] pos)
      Description copied from interface: Element
      Sets the coordinates of the element. If pos.length<=2 it sets only X and Y. If pos.length>2 it sets X, Y, and Z.
      Specified by:
      setXYZ in interface Element
      Parameters:
      pos - double[]
    • setSizeX

      public void setSizeX(double sizeX)
      Description copied from interface: Element
      Set the size along the X axis
      Specified by:
      setSizeX in interface Element
      Parameters:
      sizeX - double
    • getSizeX

      public final double getSizeX()
      Description copied from interface: Element
      Get the size along the X axis
      Specified by:
      getSizeX in interface Element
      Returns:
      double
    • setSizeY

      public void setSizeY(double sizeY)
      Description copied from interface: Element
      Set the size along the Y axis
      Specified by:
      setSizeY in interface Element
      Parameters:
      sizeY - double
    • getSizeY

      public final double getSizeY()
      Description copied from interface: Element
      Get the size along the Y axis
      Specified by:
      getSizeY in interface Element
      Returns:
      double
    • setSizeZ

      public void setSizeZ(double sizeZ)
      Description copied from interface: Element
      Set the size along the Z axis
      Specified by:
      setSizeZ in interface Element
      Parameters:
      sizeZ - double
    • getSizeZ

      public final double getSizeZ()
      Description copied from interface: Element
      Get the size along the Z axis
      Specified by:
      getSizeZ in interface Element
      Returns:
      double
    • setSizeXYZ

      public void setSizeXYZ(double sizeX, double sizeY, double sizeZ)
      Description copied from interface: Element
      Set the size along the X, Y and Z axes
      Specified by:
      setSizeXYZ in interface Element
      Parameters:
      sizeX - double
      sizeY - double
      sizeZ - double
    • setSizeXYZ

      public void setSizeXYZ(double[] size)
      Description copied from interface: Element
      Sets the size of the element. If size.length<=2 it sets only the size in X and Y. If size.length>3 it sets the size in X, Y, and Z.
      Specified by:
      setSizeXYZ in interface Element
      Parameters:
      size - double[]
    • setVisible

      public void setVisible(boolean _visible)
      Description copied from interface: Element
      Sets the visibility of the element
      Specified by:
      setVisible in interface Element
      Parameters:
      _visible - boolean
    • isVisible

      public final boolean isVisible()
      Description copied from interface: Element
      Whether the element is visible
      Specified by:
      isVisible in interface Element
      Returns:
      boolean
    • isReallyVisible

      protected final boolean isReallyVisible()
      Returns the real visibility status of the element, which will be false if it belongs to an invisible group
      Returns:
      boolean
    • getStyle

      public final Style getStyle()
      Description copied from interface: Element
      Gets the style of the element
      Specified by:
      getStyle in interface Element
      Returns:
      Style
      See Also:
    • getTransformation

      public Transformation getTransformation()
      Description copied from interface: Element
      Returns a clone of the element transformation
      Specified by:
      getTransformation in interface Element
      Returns:
      Transformation a clone of the element's transformation
    • setTransformation

      public void setTransformation(Transformation transformation)
      Description copied from interface: Element
      Sets the internal transformation of the element, that is, the transformation that converts the standard XYZ axes to the body's internal reference axes. The transformation is copied and cannot be accessed by users directy. This implies that changing the original transformation has no effect on the element unless a new setTransformation() is invoked. The transformation uses the body's position as its origin.
      Specified by:
      setTransformation in interface Element
      Parameters:
      transformation - the new transformation
      See Also:
    • toSpaceFrame

      public double[] toSpaceFrame(double[] vector)
      Description copied from interface: Element
      This method transforms a double[3] vector from the body's frame to the space's frame.
      Specified by:
      toSpaceFrame in interface Element
      Parameters:
      vector - double[] The original coordinates in the body frame
      Returns:
      double[] The same array once transformed
    • toBodyFrame

      public double[] toBodyFrame(double[] vector) throws UnsupportedOperationException
      Description copied from interface: Element
      This method converts a double[3] vector from the space's frame to the body's frame.

      This only works properly if the internal transformation is not set (i.e. it is the identity) or if it is invertible. Otherwise, a call to this method will throw an UnsupportedOperationException exception.
      Specified by:
      toBodyFrame in interface Element
      Parameters:
      vector - double[] The original coordinates in the space
      Returns:
      double[] The same array with the body coordinates
      Throws:
      UnsupportedOperationException
    • getInteractionTarget

      public InteractionTarget getInteractionTarget(int target)
      Description copied from interface: InteractionSource
      Gives access to one of the targets of this source. Sources should document the list of their available targets.
      Specified by:
      getInteractionTarget in interface InteractionSource
      Parameters:
      target - An integer number that identifies the target in the source.
      Returns:
      InteractionTarget
    • addInteractionListener

      public void addInteractionListener(InteractionListener listener)
      Description copied from interface: InteractionSource
      Adds the specified interaction listener to receive interaction events to any of its targets from this source.
      Specified by:
      addInteractionListener in interface InteractionSource
      Parameters:
      listener - An object that implements the InteractionListener interface
      See Also:
    • removeInteractionListener

      public void removeInteractionListener(InteractionListener listener)
      Description copied from interface: InteractionSource
      Removes the specified interaction listener
      Specified by:
      removeInteractionListener in interface InteractionSource
      See Also:
    • getTargetHit

      protected InteractionTarget getTargetHit(int x, int y)
      Gets the target that is under the (x,y) position of the screen
      Parameters:
      x - int
      y - int
      Returns:
      InteractionTarget
    • getHotSpotBodyCoordinates

      protected double[] getHotSpotBodyCoordinates(InteractionTarget target)
      Returns the body coordinates of the specified hotspot
      Returns:
      double[]
    • loadUnmutableObjects

      public void loadUnmutableObjects(XMLControl control)
      Description copied from interface: Element
      Loads unmutable objects of the Element, such as the style, as well as perform any extra implementation-specific initialization. For the internal use of the XML loeader. Not to be used by final users.
      Specified by:
      loadUnmutableObjects in interface Element
      Parameters:
      control - XMLControl