|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ttools.plot2.layer.LineTracer
public class LineTracer
Draws lines composed of a sequence of points, submitted one at a time.
To use it make multiple calls of addVertex
,
followed by a call to flush()
.
Sub-sequences of the point sequence are aggregated in supplied work
arrays and plotted using Graphics2D.draw(Shape)
.
This is superior to the more obvious strategy of calling
Graphics.drawLine
for every pair of points.
It is probably faster, it can work with non-integer coordinates,
and it is necessary to get the dashing right for dashed strokes,
otherwise the dash starts anew for each edge.
This class does some other useful things like avoid attempts to plot
lines which are extremely long or which are known to be outside the clip.
Constructor Summary | |
---|---|
LineTracer(Graphics g,
Rectangle bounds,
Color color,
Stroke stroke,
boolean antialias,
int nwork,
boolean isPixel)
Constructor. |
Method Summary | |
---|---|
void |
addVertex(double dx,
double dy)
Adds a point to the sequence to be plotted. |
void |
flush()
Ensures that all points have been drawn. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LineTracer(Graphics g, Rectangle bounds, Color color, Stroke stroke, boolean antialias, int nwork, boolean isPixel)
nwork
parameter determines the number of points
aggregated into a single plotting call.
There may be visual anomalies every nwork
points, so
it should not be too small, but arrays of this size are allocated,
so it should not be too large either.
g
- the base graphics contextbounds
- bounds beyond which lines should not be drawncolor
- line colourstroke
- line strokeantialias
- whether lines are to be antialiasednwork
- workspace array sizeisPixel
- if true, the graphics context is considered to be
pixellised, allowing some optimisations to be made
that should not be visibleMethod Detail |
---|
public void addVertex(double dx, double dy)
dx
- graphics X coordinatedy
- graphics Y coordinatepublic void flush()
addVertex(double, double)
calls
to ensure that the drawing has actually been done.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |