|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.objects.FigPolyline
n-points polyline object.
FigPolyline provides the basic FIG polyline objects for jfig. It supports all xfig line-styles and attributes, including front and back arrows. The actual rendering is deferred to either AWT 1.1 or Java2D based subclasses.
This class also serves as a base class for the FIG spline objects.
Field Summary | |
protected FigAttribs |
attribs
|
protected FigBbox |
bbox
|
protected java.lang.String |
comment
|
protected boolean |
debug
|
protected boolean |
is_closed
|
protected int |
min_i
|
protected int |
min_num_points
|
protected ObjectPainter |
painter
|
protected FigRenderer |
renderer
|
protected boolean |
selected
|
protected boolean |
showPoints
|
protected boolean |
syncRedrawFlag
|
protected FigTrafo2D |
trafo
|
protected boolean |
visible
|
protected java.awt.Point[] |
wcp
|
Constructor Summary | |
FigPolyline()
default constructor: a polyline with default attributes at (0,0) Default drawing Color is black, no fill. |
|
FigPolyline(int x0,
int y0,
boolean is_closed,
FigAttribs _attribs,
FigTrafo2D trafo)
Constructor with attributes, transformation, and first polyline vertex |
Method Summary | |
void |
appendPoint(java.awt.Point p)
append a point (given in world-coordinates) to this polyline. |
double |
calc_dist(java.awt.Point P)
get the minimum euclidean distance of Point p to any line segment of this polyline. |
boolean |
canRotate(double angle_in_rad)
returns true: it is always possible to rotate a polyline. |
FigObject |
copy()
build a copy of this FigPolyline. |
void |
createRenderer()
|
java.awt.Point |
deletePoint(java.awt.Point wp)
delete a Point wp from this polyline. |
void |
deselect()
mehtod stub for the deselect() mehtod |
int |
get_min_dist_index(java.awt.Point P)
get the index of the minimum distance line segment from Point P to this polyline. |
FigBbox |
get_sc_bbox()
calculate the current screen-coordinates bounding box |
FigAttribs |
getAttributes()
get object attributes |
FigBbox |
getBbox()
return the world-coordinates bounding box of this polyline. |
java.lang.String |
getComment()
get the comment for this object (may be null). |
int |
getLayer()
get layer (depth) |
java.awt.Point |
getMinDistPoint1()
|
java.awt.Point |
getMinDistPoint2()
|
double |
getMinPerpendicularDistance(java.awt.Point P)
calculate the minimum distance of Point P to the nearest segment of this polyline. |
double |
getMinPerpendicularDistance(java.awt.Point P,
java.awt.Point w1,
java.awt.Point w2)
calculate the minimum distance of Point P to the nearest segment of this polyline. |
java.awt.Point[] |
getMovePointNeighbors(java.awt.Point wp)
getMovePointNeighbors(): Find the Point wcp[i] nearest to wp on this polyline. |
java.awt.Point |
getNearestPoint(java.awt.Point target)
return the point of this object nearest to Point wp, if any. |
java.awt.Point[] |
getNeighborPoints(java.awt.Point wp)
getNeighborPoints(): find the previous and next neighbor Points for Point wp on this polyline. |
ObjectPainter |
getObjectPainter()
|
java.awt.Point[] |
getPoints()
return Point array (world coords) |
java.awt.Point |
getPosition()
return the base point of this polyline. |
protected double |
getSegmentDistance(java.awt.Point P,
java.awt.Point Q,
java.awt.Point wp)
getSegmentDistance(): calculate the minimum distance of Point WP from the line segment from P to Q. |
boolean |
getSyncRedrawFlag()
is a sync redraw pending on this object? |
java.lang.String |
getText()
get the object's text, if any |
FigTrafo2D |
getTrafo()
get transformation |
int |
indexOfNearestNeighbor(java.awt.Point wp)
|
boolean |
initialize(java.lang.String s)
|
void |
insertPoint(java.awt.Point wp,
java.awt.Point wprev)
insert a Point wp after Point wprev into the Point array. |
boolean |
isClosed()
Is this polyline closed? |
boolean |
isSelected()
get current selection status |
boolean |
isShowPoints()
|
boolean |
isVisible()
|
boolean |
isVisible(FigBbox viewport)
is this object visible within the given FigBbox? |
void |
keyPressed(java.awt.event.KeyEvent event)
react to a key event (e.g. |
int |
manhattan(java.awt.Point p,
java.awt.Point q)
|
void |
message(java.lang.String s)
|
double |
minDistance(java.awt.Point wp)
return the minimum distance of the polyline to the reference point wp. |
double |
minDistanceEuclid(java.awt.Point wp)
return the minimal euclidean distance from point wp to the nearest segment of this polyline. |
void |
mirrorX(int mirror_x,
int mirror_y)
simple implementation of mirrorX(): |
void |
mirrorY(int mirror_x,
int mirror_y)
simple implementation of mirrorY(): |
void |
move(int dx,
int dy)
method stub for the move() method |
void |
movePoint(java.awt.Point wp,
java.awt.Point wpnew)
move a point from position wp to wpnew. |
protected java.awt.Point |
nearerPoint(java.awt.Point P1,
java.awt.Point P2,
java.awt.Point W)
nearerPoint(): Check whether wp is nearer to P1 than P2. |
int |
numPoints()
get number of Points in this object |
void |
paint(java.awt.Graphics g)
paint this polyline using either AWT 1.1 or Java2D |
void |
paint(java.awt.Graphics g,
FigTrafo2D trafo)
paint this object using the specified transformation and Graphics g |
void |
paintSave(java.awt.Graphics g,
FigTrafo2D trafo)
|
protected void |
printCost(int i,
double cost,
double min_cost)
printCost(): help debugging the segment cost functions. |
void |
rebuild()
rebuild all internal data-structures for this polyline. |
void |
reset_debug()
reset debug flag |
void |
rotate(java.awt.Point anchor,
double angle_in_rad)
method stub for rotate() - allow for Exceptions if the object doesn't support the specified angle. |
void |
scale(java.awt.Point origin,
double factor_x,
double factor_y)
scale the polyline. |
void |
select()
method stub for the select() method. |
void |
set_debug()
set debug flag |
void |
setArrowMode(int _mode)
set a new arrow mode for this polyline; possible values are FigAttribs.NO_ARROW, FORWARD_ARROW, BACKWARD_ARROW, DOUBLE_ARROW. |
void |
setAttributes(FigAttribs attributes)
|
void |
setBackwardArrow(int type,
double width,
double length,
double linewidth)
set the type and width, length, linewidth for the backward arrow of this polyline. |
void |
setComment(java.lang.String s)
set a comment for this object. |
void |
setFillColor(java.awt.Color c)
set a new fill color |
void |
setFillStyle(int shade_or_pattern)
set the fill style to one of the predefined FIG values, where -1 implies NO_FILL, a value between 0..40 selects the corresponding shade/tint, and values >= 41 select one of the FIG fill patterns. |
void |
setForwardArrow(int type,
double width,
double length,
double linewidth)
set the type (FigAttribs.SIMPLE_ARROW, TRIANGLE_ARROW, ...) and arrow heads width, length, and linewidth for the forward arrow of this polyline. |
void |
setIsClosed(boolean b)
|
void |
setLayer(int _layer)
set the layer (depth) for this polyline; the FIG format allows values in the range [1..1000] with 1 being the topmost layer. |
void |
setLineColor(java.awt.Color c)
set a new line color |
void |
setLineStyle(int fig_line_style)
set the line style to one of the predefined FIG styles, e.g. |
void |
setLineWidth(int fig_line_width)
set the line width to one of the predefined FIG widths, e.g. |
void |
setObjectPainter(ObjectPainter painter)
|
void |
setPoints(java.awt.Point[] wcp)
set a new array of world-coordinate Points for this polyline. |
void |
setSyncRedrawFlag(boolean b)
set or reset whether this objects needs a sync redraw |
void |
setText(java.lang.String s)
set the object's text |
void |
setTrafo(FigTrafo2D trafo)
set a new transformation. |
void |
setVisible(boolean b)
|
void |
showPoints()
method stub for the showPoints() method. |
boolean |
supportsPointOps()
FigPolyline supports the Point insert/append/delete/... |
java.lang.String |
toString()
toString() for debug purposes. |
void |
update_bbox()
build the polyline bounding box from the world-coordinate points. |
void |
update(FigAttribs new_attribs)
update the attributes for this polyline. |
void |
updateAttributes(java.lang.String s)
|
void |
writeAsResource(java.io.PrintWriter writer)
write a complete text representation of this object |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.awt.Point[] wcp
protected int min_i
protected int min_num_points
protected boolean is_closed
protected FigRenderer renderer
protected FigAttribs attribs
protected FigTrafo2D trafo
protected FigBbox bbox
protected ObjectPainter painter
protected java.lang.String comment
protected boolean debug
protected boolean syncRedrawFlag
protected boolean selected
protected boolean showPoints
protected boolean visible
Constructor Detail |
public FigPolyline()
public FigPolyline(int x0, int y0, boolean is_closed, FigAttribs _attribs, FigTrafo2D trafo)
Method Detail |
public void createRenderer()
public void rebuild()
rebuild
in interface FigObject
public boolean isClosed()
isClosed
in interface FigObject
public void setIsClosed(boolean b)
public void appendPoint(java.awt.Point p)
appendPoint
in interface FigObject
public void update_bbox()
public void setTrafo(FigTrafo2D trafo)
setTrafo
in interface FigObject
public void setLayer(int _layer)
polyline.setLayer( newLayer );
editor.removeFromObjectList( polyline );
editor.insertIntoObjectList( polyline );
public void setArrowMode(int _mode)
public void setForwardArrow(int type, double width, double length, double linewidth)
public void setBackwardArrow(int type, double width, double length, double linewidth)
public void setLineColor(java.awt.Color c)
public void setLineWidth(int fig_line_width)
public void setLineStyle(int fig_line_style)
public void setFillColor(java.awt.Color c)
public void setFillStyle(int shade_or_pattern)
public double minDistance(java.awt.Point wp)
minDistance
in interface FigObject
public double minDistanceEuclid(java.awt.Point wp)
minDistanceEuclid
in interface FigObject
public java.lang.String toString()
toString
in interface FigObject
public void move(int dx, int dy)
FigObject
move
in interface FigObject
public FigObject copy()
copy
in interface FigObject
public boolean canRotate(double angle_in_rad)
canRotate
in interface FigObject
public void update(FigAttribs new_attribs)
update
in interface FigObject
new_attribs
- The current editor FigAttribs object.public void mirrorX(int mirror_x, int mirror_y)
mirrorX
in interface FigObject
public void mirrorY(int mirror_x, int mirror_y)
mirrorY
in interface FigObject
public boolean supportsPointOps()
supportsPointOps
in interface FigObject
public java.awt.Point[] getPoints()
getPoints
in interface FigObject
public void setPoints(java.awt.Point[] wcp)
setPoints
in interface FigObject
public void insertPoint(java.awt.Point wp, java.awt.Point wprev)
insertPoint
in interface FigObject
public java.awt.Point deletePoint(java.awt.Point wp)
deletePoint
in interface FigObject
public int indexOfNearestNeighbor(java.awt.Point wp)
public void movePoint(java.awt.Point wp, java.awt.Point wpnew)
movePoint
in interface FigObject
public java.awt.Point[] getMovePointNeighbors(java.awt.Point wp)
getMovePointNeighbors
in interface FigObject
public java.awt.Point[] getNeighborPoints(java.awt.Point wp)
getNeighborPoints
in interface FigObject
protected double getSegmentDistance(java.awt.Point P, java.awt.Point Q, java.awt.Point wp)
protected java.awt.Point nearerPoint(java.awt.Point P1, java.awt.Point P2, java.awt.Point W)
protected void printCost(int i, double cost, double min_cost)
public double calc_dist(java.awt.Point P)
public double getMinPerpendicularDistance(java.awt.Point P)
P | | Wi ---------*----------- Wi+1 s_x = wi+1_x - wi_x s_y = wi+1_y - wi_y line_w = (x,y | x = wi_x + alpha*s_x, y = wi_y + alpha*s_y) line_p = (x,y | x + p_x - beta *s_y, y = p_y + beta*sx ) and therefore: x = wi_x + alpha*s_x = p_x - beta*s_y y = wi_y + alpha*s_y = p_y + beta*s_x If 0 < alpha < 1 we use the perpendicular distance, if alpha < 0, P lies off Wi and we use the euclidean distance to Wi, if alpha > 1, P lies off Wi+1 and we use the euclidean distance to Wi+1
public double getMinPerpendicularDistance(java.awt.Point P, java.awt.Point w1, java.awt.Point w2)
P | | w1 ---------*----------- w2 s_x = w2_x - w1_x s_y = w2_y - w1_y line_w = (x,y | x = w1_x + alpha*s_x, y = w1_y + alpha*s_y) line_p = (x,y | x + p_x - beta *s_y, y = p_y + beta*sx ) and therefore: x = w1_x + alpha*s_x = p_x - beta*s_y y = w1_y + alpha*s_y = p_y + beta*s_x If 0 < alpha < 1 we use the perpendicular distance, if alpha < 0, P lies off Wi and we use the euclidean distance to Wi, if alpha > 1, P lies off Wi+1 and we use the euclidean distance to Wi+1
public int get_min_dist_index(java.awt.Point P)
public java.awt.Point getMinDistPoint1()
public java.awt.Point getMinDistPoint2()
public boolean isVisible(FigBbox viewport)
FigDrawable
isVisible
in interface FigObject
public boolean isVisible()
isVisible
in interface FigObject
public void setVisible(boolean b)
setVisible
in interface FigObject
public boolean initialize(java.lang.String s)
initialize
in interface FigObject
public void setObjectPainter(ObjectPainter painter)
setObjectPainter
in interface FigObject
public ObjectPainter getObjectPainter()
public FigTrafo2D getTrafo()
FigObject
getTrafo
in interface FigObject
public int getLayer()
FigObject
getLayer
in interface FigObject
public FigBbox getBbox()
getBbox
in interface FigObject
public FigBbox get_sc_bbox()
get_sc_bbox
in interface FigObject
public java.awt.Point getPosition()
getPosition
in interface FigObject
public FigAttribs getAttributes()
FigObject
getAttributes
in interface FigObject
public void setAttributes(FigAttribs attributes)
setAttributes
in interface FigObject
public void updateAttributes(java.lang.String s)
updateAttributes
in interface FigObject
public void set_debug()
FigObject
set_debug
in interface FigObject
public void reset_debug()
FigObject
reset_debug
in interface FigObject
public void scale(java.awt.Point origin, double factor_x, double factor_y)
We also modify the line width, line dash length, and arrow size corresponding to the factor_x value, unless the SetupManager property "jfig.scaleLineWidth" is "false".
scale
in interface FigObject
public void rotate(java.awt.Point anchor, double angle_in_rad) throws java.lang.Exception
FigObject
rotate
in interface FigObject
java.lang.Exception
public void showPoints()
FigObject
showPoints
in interface FigObject
public void select()
FigObject
select
in interface FigObject
public void deselect()
FigObject
deselect
in interface FigObject
public boolean isSelected()
FigObject
isSelected
in interface FigObject
public boolean isShowPoints()
public int numPoints()
FigObject
numPoints
in interface FigObject
public java.lang.String getText()
FigObject
getText
in interface FigObject
public void setText(java.lang.String s)
FigObject
setText
in interface FigObject
public java.awt.Point getNearestPoint(java.awt.Point target)
FigObject
getNearestPoint
in interface FigObject
public int manhattan(java.awt.Point p, java.awt.Point q)
public void keyPressed(java.awt.event.KeyEvent event)
FigObject
keyPressed
in interface FigObject
public void writeAsResource(java.io.PrintWriter writer)
FigObject
writeAsResource
in interface FigObject
public java.lang.String getComment()
FigObject
getComment
in interface FigObject
public void setComment(java.lang.String s)
FigObject
setComment
in interface FigObject
public boolean getSyncRedrawFlag()
FigDrawable
getSyncRedrawFlag
in interface FigDrawable
public void setSyncRedrawFlag(boolean b)
FigDrawable
setSyncRedrawFlag
in interface FigDrawable
public void message(java.lang.String s)
public void paint(java.awt.Graphics g)
paint
in interface FigObject
public void paint(java.awt.Graphics g, FigTrafo2D trafo)
FigDrawable
paint
in interface FigObject
public void paintSave(java.awt.Graphics g, FigTrafo2D trafo)
paintSave
in interface FigObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |