Package org.apache.batik.gvt
Class MarkerShapePainter
java.lang.Object
org.apache.batik.gvt.MarkerShapePainter
- All Implemented Interfaces:
ShapePainter
A shape painter that can be used to paint markers on a shape.
- Version:
- $Id: MarkerShapePainter.java 1808888 2017-09-19 14:22:11Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Rectangle2D
Internal Cache: Geometry boundsprivate Rectangle2D
Internal Cache: Primitive boundsprotected Marker
End Markerprivate ProxyGraphicsNode
End marker proxy.protected ExtendedShape
The Shape to be painted.private CompositeGraphicsNode
Contains the various marker proxies.protected Marker
Middle Markerprivate ProxyGraphicsNode[]
Middle marker proxy.protected Marker
Start Markerprivate ProxyGraphicsNode
Start marker proxy. -
Constructor Summary
ConstructorsConstructorDescriptionMarkerShapePainter
(Shape shape) Constructs a newMarkerShapePainter
that can be used to markers on top of a shape. -
Method Summary
Modifier and TypeMethodDescriptionprotected ProxyGraphicsNode
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the end position.protected void
Builds a new marker group with the current set of markers.protected ProxyGraphicsNode[]
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the middle positionsprotected ProxyGraphicsNode
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the start positionprivate double[]
computeInSlope
(double[] prev, int prevSegType, double[] curr, int currSegType) Returns dx/dy for the in slope.private AffineTransform
computeMarkerTransform
(Marker marker, Point2D markerPosition, double rotation) Computes the transform for the input marker, so that it is positioned at the given position with the specified rotationprivate 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.Returns the marker that shall be drawn at the last vertex of the given shape.Gets the Shape this shape painter is associated with as an Extended Shape.Returns the marker that shall be drawn at every other vertex (not the first or the last one) of the given shape.Returns the area painted by this shape painter.Returns the bounds of the area painted by this shape painterprotected Point2D
getSegmentTerminatingPoint
(double[] coords, int segType) Extracts the terminating point, depending on the segment type.Returns the area covered by this shape painter (even if not painted).Returns the bounds of the area covered by this shape painte (even if not painted).getShape()
Gets the Shape this shape painter is associated with.Returns the marker that shall be drawn at the first vertex of the given shape.boolean
inPaintedArea
(Point2D pt) Returns true if pt is in the area painted by this shape painterboolean
Returns true if pt is in the sensitive area.double[]
normalize
(double[] v) Normalizes the input vector.void
paint
(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
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.
-
Field Details
-
extShape
The Shape to be painted. -
startMarker
Start Marker -
middleMarker
Middle Marker -
endMarker
End Marker -
startMarkerProxy
Start marker proxy. -
middleMarkerProxies
Middle marker proxy. -
endMarkerProxy
End marker proxy. -
markerGroup
Contains the various marker proxies. -
dPrimitiveBounds
Internal Cache: Primitive bounds -
dGeometryBounds
Internal Cache: Geometry bounds
-
-
Constructor Details
-
MarkerShapePainter
Constructs a newMarkerShapePainter
that can be used to markers on top of a shape.- Parameters:
shape
- Shape to be painted by this painter. Should not be null
-
-
Method Details
-
paint
Paints the specified shape using the specified Graphics2D.- Specified by:
paint
in interfaceShapePainter
- Parameters:
g2d
- the Graphics2D to use
-
getPaintedArea
Returns the area painted by this shape painter.- Specified by:
getPaintedArea
in interfaceShapePainter
-
getPaintedBounds2D
Returns the bounds of the area painted by this shape painter- Specified by:
getPaintedBounds2D
in interfaceShapePainter
-
inPaintedArea
Returns true if pt is in the area painted by this shape painter- Specified by:
inPaintedArea
in interfaceShapePainter
-
getSensitiveArea
Returns the area covered by this shape painter (even if not painted). This is always null for Markers.- Specified by:
getSensitiveArea
in interfaceShapePainter
-
getSensitiveBounds2D
Returns the bounds of the area covered by this shape painte (even if not painted). This is always null for Markers.- Specified by:
getSensitiveBounds2D
in interfaceShapePainter
-
inSensitiveArea
Returns true if pt is in the sensitive area. This is always false for Markers.- Specified by:
inSensitiveArea
in interfaceShapePainter
-
setShape
Sets the Shape this shape painter is associated with.- Specified by:
setShape
in interfaceShapePainter
- Parameters:
shape
- new shape this painter should be associated with. Should not be null.
-
getExtShape
Gets the Shape this shape painter is associated with as an Extended Shape.- Returns:
- shape associated with this painter
-
getShape
Gets the Shape this shape painter is associated with.- Specified by:
getShape
in interfaceShapePainter
- Returns:
- shape associated with this painter
-
getStartMarker
Returns the marker that shall be drawn at the first vertex of the given shape. -
setStartMarker
Sets the marker that shall be drawn at the first vertex of the given shape.- Parameters:
startMarker
- the start marker
-
getMiddleMarker
Returns the marker that shall be drawn at every other vertex (not the first or the last one) of the given shape. -
setMiddleMarker
Sets the marker that shall be drawn at every other vertex (not the first or the last one) of the given shape.- Parameters:
middleMarker
- the middle marker
-
getEndMarker
Returns the marker that shall be drawn at the last vertex of the given shape. -
setEndMarker
Sets the marker that shall be drawn at the last vertex of the given shape.- Parameters:
endMarker
- the end marker
-
buildMarkerGroup
protected void buildMarkerGroup()Builds a new marker group with the current set of markers. -
buildStartMarkerProxy
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the start position -
buildEndMarkerProxy
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the end position. -
buildMiddleMarkerProxies
Builds a proxyGraphicsNode
for the inputMarker
to be drawn at the middle positions -
createMiddleMarker
private ProxyGraphicsNode createMiddleMarker(double[] prev, int prevSegType, double[] curr, int currSegType, double[] next, int nextSegType) Creates a ProxyGraphicsNode for a middle marker. -
computeRotation
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. -
computeInSlope
private double[] computeInSlope(double[] prev, int prevSegType, double[] curr, int currSegType) Returns dx/dy for the in slope. -
computeOutSlope
private double[] computeOutSlope(double[] curr, int currSegType, double[] next, int nextSegType) Returns dx/dy for the out slope. -
normalize
public double[] normalize(double[] v) Normalizes the input vector. This assumes an non-zero length -
computeMarkerTransform
private AffineTransform computeMarkerTransform(Marker marker, Point2D markerPosition, double rotation) Computes the transform for the input marker, so that it is positioned at the given position with the specified rotation -
getSegmentTerminatingPoint
Extracts the terminating point, depending on the segment type.
-