com.xj.anylogic.engine.presentation
Class ShapePolyLine

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.ShapeMultiplePoints
              extended by com.xj.anylogic.engine.presentation.ShapePolyLine
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, Path2D, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Shape3DPolyLine, ShapeCurve

public class ShapePolyLine
extends ShapeMultiplePoints

Persistent polyline 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
ShapePolyLine()
          Constructs a polyline with default attributes.
ShapePolyLine(boolean ispublic, double x, double y, java.awt.Color lineColor, java.awt.Color fillColor, int npoints, double[] dx, double[] dy, boolean closed, double lineWidth, int lineStyle)
          Constructs a polyline with specific attributes.
ShapePolyLine(boolean ispublic, double x, double y, java.lang.Object lineColor, java.lang.Object fillColor, int npoints, double[] dx, double[] dy, boolean closed, double lineWidth, int lineStyle)
          Constructs a polyline with specific attributes.
 
Method Summary
 ShapePolyLine 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 polyline in a given context
 double getXMax()
          Returns the x coordinate of the bottom-right corner of bounding rectangle for this polyline.
 double getXMin()
          Returns the x coordinate of the top-left corner of bounding rectangle for this polyline.
 double getYMax()
          Returns the y coordinate of the bottom-right corner of bounding rectangle for this polyline.
 double getYMin()
          Returns the y coordinate of the top-left corner of bounding rectangle for this polyline.
 double length()
          Calculates and returns the length of the polyline (not scaled), respecting its closeness.
 boolean onClickAt(double px, double py, boolean publicOnly)
          Tests if the polyline contains the point with the given coordinates and, if yes, executes the shape's reaction on click at that point.
 Point randomPointInside()
          Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed).
 Point randomPointInside(java.util.Random rng)
          Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed).
 void setRotation(double r)
          Sets the rotation of the shape.
 void setScale(double s)
          Sets the same scale of the shape along both axes
 void setScale(double sx, double sy)
          Sets the scales of the shape along both axes
 void setScaleX(double sx)
          Sets the scale of the shape along x axis
 void setScaleY(double sy)
          Sets the scale of the shape along y axis
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeMultiplePoints
getNPoints, getPointDx, getPointDy, isClosed, setClosed, setNPoints, setPoint, setPointDx, setPointDy
 
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, 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.Path2D
getX, getY
 

Constructor Detail

ShapePolyLine

public ShapePolyLine()
Constructs a polyline with default attributes.


ShapePolyLine

public ShapePolyLine(boolean ispublic,
                     double x,
                     double y,
                     java.awt.Color lineColor,
                     java.awt.Color fillColor,
                     int npoints,
                     double[] dx,
                     double[] dy,
                     boolean closed,
                     double lineWidth,
                     int lineStyle)
Constructs a polyline with specific attributes.

Parameters:
ispublic - if true, the polyline is visible on container's presentation
x - the x coordinate of the polyline start point
y - the y coordinate of the polyline start point
lineColor - line color of the polyline
fillColor - fill color of the polyline
npoints - the number of points in the polyline
dx - the array of (at least npoints) polyline points x coordinates relative to the start point
dy - the array of (at least npoints) polyline points y coordinates relative to the start point
closed - if true, the polyline is drawn as closed
lineWidth - the polyline width
lineStyle - the polyline stroke style (solid, dotted, dashed)

ShapePolyLine

public ShapePolyLine(boolean ispublic,
                     double x,
                     double y,
                     java.lang.Object lineColor,
                     java.lang.Object fillColor,
                     int npoints,
                     double[] dx,
                     double[] dy,
                     boolean closed,
                     double lineWidth,
                     int lineStyle)
Constructs a polyline with specific attributes.

Parameters:
ispublic - if true, the polyline is visible on container's presentation
x - the x coordinate of the polyline start point
y - the y coordinate of the polyline start point
lineColor - line color (or Texture) of the polyline
fillColor - fill color (or Texture) of the polyline
npoints - the number of points in the polyline
dx - the array of (at least npoints) polyline points x coordinates relative to the start point
dy - the array of (at least npoints) polyline points y coordinates relative to the start point
closed - if true, the polyline is drawn as closed
lineWidth - the polyline width
lineStyle - the polyline stroke style (solid, dotted, dashed)
Method Detail

onClickAt

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

randomPointInside

public Point randomPointInside()
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed). This method utilises Random Number Generator of the Presentable object containing this polyline. (Will throw an exception if the polyline has been created from code and hasn't been added to any group, - in such case please use #).
Returned point is set to the z coordinate of the polyline (zero in case of 2D)

Returns:
the randomly chosen point inside the polyline

randomPointInside

public Point randomPointInside(java.util.Random rng)
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed). This method utilises the given Random Number Generator.
Returned point is set to the z coordinate of the polyline (zero in case of 2D)

Returns:
the randomly chosen point inside the polyline

setRotation

public void setRotation(double r)
Description copied from class: Shape
Sets the rotation of the shape.

Overrides:
setRotation in class Shape
Parameters:
r - the new value of rotation in radians

setScaleX

public void setScaleX(double sx)
Description copied from class: Shape
Sets the scale of the shape along x axis

Overrides:
setScaleX in class Shape
Parameters:
sx - the new value of scale along x axis, 1 = keep original size

setScaleY

public void setScaleY(double sy)
Description copied from class: Shape
Sets the scale of the shape along y axis

Overrides:
setScaleY in class Shape
Parameters:
sy - the new value of scale along y axis, 1 = keep original size

setScale

public void setScale(double s)
Description copied from class: Shape
Sets the same scale of the shape along both axes

Overrides:
setScale in class Shape
Parameters:
s - the new value of scale along both axis, 1 = keep original size

setScale

public void setScale(double sx,
                     double sy)
Description copied from class: Shape
Sets the scales of the shape along both axes

Overrides:
setScale in class Shape
Parameters:
sx - the new value of scale along x axis, 1 = keep original size
sy - the new value of scale along y axis, 1 = keep original size

getXMin

public double getXMin()
Returns the x coordinate of the top-left corner of bounding rectangle for this polyline. (Shape.getX() is included)

Returns:
the minimum x coordinate of the polyline

getXMax

public double getXMax()
Returns the x coordinate of the bottom-right corner of bounding rectangle for this polyline. (Shape.getX() is included)

Returns:
the maximum x coordinate of the polyline
Since:
6.8

getYMin

public double getYMin()
Returns the y coordinate of the top-left corner of bounding rectangle for this polyline. (Shape.getY() is included)

Returns:
the minimum y coordinate of the polyline
Since:
6.8

getYMax

public double getYMax()
Returns the y coordinate of the bottom-right corner of bounding rectangle for this polyline. (Shape.getY() is included)

Returns:
the maximum y coordinate of the polyline
Since:
6.8

length

public double length()
Calculates and returns the length of the polyline (not scaled), respecting its closeness.
For 3D polylines this method also respects z coordinates of points.
This method doesn't work for Curve.

Returns:
the length of the polyline, respecting its closeness

draw

public void draw(Panel panel,
                 java.awt.Graphics2D g,
                 java.awt.geom.AffineTransform xform,
                 boolean publicOnly)
Draws the polyline 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 ShapePolyLine 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.