org.opensourcephysics.displayejs
Interface InteractiveElement

All Superinterfaces:
Drawable, Drawable3D, HasDataObjectInterface, InteractionSource, Interactive, Measurable, Measurable3D
All Known Implementing Classes:
AbstractInteractiveElement, AbstractInteractiveTile, InteractiveArrow, InteractiveBox, InteractiveCone, InteractiveCursor, InteractiveCylinder, InteractiveCylinderSimple, InteractiveImage, InteractiveParticle, InteractivePlane, InteractivePoints, InteractivePoligon, InteractiveSphere, InteractiveSpring, InteractiveSurface, InteractiveText, InteractiveTrace, Pipe

public interface InteractiveElement
extends Drawable3D, InteractionSource, Interactive, Measurable3D, HasDataObjectInterface

InteractiveElement is an interface that extends Drawable3D and Measurable3D, but also Interactive and InteractionSource. This means already that an interactive element is ready to be drawn in three dimensions, responds to user interaction, and is able to send interactive events to registered listeners.

This interface also defines methods designed to help you work with elements in a way similar to that you work with physical objects in real life. Using implementing classes, you will find yourself creating and handling (moving, resizing,...) objects in a way similar to what you would do in real life.

This interface provides an API for three-dimensional (interactive, drawable) objects that:

Version:
1.0, August 2003
Author:
Francisco Esquembre (http://fem.um.es)

Field Summary
static int TARGET_POSITION
           
static int TARGET_SIZE
           
 
Method Summary
 void canBeMeasured(boolean _canBe)
          Whether the element should be taken into account for computing the scales.
 void copyFrom(InteractiveElement _element)
           
 Control getControl()
           
 Group getGroup()
          Gets the group to which the element belongs.
 Resolution getResolution()
          Get the resolution suggestions for this element.
 int getSensitivity()
           
 ElementSet getSet()
           
 int getSetIndex()
           
 double getSizeX()
          Returns the size of the element in the X dimension
 double getSizeY()
          Returns the size of the element in the Y dimension
 double getSizeZ()
          Returns the size of the element in the Z dimension
 Style getStyle()
          The set of style suggestions for this element.
 double getX()
          Returns the X location of the element
 double getY()
          Returns the Y location of the element
 double getZ()
          Returns the Z location of the element
 void initializeMemberOfSet()
          Special initialization when used as a memeber of a Set
 boolean isGroupEnabled()
          Whether interaction on any of the targets of this element affects the whole group
 boolean isGroupEnabled(int target)
          Whether interaction on a given target of this element affects the whole group
 boolean isVisible()
          Whether the element is visible or not
 void setControl(Control control)
           
 void setGroup(Group group)
          Sets whether this element should move and size as part of a group.
 void setGroupEnabled(boolean affectsGroup)
          Whether interaction on any of the targets of the element should affect the whole group (if the element is in a group).
 void setGroupEnabled(int target, boolean affectsGroup)
          Whether interaction on a given target of the element should affect the whole group (if the element is in a group) By default, only TARGET_POSITION targets are group-enabled.
 void setResolution(Resolution resolution)
          Resolution suggestions for the element.
 void setSensitivity(int sensitiviy)
          Sets the size of the interaction hot spot (in pixels).
 void setSet(ElementSet set, int index)
           
 void setSizeX(double x)
          Resizes the element in the X dimension
 void setSizeXY(double x, double y)
          Resizes the element in the X and Y dimensions
 void setSizeXYZ(double x, double y, double z)
          Resizes the element in the X, Y, and Z dimensions
 void setSizeY(double y)
          Resizes the element in the Y dimension
 void setSizeZ(double z)
          Resizes the element in the Z dimension
 void setVisible(boolean visible)
          Sets the visibility of the element
 void setX(double x)
          Moves the element to a new X location
 void setXY(double x, double y)
          Moves the element to a new X and Y location
 void setXYZ(double x, double y, double z)
          Moves the element to a new X, Y, and Z location
 void setY(double y)
          Moves the element to a new Y location
 void setZ(double z)
          Moves the element to a new Z location
 java.lang.String toXML()
          Get an XML description of this element.
 
Methods inherited from interface org.opensourcephysics.displayejs.Drawable3D
draw, drawQuickly, getObjects3D, needsToProject
 
Methods inherited from interface org.opensourcephysics.displayejs.InteractionSource
addListener, invokeActions, isEnabled, isEnabled, removeAllListeners, removeListener, setEnabled, setEnabled
 
Methods inherited from interface org.opensourcephysics.display.Interactive
findInteractive, isEnabled, setEnabled
 
Methods inherited from interface org.opensourcephysics.displayejs.Measurable3D
getZMax, getZMin
 
Methods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
 
Methods inherited from interface org.opensourcephysics.display.Drawable
draw
 
Methods inherited from interface org.opensourcephysics.displayejs.HasDataObjectInterface
getDataObject, setDataObject
 

Field Detail

TARGET_POSITION

static final int TARGET_POSITION
See Also:
Constant Field Values

TARGET_SIZE

static final int TARGET_SIZE
See Also:
Constant Field Values
Method Detail

setX

void setX(double x)
Moves the element to a new X location

Specified by:
setX in interface Interactive
Parameters:
x - the new X location for the element

getX

double getX()
Returns the X location of the element

Specified by:
getX in interface Interactive
Returns:
the X location for the element

setY

void setY(double y)
Moves the element to a new Y location

Specified by:
setY in interface Interactive
Parameters:
y - the new Y location for the element

getY

double getY()
Returns the Y location of the element

Specified by:
getY in interface Interactive
Returns:
the Y location for the element

setZ

void setZ(double z)
Moves the element to a new Z location

Parameters:
z - the new Z location for the element

getZ

double getZ()
Returns the Z location of the element

Returns:
the Z location for the element

setXY

void setXY(double x,
           double y)
Moves the element to a new X and Y location

Specified by:
setXY in interface Interactive
Parameters:
x - the new X location for the element
y - the new Y location for the element

setXYZ

void setXYZ(double x,
            double y,
            double z)
Moves the element to a new X, Y, and Z location

Parameters:
x - the new X location for the element
y - the new Y location for the element
z - the new Z location for the element

setSizeX

void setSizeX(double x)
Resizes the element in the X dimension

Parameters:
sizex - the new X size for the element

getSizeX

double getSizeX()
Returns the size of the element in the X dimension

Returns:
the X size of the element

setSizeY

void setSizeY(double y)
Resizes the element in the Y dimension

Parameters:
sizey - the new Y size for the element

getSizeY

double getSizeY()
Returns the size of the element in the Y dimension

Returns:
the Y size of the element

setSizeZ

void setSizeZ(double z)
Resizes the element in the Z dimension

Parameters:
sizez - the new Z size for the element

getSizeZ

double getSizeZ()
Returns the size of the element in the Z dimension

Returns:
the Z size of the element

setSizeXY

void setSizeXY(double x,
               double y)
Resizes the element in the X and Y dimensions

Parameters:
sizex - the new X size for the element
sizey - the new Y size for the element

setSizeXYZ

void setSizeXYZ(double x,
                double y,
                double z)
Resizes the element in the X, Y, and Z dimensions

Parameters:
sizex - the new X size for the element
sizey - the new Y size for the element
sizez - the new Z size for the element

setVisible

void setVisible(boolean visible)
Sets the visibility of the element

Parameters:
visible - the desired visibility for the element

isVisible

boolean isVisible()
Whether the element is visible or not

Returns:
the visibility status

canBeMeasured

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


getStyle

Style getStyle()
The set of style suggestions for this element. The style instance itself can't be changed, but its fields are mutable.

Returns:
the instance of the Style class for this element.
See Also:
Style

setResolution

void setResolution(Resolution resolution)
Resolution suggestions for the element.

Parameters:
the - new resolution for the element.
See Also:
Resolution

getResolution

Resolution getResolution()
Get the resolution suggestions for this element.

Returns:
the current resolution of the element.
See Also:
Resolution

setSensitivity

void setSensitivity(int sensitiviy)
Sets the size of the interaction hot spot (in pixels). If zero or negative, some elements (such as Images and Particles) may use the full area. Others will use a default of 5.

Parameters:
sensitiviy - int

getSensitivity

int getSensitivity()

setGroup

void setGroup(Group group)
Sets whether this element should move and size as part of a group.

Parameters:
_element - the group to which the element belongs. null if it doesn't belong to any group.
See Also:
Group

getGroup

Group getGroup()
Gets the group to which the element belongs.

Returns:
the group to which the element belongs. null if it doesn't belong to any group.
See Also:
Group

setGroupEnabled

void setGroupEnabled(boolean affectsGroup)
Whether interaction on any of the targets of the element should affect the whole group (if the element is in a group). By default, only TARGET_POSITION targets are group-enabled.

Parameters:
affectsGroup - true if interactions should affect the whole group, false if they should affect only the element within the group.

isGroupEnabled

boolean isGroupEnabled()
Whether interaction on any of the targets of this element affects the whole group

Returns:
true (the default) if the interaction affects the whole group, false if the motion affects only the element within the group.

setGroupEnabled

void setGroupEnabled(int target,
                     boolean affectsGroup)
Whether interaction on a given target of the element should affect the whole group (if the element is in a group) By default, only TARGET_POSITION targets are group-enabled.

Parameters:
target - An integer that identifies a target of the element.
affectsGroup - true (the default) if interactions on this target should affect the whole group, false if they should affect only the element within the group.

isGroupEnabled

boolean isGroupEnabled(int target)
Whether interaction on a given target of this element affects the whole group

Parameters:
target - An integer that identifies a target of the element.
Returns:
true (the default) if the interaction affects the whole group, false if the motion affects only the element within the group.

setSet

void setSet(ElementSet set,
            int index)

getSet

ElementSet getSet()

getSetIndex

int getSetIndex()

initializeMemberOfSet

void initializeMemberOfSet()
Special initialization when used as a memeber of a Set


setControl

void setControl(Control control)

getControl

Control getControl()

toXML

java.lang.String toXML()
Get an XML description of this element.

Returns:
the XML formatted description of the element

copyFrom

void copyFrom(InteractiveElement _element)