|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfig.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. |
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. for a text object) |
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)
method stub for the scale() method |
void |
select()
method stub for the select() method. |
void |
set_debug()
set debug flag |
void |
setAttributes(FigAttribs attributes)
|
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 fig_fill_style)
|
void |
setIsClosed(boolean b)
|
void |
setLineColor(java.awt.Color c)
set a new line color |
void |
setLineStyle(int fig_line_style)
|
void |
setLineWidth(int width_in_pixels)
|
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/... operations |
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 |
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 FigObjectpublic boolean isClosed()
isClosed in interface FigObjectpublic void setIsClosed(boolean b)
public void appendPoint(java.awt.Point p)
appendPoint in interface FigObjectpublic void update_bbox()
public void setTrafo(FigTrafo2D trafo)
setTrafo in interface FigObjectpublic void setLineColor(java.awt.Color c)
public void setFillColor(java.awt.Color c)
public void setLineWidth(int width_in_pixels)
public void setLineStyle(int fig_line_style)
public void setFillStyle(int fig_fill_style)
public double minDistance(java.awt.Point wp)
minDistance in interface FigObjectpublic double minDistanceEuclid(java.awt.Point wp)
minDistanceEuclid in interface FigObjectpublic java.lang.String toString()
toString in interface FigObject
public void move(int dx,
int dy)
FigObject
move in interface FigObjectpublic FigObject copy()
copy in interface FigObjectpublic boolean canRotate(double angle_in_rad)
canRotate in interface FigObjectpublic void update(FigAttribs new_attribs)
update in interface FigObjectnew_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 FigObjectpublic boolean supportsPointOps()
supportsPointOps in interface FigObjectpublic java.awt.Point[] getPoints()
getPoints in interface FigObjectpublic void setPoints(java.awt.Point[] wcp)
setPoints in interface FigObject
public void insertPoint(java.awt.Point wp,
java.awt.Point wprev)
insertPoint in interface FigObjectpublic java.awt.Point deletePoint(java.awt.Point wp)
deletePoint in interface FigObjectpublic int indexOfNearestNeighbor(java.awt.Point wp)
public void movePoint(java.awt.Point wp,
java.awt.Point wpnew)
movePoint in interface FigObjectpublic java.awt.Point[] getMovePointNeighbors(java.awt.Point wp)
getMovePointNeighbors in interface FigObjectpublic 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 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 FigObjectpublic boolean isVisible()
isVisible in interface FigObjectpublic void setVisible(boolean b)
setVisible in interface FigObjectpublic boolean initialize(java.lang.String s)
initialize in interface FigObjectpublic void setObjectPainter(ObjectPainter painter)
setObjectPainter in interface FigObjectpublic ObjectPainter getObjectPainter()
public FigTrafo2D getTrafo()
FigObject
getTrafo in interface FigObjectpublic int getLayer()
FigObject
getLayer in interface FigObjectpublic FigBbox getBbox()
getBbox in interface FigObjectpublic FigBbox get_sc_bbox()
get_sc_bbox in interface FigObjectpublic java.awt.Point getPosition()
getPosition in interface FigObjectpublic FigAttribs getAttributes()
FigObject
getAttributes in interface FigObjectpublic void setAttributes(FigAttribs attributes)
setAttributes in interface FigObjectpublic void set_debug()
FigObject
set_debug in interface FigObjectpublic void reset_debug()
FigObject
reset_debug in interface FigObject
public void scale(java.awt.Point origin,
double factor_x,
double factor_y)
FigObject
scale in interface FigObject
public void rotate(java.awt.Point anchor,
double angle_in_rad)
throws java.lang.Exception
FigObject
rotate in interface FigObjectjava.lang.Exceptionpublic void showPoints()
FigObject
showPoints in interface FigObjectpublic void select()
FigObject
select in interface FigObjectpublic void deselect()
FigObject
deselect in interface FigObjectpublic boolean isSelected()
FigObject
isSelected in interface FigObjectpublic boolean isShowPoints()
public int numPoints()
FigObject
numPoints in interface FigObjectpublic java.lang.String getText()
FigObject
getText in interface FigObjectpublic void setText(java.lang.String s)
FigObject
setText in interface FigObjectpublic 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 FigObjectpublic void writeAsResource(java.io.PrintWriter writer)
FigObject
writeAsResource in interface FigObjectpublic java.lang.String getComment()
FigObject
getComment in interface FigObjectpublic void setComment(java.lang.String s)
FigObject
setComment in interface FigObjectpublic boolean getSyncRedrawFlag()
FigDrawable
getSyncRedrawFlag in interface FigDrawablepublic void setSyncRedrawFlag(boolean b)
FigDrawable
setSyncRedrawFlag in interface FigDrawablepublic 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 | |||||||||