|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.presentation.Shape
com.xj.anylogic.engine.presentation.ShapeControl
public abstract class ShapeControl
The base class for all controls, i.e. presentation shapes that have JComponents,
(like buttons, sliders, text fields, and also charts) both persistent and not
persistent. The non-persistent controls are idetified by their owner Presentable
object, id and index.
The concept of persistent and non-persistent controls helps you to save significant
amount of memory at runtime, which is critical when you have a lot of active objects,
e.g. agents, each with its own controls/charts on the presentation. It works in the
following way. If you have marked control as persistent, it will always exist during
the active object lifetime. If you mark it as non-persistent, it will only exist when
it is displayed. Therefore if you are viewing the presentation of one agent at a
time, the non-persistent controls of other agents will not take any memory.
The only limitation of non-persistent controls is that you cannot access them
programmatically while they are not visible. While they are visible, you can access
them by calling getShapeControl( id, index ) and then call its methods, however
the changes you make this way will be lost if the control disappears from the
view and is displayed again. With persistent controls you can call their methods
any time, just like you do with any normal objects.
If you do not have a lot of active objects and thus do not care about the momory
occupied by the controls, you can have all your controls as persistent.
| Field Summary | |
|---|---|
static int |
TYPE_DOUBLE
Control value-type constant for double number editing mode,
applicable for ShapeSlider, ShapeTextField, ShapeComboBox. |
static int |
TYPE_INT
Control value-type constant for int number editing mode,
applicable for ShapeSlider, ShapeTextField, ShapeComboBox. |
static int |
TYPE_STRING
Control value-type constant for String editing mode,
applicable for ShapeTextField, ShapeComboBox. |
| Fields inherited from class com.xj.anylogic.engine.presentation.Shape |
|---|
UNKNOWN_NAME |
| Method Summary | |
|---|---|
abstract void |
action()
Executes the action associated with the control. |
Shape |
clone()
Cloning of controls is not supported (Other shapes except GIS and charts allow cloning) This method throws UnsupportedOperationException if called |
boolean |
contains(double px,
double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y) |
void |
draw(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
boolean publicOnly)
Draws a persistent control in a given context |
double |
getHeight()
Returns the height of the control. |
abstract javax.swing.JComponent |
getJComponent()
Returns the JComponent of this control. |
Presentable |
getPresentable()
Returns the presentable object owning the control |
double |
getWidth()
Returns the width of the control. |
boolean |
isEnabled()
Tests if the coltrol is enabled or disabled. |
boolean |
onClickAt(double px,
double py,
boolean publicOnly)
Tests if the control contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point. |
void |
restoreOwner(java.lang.Object owner)
This method normally should not be called by user This method restores owner of this object The method is used in snapshot saving/loading |
void |
setEnabled(boolean yes)
Sets the control enabled or disabled |
void |
setHeight(double h)
Sets the height of the control. |
void |
setValueToDefault()
Sets the value of a non-persistent control to what was provided as the default one. |
void |
setWidth(double w)
Sets the width of the control. |
void |
update()
Updates the speific properties of a (non-persistent) control that are to be updated on each frame. |
| Methods inherited from class com.xj.anylogic.engine.presentation.Shape |
|---|
canHandleClick, getGroup, getName, getRotation, getScaleX, getScaleY, getX, getY, isVisible, onClick, setPos, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_DOUBLE
double number editing mode,
applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
public static final int TYPE_INT
int number editing mode,
applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
public static final int TYPE_STRING
String editing mode,
applicable for ShapeTextField, ShapeComboBox.
| Method Detail |
|---|
public abstract void action()
public abstract javax.swing.JComponent getJComponent()
public void setEnabled(boolean yes)
yes - the new enabled statepublic boolean isEnabled()
public void setValueToDefault()
public void setWidth(double w)
w - the new widthpublic double getWidth()
public void setHeight(double h)
h - the new heightpublic double getHeight()
public boolean onClickAt(double px,
double py,
boolean publicOnly)
onClickAt in class Shapepx - the x coordinate of the clickpy - the y coordinate of the clickpublicOnly - if true, not public shape returns false
public boolean contains(double px,
double py)
Shape
contains in class Shapepx - the x coordinate relative to this shape's containerpy - the y coordinate relative to this shape's container
public Presentable getPresentable()
getPresentable in class Shapepublic void restoreOwner(java.lang.Object owner)
Shape
restoreOwner in interface com.xj.anylogic.engine.internal.ChildrestoreOwner in class Shapeowner - owner of this object, usually ActiveObject,
Experiment or
ShapeGrouppublic void update()
public void draw(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
boolean publicOnly)
draw in class Shapepanel - the panel where the drawing is doneg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingpublicOnly - if true, the shape is only drawn if it is publicpublic Shape clone()
UnsupportedOperationException if called
clone in class Shape
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||