Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.gvt
Class MarkerShapePainter  view MarkerShapePainter download MarkerShapePainter.java

java.lang.Object
  extended byorg.apache.batik.gvt.MarkerShapePainter
All Implemented Interfaces:
ShapePainter

public class MarkerShapePainter
extends java.lang.Object
implements ShapePainter

A shape painter that can be used to paint markers on a shape.

Version:
$Id: MarkerShapePainter.java,v 1.17 2005/03/27 08:58:34 cam Exp $

Field Summary
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  org.apache.batik.ext.awt.geom.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 Summary
MarkerShapePainter(java.awt.Shape shape)
          Constructs a new MarkerShapePainter that can be used to markers on top of a shape.
 
Method Summary
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.
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.
 org.apache.batik.ext.awt.geom.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extShape

protected org.apache.batik.ext.awt.geom.ExtendedShape extShape
The Shape to be painted.


startMarker

protected Marker startMarker
Start Marker


middleMarker

protected Marker middleMarker
Middle Marker


endMarker

protected Marker endMarker
End Marker


startMarkerProxy

private ProxyGraphicsNode startMarkerProxy
Start marker proxy.


middleMarkerProxies

private ProxyGraphicsNode[] middleMarkerProxies
Middle marker proxy.


endMarkerProxy

private ProxyGraphicsNode endMarkerProxy
End marker proxy.


markerGroup

private CompositeGraphicsNode markerGroup
Contains the various marker proxies.


dPrimitiveBounds

private java.awt.geom.Rectangle2D dPrimitiveBounds
Internal Cache: Primitive bounds


dGeometryBounds

private java.awt.geom.Rectangle2D dGeometryBounds
Internal Cache: Geometry bounds

Constructor Detail

MarkerShapePainter

public MarkerShapePainter(java.awt.Shape shape)
Constructs a new MarkerShapePainter that can be used to markers on top of a shape.

Method Detail

paint

public void paint(java.awt.Graphics2D g2d)
Paints the specified shape using the specified Graphics2D.

Specified by:
paint in interface ShapePainter

getPaintedArea

public java.awt.Shape getPaintedArea()
Returns the area painted by this shape painter.

Specified by:
getPaintedArea in interface ShapePainter

getPaintedBounds2D

public java.awt.geom.Rectangle2D getPaintedBounds2D()
Returns the bounds of the area painted by this shape painter

Specified by:
getPaintedBounds2D in interface ShapePainter

inPaintedArea

public boolean inPaintedArea(java.awt.geom.Point2D pt)
Returns true if pt is in the area painted by this shape painter

Specified by:
inPaintedArea in interface ShapePainter

getSensitiveArea

public java.awt.Shape getSensitiveArea()
Returns the area covered by this shape painter (even if not painted). This is always null for Markers.

Specified by:
getSensitiveArea in interface ShapePainter

getSensitiveBounds2D

public java.awt.geom.Rectangle2D 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 interface ShapePainter

inSensitiveArea

public boolean inSensitiveArea(java.awt.geom.Point2D pt)
Returns true if pt is in the sensitive area. This is always false for Markers.

Specified by:
inSensitiveArea in interface ShapePainter

setShape

public void setShape(java.awt.Shape shape)
Sets the Shape this shape painter is associated with.

Specified by:
setShape in interface ShapePainter

getExtShape

public org.apache.batik.ext.awt.geom.ExtendedShape getExtShape()
Gets the Shape this shape painter is associated with as an Extended Shape.


getShape

public java.awt.Shape getShape()
Gets the Shape this shape painter is associated with.

Specified by:
getShape in interface ShapePainter

getStartMarker

public Marker getStartMarker()
Returns the marker that shall be drawn at the first vertex of the given shape.


setStartMarker

public void setStartMarker(Marker startMarker)
Sets the marker that shall be drawn at the first vertex of the given shape.


getMiddleMarker

public 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

public 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.


getEndMarker

public Marker getEndMarker()
Returns the marker that shall be drawn at the last vertex of the given shape.


setEndMarker

public void setEndMarker(Marker endMarker)
Sets the marker that shall be drawn at the last vertex of the given shape.


buildMarkerGroup

protected void buildMarkerGroup()
Builds a new marker group with the current set of markers.


buildStartMarkerProxy

protected ProxyGraphicsNode buildStartMarkerProxy()
Builds a proxy GraphicsNode for the input Marker to be drawn at the start position


buildEndMarkerProxy

protected ProxyGraphicsNode buildEndMarkerProxy()
Builds a proxy GraphicsNode for the input Marker to be drawn at the end position.


buildMiddleMarkerProxies

protected ProxyGraphicsNode[] buildMiddleMarkerProxies()
Builds a proxy GraphicsNode for the input Marker 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.


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 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


getSegmentTerminatingPoint

protected java.awt.geom.Point2D getSegmentTerminatingPoint(double[] coords,
                                                           int segType)
Extracts the terminating point, depending on the segment type.