|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.drawing2d.Element
public abstract class Element
Title: Element
Description: A basic individual, interactive drawing element.
Interaction: An Element includes the following targets:
Field Summary | |
---|---|
static int |
TARGET_POSITION
The id for the target that allows to reposition the element. |
static int |
TARGET_SIZE
The id for the target that allows to resize the element. |
Constructor Summary | |
---|---|
Element()
|
Method Summary | |
---|---|
void |
addInteractionListener(InteractionListener listener)
|
abstract void |
draw(DrawingPanel _panel,
java.awt.Graphics _g)
Draws the element on a given Graphics2D. |
abstract Interactive |
findInteractive(DrawingPanel _panel,
int _xpix,
int _ypix)
Gets the target that is under the (x,y) position of the screen. |
boolean |
getCanBeMeasured()
The element measurable flag. |
java.lang.Object |
getDataObject()
Returns the data object |
InteractionTarget |
getInteractionTarget(int target)
Provides access to the element's targets |
java.lang.String |
getName()
Gets the name of the element |
DrawingPanel |
getPanel()
Returns the DrawingPanel in which it (or its final ancestor group) is displayed. |
double[] |
getPosition()
Get the coordinates of the element |
double[] |
getSize()
Get the size along the axes |
double |
getSizeX()
Get the size along the X axis |
double |
getSizeY()
Get the size along the Y axis |
Style |
getStyle()
Gets the style of the element |
java.lang.Object |
getTransformation()
Returns a copy of the element transformation |
double |
getX()
Get the X coordinate of the element |
double |
getXMax()
Gets the maximum x needed to draw this object. |
double |
getXMaxLogscale()
Gets the maximum x needed to draw this object on a log scale. |
double |
getXMin()
Gets the minimum x needed to draw this object. |
double |
getXMinLogscale()
Gets the minimum x needed to draw this object on a log scale. |
double |
getY()
Get the Y coordinate of the element |
double |
getYMax()
Gets the maximum y needed to draw this object. |
double |
getYMaxLogscale()
Gets the maximum y needed to draw this object on a log scale on a log scale. |
double |
getYMin()
Gets the minimum y needed to draw this object. |
double |
getYMinLogscale()
Gets the minimum y needed to draw this object on a log scale. |
boolean |
hasChanged()
Returns whether the element has changed significantly. |
void |
invokeActions(InteractionEvent event)
Invokes the interactionPerformed() methods on the registered interaction listeners. |
boolean |
isEnabled()
Whether any of the targets is enabled. |
boolean |
isMeasured()
Determines if information is available to set min/max values. |
boolean |
isVisible()
Whether the element is visible |
void |
removeInteractionListener(InteractionListener listener)
|
void |
setCanBeMeasured(boolean measured)
Whether the element is taken into account when autoscaling |
void |
setDataObject(java.lang.Object _object)
A place holder for data objects To be used internally by ControlElements |
void |
setElementChanged()
Tells the element that it has changed. |
void |
setEnabled(boolean _enabled)
Sets the enabled condition of all targets at once. |
void |
setName(java.lang.String _aName)
Gives a name to the element. |
void |
setNeedToProject(boolean _need)
Tells the element whether it should reproject its points because the panel has changed its projection parameters. |
void |
setPanel(DrawingPanel _panel)
To be used internally by DrawingPanel only! Sets the panel for this element. |
void |
setPosition(double[] _pos)
Set the coordinates of the element |
void |
setSize(double[] _size)
Set the size along the axes |
void |
setSizeX(double _sizeX)
Set the size along the X axis |
void |
setSizeXY(double _sizeX,
double _sizeY)
Set the size along the axes |
void |
setSizeY(double _sizeY)
Set the size along the Y axis |
void |
setTransformation(java.lang.Object _transform)
Sets the internal transformation of the element, that is, the transformation that converts the standard world 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 |
setXY(double _x,
double _y)
Set the coordinates of the element |
void |
setY(double _y)
Set the Y coordinate of the element |
double[] |
toBodyFrame(double[] vector)
This method converts a double[] vector from the space's frame to the body's frame. |
double[] |
toSpaceFrame(double[] vector)
This method transforms a double[] vector from the body's frame to the space's frame. |
void |
updateHotSpot(InteractionTarget target,
double[] point)
This method updates the position or size of the element according to the position of the cursor during the interaction. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TARGET_POSITION
public static final int TARGET_SIZE
Constructor Detail |
---|
public Element()
Method Detail |
---|
public final void setDataObject(java.lang.Object _object)
_object
- Objectpublic final java.lang.Object getDataObject()
public final void setPanel(DrawingPanel _panel)
_panel
- DrawingPanelpublic final DrawingPanel getPanel()
public final void setName(java.lang.String _aName)
name
- Stringpublic final java.lang.String getName()
public final void setX(double _x)
setX
in interface Interactive
x
- doublepublic final double getX()
getX
in interface Interactive
public final void setY(double _y)
setY
in interface Interactive
y
- doublepublic final double getY()
getY
in interface Interactive
public final void setXY(double _x, double _y)
setXY
in interface Interactive
_x
- double the x position_y
- double the y positionpublic final void setPosition(double[] _pos)
pos
- double[] an array of dimension 2public final double[] getPosition()
public void setSizeX(double _sizeX)
sizeX
- doublepublic final double getSizeX()
public void setSizeY(double _sizeY)
sizeY
- doublepublic final double getSizeY()
public void setSizeXY(double _sizeX, double _sizeY)
sizeX
- double the size along the X axissizeY
- double the size along the Y axispublic void setSize(double[] _size)
size
- double[] an array of the dimension 2public final double[] getSize()
public void setCanBeMeasured(boolean measured)
measured
- booleanpublic boolean getCanBeMeasured()
public double getXMin()
Measurable
getXMin
in interface Measurable
public double getXMax()
Measurable
getXMax
in interface Measurable
public double getYMin()
Measurable
getYMin
in interface Measurable
public double getYMax()
Measurable
getYMax
in interface Measurable
public double getXMinLogscale()
LogMeasurable
getXMinLogscale
in interface LogMeasurable
public double getXMaxLogscale()
LogMeasurable
getXMaxLogscale
in interface LogMeasurable
public double getYMinLogscale()
LogMeasurable
getYMinLogscale
in interface LogMeasurable
public double getYMaxLogscale()
LogMeasurable
getYMaxLogscale
in interface LogMeasurable
public boolean isMeasured()
Measurable
isMeasured
in interface Measurable
public final void setVisible(boolean _visible)
visible
- booleanpublic final boolean isVisible()
public final Style getStyle()
Style
public boolean hasChanged()
public final void setElementChanged()
change
- Whether the element has changedpublic final void setTransformation(java.lang.Object _transform) throws java.lang.ClassCastException
transformation
- the new transformation
java.lang.ClassCastException
- if an object of a non-supported class is passed as argumentpublic final java.lang.Object getTransformation()
public final double[] toSpaceFrame(double[] vector)
vector
- double[] The original coordinates in the body frame
public final double[] toBodyFrame(double[] vector) throws java.awt.geom.NoninvertibleTransformException
vector
- double[] The original coordinates in the space
java.awt.geom.NoninvertibleTransformException
public abstract void draw(DrawingPanel _panel, java.awt.Graphics _g)
draw
in interface Drawable
public void setNeedToProject(boolean _need)
public void setEnabled(boolean _enabled)
setEnabled
in interface Interactive
public boolean isEnabled()
isEnabled
in interface Interactive
public final InteractionTarget getInteractionTarget(int target)
public final void addInteractionListener(InteractionListener listener)
public final void removeInteractionListener(InteractionListener listener)
public final void invokeActions(InteractionEvent event)
event
- InteractionEventpublic abstract Interactive findInteractive(DrawingPanel _panel, int _xpix, int _ypix)
findInteractive
in interface Interactive
_panel
- org.opensourcephysics.display.DrawingPanel The drawing panel which originated the call_xpix
- int_ypix
- int
public void updateHotSpot(InteractionTarget target, double[] point)
target
- InteractionTarget The target interactedpoint
- double[] The position of the cursor during the interaction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |