com.xj.anylogic.engine.presentation
Class ShapeImage

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.presentation.ShapeImage
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Shape3DImage

public class ShapeImage
extends Shape
implements com.xj.anylogic.engine.internal.Child

Persistent image shape. The set of images is fixed during the lifetime of this object, but you can control the index of the image to display.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.xj.anylogic.engine.presentation.Shape
UNKNOWN_NAME
 
Constructor Summary
ShapeImage(Presentable presentable, boolean ispublic, double x, double y, double rotation, double width, double height, java.lang.String[] filenames)
          Deprecated. use ShapeImage(Presentable, boolean, double, double, double, double, double, String, String[])
ShapeImage(Presentable presentable, boolean ispublic, double x, double y, double rotation, double width, double height, java.lang.String packagePrefix, java.lang.String[] filenames)
          Constructs an image shape with specific attributes.
 
Method Summary
 void add(java.lang.String filename)
          Adds an image to the image shape.
 ShapeImage clone()
          Creates and returns a copy of this shape (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 image in a given context.
 double getHeight()
          Returns the height of the image.
 java.lang.String getImageFileName(int i)
          Returns the file name of the image with the given index.
 java.util.ArrayList<java.lang.String> getImageFileNames()
          Returns the list of image file names of this image shape.
 int getIndex()
          Returns the current index of the image being displayed.
 Presentable getPresentable()
          Returns the Presentable object (ActiveObject or Experiment) where this shape belongs to, or null.
 double getWidth()
          Returns the width of the image.
 boolean onClickAt(double px, double py, boolean publicOnly)
          Tests if the image contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point.
 void remove(int i)
          Removes the image with the given index from the image shape.
 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 setHeight(double height)
          Sets the height of the image.
 void setIndex(int index)
          Sets the index of the image to display.
 void setSize(double width, double height)
          Sets the width and height of the image.
 void setWidth(double width)
          Sets the width of the image.
 
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

ShapeImage

@Deprecated
public ShapeImage(Presentable presentable,
                             boolean ispublic,
                             double x,
                             double y,
                             double rotation,
                             double width,
                             double height,
                             java.lang.String[] filenames)
Deprecated. use ShapeImage(Presentable, boolean, double, double, double, double, double, String, String[])

Constructs an image shape with specific attributes.

Parameters:
presentable - the presentable object owning this image
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the image upper left corner
y - the y coordinate of the image upper left corner
rotation - the rotation of the image in radians
width - the width of the image
height - the height of the image
filenames - the array of image file names

ShapeImage

public ShapeImage(Presentable presentable,
                  boolean ispublic,
                  double x,
                  double y,
                  double rotation,
                  double width,
                  double height,
                  java.lang.String packagePrefix,
                  java.lang.String[] filenames)
Constructs an image shape with specific attributes.

Parameters:
presentable - the presentable object owning this image
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the image upper left corner
y - the y coordinate of the image upper left corner
rotation - the rotation of the image in radians
width - the width of the image
height - the height of the image
packagePrefix - the package name of original active object where this image is defined, formatted using '/' characters; with '/' character at the beginning and at the end
filenames - the array of image file names
Method Detail

setWidth

public void setWidth(double width)
Sets the width of the image.

Parameters:
width - the width of the image

getWidth

public double getWidth()
Returns the width of the image.

Returns:
the width of the image

setHeight

public void setHeight(double height)
Sets the height of the image.

Parameters:
height - the height of the image

getHeight

public double getHeight()
Returns the height of the image.

Returns:
the height of the image

setSize

public void setSize(double width,
                    double height)
Sets the width and height of the image.

Parameters:
width - the new width of the image
height - the new height of the image

setIndex

public void setIndex(int index)
Sets the index of the image to display.

Parameters:
index - the index of the image to display

getIndex

public int getIndex()
Returns the current index of the image being displayed.

Returns:
the current index of the image being displayed

getImageFileNames

public java.util.ArrayList<java.lang.String> getImageFileNames()
Returns the list of image file names of this image shape.

Returns:
the list of image file names of this image shape

getImageFileName

public java.lang.String getImageFileName(int i)
Returns the file name of the image with the given index.

Parameters:
i - the index
Returns:
the file name of the image with the given index

add

public void add(java.lang.String filename)
Adds an image to the image shape.

Parameters:
filename - the file name of the image being added

remove

public void remove(int i)
Removes the image with the given index from the image shape.

Parameters:
i - the index of the image

onClickAt

public boolean onClickAt(double px,
                         double py,
                         boolean publicOnly)
Tests if the image contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point.

Overrides:
onClickAt in class Shape
Parameters:
px - the x coordinate of the click
py - the y coordinate of the click
publicOnly - if true, not public shape returns false
Returns:
true if the click has been handled AND further click processing is not needed, false otherwise

contains

public boolean contains(double px,
                        double py)
Description copied from class: Shape
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)

Specified by:
contains in class Shape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

draw

public void draw(Panel panel,
                 java.awt.Graphics2D g,
                 java.awt.geom.AffineTransform xform,
                 boolean publicOnly)
Draws the image in a given context. If the index exceeds the number of images currently added, does nothing.

Specified by:
draw in class Shape
Parameters:
panel - the panel where the drawing is done
g - the graphics where the drawing takes place
xform - the "original" transform that must be restored before drawing
publicOnly - if true, the shape is only drawn if it is public

getPresentable

public Presentable getPresentable()
Description copied from class: Shape
Returns the Presentable object (ActiveObject or Experiment) where this shape belongs to, or null.

Overrides:
getPresentable in class Shape
Returns:
the Presentable that owns this shape, or null

restoreOwner

public void restoreOwner(java.lang.Object owner)
Description copied from class: Shape
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading

Specified by:
restoreOwner in interface com.xj.anylogic.engine.internal.Child
Overrides:
restoreOwner in class Shape
Parameters:
owner - owner of this object, usually ActiveObject, Experiment or ShapeGroup

clone

public ShapeImage clone()
Description copied from class: Shape
Creates and returns a copy of this shape (i.e. new shape instance).
The returned shape is the object of the same class
The returned copy isn't automatically added to the group this shape belongs to.
The clone is created in the context of the same experiment or active object

Note that cloning of GIS shape, controls and charts is not supported

Overrides:
clone in class Shape


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.