com.xj.anylogic.engine.presentation
Class ShapeRectangle

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.presentation.ShapeLineFill
          extended by com.xj.anylogic.engine.presentation.ShapeRectangle
All Implemented Interfaces:
Area2D, com.xj.anylogic.engine.internal.Child, Locatable2D, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Shape3DRectangle, ShapeRoundedRectangle

public class ShapeRectangle
extends ShapeLineFill
implements Area2D

Persistent rectangle 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
ShapeRectangle()
          Constructs a rectangle with default attributes.
ShapeRectangle(boolean ispublic, double x, double y, double rotation, java.awt.Color lineColor, java.awt.Color fillColor, double width, double height, double lineWidth, int lineStyle)
          Constructs a rectangle with specific attributes.
ShapeRectangle(boolean ispublic, double x, double y, double rotation, java.lang.Object lineColor, java.lang.Object fillColor, double width, double height, double lineWidth, int lineStyle)
          Constructs a rectangle with specific attributes.
 
Method Summary
 ShapeRectangle 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 rectangle in a given context
 double getHeight()
          Returns the height of the rectangle.
 double getWidth()
          Returns the width of the rectangle.
 boolean onClickAt(double px, double py, boolean publicOnly)
          Tests if the rectangle contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point.
 void setHeight(double height)
          Sets the height of the rectangle.
 void setSize(double width, double height)
          Sets the width and height of the rectangle.
 void setWidth(double width)
          Sets the width of the rectangle.
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeLineFill
getFillColor, getFillTexture, getLineColor, getLineStyle, getLineTexture, getLineWidth, setFillColor, setFillColor, setLineColor, setLineColor, setLineStyle, setLineWidth
 
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
 
Methods inherited from interface com.xj.anylogic.engine.Area2D
getX, getY
 

Constructor Detail

ShapeRectangle

public ShapeRectangle()
Constructs a rectangle with default attributes.


ShapeRectangle

public ShapeRectangle(boolean ispublic,
                      double x,
                      double y,
                      double rotation,
                      java.awt.Color lineColor,
                      java.awt.Color fillColor,
                      double width,
                      double height,
                      double lineWidth,
                      int lineStyle)
Constructs a rectangle with specific attributes.

Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the rectangle upper left corner
y - the y coordinate of the rectangle upper left corner
rotation - the rotation of the rectangle in radians
lineColor - line color of the rectangle
fillColor - fill color of the rectangle
width - the width of the rectangle
height - the height of the rectangle
lineWidth - the line width of the rectangle
lineStyle - the line stroke style of the rectangle (solid, dotted, dashed)

ShapeRectangle

public ShapeRectangle(boolean ispublic,
                      double x,
                      double y,
                      double rotation,
                      java.lang.Object lineColor,
                      java.lang.Object fillColor,
                      double width,
                      double height,
                      double lineWidth,
                      int lineStyle)
Constructs a rectangle with specific attributes.

Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the rectangle upper left corner
y - the y coordinate of the rectangle upper left corner
rotation - the rotation of the rectangle in radians
lineColor - line color (or Texture) of the rectangle
fillColor - fill color (or Texture) of the rectangle
width - the width of the rectangle
height - the height of the rectangle
lineWidth - the line width of the rectangle
lineStyle - the line stroke style of the rectangle (solid, dotted, dashed)
Method Detail

setWidth

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

Parameters:
width - the new width of the rectangle

getWidth

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

Specified by:
getWidth in interface Area2D
Returns:
the width of the rectangle

setHeight

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

Parameters:
height - the new height of the rectangle

getHeight

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

Specified by:
getHeight in interface Area2D
Returns:
the height of the rectangle

setSize

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

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

onClickAt

public boolean onClickAt(double px,
                         double py,
                         boolean publicOnly)
Tests if the rectangle 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 rectangle 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 ShapeRectangle 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.