treebolic.view
Class Painter

java.lang.Object
  extended by treebolic.view.Mapper
      extended by treebolic.view.AbstractPainter
          extended by treebolic.view.Painter

public class Painter
extends AbstractPainter

Painter class

Author:
Bernard Bou

Nested Class Summary
private  class Painter.NodeData
          Class collecting drawing data
 
Field Summary
private static float[] theDashPattern
          Dash pattern
private static java.awt.BasicStroke theDashStroke
          Dash stroke
private static int theDebugFlag
          Debug flag, bit1=draw circles, bit2=suppress
private static float[] theDotPattern
          Dot pattern
private static java.awt.BasicStroke theDotStroke
          Dot stroke
private static int theMinSpanForTerminators
          Minimum span for terminators
private static double theTerminatorWidth
          Edge terminator width
private static double theTerminorLength
          Edge terminator length
private static int theTextPadding
          Text padding
 
Fields inherited from class treebolic.view.AbstractPainter
hyperbolicEdges, isDragging, NFONTS, theBackColor, theBackgroundImage, theDefaultEdgeImage, theDefaultNodeImage, theDefaultTreeEdgeImage, theEdgeColor, theEdgeStyle, theFonts, theForeColor, theGraphics, theNodeBackColor, theNodeForeColor, theTreeEdgeColor, theTreeEdgeStyle, theXInset, theYInset
 
Fields inherited from class treebolic.view.Mapper
theLeft, theScaleX, theScaleY, theSize, theTop, theXShift, theYShift
 
Constructor Summary
Painter()
           
 
Method Summary
private  boolean boxesIntersect(java.awt.geom.Rectangle2D thisBox1, java.awt.geom.Rectangle2D thisBox2)
          Get whether boxes intersect (boxes have to be infalted by one pixel)
private  Painter.NodeData computeNodeData(INode thisNode)
          Compute node data
private  void computeTree(INode thisNode)
          Compute tree recursively
private  void draw(Arc thisArc, java.lang.String thisLabel, java.awt.Image thisImage, int thisStyle, java.awt.geom.Rectangle2D thisFromBox, java.awt.geom.Rectangle2D thisToBox, boolean isBorder)
          Draw arc
private  void draw(IEdge thisEdge)
          Draw non-tree edge
private  void drawArc(java.awt.geom.Arc2D thisArc2D, java.awt.geom.Point2D thisFromAnchor, java.awt.geom.Point2D thisToAnchor, int thisStyle)
          Draw arc2D
private  void drawArc(Complex z1, Complex z2, java.lang.String thisLabel, java.awt.Image thisImage, int thisStyle, java.awt.geom.Rectangle2D thisFromBox, java.awt.geom.Rectangle2D thisToBox, boolean isBorder)
          Draw geodesic arc from z1 to z2 which models line from z1 to z2
private  void drawCircle(double x, double y, double r, java.awt.Color thisColor)
          Draw circle
private  void drawEdgeEnds(java.awt.geom.Point2D thisFrom, java.awt.geom.Point2D thisTo, java.awt.geom.Arc2D thisArc2D, int thisStyle)
          Draw edge ends
private  void drawImage(java.awt.Image thisImage, java.awt.geom.Point2D where)
          Draw image at point
private  void drawLine(java.awt.geom.Point2D thisFromPoint, java.awt.geom.Point2D thisToPoint, int thisStyle)
          Draw line from p1 to p2
private  void drawNode(Painter.NodeData thisNodeData)
          Draw node
private  void drawSpace(INode thisNode)
          Draw node's space
private  void drawText(java.lang.String thisString, java.awt.geom.Point2D thisWhere, double thisOrientation)
          Draw text
private  void drawText(java.lang.String thisString, java.awt.geom.Point2D thisFrom, java.awt.geom.Point2D thisTo)
          Draw text from (x1,y1) to (x2,y2)
private  void drawTree(INode thisNode)
          Draw tree recursively
private  void drawTreeEdge(INode thisParent, INode thisNode)
          Draw tree edge, from parent to child
private static double getEccentricity(java.awt.geom.Arc2D thisArc2D)
          Get arc eccentricity
private  java.awt.geom.Point2D getIntersection(java.awt.geom.Rectangle2D thisRect, java.awt.geom.Arc2D thisArc)
          Get intersection between arc and rectangle
private  java.awt.geom.Point2D getIntersection(java.awt.geom.Rectangle2D thisRect, java.awt.geom.Point2D thisFrom, java.awt.geom.Point2D thisTo)
          Get intersection between line and rectangle
private  java.awt.geom.Point2D getMidArc(java.awt.geom.Arc2D thisArc2D)
          Get mid-arc point
private  java.awt.geom.Point2D getMiddle(java.awt.geom.Point2D x1, java.awt.geom.Point2D x2)
          Get middle
private  double getTangent(java.awt.geom.Arc2D thisArc2D, java.awt.geom.Point2D thisWhere)
          Get tangent to this Arc2D at given point
private  boolean isOnArc(double dx, double dy, java.awt.geom.Arc2D thisArc)
          Test whether point is on arc
private  java.lang.String mangleString(java.lang.String thisString, java.awt.geom.Point2D thisFrom, java.awt.geom.Point2D thisTo)
          Mangle string to fit in
 void paint(INode thisRoot, java.util.List<IEdge> thisEdgeList)
          Paint
 void paintBackground()
          Paint background
private  double pointToAngle(double dx, double dy, java.awt.geom.Arc2D thisArc)
          Compute angle for point
private  java.awt.geom.Arc2D toArc2D(Arc thisArc)
          Convert Arc to Arc2D
 
Methods inherited from class treebolic.view.AbstractPainter
enterDrag, getHyperbolicEdges, leaveDrag, resetColors, setColors, setEdgeStyles, setFonts, setHyperbolicEdges, setImages, setup
 
Methods inherited from class treebolic.view.Mapper
computeScale, getSize, getViewLocation, getXShift, getYShift, hUnitCircleToView, hViewToUnitCircle, setXShift, setYShift, setZoomFactor, viewToUnitCircle, wUnitCircleToView, wViewToUnitCircle, xUnitCircleToView, xViewToUnitCircle, yUnitCircleToView, yViewToUnitCircle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theDotPattern

private static final float[] theDotPattern
Dot pattern


theDotStroke

private static final java.awt.BasicStroke theDotStroke
Dot stroke


theDashPattern

private static final float[] theDashPattern
Dash pattern


theDashStroke

private static final java.awt.BasicStroke theDashStroke
Dash stroke


theMinSpanForTerminators

private static final int theMinSpanForTerminators
Minimum span for terminators

See Also:
Constant Field Values

theTextPadding

private static final int theTextPadding
Text padding

See Also:
Constant Field Values

theTerminorLength

private static final double theTerminorLength
Edge terminator length

See Also:
Constant Field Values

theTerminatorWidth

private static final double theTerminatorWidth
Edge terminator width

See Also:
Constant Field Values

theDebugFlag

private static final int theDebugFlag
Debug flag, bit1=draw circles, bit2=suppress

See Also:
Constant Field Values
Constructor Detail

Painter

public Painter()
Method Detail

paintBackground

public void paintBackground()
Description copied from class: AbstractPainter
Paint background

Specified by:
paintBackground in class AbstractPainter

paint

public void paint(INode thisRoot,
                  java.util.List<IEdge> thisEdgeList)
Description copied from class: AbstractPainter
Paint

Specified by:
paint in class AbstractPainter
Parameters:
thisRoot - starting node
thisEdgeList - edges

computeTree

private void computeTree(INode thisNode)
Compute tree recursively

Parameters:
thisNode - starting node

drawTree

private void drawTree(INode thisNode)
Draw tree recursively

Parameters:
thisNode - starting node

drawNode

private void drawNode(Painter.NodeData thisNodeData)
Draw node

Parameters:
thisNodeData - computed node data

computeNodeData

private Painter.NodeData computeNodeData(INode thisNode)
Compute node data

Parameters:
thisNode - node
Returns:
node data

drawTreeEdge

private void drawTreeEdge(INode thisParent,
                          INode thisNode)
Draw tree edge, from parent to child

Parameters:
thisParent - from-node
thisNode - to-node

draw

private void draw(IEdge thisEdge)
Draw non-tree edge

Parameters:
thisEdge - edge

drawArc

private void drawArc(Complex z1,
                     Complex z2,
                     java.lang.String thisLabel,
                     java.awt.Image thisImage,
                     int thisStyle,
                     java.awt.geom.Rectangle2D thisFromBox,
                     java.awt.geom.Rectangle2D thisToBox,
                     boolean isBorder)
Draw geodesic arc from z1 to z2 which models line from z1 to z2

Parameters:
z1 - from-end
z2 - to-end
thisLabel - arc label
thisImage - arc image
thisStyle - code for edge style
thisFromBox - from-node box
thisToBox - to-node box
isBorder - true if arc neighbours border

draw

private void draw(Arc thisArc,
                  java.lang.String thisLabel,
                  java.awt.Image thisImage,
                  int thisStyle,
                  java.awt.geom.Rectangle2D thisFromBox,
                  java.awt.geom.Rectangle2D thisToBox,
                  boolean isBorder)
Draw arc

Parameters:
thisArc - arc
thisLabel - arc label
thisImage - arc image
isBorder - true if arc neighbours border

drawArc

private void drawArc(java.awt.geom.Arc2D thisArc2D,
                     java.awt.geom.Point2D thisFromAnchor,
                     java.awt.geom.Point2D thisToAnchor,
                     int thisStyle)
Draw arc2D

Parameters:
thisArc2D - arc

drawEdgeEnds

private void drawEdgeEnds(java.awt.geom.Point2D thisFrom,
                          java.awt.geom.Point2D thisTo,
                          java.awt.geom.Arc2D thisArc2D,
                          int thisStyle)
Draw edge ends

Parameters:
thisFrom - from-end
thisTo - to-end
thisArc2D - arc
thisStyle - style code

toArc2D

private java.awt.geom.Arc2D toArc2D(Arc thisArc)
Convert Arc to Arc2D

Parameters:
thisArc - arc
Returns:
arc

getEccentricity

private static double getEccentricity(java.awt.geom.Arc2D thisArc2D)
Get arc eccentricity

Parameters:
thisArc2D - arc
Returns:
eccentricity of arc

getMidArc

private java.awt.geom.Point2D getMidArc(java.awt.geom.Arc2D thisArc2D)
Get mid-arc point

Parameters:
thisArc2D - arc
Returns:
point at mid-arc

getTangent

private double getTangent(java.awt.geom.Arc2D thisArc2D,
                          java.awt.geom.Point2D thisWhere)
Get tangent to this Arc2D at given point

Parameters:
thisArc2D - arc
thisWhere - point on arc
Returns:
tangent of this arc at given point

drawText

private void drawText(java.lang.String thisString,
                      java.awt.geom.Point2D thisWhere,
                      double thisOrientation)
Draw text

Parameters:
thisString - string to be drawn
thisWhere - where to put text (centered on this point)
thisOrientation - text orientation

drawText

private void drawText(java.lang.String thisString,
                      java.awt.geom.Point2D thisFrom,
                      java.awt.geom.Point2D thisTo)
Draw text from (x1,y1) to (x2,y2)

Parameters:
thisString - text
thisFrom - from-point
thisTo - to-point

mangleString

private java.lang.String mangleString(java.lang.String thisString,
                                      java.awt.geom.Point2D thisFrom,
                                      java.awt.geom.Point2D thisTo)
Mangle string to fit in

Parameters:
thisString -
thisFrom - from-point
thisTo - to-point
Returns:
mangled string or null

drawLine

private void drawLine(java.awt.geom.Point2D thisFromPoint,
                      java.awt.geom.Point2D thisToPoint,
                      int thisStyle)
Draw line from p1 to p2

Parameters:
thisFromPoint - from-point
thisToPoint - to-point

drawImage

private void drawImage(java.awt.Image thisImage,
                       java.awt.geom.Point2D where)
Draw image at point

Parameters:
thisImage - image
where - location

getMiddle

private java.awt.geom.Point2D getMiddle(java.awt.geom.Point2D x1,
                                        java.awt.geom.Point2D x2)
Get middle

Parameters:
x1 - from point
x2 - to mpoint
Returns:
middle

drawSpace

private void drawSpace(INode thisNode)
Draw node's space

Parameters:
thisNode - node

drawCircle

private void drawCircle(double x,
                        double y,
                        double r,
                        java.awt.Color thisColor)
Draw circle

Parameters:
x - center x-coordinate
y - center y-coordinate
r - radius
thisColor - color

getIntersection

private java.awt.geom.Point2D getIntersection(java.awt.geom.Rectangle2D thisRect,
                                              java.awt.geom.Point2D thisFrom,
                                              java.awt.geom.Point2D thisTo)
Get intersection between line and rectangle

Parameters:
thisRect - rectangle
thisFrom - from-point on line
thisTo - to-point on line
Returns:
intersection point

boxesIntersect

private boolean boxesIntersect(java.awt.geom.Rectangle2D thisBox1,
                               java.awt.geom.Rectangle2D thisBox2)
Get whether boxes intersect (boxes have to be infalted by one pixel)

Parameters:
thisBox1 - box1
thisBox2 - box2
Returns:
true if nodes' boxes intersect

getIntersection

private java.awt.geom.Point2D getIntersection(java.awt.geom.Rectangle2D thisRect,
                                              java.awt.geom.Arc2D thisArc)
Get intersection between arc and rectangle

Parameters:
thisRect - rectangle
thisArc - arc
Returns:
intersection point

isOnArc

private boolean isOnArc(double dx,
                        double dy,
                        java.awt.geom.Arc2D thisArc)
Test whether point is on arc

Parameters:
dx - x-offset from arc center
dy - y-offset from arc center
thisArc - arc
Returns:
whether the point is on arc

pointToAngle

private double pointToAngle(double dx,
                            double dy,
                            java.awt.geom.Arc2D thisArc)
Compute angle for point

Parameters:
dx - x-offset from arc center
dy - y-offset from arc center
thisArc - arc
Returns:
computed angle