com.xj.anylogic.engine.presentation
Class ShapeLine

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

public class ShapeLine
extends Shape
implements Segment2D

Persistent line 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
ShapeLine()
          Constructs a line with default attributes.
ShapeLine(boolean ispublic, double x, double y, java.awt.Color color, double dx, double dy, double width, int style)
          Constructs a line with specific attributes.
ShapeLine(boolean ispublic, double x, double y, java.lang.Object color, double dx, double dy, double width, int style)
          Constructs a line with specific attributes.
 
Method Summary
 ShapeLine clone()
          Creates and returns a copy of this shape (i.e. new shape instance).
 boolean contains(double px, double py)
          Always returns false as line has no area and does not contain any point.
 void draw(Panel panel, java.awt.Graphics2D g, java.awt.geom.AffineTransform xform, boolean publicOnly)
          Draws the line in a given context
 java.awt.Color getColor()
          Returns the color of the line, or null if line has no color or has texture (in this case getTexture() should be used instead)
 double getDx()
          Returns the difference of x coordinates of the line end and start points.
 double getDy()
          Returns the difference of y coordinates of the line end and start points.
 double getEndX()
          Returns the x coordinate of the line end point.
 double getEndY()
          Returns the y coordinate of the line end point.
 double getLength()
          Returns the length of the line.
 int getLineStyle()
          Returns the style of the line: ActiveObject.
 double getLineWidth()
          Returns the width of the line.
 Texture getTexture()
          Returns the texture of the line, if the line has it
 boolean onClickAt(double px, double py, boolean publicOnly)
          Always returns false as line has no area and does not handle clicks.
 void setColor(java.awt.Color color)
          Sets the color of the line.
 void setDx(double dx)
          Sets the difference of x coordinates of the line end and start points.
 void setDy(double dy)
          Sets the difference of y coordinates of the line end and start points.
 void setEndX(double endx)
          Sets the x coordinate of the line end point.
 void setEndY(double endy)
          Sets the y coordinate of the line end point.
 void setLineStyle(int style)
          Sets the style of the line: ActiveObject.
 void setLineWidth(double width)
          Sets the width of the line, 0 means thinnest possible
 
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.Segment2D
getX, getY
 

Constructor Detail

ShapeLine

public ShapeLine()
Constructs a line with default attributes.


ShapeLine

public ShapeLine(boolean ispublic,
                 double x,
                 double y,
                 java.awt.Color color,
                 double dx,
                 double dy,
                 double width,
                 int style)
Constructs a line with specific attributes.

Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the line start point
y - the y coordinate of the line start point
color - color of the line
dx - the difference of x coordinates of the line end and start points
dy - the difference of y coordinates of the line end and start points

ShapeLine

public ShapeLine(boolean ispublic,
                 double x,
                 double y,
                 java.lang.Object color,
                 double dx,
                 double dy,
                 double width,
                 int style)
Constructs a line with specific attributes.

Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the line start point
y - the y coordinate of the line start point
color - color (or Texture) of the line
dx - the difference of x coordinates of the line end and start points
dy - the difference of y coordinates of the line end and start points
width - the line width
style - the line stroke style (solid, dotted, dashed)
Method Detail

setColor

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

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

getColor

public java.awt.Color getColor()
Returns the color of the line, or null if line has no color or has texture (in this case getTexture() should be used instead)

Returns:
the color of the line

getTexture

public Texture getTexture()
Returns the texture of the line, if the line has it

Returns:
the texture of the line

setDx

public void setDx(double dx)
Sets the difference of x coordinates of the line end and start points.

Parameters:
dx - the new difference of x coordinates of the line end and start points

getDx

public double getDx()
Returns the difference of x coordinates of the line end and start points.

Specified by:
getDx in interface Segment2D
Returns:
the difference of x coordinates of the line end and start points

setDy

public void setDy(double dy)
Sets the difference of y coordinates of the line end and start points.

Parameters:
dy - the new difference of y coordinates of the line end and start points

getDy

public double getDy()
Returns the difference of y coordinates of the line end and start points.

Specified by:
getDy in interface Segment2D
Returns:
the difference of y coordinates of the line end and start points

setEndX

public void setEndX(double endx)
Sets the x coordinate of the line end point.

Parameters:
endx - the new value of x coordinate of line end

getEndX

public double getEndX()
Returns the x coordinate of the line end point.

Specified by:
getEndX in interface Segment2D
Returns:
the x coordinate of the line end

setEndY

public void setEndY(double endy)
Sets the y coordinate of the line end point.

Parameters:
endy - the new value of y coordinate of line end

getEndY

public double getEndY()
Returns the y coordinate of the line end point.

Specified by:
getEndY in interface Segment2D
Returns:
the y coordinate of the line end

getLength

public double getLength()
Returns the length of the line.

Returns:
the length of the line

setLineWidth

public void setLineWidth(double width)
Sets the width of the line, 0 means thinnest possible

Parameters:
width - the new width of the line

getLineWidth

public double getLineWidth()
Returns the width of the line.

Returns:
the width of the line

setLineStyle

public void setLineStyle(int style)
Sets the style of the line: ActiveObject.{LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED}

Parameters:
style - the new style of the line

getLineStyle

public int getLineStyle()
Returns the style of the line: ActiveObject.{LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED}

Returns:
the style of the line

onClickAt

public boolean onClickAt(double px,
                         double py,
                         boolean publicOnly)
Always returns false as line has no area and does not handle clicks.

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:
false

contains

public boolean contains(double px,
                        double py)
Always returns false as line has no area and does not contain any point.

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 line in a given context

Specified by:
draw in class Shape
Parameters:
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
panel - the panel where the drawing is done

clone

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