com.googlecode.whatswrong
Class SpanLayout

java.lang.Object
  extended by com.googlecode.whatswrong.AbstractEdgeLayout
      extended by com.googlecode.whatswrong.SpanLayout

public class SpanLayout
extends AbstractEdgeLayout

A SpanLayouy lays out edges as rectangular blocks under or above the tokens that the edge covers. The label is written into these blocks. If there are multiple edge types then all spans of the same type appear in the same contiguous vertical area.

Author:
Sebastian Riedel

Field Summary
 
Fields inherited from class com.googlecode.whatswrong.AbstractEdgeLayout
baseline, curve, from, heightPerLevel, maxHeight, maxWidth, shapes, to, vertexExtraSpace, visible
 
Constructor Summary
SpanLayout()
          Creates a new SpanLayout.
 
Method Summary
 java.util.Map<Token,java.lang.Integer> estimateRequiredTokenWidths(java.util.Collection<Edge> edges, java.awt.Graphics2D g2d)
          For each token that has a self-loop we need the token to be wide enough.
 int getOrder(java.lang.String type)
          Returns the order/vertical layer in which the area of a certain type should be drawn.
 boolean isSeparationLines()
          Should we draw separation lines between the areas for different span types.
 java.awt.Dimension layoutEdges(java.util.Collection<Edge> edges, java.util.Map<Token,Bounds1D> bounds, java.awt.Graphics2D g2d)
          Lays out the edges as spans (blocks) under or above the tokens they contain.
 void setSeparationLines(boolean separationLines)
          Should we draw separation lines between the areas for different span types.
 void setTypeOrder(java.lang.String type, int order)
          Sets the order/vertical layer in which the area of a certain type should be drawn.
 
Methods inherited from class com.googlecode.whatswrong.AbstractEdgeLayout
addToSelection, calculateDepth, clearSelection, getBaseline, getColor, getEdgeAt, getFrom, getHeight, getHeightPerLevel, getSelected, getStroke, getStroke, getTo, getVertexExtraSpace, getWidth, isCurve, onlyShow, removeFromSelection, select, setBaseline, setColor, setCurve, setHeightPerLevel, setStroke, setVertexExtraSpace, showAll, toggleSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpanLayout

public SpanLayout()
Creates a new SpanLayout.

Method Detail

setTypeOrder

public void setTypeOrder(java.lang.String type,
                         int order)
Sets the order/vertical layer in which the area of a certain type should be drawn.

Parameters:
type - the type we want to change the order for.
order - the order/vertical layer in which the area of the given type should be drawn.

getOrder

public int getOrder(java.lang.String type)
Returns the order/vertical layer in which the area of a certain type should be drawn.

Parameters:
type - the type we want to get the order for.
Returns:
the order/vertical layer in which the area of the given type should be drawn.

isSeparationLines

public boolean isSeparationLines()
Should we draw separation lines between the areas for different span types.

Returns:
true iff separation lines should be drawn.

setSeparationLines

public void setSeparationLines(boolean separationLines)
Should we draw separation lines between the areas for different span types.

Parameters:
separationLines - true iff separation lines should be drawn.

estimateRequiredTokenWidths

public java.util.Map<Token,java.lang.Integer> estimateRequiredTokenWidths(java.util.Collection<Edge> edges,
                                                                          java.awt.Graphics2D g2d)
For each token that has a self-loop we need the token to be wide enough. This method calculates the needed token width for a given set of edges. That is, for all self-loops in the set of edges we calculate how wide the corresponding token need to be.

Parameters:
edges - the set of edges that can contain self-loops.
g2d - the graphics object needed to find out the actual width of text.
Returns:
A mapping from tokens with self-loops to pixel widths.

layoutEdges

public java.awt.Dimension layoutEdges(java.util.Collection<Edge> edges,
                                      java.util.Map<Token,Bounds1D> bounds,
                                      java.awt.Graphics2D g2d)
Lays out the edges as spans (blocks) under or above the tokens they contain.

Parameters:
edges - the edges to layout.
bounds - the bounds of the tokens the spans connect.
g2d - the graphics object to draw on.
Returns:
the dimensions of the drawn graph.


Copyright © 2010. All Rights Reserved.