public class MarkerShapePainter extends java.lang.Object implements ShapePainter
Modifier and Type | Field and Description |
---|---|
private java.awt.geom.Rectangle2D |
dGeometryBounds
Internal Cache: Geometry bounds
|
private java.awt.geom.Rectangle2D |
dPrimitiveBounds
Internal Cache: Primitive bounds
|
protected Marker |
endMarker
End Marker
|
private ProxyGraphicsNode |
endMarkerProxy
End marker proxy.
|
protected ExtendedShape |
extShape
The Shape to be painted.
|
private CompositeGraphicsNode |
markerGroup
Contains the various marker proxies.
|
protected Marker |
middleMarker
Middle Marker
|
private ProxyGraphicsNode[] |
middleMarkerProxies
Middle marker proxy.
|
protected Marker |
startMarker
Start Marker
|
private ProxyGraphicsNode |
startMarkerProxy
Start marker proxy.
|
Constructor and Description |
---|
MarkerShapePainter(java.awt.Shape shape)
Constructs a new
MarkerShapePainter that can be used to markers
on top of a shape. |
Modifier and Type | Method and Description |
---|---|
protected ProxyGraphicsNode |
buildEndMarkerProxy()
Builds a proxy
GraphicsNode for the input Marker to be
drawn at the end position. |
protected void |
buildMarkerGroup()
Builds a new marker group with the current set of markers.
|
protected ProxyGraphicsNode[] |
buildMiddleMarkerProxies()
Builds a proxy
GraphicsNode for the input
Marker to be drawn at the middle positions |
protected ProxyGraphicsNode |
buildStartMarkerProxy()
Builds a proxy
GraphicsNode for the input Marker to be
drawn at the start position |
private double[] |
computeInSlope(double[] prev,
int prevSegType,
double[] curr,
int currSegType)
Returns dx/dy for the in slope.
|
private java.awt.geom.AffineTransform |
computeMarkerTransform(Marker marker,
java.awt.geom.Point2D markerPosition,
double rotation)
Computes the transform for the input marker, so that it is positioned at
the given position with the specified rotation
|
private double[] |
computeOutSlope(double[] curr,
int currSegType,
double[] next,
int nextSegType)
Returns dx/dy for the out slope.
|
private double |
computeRotation(double[] prev,
int prevSegType,
double[] curr,
int currSegType,
double[] next,
int nextSegType)
Returns the rotation according to the specified parameters in degrees.
|
private ProxyGraphicsNode |
createMiddleMarker(double[] prev,
int prevSegType,
double[] curr,
int currSegType,
double[] next,
int nextSegType)
Creates a ProxyGraphicsNode for a middle marker.
|
Marker |
getEndMarker()
Returns the marker that shall be drawn at the last vertex of the given
shape.
|
ExtendedShape |
getExtShape()
Gets the Shape this shape painter is associated with as an
Extended Shape.
|
Marker |
getMiddleMarker()
Returns the marker that shall be drawn at every other vertex (not the
first or the last one) of the given shape.
|
java.awt.Shape |
getPaintedArea()
Returns the area painted by this shape painter.
|
java.awt.geom.Rectangle2D |
getPaintedBounds2D()
Returns the bounds of the area painted by this shape painter
|
protected java.awt.geom.Point2D |
getSegmentTerminatingPoint(double[] coords,
int segType)
Extracts the terminating point, depending on the segment type.
|
java.awt.Shape |
getSensitiveArea()
Returns the area covered by this shape painter (even if not painted).
|
java.awt.geom.Rectangle2D |
getSensitiveBounds2D()
Returns the bounds of the area covered by this shape painte
(even if not painted).
|
java.awt.Shape |
getShape()
Gets the Shape this shape painter is associated with.
|
Marker |
getStartMarker()
Returns the marker that shall be drawn at the first vertex of the given
shape.
|
boolean |
inPaintedArea(java.awt.geom.Point2D pt)
Returns true if pt is in the area painted by this shape painter
|
boolean |
inSensitiveArea(java.awt.geom.Point2D pt)
Returns true if pt is in the sensitive area.
|
double[] |
normalize(double[] v)
Normalizes the input vector.
|
void |
paint(java.awt.Graphics2D g2d)
Paints the specified shape using the specified Graphics2D.
|
void |
setEndMarker(Marker endMarker)
Sets the marker that shall be drawn at the last vertex of the given
shape.
|
void |
setMiddleMarker(Marker middleMarker)
Sets the marker that shall be drawn at every other vertex (not the first
or the last one) of the given shape.
|
void |
setShape(java.awt.Shape shape)
Sets the Shape this shape painter is associated with.
|
void |
setStartMarker(Marker startMarker)
Sets the marker that shall be drawn at the first vertex of the given
shape.
|
protected ExtendedShape extShape
protected Marker startMarker
protected Marker middleMarker
protected Marker endMarker
private ProxyGraphicsNode startMarkerProxy
private ProxyGraphicsNode[] middleMarkerProxies
private ProxyGraphicsNode endMarkerProxy
private CompositeGraphicsNode markerGroup
private java.awt.geom.Rectangle2D dPrimitiveBounds
private java.awt.geom.Rectangle2D dGeometryBounds
public MarkerShapePainter(java.awt.Shape shape)
MarkerShapePainter
that can be used to markers
on top of a shape.shape
- Shape to be painted by this painter.
Should not be nullpublic void paint(java.awt.Graphics2D g2d)
paint
in interface ShapePainter
g2d
- the Graphics2D to usepublic java.awt.Shape getPaintedArea()
getPaintedArea
in interface ShapePainter
public java.awt.geom.Rectangle2D getPaintedBounds2D()
getPaintedBounds2D
in interface ShapePainter
public boolean inPaintedArea(java.awt.geom.Point2D pt)
inPaintedArea
in interface ShapePainter
public java.awt.Shape getSensitiveArea()
getSensitiveArea
in interface ShapePainter
public java.awt.geom.Rectangle2D getSensitiveBounds2D()
getSensitiveBounds2D
in interface ShapePainter
public boolean inSensitiveArea(java.awt.geom.Point2D pt)
inSensitiveArea
in interface ShapePainter
public void setShape(java.awt.Shape shape)
setShape
in interface ShapePainter
shape
- new shape this painter should be associated with.
Should not be null.public ExtendedShape getExtShape()
public java.awt.Shape getShape()
getShape
in interface ShapePainter
public Marker getStartMarker()
public void setStartMarker(Marker startMarker)
startMarker
- the start markerpublic Marker getMiddleMarker()
public void setMiddleMarker(Marker middleMarker)
middleMarker
- the middle markerpublic Marker getEndMarker()
public void setEndMarker(Marker endMarker)
endMarker
- the end markerprotected void buildMarkerGroup()
protected ProxyGraphicsNode buildStartMarkerProxy()
GraphicsNode
for the input Marker
to be
drawn at the start positionprotected ProxyGraphicsNode buildEndMarkerProxy()
GraphicsNode
for the input Marker
to be
drawn at the end position.protected ProxyGraphicsNode[] buildMiddleMarkerProxies()
GraphicsNode
for the input
Marker
to be drawn at the middle positionsprivate ProxyGraphicsNode createMiddleMarker(double[] prev, int prevSegType, double[] curr, int currSegType, double[] next, int nextSegType)
private double computeRotation(double[] prev, int prevSegType, double[] curr, int currSegType, double[] next, int nextSegType)
private double[] computeInSlope(double[] prev, int prevSegType, double[] curr, int currSegType)
private double[] computeOutSlope(double[] curr, int currSegType, double[] next, int nextSegType)
public double[] normalize(double[] v)
private java.awt.geom.AffineTransform computeMarkerTransform(Marker marker, java.awt.geom.Point2D markerPosition, double rotation)
protected java.awt.geom.Point2D getSegmentTerminatingPoint(double[] coords, int segType)