public class JGraphFacade
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
JGraphFacade.CellVisitor
Defines the interface that visitors use to perform operations upon the
graph information during depth first search (dfs) or other tree-traversal
strategies implemented by subclassers.
|
class |
JGraphFacade.DefaultComparator
A default comparator for ordering cell views.
|
Modifier and Type | Field and Description |
---|---|
protected JGraphAlgebra |
algebra
The default graph algebra used for basic algorithms and functions.
|
protected java.util.Hashtable |
attributes
The map of attribute changes made be the layout.
|
protected double |
circleRadiusFactor
The factor by which to multiple the radius of the circle layout
|
protected boolean |
directed
Stores whether or not the graph is to be treated as a directed graph.
|
protected JGraphCostFunction |
distanceCostFunction
The default cost function used for shortest path search.
|
protected boolean |
edgePromotion
Whether or not edges connected to collapsed children are promoted to
their first visible parent within the facade, not the actual model
|
protected JGraph |
graph
The JGraph to have the layout applied to it.
|
protected GraphLayoutCache |
graphLayoutCache
The layout cache to have the layout applied to it.
|
protected java.util.List |
groupHierarchies
A collection of groups of sibling vertices
|
protected boolean |
ignoresCellsInGroups
Stores whether or not the layout is to only act on root cells in the
model.
|
protected boolean |
ignoresHiddenCells
Stores whether or not the layout is to act on only visible cells i.e.
|
protected boolean |
ignoresUnconnectedCells
Stores whether or not the layout is to act on only cells that have at
least one connection.
|
protected GraphModel |
model
The model to have the layout applied to it.
|
protected java.util.Comparator |
order
The default comparator to be used where ordering is required in layouts
|
protected boolean |
ordered
Whether or not cells should be returned in the same order as found
in the model.
|
protected java.util.List |
roots
The root vertex to be used by tree layouts.
|
protected java.util.Set |
verticesFilter
If instaniated, this set defines which vertices are to be processed in
any layouts.
|
Constructor and Description |
---|
JGraphFacade(GraphLayoutCache cache)
Creates a JGraphFacade specifying the graph passed in as the input
graph.
|
JGraphFacade(GraphLayoutCache cache,
java.lang.Object[] roots,
boolean ignoresHiddenCells,
boolean ignoresCellsInGroups,
boolean ignoresUnconnectedCells,
boolean directed,
JGraphCostFunction distanceCostFunction,
JGraphAlgebra algebra)
Creates a JGraphFacade specifying the graph passed in as the input
graph.
|
JGraphFacade(GraphModel model,
GraphLayoutCache cache,
java.lang.Object[] roots,
boolean ignoresHiddenCells,
boolean ignoresCellsInGroups,
boolean ignoresUnconnectedCells,
boolean directed,
JGraphCostFunction distanceCostFunction,
JGraphAlgebra algebra)
Creates a JGraphGenericFacade specifying the graph passed in as the input
graph.
|
JGraphFacade(GraphModel model,
java.lang.Object[] roots,
boolean ignoresHiddenCells,
boolean ignoresCellsInGroups,
boolean ignoresUnconnectedCells,
boolean directed,
JGraphCostFunction distanceCostFunction,
JGraphAlgebra algebra)
Creates a JGraphGenericFacade specifying the graph passed in as the input
graph.
|
JGraphFacade(JGraph graph)
Constructs a JGraphGraphFacade specifying the graph passed in as the
input graph
|
JGraphFacade(JGraph graph,
java.lang.Object[] roots)
Constructs a JGraphGraphFacade specifying the graph passed in as the
input graph
|
JGraphFacade(JGraph graph,
java.lang.Object[] roots,
boolean ignoresHiddenCells,
boolean ignoresCellsInGroups,
boolean ignoresUnconnectedCells,
boolean directed)
Constructs a JGraphGraphFacade
|
JGraphFacade(JGraph graph,
java.lang.Object[] roots,
boolean ignoresHiddenCells,
boolean ignoresCellsInGroups,
boolean ignoresUnconnectedCells,
boolean directed,
JGraphCostFunction distanceCostFunction,
JGraphAlgebra algebra)
Creates a JGraphGraphFacade specifying the graph passed in as the input
graph.
|
Modifier and Type | Method and Description |
---|---|
void |
bfs(java.lang.Object root,
JGraphFacade.CellVisitor visitor)
Performs a breath-first search of the input graph from the specified root
cell using the specified visitor to extract the tree information.
|
void |
circle(java.util.Collection vertices)
Arrange the specified vertices into a circular shape, with a regular
distance between each vertex
|
java.util.Map |
createNestedMap(boolean ignoreGrid,
boolean flushOrigin)
Compatibility method to invoke
createNestedMap(boolean, Point2D)
with an origin or null depending on flushOrigin . |
java.util.Map |
createNestedMap(boolean ignoreGrid,
java.awt.geom.Point2D origin)
Creates and returns nested attribute map specifying what changes the
layout made to the input graph.
|
java.util.Map |
createNestedMap(java.util.Map nestedMap)
Deprecated.
as of version 1.1
|
protected void |
determineLayoutHierarchies()
Divides the graph into groups of sibling vertices, vertices that
share the same parent.
|
void |
dfs(java.lang.Object root,
JGraphFacade.CellVisitor visitor)
Performs a depth-first search of the input graph from the specified root
cell using the specified visitor to extract the tree information.
|
void |
dfs(java.lang.Object parent,
java.lang.Object root,
java.lang.Object previousSibling,
JGraphFacade.CellVisitor visitor,
java.util.Set seen,
int layer,
int sibling)
Performs a depth-first search of the input graph from the specified root
cell using the specified visitor to extract the tree information
|
void |
dfs(java.lang.Object parent,
java.lang.Object root,
java.lang.Object previousSibling,
JGraphFacade.CellVisitor visitor,
java.util.Set seen,
java.util.Set ancestors,
int layer,
int sibling)
Performs a depth-first search of the input graph from the specified root
cell using the specified visitor to extract the tree information
|
void |
disableRouting(java.lang.Object edge)
Disables per-edge on the specified edge
|
void |
findTreeRoots()
Utility method to update the array of tree roots in a graph.
|
protected java.util.List |
getAll()
Returns all cells including all descendants.
|
java.util.Hashtable |
getAttributes()
Returns the nested map that specifies what changes the layout has made to
the input graph.
|
java.util.Map |
getAttributes(java.lang.Object cell)
Returns the local attributes for the specified cell.
|
java.awt.geom.Rectangle2D |
getBounds(java.util.List vertices)
Returns the minimal rectangular bounds that enclose the specified
vertices
|
java.awt.geom.Rectangle2D |
getBounds(java.lang.Object cell)
Returns the current bounds for the specified cell.
|
double[][] |
getBounds(java.lang.Object[] cells)
Same as getLocations, but with width and height added at index 3 and 4
respectively.
|
java.awt.geom.Rectangle2D |
getCellBounds()
Returns the minimal rectangular bounds that enclose all the elements in
the
bounds map. |
protected java.util.Collection |
getCells(java.util.Collection cells,
boolean edges,
boolean ordered)
Returns a collection of cells in the current graph.
|
java.lang.Object |
getCellView(java.lang.Object cell)
Obtains the cell view corresponding the cell passed in
|
double |
getCircleRadiusFactor() |
java.util.List |
getComponents()
Calculates a list of non-connected graph components for the current
graph.
|
JGraphUnionFind |
getConnectionComponents(java.lang.Object[] v,
java.lang.Object[] e)
Returns a union find structure representing the connection components of
G=(E,V).
|
double |
getDistance(java.lang.Object v1,
java.lang.Object v2,
int maxHops)
Returns the length of the shortest path connecting
v1 and
v2 wrt distanceFunction . |
java.util.Collection |
getEdges()
Returns all edges in the graph.
|
java.lang.Object[] |
getEdges(java.lang.Object cell)
Returns the connected edges for a cell.
|
java.lang.Object[] |
getEdges(java.lang.Object cell,
boolean incoming)
Returns the incoming or outgoing edges for cell.
|
java.lang.Object[] |
getEdgesBetween(java.lang.Object cell1,
java.lang.Object cell2,
boolean directed)
Returns the edges between two specified ports or two specified vertices.
|
java.awt.geom.Rectangle2D |
getGraphBounds()
Returns the minimal rectangular bounds that enclose all the elements in
the
bounds map. |
java.awt.geom.Point2D |
getGraphOrigin()
Returns the origin of the graph (ie the top left corner of the root
cells) for the original geometry.
|
java.util.List |
getGroupHierarchies() |
java.util.List |
getIncomingEdges(java.lang.Object cell,
java.util.Set exclude,
boolean visibleCells,
boolean selfLoops)
Returns the incoming edges for cell.
|
double |
getLength(java.lang.Object edge)
Returns the length of the specified edge wrt
distanceFunction . |
java.awt.geom.Point2D |
getLocation(java.lang.Object cell)
Returns the current location of the specified cell
|
double[][] |
getLocations(java.lang.Object[] cells)
Returns an array of arrays (index 0 is x-coordinate, index 1 is
y-coordinate in the second array) that fast layouts can operate upon.
|
java.awt.Dimension |
getMaxSize(java.util.Collection vertices)
Obtains the maximum width or height dimension of any of the vertices in
the specified collection
|
java.lang.Object[] |
getMinimumSpanningTree(java.lang.Object[] v,
JGraphCostFunction cf)
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).
|
java.util.List |
getNeighbours(java.lang.Object cell,
boolean ordered)
A shortcut method that calls getNeighbours with no cells to exclude.
|
java.util.List |
getNeighbours(java.lang.Object cell,
java.util.Set exclude,
boolean ordered)
Returns a collection of cells that are connected to the specified cell by
edges.
|
java.util.Comparator |
getOrder() |
java.util.List |
getOutgoingEdges(java.lang.Object cell,
java.util.Set exclude,
boolean visibleCells,
boolean selfLoops)
Returns the outgoing edges for cell.
|
java.lang.Object[] |
getPath(java.lang.Object v1,
java.lang.Object v2,
int steps,
JGraphCostFunction cf)
Returns the shortest path connecting
v1 and
v2 wrt cf with traverses no more than
steps edges. |
java.util.List |
getPoints(java.lang.Object edge)
Returns the points of the specified edge.
|
java.lang.Object |
getRootAt(int index)
Returns the root at
index to be used by tree layouts for
tree traversal. |
int |
getRootCount()
Returns the number of root vertices to be used by tree layouts for tree
traversal.
|
java.util.List |
getRoots()
Returns the list of root vertices.
|
java.awt.geom.Dimension2D |
getSize(java.lang.Object cell)
Return the size of the specified cell
|
java.lang.Object |
getSource(java.lang.Object edge)
Returns the vertex that is connected to the source end of the specified
edge
|
java.lang.Object |
getSourcePort(java.lang.Object edge)
Returns the port that is connected to the source end of the specified
edge
|
java.lang.Object |
getTarget(java.lang.Object edge)
Returns the vertex that is connected to the target end of the specified
edge
|
java.lang.Object |
getTargetPort(java.lang.Object edge)
Returns the port that is connected to the target end of the specified
edge
|
java.util.Collection |
getUnconnectedVertices(boolean ordered)
Returns all unconnected vertices in the graph.
|
java.util.Collection |
getVertices()
Returns all vertices in the graph.
|
java.util.Collection |
getVertices(java.util.Collection cells,
boolean ordered)
Returns a collection of vertices found in the specified collection.
|
java.util.Set |
getVerticesFilter() |
boolean |
isDirected() |
boolean |
isEdge(java.lang.Object cell)
Returns whether or not the specified cell is an edge and should be taken
into account by the layout
|
boolean |
isEdgePromotion() |
boolean |
IsIgnoresCellsInGroups() |
boolean |
isIgnoresHiddenCells() |
boolean |
isIgnoresUnconnectedCells() |
boolean |
isMoveable(java.lang.Object cell)
Returns true if the cell is moveable.
|
boolean |
isOrdered() |
boolean |
isRoot(java.lang.Object cell)
Returns true if
cell is a root. |
boolean |
isVertex(java.lang.Object cell)
Returns whether or not the specified cell is a vertex and should be taken
into account by the layout
|
double |
norm(java.awt.geom.Point2D p)
Calculates the euklidische Norm for the point p.
|
protected void |
populateGroupHierarchies(java.lang.Object vertex)
Creates a set of sibling vertices and adds them to the group
hierarchy collection.
|
void |
randomize(java.util.Collection vertices,
int maxx,
int maxy)
Moves the specified vertices to random locations in the x and y axes
directions between zero and a specified maximum.
|
void |
resetControlPoints()
Resets the control points of all moveable edges in the graph.
|
void |
resetControlPoints(boolean setRouting,
Edge.Routing routing)
Resets the control points of all moveable edges in the graph.
|
void |
run(JGraphLayout layout,
boolean processByGroups)
The main method to execute layouts
|
void |
scale(java.util.Collection vertices,
double scalex,
double scaley,
double dx,
double dy)
Scales the bounds of the specified cells adding
dx and
dy to the respective location axes of the cell, then by
scaling them by scalex and scaley |
void |
scale(java.awt.geom.Rectangle2D frame)
Scales the graph bounds defined in
bounds to fit into the
specified frame |
void |
setAttributes(java.util.Hashtable attributes)
Sets the map that stores all attributes that comprise the changes made by
the layout to the input graph
|
void |
setAttributes(java.lang.Object cell,
java.util.Map map)
Sets the local attributes for the specified cell.
|
void |
setBounds(java.util.Map nestedMap)
Reads the bounds from the nested map for each cell and invokes setBounds
for that cell with a clone of the bounds.
|
void |
setBounds(java.lang.Object[] cells,
double[][] locations)
Same as setLocations, but with width and height added at index 3 and 4
respectively.
|
void |
setBounds(java.lang.Object cell,
java.awt.geom.Rectangle2D rect)
Sets the current bounds for the specified cell.
|
void |
setCircleRadiusFactor(double circleRadiusFactor) |
void |
setDirected(boolean directed) |
void |
setEdgePromotion(boolean edgePromotion) |
void |
setGroupHierarchies(java.util.List groupHierarchies) |
void |
setIgnoresCellsInGroups(boolean ignoresCellsInGroups) |
void |
setIgnoresHiddenCells(boolean ignoresHiddenCells)
The GraphLayoutCache instance on the JGraphFacade object must be
set correctly in order to change this flag.
|
void |
setIgnoresUnconnectedCells(boolean ignoresUnconnectedCells) |
void |
setLocation(java.lang.Object cell,
double x,
double y)
Sets the current location of the specified cell.
|
void |
setLocation(java.lang.Object cell,
double x,
double y,
boolean moveGroups)
Sets the current location of the specified cell.
|
void |
setLocations(java.lang.Object[] cells,
double[][] locations)
Sets the locations of the specified cells according to the arrays
specified in
locations . |
void |
setLoggerLevel(java.util.logging.Level level)
Sets the logging level of this class
|
void |
setOrder(java.util.Comparator order) |
void |
setOrdered(boolean ordered) |
void |
setPoints(java.lang.Object edge,
java.util.List points)
Sets the points of the specified edge
|
void |
setRoots(java.util.List roots) |
void |
setSize(java.lang.Object cell,
double width,
double height)
Sets the current size of the specified cell.
|
void |
setVerticesFilter(java.util.Set verticesFilter) |
void |
tilt(java.util.Collection vertices,
int maxx,
int maxy)
Simulates a 'nudge' to the graph, moving the specified vertices a random
distance in the x and y axes directions between zero and a specified
maximum.
|
void |
translate(java.lang.Object cell,
double dx,
double dy)
Moved the specified cell by the specified x and y co-ordinate amounts
|
void |
translateCells(java.util.Collection cells,
double dx,
double dy)
Translates the bounds of the specified cells adding
dx and
dy to the respective location axes of the cell, |
protected boolean ignoresHiddenCells
true
means only act on visible cells, false
act on cells regardless of their visibility. Default is true
.protected boolean ignoresUnconnectedCells
true
means only act on connected
cells, false
act on cells regardless of their connections.
Default is true
.protected boolean ignoresCellsInGroups
true
means only act on root cells,
false
means act upon roots and their children. Default is
false
.protected boolean directed
true
means follow edges in target to source direction,y
false
means treat edges as directionlessprotected boolean edgePromotion
protected boolean ordered
protected transient JGraph graph
protected transient GraphLayoutCache graphLayoutCache
protected transient GraphModel model
protected transient java.util.Hashtable attributes
protected transient java.util.Comparator order
protected transient JGraphCostFunction distanceCostFunction
protected transient JGraphAlgebra algebra
protected transient java.util.List roots
protected transient java.util.Set verticesFilter
protected transient java.util.List groupHierarchies
protected double circleRadiusFactor
public JGraphFacade(JGraph graph)
graph
- the JGraph to be laid outpublic JGraphFacade(JGraph graph, java.lang.Object[] roots)
graph
- the JGraph to be laid outroots
- the root vertices to be used by tree and hierarchical layouts -
NOTE, any roots will be subject to the facade filters at the
time of construction.public JGraphFacade(JGraph graph, java.lang.Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed)
public JGraphFacade(JGraph graph, java.lang.Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed, JGraphCostFunction distanceCostFunction, JGraphAlgebra algebra)
graph
- The graph used as input to the layoutroots
- the root vertices to be used by tree and hierarchical layouts -
NOTE, any roots will be subject to the facade filters at the
time of construction.ignoresHiddenCells
- ignoresCellsInGroups
- ignoresUnconnectedCells
- directed
- distanceCostFunction
- the cost function that defines the distance metricsalgebra
- the algebra used for basic algorithms and functionsisVertex(java.lang.Object)
,
ignoresHiddenCells
,
ignoresCellsInGroups
,
ignoresUnconnectedCells
,
directed
public JGraphFacade(GraphLayoutCache cache)
cache
- The GraphLayoutCache to be used as input to the layoutpublic JGraphFacade(GraphLayoutCache cache, java.lang.Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed, JGraphCostFunction distanceCostFunction, JGraphAlgebra algebra)
cache
- The GraphLayoutCache to be used as input to the layoutroots
- the root vertices to be used by tree and hierarchical layouts -
NOTE, any roots will be subject to the facade filters at the
time of construction.ignoresHiddenCells
- ignoresCellsInGroups
- ignoresUnconnectedCells
- directed
- distanceCostFunction
- the cost function that defines the distance metricsalgebra
- the algebra used for basic algorithms and functionsisVertex(java.lang.Object)
,
ignoresHiddenCells
,
ignoresCellsInGroups
,
ignoresUnconnectedCells
,
directed
public JGraphFacade(GraphModel model, java.lang.Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed, JGraphCostFunction distanceCostFunction, JGraphAlgebra algebra)
model
- The GraphModel to be used as input to the layoutroots
- the root vertices to be used by tree and hierarchical layouts -
NOTE, any roots will be subject to the facade filters at the
time of construction.ignoresHiddenCells
- ignoresCellsInGroups
- ignoresUnconnectedCells
- directed
- distanceCostFunction
- the cost function that defines the distance metricsalgebra
- the algebra used for basic algorithms and functionsisVertex(java.lang.Object)
,
ignoresHiddenCells
,
ignoresCellsInGroups
,
ignoresUnconnectedCells
,
directed
public JGraphFacade(GraphModel model, GraphLayoutCache cache, java.lang.Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed, JGraphCostFunction distanceCostFunction, JGraphAlgebra algebra)
model
- The GraphModel to be used as input to the layoutcache
- The GraphLayoutCache to be used as input to the layoutroots
- the root vertices to be used by tree and hierarchical layouts -
NOTE, any roots will be subject to the facade filters at the
time of construction.ignoresHiddenCells
- ignoresCellsInGroups
- ignoresUnconnectedCells
- directed
- distanceCostFunction
- the cost function that defines the distance metricsalgebra
- the algebra used for basic algorithms and functionsisVertex(java.lang.Object)
,
ignoresHiddenCells
,
ignoresCellsInGroups
,
ignoresUnconnectedCells
,
directed
public void run(JGraphLayout layout, boolean processByGroups)
layout
- the layout to be executedprocessByGroups
- Whether or not to process cell only at the level of their own
group When true, children are only processed with siblings and
their parent only with its siblings and so onpublic void resetControlPoints()
public void resetControlPoints(boolean setRouting, Edge.Routing routing)
whether
- or not to set a new routing style on each edgethe
- routing style to set on each edge if setRouting
is true
public boolean isVertex(java.lang.Object cell)
cell
- the cell that is to be classified as a vertex or notcell
is a vertexpublic boolean isEdge(java.lang.Object cell)
cell
- the cell that is to be classified as an edge or notpublic java.util.List getNeighbours(java.lang.Object cell, boolean ordered)
getNeighbours(Object, Set, boolean)
public java.util.List getNeighbours(java.lang.Object cell, java.util.Set exclude, boolean ordered)
cell
- The cell from which the neighbours will be determinedexclude
- The set of cells to ignore when searchingordered
- whether or not to order the returned value in the order of the
current order
comparator. Be very careful
using the default comparator on the default graph model,
getIndexOfRoot
has linear performance and so
sorting the entire model roots will have quadratic
performance.cell
public double getLength(java.lang.Object edge)
distanceFunction
.edge
- the edge whos length is returnededge
distanceCostFunction
,
getPath(Object, Object, int, JGraphCostFunction)
public double getDistance(java.lang.Object v1, java.lang.Object v2, int maxHops)
v1
and
v2
wrt distanceFunction
. The path has no
more than maxHops
elements.v1
- the source vertexv2
- the target vertexmaxHops
- the maximum number of edges the path may havedistanceCostFunction
,
getPath(Object, Object, int, JGraphCostFunction)
public java.lang.Object[] getPath(java.lang.Object v1, java.lang.Object v2, int steps, JGraphCostFunction cf)
v1
and
v2
wrt cf
with traverses no more than
steps
edges. The cost function defines the metric that is
used as the edges length.v1
- the source vertexv2
- the target vertexsteps
- the maximum number of edges in the pathcf
- the cost function that defines the edge lengthsJGraphAlgebra.getShortestPath(GraphModel, Object, Object,
JGraphCostFunction, int, boolean)
public JGraphUnionFind getConnectionComponents(java.lang.Object[] v, java.lang.Object[] e)
Object[] v = facade.getVertices();
Object[] e = facade.getEdges();
JGraphUnionFind uf = facade.getConnectionComponents(v, e);
boolean connected = uf.differ(vertex1, vertex2);
v
- the vertices of the graphe
- the edges of the graphJGraphAlgebra.getConnectionComponents(GraphModel, Object[],
Object[])
public java.lang.Object[] getMinimumSpanningTree(java.lang.Object[] v, JGraphCostFunction cf)
v
- the vertices of the graphJGraphAlgebra.getMinimumSpanningTree(GraphModel, Object[],
JGraphCostFunction, boolean)
public java.util.Collection getVertices()
isVertex(Object)
public java.util.Collection getUnconnectedVertices(boolean ordered)
public java.util.Collection getEdges()
isEdge(Object)
public java.lang.Object[] getEdges(java.lang.Object cell)
cell
- the cell whose edges are to be obtainedpublic java.lang.Object[] getEdges(java.lang.Object cell, boolean incoming)
cell
- the graph cell whose edges are to be obtainedincoming
- whether or not to obtain incoming edges onlypublic java.lang.Object getSource(java.lang.Object edge)
edge
- the reference edgepublic java.lang.Object getTarget(java.lang.Object edge)
edge
- the reference edgepublic java.lang.Object getSourcePort(java.lang.Object edge)
edge
- the reference edgepublic java.lang.Object getTargetPort(java.lang.Object edge)
edge
- the reference edgeprotected java.util.List getAll()
protected java.util.Collection getCells(java.util.Collection cells, boolean edges, boolean ordered)
ordered
flag is set to true
the result will be ordered by the
current comparator set for this facade. cells
- the cells to be filtered and return the correct cell typesedges
- whether or not to return the edges of the graphordered
- whether or not to order the returned value in the order of the
current order
comparator. Be very careful
using the default comparator on the default graph model,
getIndexOfRoot
has linear performance and so
sorting the entire model roots will have quadratic
performance.public java.lang.Object getCellView(java.lang.Object cell)
cell
- the cell whose view is to be obtainedpublic java.util.Collection getVertices(java.util.Collection cells, boolean ordered)
cells
- the set of potential verticesordered
- whether or not to order the returned value in the order of the
current order
comparator. Be very careful
using the default comparator on the default graph model,
getIndexOfRoot
has linear performance and so
sorting the entire model roots will have quadratic
performance.isVertex(Object)
public java.util.List getOutgoingEdges(java.lang.Object cell, java.util.Set exclude, boolean visibleCells, boolean selfLoops)
cell
- The cell from which the outgoing edges will be determinedexclude
- The set of edges to ignore when searchingvisibleCells
- whether or not only visible cells should be processedselfLoops
- whether or not to include self loops in the returned listcell
public java.util.List getIncomingEdges(java.lang.Object cell, java.util.Set exclude, boolean visibleCells, boolean selfLoops)
cell
- The cell from which the incoming edges will be determinedexclude
- The set of edges to ignore when searchingvisibleCells
- whether or not only visible cells should be processedselfLoops
- whether or not to include self loops in the returned listcell
public java.util.Map createNestedMap(java.util.Map nestedMap)
Map
of the changes the layout made upon
the input graphcreateNestedMap(boolean, boolean)
,
GraphConstants.merge(Map, Map)
public java.util.Map createNestedMap(boolean ignoreGrid, boolean flushOrigin)
createNestedMap(boolean, Point2D)
with an origin or null depending on flushOrigin
.ignoreGrid
- whether or not the map returned is snapped to the current gridflushOrigin
- whether or not the bounds of the graph should be moved to
(0,0)Map
of the changes the layout made upon
the input graphpublic java.util.Map createNestedMap(boolean ignoreGrid, java.awt.geom.Point2D origin)
ignoreGrid
- whether or not the map returned is snapped to the current gridorigin
- the new origin to which the graph bounds will be flushed toMap
of the changes the layout made upon
the input graphpublic java.util.List getComponents()
public double norm(java.awt.geom.Point2D p)
p
- the point to calculate the norm forpublic java.util.Hashtable getAttributes()
public void setAttributes(java.util.Hashtable attributes)
attributes
- the new map of cell, map pairspublic java.util.Map getAttributes(java.lang.Object cell)
public boolean isMoveable(java.lang.Object cell)
moveable
attribute. Subclassers can override
this eg. to check if a cell is not selected in the graph.public void setAttributes(java.lang.Object cell, java.util.Map map)
cell
- the cell to set the attributes formap
- the new attributes for the cellpublic java.awt.geom.Rectangle2D getBounds(java.util.List vertices)
vertices
- the vertices whose collective bounds are to be determinedpublic java.awt.geom.Rectangle2D getGraphBounds()
bounds
map. After a layout has completed this method
will return the collective bounds of the new laid out graph.
Note this method may return null and should be checked before using.bounds
public java.awt.geom.Point2D getGraphOrigin()
public java.awt.geom.Rectangle2D getCellBounds()
bounds
map. After a layout has completed this method
will return the collective bounds of the new laid out graph.bounds
public void translateCells(java.util.Collection cells, double dx, double dy)
dx
and
dy
to the respective location axes of the cell,dx
- the amount to be added to be x-axis positions of the vertices
before scaling is applieddy
- the amount to be added to be y-axis positions of the vertices
before scaling is appliedpublic void scale(java.awt.geom.Rectangle2D frame)
bounds
to fit into the
specified frameframe
- the frame the bounds
map colective bounds is to
be scaled topublic void scale(java.util.Collection vertices, double scalex, double scaley, double dx, double dy)
dx
and
dy
to the respective location axes of the cell, then by
scaling them by scalex
and scaley
vertices
- the collection of vertices to be scaledscalex
- the amount by which the x-axis positions of the vertices will
be scaledscaley
- the amount by which the y-axis positions of the vertices will
be scaleddx
- the amount to be added to be x-axis positions of the vertices
before scaling is applieddy
- the amount to be added to be y-axis positions of the vertices
before scaling is appliedpublic void randomize(java.util.Collection vertices, int maxx, int maxy)
vertices
- the collection of vertices to be movedmaxx
- the maximum translation that may occur in the x-axismaxy
- the maximum translation that may occur in the y-axispublic void tilt(java.util.Collection vertices, int maxx, int maxy)
vertices
- the collection of vertices to be movedmaxx
- the maximum translation that may occur in the x-axismaxy
- the maximum translation that may occur in the y-axispublic void circle(java.util.Collection vertices)
vertices
- the collection of vertices to be arrangedpublic java.awt.geom.Rectangle2D getBounds(java.lang.Object cell)
cell
- the cell whose bounds are to be determinedpublic void setBounds(java.util.Map nestedMap)
nestedMap
- A map of (cell, map) pairsGraphConstants.getBounds(Map)
public void setBounds(java.lang.Object cell, java.awt.geom.Rectangle2D rect)
cell
- the cell whose bounds are to be setrect
- the new bounds of the specified cellpublic double[][] getLocations(java.lang.Object[] cells)
This method is normally used at the beginning of a layout to setup fast internal datastructures. The layout then changes the array in-place and when finished, writes the result back using the setLocations(Object[] cells, double[][] locations) method:
public void run(JGraphFacade facade) { 1. vertices = facade.getVertices().toArray(); 2. locations = facade.getLocations(vertices); 3. perform layout on local arrays 4. return result: facade.setLocations(vertices, locations); }
cells
- The cells to return the locations forpublic double[][] getBounds(java.lang.Object[] cells)
cells
- The cells to return the bounds forgetLocations(Object[])
public java.awt.geom.Point2D getLocation(java.lang.Object cell)
cell
- the cell whose location is to be determinedpublic void setLocations(java.lang.Object[] cells, double[][] locations)
locations
. The cells and locations array
must contain the same number of elements.cells
- The cells to change the locations forlocations
- The new locations as an array of arraysgetLocations(Object[])
public void setBounds(java.lang.Object[] cells, double[][] locations)
cells
- The cells to change the bounds forlocations
- The new bounds as an array of arraysgetLocations(Object[])
public void setLocation(java.lang.Object cell, double x, double y)
cell
- the cell whose location is to be setx
- the new x-axs location of the celly
- the new y-axs location of the cellisMoveable(Object)
public void setLocation(java.lang.Object cell, double x, double y, boolean moveGroups)
cell
- the cell whose location is to be setx
- the new x-axs location of the celly
- the new y-axs location of the cellmoveGroups
- whether or not to move group cellsisMoveable(Object)
public void translate(java.lang.Object cell, double dx, double dy)
cell
- the cell to be moveddx
- the amount by which the cell will be translated in the x-axisdy
- the amount by which the cell will be translated in the y-axispublic java.awt.Dimension getMaxSize(java.util.Collection vertices)
vertices
- collection of vertices to be analysedpublic void setSize(java.lang.Object cell, double width, double height)
cell
- the cell whose size is to be setwidth
- the new width of the cellheight
- the new height of the cellpublic java.awt.geom.Dimension2D getSize(java.lang.Object cell)
cell
- the cell whose size is to be returnedpublic java.util.List getPoints(java.lang.Object edge)
edge
- the cell whose points are returnedpublic void setPoints(java.lang.Object edge, java.util.List points)
edge
- the edge whose points are to be setpoints
- the new list of points for the edgepublic void disableRouting(java.lang.Object edge)
edge
- the edge to have per-edge routing disabledpublic java.lang.Object[] getEdgesBetween(java.lang.Object cell1, java.lang.Object cell2, boolean directed)
cell1
must be the source of the
returned edges.cell1
- the first of the pair of cells to find edges betweencell2
- the second of the pair of cells to find edges betweendirected
- whether or not only edges going from cell1
to
cell2
should be returned and not edges in the
other directionprotected void determineLayoutHierarchies()
protected void populateGroupHierarchies(java.lang.Object vertex)
vertex
- The parent vertex to the returned verticespublic int getRootCount()
public java.lang.Object getRootAt(int index)
index
to be used by tree layouts for
tree traversal.dfs(Object, JGraphFacade.CellVisitor)
public boolean isRoot(java.lang.Object cell)
cell
is a root.cell
- the cell to testcell
is a rootpublic java.util.List getRoots()
roots
public void setRoots(java.util.List roots)
roots
- The roots to set.public boolean isDirected()
public void setDirected(boolean directed)
directed
- The directed to set.public java.util.Comparator getOrder()
public void setOrder(java.util.Comparator order)
order
- The order to set.public boolean IsIgnoresCellsInGroups()
public void setIgnoresCellsInGroups(boolean ignoresCellsInGroups)
ignoresCellsInGroups
- Sets ignoresCellsInGroups.public boolean isIgnoresHiddenCells()
public void setIgnoresHiddenCells(boolean ignoresHiddenCells)
ignoresHiddenCells
- The ignoresHiddenCells to set.public boolean isIgnoresUnconnectedCells()
public void setIgnoresUnconnectedCells(boolean ignoresUnconnectedCells)
ignoresUnconnectedCells
- The ignoresUnconnectedCells to set.public boolean isEdgePromotion()
public void setEdgePromotion(boolean edgePromotion)
edgePromotion
- The edgePromotion to set.public java.util.Set getVerticesFilter()
public void setVerticesFilter(java.util.Set verticesFilter)
verticesFilter
- The verticesFilter to set.public java.util.List getGroupHierarchies()
public void setGroupHierarchies(java.util.List groupHierarchies)
groupHierarchies
- the groupHierarchies to setpublic double getCircleRadiusFactor()
public void setCircleRadiusFactor(double circleRadiusFactor)
circleRadiusFactor
- the minCircleRadius to setpublic void dfs(java.lang.Object root, JGraphFacade.CellVisitor visitor)
root
- the node to start the search fromvisitor
- the visitor that defines the operations to be performed upon
the graph modelpublic void dfs(java.lang.Object parent, java.lang.Object root, java.lang.Object previousSibling, JGraphFacade.CellVisitor visitor, java.util.Set seen, int layer, int sibling)
parent
- the parent of the current cellroot
- the node to start the search frompreviousSibling
- the last neighbour of the current cell foundvisitor
- the visitor that defines the operations to be performed upon
the graph modelseen
- the set of cells that have already been seenlayer
- the current layer of the treesibling
- the number of siblings to the current cellpublic void dfs(java.lang.Object parent, java.lang.Object root, java.lang.Object previousSibling, JGraphFacade.CellVisitor visitor, java.util.Set seen, java.util.Set ancestors, int layer, int sibling)
parent
- the parent of the current cellroot
- the node to start the search frompreviousSibling
- the last neighbour of the current cell foundvisitor
- the visitor that defines the operations to be performed upon
the graph modelseen
- the set of cells that have already been seenlayer
- the current layer of the treesibling
- the number of siblings to the current cellpublic void bfs(java.lang.Object root, JGraphFacade.CellVisitor visitor)
visitor
- the visitor that defines the operations to be performed upon
the graph modelpublic void findTreeRoots()
public boolean isOrdered()
public void setOrdered(boolean ordered)
ordered
- The ordered to set.public void setLoggerLevel(java.util.logging.Level level)
level
- the logging level to setCopyright (C) 2001-2009 JGraph Ltd. All rights reserved.