|
||||||||||
| 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.ShapeGroup
public class ShapeGroup
Persistent group shape. Contains a collection of shapes that can be either
non-persistent (i.e. having ids), or persistent. Shapes may also be replicated.
The user can add, remove and change shapes in the group dynamically.
Persistent shapes contained in a group have reference to that group.
| Field Summary |
|---|
| Fields inherited from class com.xj.anylogic.engine.presentation.Shape |
|---|
UNKNOWN_NAME |
| Constructor Summary | |
|---|---|
ShapeGroup(Presentable presentable)
Constructs an empty group with default attributes. |
|
ShapeGroup(Presentable presentable,
boolean ispublic,
double x,
double y,
double rotation,
java.lang.Object... contents)
Constructs a group with specific attributes and possibly with some content |
|
| Method Summary | |
|---|---|
void |
add(int shape)
Adds a non-persistent shape to the group. |
void |
add(ReplicatedShape<?> rshape)
Adds a replicated shape to the group. |
void |
add(Shape shape)
Adds a persistent shape to the group. |
void |
clear()
Removes all shapes from the group. |
ShapeGroup |
clone()
Creates and returns a copy of this group (i.e. new shape instance). |
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 the group of shapes in a given context |
java.lang.Object |
get(int i)
Returns the shape (either object of class Shape or integer in case of non-persistent shape, or object of class ReplicatedShape) with the given index. |
Presentable |
getPresentable()
Returns the presentable (ActiveObject or Experiment) where this group belongs to. |
java.util.ArrayList<java.lang.Object> |
getShapes()
Returns the collection of shapes in the group (not a copy). |
int |
indexOf(java.lang.Object shape)
Returns the index of the the specified shape (either object of class Shape or integer in case of non-persistent shape, or object of class ReplicatedShape) in this group, or -1 if this group does not
contain the shape. |
boolean |
onClickAt(double px,
double py,
boolean publicOnly)
Tests if any of the group shapes contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point. |
void |
onDraw(Panel panel,
java.awt.Graphics2D g)
A callback called by the group after the group has drawn itself (and only if the group drawing is needed - it is visible, etc.). |
boolean |
remove(int shape)
Tries to remove a non-persistent shape from the group, returns false if the shape was not contained. |
boolean |
remove(ReplicatedShape<?> rshape)
Tries to remove a replicated shape from the group, returns false if the shape was not contained. |
boolean |
remove(Shape shape)
Tries to remove a persistent shape from the group, returns false if the shape was not contained. |
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 |
int |
size()
Returns the number of shapes in the group. |
| 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 |
| Constructor Detail |
|---|
public ShapeGroup(Presentable presentable)
presentable - the presentable object owning this shape
public ShapeGroup(Presentable presentable,
boolean ispublic,
double x,
double y,
double rotation,
java.lang.Object... contents)
presentable - the presentable object owning this shapeispublic - if true, the shape is visible on container's presentationx - the x coordinate of groupy - the y coordinate of grouprotation - the rotation of the group in radianscontents - the (possibly, empty) initial set of shapes (Shape objects, int ids, or ReplicatedShape objects)| Method Detail |
|---|
public java.util.ArrayList<java.lang.Object> getShapes()
public int size()
public java.lang.Object get(int i)
i - the index of the shape
public int indexOf(java.lang.Object shape)
-1 if this group does not
contain the shape.-1 if
there is no such index.
shape - the shape to find index of
-1public void add(Shape shape)
shape - the shape to addpublic void add(int shape)
shape - the shape id to addpublic void add(ReplicatedShape<?> rshape)
rshape - the replicated shape to addpublic boolean remove(Shape shape)
shape - the shape to remove
public boolean remove(int shape)
shape - the id of the shape to remove
public boolean remove(ReplicatedShape<?> rshape)
rshape - the replicated shape to remove
public void clear()
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 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 public
public void onDraw(Panel panel,
java.awt.Graphics2D g)
panel - the panel where the drawing is doneg - the graphics where the drawing takes placepublic 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 ShapeGroup clone()
clone in class Shape
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||