com.googlecode.whatswrong
Class AbstractEdgeLayout

java.lang.Object
  extended by com.googlecode.whatswrong.AbstractEdgeLayout
Direct Known Subclasses:
DependencyLayout, SpanLayout

public abstract class AbstractEdgeLayout
extends java.lang.Object

An AbstractEdgeLayout serves as a base class for edge layout classes. It mostly stores properties associated with drawing edge layouts, such as whether lines should be curved or not.

Author:
Sebastian Riedel

Field Summary
protected  int baseline
          Where do we start to draw
protected  boolean curve
          Should the edges be curved.
protected  java.util.HashMap<Edge,java.awt.Point> from
          A mapping from edges to their start points in the layout.
protected  int heightPerLevel
          How many pixels to use per height level
protected  int maxHeight
          The height of the layout.
protected  int maxWidth
          The width of the layout.
protected  java.util.HashMap<java.awt.Shape,Edge> shapes
          A mapping from edge shapes to the corresponding edge objects.
protected  java.util.HashMap<Edge,java.awt.Point> to
          A mapping from edges to their end points in the layout.
protected  int vertexExtraSpace
          How many extra pixels to start and end arrows from.
protected  java.util.HashSet<Edge> visible
          The set of visisible edges.
 
Constructor Summary
AbstractEdgeLayout()
           
 
Method Summary
 void addToSelection(Edge edge)
          Add an edge to the selection.
protected  int calculateDepth(HashMultiMapLinkedList<Edge,Edge> dominates, Counter<Edge> depth, Edge root)
          Calculate the number of edges under each edge and returns the max.
 void clearSelection()
          Remove all edges from the selection.
 int getBaseline()
          The number of pixels below the graph (between the tokens and the edges).
 java.awt.Color getColor(java.lang.String type)
          Return the color for edges of the given type.
 Edge getEdgeAt(java.awt.geom.Point2D p, int radius)
          Get the Edge at a given location.
 java.awt.Point getFrom(Edge edge)
          Return the point at the start of the given edge.
 int getHeight()
          Return the height of the graph layout.
 int getHeightPerLevel()
          The number of pixels per graph layer.
 java.util.Set<Edge> getSelected()
          Returns the set of selected edges.
 java.awt.BasicStroke getStroke(Edge edge)
          Get the stroke for a given edge.
 java.awt.BasicStroke getStroke(java.lang.String type)
          Returns the stroke for a given type.
 java.awt.Point getTo(Edge edge)
          Return the point at the end of the given edge.
 int getVertexExtraSpace()
          The extra number of pixels around a token vertex we can use for starting and end points of edges.
 int getWidth()
          Return the width of the graph layout.
 boolean isCurve()
          Should edges be curved
 void onlyShow(java.util.Collection<Edge> edges)
          Show only the given edges.
 void removeFromSelection(Edge edge)
          Remove an edge from the selection.
 void select(Edge edge)
          Select only one edge and remove all other edges from the selection.
 void setBaseline(int baseline)
          At how many pixels from the bottom should the graph start.
 void setColor(java.lang.String type, java.awt.Color color)
          Set the color for edges of a certain type.
 void setCurve(boolean curve)
          Should edges be curved
 void setHeightPerLevel(int heightPerLevel)
          Sets the number of pixels for each graph layer.
 void setStroke(java.lang.String type, java.awt.BasicStroke stroke)
          Set the stroke type for edges of a certain type.
 void setVertexExtraSpace(int vertexExtraSpace)
          The extra number of pixels around a token vertex we can use for starting and end points of edges.
 void showAll()
          Show all edges.
 void toggleSelection(Edge edge)
          Change whether the given edge is selected or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseline

protected int baseline
Where do we start to draw


heightPerLevel

protected int heightPerLevel
How many pixels to use per height level


vertexExtraSpace

protected int vertexExtraSpace
How many extra pixels to start and end arrows from.


curve

protected boolean curve
Should the edges be curved.


from

protected java.util.HashMap<Edge,java.awt.Point> from
A mapping from edges to their start points in the layout.


to

protected java.util.HashMap<Edge,java.awt.Point> to
A mapping from edges to their end points in the layout.


shapes

protected java.util.HashMap<java.awt.Shape,Edge> shapes
A mapping from edge shapes to the corresponding edge objects.


visible

protected java.util.HashSet<Edge> visible
The set of visisible edges.


maxHeight

protected int maxHeight
The height of the layout. This property is to be set by the EdgeLayout.layout(java.util.Collection, TokenLayout, java.awt.Graphics2D) method after the layout process.


maxWidth

protected int maxWidth
The width of the layout. This property is to be set by the EdgeLayout.layout(java.util.Collection, TokenLayout, java.awt.Graphics2D) method after the layout process.

Constructor Detail

AbstractEdgeLayout

public AbstractEdgeLayout()
Method Detail

setColor

public void setColor(java.lang.String type,
                     java.awt.Color color)
Set the color for edges of a certain type.

Parameters:
type - the type of the edges we want to change the color for.
color - the color of the edges of the given type.

setStroke

public void setStroke(java.lang.String type,
                      java.awt.BasicStroke stroke)
Set the stroke type for edges of a certain type.

Parameters:
type - the type to change the stroke for.
stroke - the stroke for edges of the given type.

getStroke

public java.awt.BasicStroke getStroke(Edge edge)
Get the stroke for a given edge.

Parameters:
edge - the edge we need the stroke for.
Returns:
the stroke for the edge.

getStroke

public java.awt.BasicStroke getStroke(java.lang.String type)
Returns the stroke for a given type.

Parameters:
type - the type of edges to get the stroke for.
Returns:
the stroke for the given type.

getColor

public java.awt.Color getColor(java.lang.String type)
Return the color for edges of the given type.

Parameters:
type - the type for which we want the color for.
Returns:
the color for the given edge type.

addToSelection

public void addToSelection(Edge edge)
Add an edge to the selection. Selected edges will be drawn using a bolder stroke.

Parameters:
edge - the edge to add to the selection.

removeFromSelection

public void removeFromSelection(Edge edge)
Remove an edge from the selection.

Parameters:
edge - the edge to remove.

clearSelection

public void clearSelection()
Remove all edges from the selection.


onlyShow

public void onlyShow(java.util.Collection<Edge> edges)
Show only the given edges.

Parameters:
edges - the edges to show.

showAll

public void showAll()
Show all edges.


toggleSelection

public void toggleSelection(Edge edge)
Change whether the given edge is selected or not.

Parameters:
edge - the edge to add or remove from the selection.

getSelected

public java.util.Set<Edge> getSelected()
Returns the set of selected edges.

Returns:
the set of selected edges.

select

public void select(Edge edge)
Select only one edge and remove all other edges from the selection.

Parameters:
edge - the edge to select.

getEdgeAt

public Edge getEdgeAt(java.awt.geom.Point2D p,
                      int radius)
Get the Edge at a given location.

Parameters:
p - the location of the edge.
radius - the radius around the point which the edge should cross.
Returns:
the edge that crosses circle around the given point with the given radius.

calculateDepth

protected int calculateDepth(HashMultiMapLinkedList<Edge,Edge> dominates,
                             Counter<Edge> depth,
                             Edge root)
Calculate the number of edges under each edge and returns the max. of these numbers.

Parameters:
dominates - a map from edges to the edges it dominates.
depth - the resulting depths of each edge.
root - the root of the graph.
Returns:
the max. depth.

getFrom

public java.awt.Point getFrom(Edge edge)
Return the point at the start of the given edge.

Parameters:
edge - the edge to get the starting point from.
Returns:
the start point of the given edge.

getTo

public java.awt.Point getTo(Edge edge)
Return the point at the end of the given edge.

Parameters:
edge - the edge to get the end point from.
Returns:
the end point of the given edge.

getHeight

public int getHeight()
Return the height of the graph layout.

Returns:
the height of the graph.
See Also:
EdgeLayout.getHeight()

getWidth

public int getWidth()
Return the width of the graph layout.

Returns:
the width of the graph.
See Also:
EdgeLayout.getWidth()

getHeightPerLevel

public int getHeightPerLevel()
The number of pixels per graph layer.

Returns:
the number of pixels per graph layer.

isCurve

public boolean isCurve()
Should edges be curved

Returns:
true iff graph is curved.

setCurve

public void setCurve(boolean curve)
Should edges be curved

Parameters:
curve - true iff if graph should be curved.

setBaseline

public void setBaseline(int baseline)
At how many pixels from the bottom should the graph start.

Parameters:
baseline - how many pixels from the bottom should the graph start.

setHeightPerLevel

public void setHeightPerLevel(int heightPerLevel)
Sets the number of pixels for each graph layer.

Parameters:
heightPerLevel - number of pixels for each graph layer.

setVertexExtraSpace

public void setVertexExtraSpace(int vertexExtraSpace)
The extra number of pixels around a token vertex we can use for starting and end points of edges.

Parameters:
vertexExtraSpace - The extra number of pixels around a token vertex we can use for starting and end points of edges.

getVertexExtraSpace

public int getVertexExtraSpace()
The extra number of pixels around a token vertex we can use for starting and end points of edges.

Returns:
The extra number of pixels around a token vertex we can use for starting and end points of edges.

getBaseline

public int getBaseline()
The number of pixels below the graph (between the tokens and the edges).

Returns:
the baseline size.


Copyright © 2010. All Rights Reserved.