org.opensourcephysics.displayejs
Class ElementSet

java.lang.Object
  extended by org.opensourcephysics.displayejs.AbstractInteractionSource
      extended by org.opensourcephysics.displayejs.ElementSet
All Implemented Interfaces:
Drawable, Interactive, Measurable, Drawable3D, InteractionSource, Measurable3D
Direct Known Subclasses:
TraceSet, VectorField3D

public class ElementSet
extends AbstractInteractionSource
implements Interactive, Drawable3D, Measurable3D

An ElementSet is a simple interactive, drawable3D, measurable3D, that helps create and set some of the values of a large number of InteractiveElements using arrays. It is NOT and InteractiveElement itself, though it is an InteractionSource. When iteracting with it, it returns targets of the InteractionTargetSetElement class. Because of this peculiarity, you should not add listeners to elements of a set directly. This is th eonly restriction that a set imposes on addressing its elements directly.


Constructor Summary
ElementSet(int _n, java.lang.Class<?> _aClass)
           
 
Method Summary
 void canBeMeasured(boolean _canBe)
          Whether the element should be taken into account for computing the scales.
 void draw(DrawingPanel3D _panel, java.awt.Graphics2D _g2, int _index)
          Draws a given Object3D (indicated by its index).
 void draw(DrawingPanel _panel, java.awt.Graphics _g)
          Draws a representation of an object in a drawing panel.
 void drawQuickly(DrawingPanel3D _panel, java.awt.Graphics2D _g2)
          Sketches the drawable
 InteractiveElement elementAt(int i)
           
 Interactive findInteractive(DrawingPanel _panel, int _xpix, int _ypix)
           
 int getElementInteracted()
           
 int getInteractedIndex()
           
 java.lang.String getName()
           
 int getNumberOfElements()
           
 Object3D[] getObjects3D(DrawingPanel3D _panel)
          Returns an array of Objects3D to (sort according to its distance and) draw.
 double[] getSizeXs()
           
 double[] getSizeYs()
           
 double[] getSizeZs()
           
 double getX()
           
 double getXMax()
          Gets the maximum x needed to draw this object.
 double getXMin()
          Gets the minimum x needed to draw this object.
 double[] getXs()
           
 double getY()
           
 double getYMax()
          Gets the maximum y needed to draw this object.
 double getYMin()
          Gets the minimum y needed to draw this object.
 double[] getYs()
           
 double getZMax()
          Gets the maximum z needed to draw this object.
 double getZMin()
          Gets the minimum z needed to draw this object.
 double[] getZs()
           
 boolean isEnabled()
          Whether any of the targets of this source is enabled
 boolean isEnabled(int _target)
          Whether a particular target of this source is enabled
 boolean isMeasured()
          Determines if information is available to set min/max values.
 boolean isVisible()
           
 void needsToProject(DrawingPanel _panel)
          Tells the drawable that it should reproject its points because this panel has changed its projection parameters.
 void setEnabled(boolean _enabled)
          Enables all the targets of this source
 void setEnabled(int _target, boolean _enabled)
          Enables a particular target of this source
 void setEnableds(boolean[] _enab)
           
 void setEnableds(int _target, boolean[] _enab)
           
 void setName(java.lang.String _name)
           
 void setNumberOfElements(int _n)
           
 void setSizeXs(double[] _x)
           
 void setSizeXYZs(double[] _x, double[] _y, double[] _z)
           
 void setSizeYs(double[] _y)
           
 void setSizeZs(double[] _z)
           
 void setVisible(boolean _visible)
           
 void setVisibles(boolean[] _vis)
           
 void setX(double _x)
           
 void setXs(double[] _x)
           
 void setXY(double _x, double _y)
           
 void setXYZs(double[] _x, double[] _y, double[] _z)
           
 void setY(double _y)
           
 void setYs(double[] _y)
           
 void setZs(double[] _z)
           
 java.lang.String toXML()
           
 
Methods inherited from class org.opensourcephysics.displayejs.AbstractInteractionSource
addListener, invokeActions, removeAllListeners, removeListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementSet

public ElementSet(int _n,
                  java.lang.Class<?> _aClass)
Method Detail

setName

public void setName(java.lang.String _name)

getName

public java.lang.String getName()

getNumberOfElements

public int getNumberOfElements()

setNumberOfElements

public void setNumberOfElements(int _n)

elementAt

public InteractiveElement elementAt(int i)

setXs

public void setXs(double[] _x)

getXs

public double[] getXs()

setYs

public void setYs(double[] _y)

getYs

public double[] getYs()

setZs

public void setZs(double[] _z)

getZs

public double[] getZs()

setXYZs

public void setXYZs(double[] _x,
                    double[] _y,
                    double[] _z)

setSizeXs

public void setSizeXs(double[] _x)

getSizeXs

public double[] getSizeXs()

setSizeYs

public void setSizeYs(double[] _y)

getSizeYs

public double[] getSizeYs()

setSizeZs

public void setSizeZs(double[] _z)

getSizeZs

public double[] getSizeZs()

setSizeXYZs

public void setSizeXYZs(double[] _x,
                        double[] _y,
                        double[] _z)

setVisible

public void setVisible(boolean _visible)

isVisible

public boolean isVisible()

setVisibles

public void setVisibles(boolean[] _vis)

setEnabled

public void setEnabled(boolean _enabled)
Description copied from interface: InteractionSource
Enables all the targets of this source

Specified by:
setEnabled in interface Interactive
Specified by:
setEnabled in interface InteractionSource

isEnabled

public boolean isEnabled()
Description copied from interface: InteractionSource
Whether any of the targets of this source is enabled

Specified by:
isEnabled in interface Interactive
Specified by:
isEnabled in interface InteractionSource

setEnabled

public void setEnabled(int _target,
                       boolean _enabled)
Description copied from interface: InteractionSource
Enables a particular target of this source

Specified by:
setEnabled in interface InteractionSource

isEnabled

public boolean isEnabled(int _target)
Description copied from interface: InteractionSource
Whether a particular target of this source is enabled

Specified by:
isEnabled in interface InteractionSource

setEnableds

public void setEnableds(boolean[] _enab)

setEnableds

public void setEnableds(int _target,
                        boolean[] _enab)

toXML

public java.lang.String toXML()

getElementInteracted

public int getElementInteracted()

getInteractedIndex

public int getInteractedIndex()

findInteractive

public Interactive findInteractive(DrawingPanel _panel,
                                   int _xpix,
                                   int _ypix)
Specified by:
findInteractive in interface Interactive

needsToProject

public void needsToProject(DrawingPanel _panel)
Description copied from interface: Drawable3D
Tells the drawable that it should reproject its points because this panel has changed its projection parameters.

Specified by:
needsToProject in interface Drawable3D
Parameters:
_panel - the DrawingPanel that has changed or null if the drawable should update its projection in all possible panels

getObjects3D

public Object3D[] getObjects3D(DrawingPanel3D _panel)
Description copied from interface: Drawable3D
Returns an array of Objects3D to (sort according to its distance and) draw.

Specified by:
getObjects3D in interface Drawable3D

draw

public void draw(DrawingPanel3D _panel,
                 java.awt.Graphics2D _g2,
                 int _index)
Description copied from interface: Drawable3D
Draws a given Object3D (indicated by its index).

Specified by:
draw in interface Drawable3D

drawQuickly

public void drawQuickly(DrawingPanel3D _panel,
                        java.awt.Graphics2D _g2)
Description copied from interface: Drawable3D
Sketches the drawable

Specified by:
drawQuickly in interface Drawable3D

draw

public void draw(DrawingPanel _panel,
                 java.awt.Graphics _g)
Description copied from interface: Drawable
Draws a representation of an object in a drawing panel.

Specified by:
draw in interface Drawable

canBeMeasured

public void canBeMeasured(boolean _canBe)
Whether the element should be taken into account for computing the scales. This is used by DrawingPanel3D's decoration.


isMeasured

public final boolean isMeasured()
Description copied from interface: Measurable
Determines if information is available to set min/max values. Objects that store data should return false if data is null.

Specified by:
isMeasured in interface Measurable
Returns:
true if min/max values are valid

getXMin

public double getXMin()
Description copied from interface: Measurable
Gets the minimum x needed to draw this object.

Specified by:
getXMin in interface Measurable
Returns:
minimum

getXMax

public double getXMax()
Description copied from interface: Measurable
Gets the maximum x needed to draw this object.

Specified by:
getXMax in interface Measurable
Returns:
maximum

getYMin

public double getYMin()
Description copied from interface: Measurable
Gets the minimum y needed to draw this object.

Specified by:
getYMin in interface Measurable
Returns:
minimum

getYMax

public double getYMax()
Description copied from interface: Measurable
Gets the maximum y needed to draw this object.

Specified by:
getYMax in interface Measurable
Returns:
minimum

getZMin

public double getZMin()
Description copied from interface: Measurable3D
Gets the minimum z needed to draw this object.

Specified by:
getZMin in interface Measurable3D
Returns:
minimum

getZMax

public double getZMax()
Description copied from interface: Measurable3D
Gets the maximum z needed to draw this object.

Specified by:
getZMax in interface Measurable3D
Returns:
maximum

setXY

public void setXY(double _x,
                  double _y)
Specified by:
setXY in interface Interactive

setX

public void setX(double _x)
Specified by:
setX in interface Interactive

setY

public void setY(double _y)
Specified by:
setY in interface Interactive

getX

public double getX()
Specified by:
getX in interface Interactive

getY

public double getY()
Specified by:
getY in interface Interactive