com.xj.anylogic.engine.presentation
Class ShapeText

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

public class ShapeText
extends Shape

Persistent text shape.

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
ShapeText()
          Constructs a text shape with default attributes.
ShapeText(boolean ispublic, double x, double y, double rotation, java.awt.Color color, java.lang.String text, java.awt.Font font, int alignment)
          Constructs a text shape with specific attributes.
 
Method Summary
 ShapeText 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 text in a given context
 int getAlignment()
          Returns the alignment of the text shape.
 java.awt.Color getColor()
          Returns the color of the text.
 java.awt.Font getFont()
          Returns the font of the text shape.
 java.lang.String getText()
          Returns the text of the text shape.
 boolean onClickAt(double px, double py, boolean publicOnly)
          Tests if the text shape contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point.
 void setAlignment(int alignment)
          Sets the alignment of the text shape.
 void setColor(java.awt.Color color)
          Sets the color of the text.
 void setFont(java.awt.Font font)
          Sets the font of the text shape.
 void setText(java.lang.Object text)
          Sets the text of the text shape.
 
Methods inherited from class com.xj.anylogic.engine.presentation.Shape
canHandleClick, getGroup, getName, getPresentable, getRotation, getScaleX, getScaleY, getX, getY, isVisible, onClick, restoreOwner, 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

ShapeText

public ShapeText()
Constructs a text shape with default attributes.


ShapeText

public ShapeText(boolean ispublic,
                 double x,
                 double y,
                 double rotation,
                 java.awt.Color color,
                 java.lang.String text,
                 java.awt.Font font,
                 int alignment)
Constructs a text shape with specific attributes.

Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the beginning of the first line of the text
y - the y coordinate of the beginning of the first line of the text
rotation - the rotation of the text in radians
color - color of the text
text - the text displayed by the text shape
font - the font used by the text shape
alignment - the alignment of the text shape
Method Detail

setColor

public void setColor(java.awt.Color color)
Sets the color of the text.

Parameters:
color - the new color, null = do not draw the text

getColor

public java.awt.Color getColor()
Returns the color of the text.

Returns:
the color of the text

setText

public void setText(java.lang.Object text)
Sets the text of the text shape.

Parameters:
text - the new text of the text shape

getText

public java.lang.String getText()
Returns the text of the text shape.

Returns:
the text of the text shape

setFont

public void setFont(java.awt.Font font)
Sets the font of the text shape.

Parameters:
font - the new font of the text shape

getFont

public java.awt.Font getFont()
Returns the font of the text shape.

Returns:
the font of the text shape

setAlignment

public void setAlignment(int alignment)
Sets the alignment of the text shape.

Parameters:
alignment - the new alignment of the text shape, one of:

getAlignment

public int getAlignment()
Returns the alignment of the text shape. Possible values are:

Returns:
the alignment of the text shape

onClickAt

public boolean onClickAt(double px,
                         double py,
                         boolean publicOnly)
Tests if the text shape 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 text in a given context

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

clone

public ShapeText 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.