gishur.gui2
Class LineShape

java.lang.Object
  |
  +--java.awt.Polygon
        |
        +--gishur.gui2.PolygonShape
              |
              +--gishur.gui2.LineShape
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, java.io.Serializable, Shape, java.awt.Shape

public class LineShape
extends PolygonShape

A special PolygonShape class, especially for line- and curve-polygons.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Fields inherited from class java.awt.Polygon
bounds, npoints, xpoints, ypoints
 
Constructor Summary
LineShape()
          Creates an empty LineShape.
LineShape(int x1, int y1, int x2, int y2, int width)
          Creates a LineShape representing the line segment (x1,y1)-(x2,y2) with the width width.
LineShape(java.awt.Point p1, java.awt.Point p2, int width)
          Creates a LineShape representing the line segment p1-p2 with the width width.
 
Method Summary
 double calculateLength()
           
 java.awt.Point calculatePoint(java.awt.Point p, double x)
           
static LineShape createArrowLine(int x1, int y1, int x2, int y2, int width, int arrow_width, int arrow_height, boolean src_arrow, boolean trg_arrow)
          Creates an arrow line polygon.
static LineShape createArrowLine(java.awt.Point src, java.awt.Point trg, int width, int arrow_width, int arrow_height, boolean src_arrow, boolean trg_arrow)
          Creates an arrow line polygon.
static LineShape createCurve(int x1, int y1, int x2, int y2, int x3, int y3, int width, int steps)
          Creates a bezier curve.
 void setArrowLine(int x1, int y1, int x2, int y2, int width, int arrow_width, int arrow_height, boolean src_arrow, boolean trg_arrow)
          Sets the PolygonShape to one that represents an arrow line polygon.
 void setArrowLine(java.awt.Point src, java.awt.Point trg, int width, int arrow_width, int arrow_height, boolean src_arrow, boolean trg_arrow)
          Sets the PolygonShape to one that represents an arrow line polygon.
 void setCurveArrowLine(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int x5, int y5, int x6, int y6, int width, int steps, int arrow_width, int arrow_height, boolean src_arrow, boolean trg_arrow)
          Sets the PolygonShape to one that represents an curve polygon.
 void setCurveLine(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int x5, int y5, int x6, int y6, int width, int steps)
          Sets the PolygonShape to one that represents an curve polygon.
 void setLine(int x1, int y1, int x2, int y2, int width)
          Sets the PolygonShape to one that represents the line segment (x1,y1)-(x2,y2) with the width width.
 void setLine(java.awt.Point src, java.awt.Point trg, int width)
          Sets the PolygonShape to one that represents the line segment src-trg with the width width.
 
Methods inherited from class gishur.gui2.PolygonShape
clear, clone, contains, contains, contains, draw, fill, getBounds, getBoundShape, getCenter, getCenterX, getCenterY, intersects, set, set, setArrow, setCurve, setLine, setLocation, toString
 
Methods inherited from class java.awt.Polygon
addPoint, contains, contains, contains, contains, getBoundingBox, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, translate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gishur.gui2.Shape
translate
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getBounds2D, getPathIterator, getPathIterator, intersects, intersects
 

Constructor Detail

LineShape

public LineShape()
Creates an empty LineShape.

LineShape

public LineShape(int x1,
                 int y1,
                 int x2,
                 int y2,
                 int width)
Creates a LineShape representing the line segment (x1,y1)-(x2,y2) with the width width.
Parameters:
x1,y1 - first segment endpoint
x2,y2 - second segment endpoint
width - linewidth

LineShape

public LineShape(java.awt.Point p1,
                 java.awt.Point p2,
                 int width)
Creates a LineShape representing the line segment p1-p2 with the width width.
Parameters:
p1 - first segment endpoint
p2 - second segment endpoint
width - linewidth
Method Detail

createArrowLine

public static LineShape createArrowLine(java.awt.Point src,
                                        java.awt.Point trg,
                                        int width,
                                        int arrow_width,
                                        int arrow_height,
                                        boolean src_arrow,
                                        boolean trg_arrow)
Creates an arrow line polygon.
Parameters:
src - the source point
trg - the target point
width - the line width
arrow_width - the width of the arrow
arrow_height - the height of the arrow (only one side)
src_arrow - if true, creates an arrow at the source side
trg_arrow - if true, creates an arrow at the target side
Returns:
the constructed arrow line polygon

createArrowLine

public static LineShape createArrowLine(int x1,
                                        int y1,
                                        int x2,
                                        int y2,
                                        int width,
                                        int arrow_width,
                                        int arrow_height,
                                        boolean src_arrow,
                                        boolean trg_arrow)
Creates an arrow line polygon.
Parameters:
x1,y1 - the source point
x2,y2 - the target point
width - the line width
arrow_width - the width of the arrow
arrow_height - the height of the arrow (only one side)
src_arrow - if true, creates an arrow at the source side
trg_arrow - if true, creates an arrow at the target side
Returns:
the constructed arrow line polygon

createCurve

public static LineShape createCurve(int x1,
                                    int y1,
                                    int x2,
                                    int y2,
                                    int x3,
                                    int y3,
                                    int width,
                                    int steps)
Creates a bezier curve.
Parameters:
x1,y1 - first bezier point
x2,y2 - second bezier point
x3,y3 - third bezier point
width - line width
steps - approximation steps

setLine

public void setLine(int x1,
                    int y1,
                    int x2,
                    int y2,
                    int width)
Sets the PolygonShape to one that represents the line segment (x1,y1)-(x2,y2) with the width width.
Parameters:
x1,y1 - first segment endpoint
x2,y2 - second segment endpoint
width - linewidth

setLine

public void setLine(java.awt.Point src,
                    java.awt.Point trg,
                    int width)
Sets the PolygonShape to one that represents the line segment src-trg with the width width.
Parameters:
src - first segment endpoint
trg - second segment endpoint
width - linewidth

setArrowLine

public void setArrowLine(int x1,
                         int y1,
                         int x2,
                         int y2,
                         int width,
                         int arrow_width,
                         int arrow_height,
                         boolean src_arrow,
                         boolean trg_arrow)
Sets the PolygonShape to one that represents an arrow line polygon.
Parameters:
x1,y1 - the source point
x2,y2 - the target point
width - the line width
arrow_width - the width of the arrow
arrow_height - the height of the arrow (only one side)
src_arrow - if true, creates an arrow at the source side
trg_arrow - if true, creates an arrow at the target side

setArrowLine

public void setArrowLine(java.awt.Point src,
                         java.awt.Point trg,
                         int width,
                         int arrow_width,
                         int arrow_height,
                         boolean src_arrow,
                         boolean trg_arrow)
Sets the PolygonShape to one that represents an arrow line polygon.
Parameters:
src - the source point
trg - the target point
width - the line width
arrow_width - the width of the arrow
arrow_height - the height of the arrow (only one side)
src_arrow - if true, creates an arrow at the source side
trg_arrow - if true, creates an arrow at the target side

setCurveLine

public void setCurveLine(int x1,
                         int y1,
                         int x2,
                         int y2,
                         int x3,
                         int y3,
                         int x4,
                         int y4,
                         int x5,
                         int y5,
                         int x6,
                         int y6,
                         int width,
                         int steps)
Sets the PolygonShape to one that represents an curve polygon. The polygon has two bezier-curved parts: from (x1,y1) via control point (x5,y5) to (x2,y2) and from (x3,y3) via control point (x6,y6) to (x4,y4). The part between (x2,y2) and (x3,y3) is a normal line.
Parameters:
x1,y1 - the source point
x2,y2 - first via point
x3,y3 - second via point
x4,y4 - the target point
x5,y5 - first control point
x6,y6 - second control point
width - the line width
steps - the approximation steps pro curve part

setCurveArrowLine

public void setCurveArrowLine(int x1,
                              int y1,
                              int x2,
                              int y2,
                              int x3,
                              int y3,
                              int x4,
                              int y4,
                              int x5,
                              int y5,
                              int x6,
                              int y6,
                              int width,
                              int steps,
                              int arrow_width,
                              int arrow_height,
                              boolean src_arrow,
                              boolean trg_arrow)
Sets the PolygonShape to one that represents an curve polygon. The polygon has two bezier-curved parts: from (x1,y1) via control point (x5,y5) to (x2,y2) and from (x3,y3) via control point (x6,y6) to (x4,y4). The part between (x2,y2) and (x3,y3) is a normal line. Additional to #setCurveLinePolygon the curve may have arrows at the end
Parameters:
x1,y1 - the source point
x2,y2 - first via point
x3,y3 - second via point
x4,y4 - the target point
x5,y5 - first control point
x6,y6 - second control point
width - the line width
steps - the approximation steps pro curve part
arrow_width - the width of the arrow
arrow_height - the height of the arrow (only one side)
src_arrow - if true, creates an arrow at the source side
trg_arrow - if true, creates an arrow at the target side

calculateLength

public double calculateLength()

calculatePoint

public java.awt.Point calculatePoint(java.awt.Point p,
                                     double x)