Class JGraphFacade
java.lang.Object
com.jgraph.layout.JGraphFacade
- Direct Known Subclasses:
JGraphModelFacade
An abstract description of a graph that can be used by a layout algorithm.
This abstracts visibility, grouping, directed edges, any root cells,
translation and scaling functions. It also stores the actual graph to be
acted upon by the layout and provides utility method to determine the
characteristics of the contained cells. After the layout has been applied
this class stores the result of that layout as a nested attribute map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines 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.classA default comparator for ordering cell views. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JGraphAlgebraThe default graph algebra used for basic algorithms and functions.protected HashtableThe map of attribute changes made be the layout.protected doubleThe factor by which to multiple the radius of the circle layoutprotected booleanStores whether or not the graph is to be treated as a directed graph.protected JGraphCostFunctionThe default cost function used for shortest path search.protected booleanWhether or not edges connected to collapsed children are promoted to their first visible parent within the facade, not the actual modelprotected JGraphThe JGraph to have the layout applied to it.protected GraphLayoutCacheThe layout cache to have the layout applied to it.protected ListA collection of groups of sibling verticesprotected booleanStores whether or not the layout is to only act on root cells in the model.protected booleanStores whether or not the layout is to act on only visible cells i.e.protected booleanStores whether or not the layout is to act on only cells that have at least one connection.protected GraphModelThe model to have the layout applied to it.protected ComparatorThe default comparator to be used where ordering is required in layoutsprotected booleanWhether or not cells should be returned in the same order as found in the model.protected ListThe root vertex to be used by tree layouts.protected SetIf instaniated, this set defines which vertices are to be processed in any layouts. -
Constructor Summary
ConstructorsConstructorDescriptionJGraphFacade(GraphLayoutCache cache) Creates a JGraphFacade specifying the graph passed in as the input graph.JGraphFacade(GraphLayoutCache cache, 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, 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, GraphLayoutCache cache, 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 graphJGraphFacade(JGraph graph, Object[] roots) Constructs a JGraphGraphFacade specifying the graph passed in as the input graphJGraphFacade(JGraph graph, Object[] roots, boolean ignoresHiddenCells, boolean ignoresCellsInGroups, boolean ignoresUnconnectedCells, boolean directed) Constructs a JGraphGraphFacadeJGraphFacade(JGraph graph, 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. -
Method Summary
Modifier and TypeMethodDescriptionvoidbfs(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.voidcircle(Collection vertices) Arrange the specified vertices into a circular shape, with a regular distance between each vertexcreateNestedMap(boolean ignoreGrid, boolean flushOrigin) Compatibility method to invokecreateNestedMap(boolean, Point2D)with an origin or null depending onflushOrigin.createNestedMap(boolean ignoreGrid, Point2D origin) Creates and returns nested attribute map specifying what changes the layout made to the input graph.createNestedMap(Map nestedMap) Deprecated.as of version 1.1protected voidDivides the graph into groups of sibling vertices, vertices that share the same parent.voiddfs(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.voiddfs(Object parent, Object root, Object previousSibling, JGraphFacade.CellVisitor visitor, 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 informationvoiddfs(Object parent, Object root, Object previousSibling, JGraphFacade.CellVisitor visitor, Set seen, 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 informationvoiddisableRouting(Object edge) Disables per-edge on the specified edgevoidUtility method to update the array of tree roots in a graph.protected ListgetAll()Returns all cells including all descendants.Returns the nested map that specifies what changes the layout has made to the input graph.getAttributes(Object cell) Returns the local attributes for the specified cell.Returns the current bounds for the specified cell.double[][]Same as getLocations, but with width and height added at index 3 and 4 respectively.Returns the minimal rectangular bounds that enclose the specified verticesReturns the minimal rectangular bounds that enclose all the elements in theboundsmap.protected CollectiongetCells(Collection cells, boolean edges, boolean ordered) Returns a collection of cells in the current graph.getCellView(Object cell) Obtains the cell view corresponding the cell passed indoubleCalculates a list of non-connected graph components for the current graph.getConnectionComponents(Object[] v, Object[] e) Returns a union find structure representing the connection components of G=(E,V).doublegetDistance(Object v1, Object v2, int maxHops) Returns the length of the shortest path connectingv1andv2wrtdistanceFunction.getEdges()Returns all edges in the graph.Object[]Returns the connected edges for a cell.Object[]Returns the incoming or outgoing edges for cell.Object[]getEdgesBetween(Object cell1, Object cell2, boolean directed) Returns the edges between two specified ports or two specified vertices.Returns the minimal rectangular bounds that enclose all the elements in theboundsmap.Returns the origin of the graph (ie the top left corner of the root cells) for the original geometry.getIncomingEdges(Object cell, Set exclude, boolean visibleCells, boolean selfLoops) Returns the incoming edges for cell.doubleReturns the length of the specified edge wrtdistanceFunction.getLocation(Object cell) Returns the current location of the specified celldouble[][]getLocations(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.getMaxSize(Collection vertices) Obtains the maximum width or height dimension of any of the vertices in the specified collectionObject[]Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).getNeighbours(Object cell, boolean ordered) A shortcut method that calls getNeighbours with no cells to exclude.getNeighbours(Object cell, Set exclude, boolean ordered) Returns a collection of cells that are connected to the specified cell by edges.getOrder()getOutgoingEdges(Object cell, Set exclude, boolean visibleCells, boolean selfLoops) Returns the outgoing edges for cell.Object[]getPath(Object v1, Object v2, int steps, JGraphCostFunction cf) Returns the shortest path connectingv1andv2wrtcfwith traverses no more thanstepsedges.Returns the points of the specified edge.getRootAt(int index) Returns the root atindexto be used by tree layouts for tree traversal.intReturns the number of root vertices to be used by tree layouts for tree traversal.getRoots()Returns the list of root vertices.Return the size of the specified cellReturns the vertex that is connected to the source end of the specified edgegetSourcePort(Object edge) Returns the port that is connected to the source end of the specified edgeReturns the vertex that is connected to the target end of the specified edgegetTargetPort(Object edge) Returns the port that is connected to the target end of the specified edgegetUnconnectedVertices(boolean ordered) Returns all unconnected vertices in the graph.Returns all vertices in the graph.getVertices(Collection cells, boolean ordered) Returns a collection of vertices found in the specified collection.booleanbooleanReturns whether or not the specified cell is an edge and should be taken into account by the layoutbooleanbooleanbooleanbooleanbooleanisMoveable(Object cell) Returns true if the cell is moveable.booleanbooleanReturns true ifcellis a root.booleanReturns whether or not the specified cell is a vertex and should be taken into account by the layoutdoubleCalculates the euklidische Norm for the point p.protected voidpopulateGroupHierarchies(Object vertex) Creates a set of sibling vertices and adds them to the group hierarchy collection.voidrandomize(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.voidResets the control points of all moveable edges in the graph.voidresetControlPoints(boolean setRouting, Edge.Routing routing) Resets the control points of all moveable edges in the graph.voidrun(JGraphLayout layout, boolean processByGroups) The main method to execute layoutsvoidscale(Rectangle2D frame) Scales the graph bounds defined inboundsto fit into the specified framevoidscale(Collection vertices, double scalex, double scaley, double dx, double dy) Scales the bounds of the specified cells addingdxanddyto the respective location axes of the cell, then by scaling them byscalexandscaleyvoidsetAttributes(Object cell, Map map) Sets the local attributes for the specified cell.voidsetAttributes(Hashtable attributes) Sets the map that stores all attributes that comprise the changes made by the layout to the input graphvoidSame as setLocations, but with width and height added at index 3 and 4 respectively.voidsetBounds(Object cell, Rectangle2D rect) Sets the current bounds for the specified cell.voidReads the bounds from the nested map for each cell and invokes setBounds for that cell with a clone of the bounds.voidsetCircleRadiusFactor(double circleRadiusFactor) voidsetDirected(boolean directed) voidsetEdgePromotion(boolean edgePromotion) voidsetGroupHierarchies(List groupHierarchies) voidsetIgnoresCellsInGroups(boolean ignoresCellsInGroups) voidsetIgnoresHiddenCells(boolean ignoresHiddenCells) The GraphLayoutCache instance on the JGraphFacade object must be set correctly in order to change this flag.voidsetIgnoresUnconnectedCells(boolean ignoresUnconnectedCells) voidsetLocation(Object cell, double x, double y) Sets the current location of the specified cell.voidsetLocation(Object cell, double x, double y, boolean moveGroups) Sets the current location of the specified cell.voidsetLocations(Object[] cells, double[][] locations) Sets the locations of the specified cells according to the arrays specified inlocations.voidsetLoggerLevel(Level level) Sets the logging level of this classvoidsetOrder(Comparator order) voidsetOrdered(boolean ordered) voidSets the points of the specified edgevoidvoidSets the current size of the specified cell.voidsetVerticesFilter(Set verticesFilter) voidtilt(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.voidMoved the specified cell by the specified x and y co-ordinate amountsvoidtranslateCells(Collection cells, double dx, double dy) Translates the bounds of the specified cells addingdxanddyto the respective location axes of the cell,
-
Field Details
-
ignoresHiddenCells
protected boolean ignoresHiddenCellsStores whether or not the layout is to act on only visible cells i.e.truemeans only act on visible cells,falseact on cells regardless of their visibility. Default istrue. -
ignoresUnconnectedCells
protected boolean ignoresUnconnectedCellsStores whether or not the layout is to act on only cells that have at least one connection.truemeans only act on connected cells,falseact on cells regardless of their connections. Default istrue. -
ignoresCellsInGroups
protected boolean ignoresCellsInGroupsStores whether or not the layout is to only act on root cells in the model.truemeans only act on root cells,falsemeans act upon roots and their children. Default isfalse. -
directed
protected boolean directedStores whether or not the graph is to be treated as a directed graph.truemeans follow edges in target to source direction,yfalsemeans treat edges as directionless -
edgePromotion
protected boolean edgePromotionWhether or not edges connected to collapsed children are promoted to their first visible parent within the facade, not the actual model -
ordered
protected boolean orderedWhether or not cells should be returned in the same order as found in the model. Set to true to obtain deterministic results for things such as the order of cells with a particular level of a tree layout. Note that setting this variable to true can cause quadratic performance, therefore it defaults to false. -
graph
The JGraph to have the layout applied to it. There is no accessor to the graph for the layouts. If you need access to the graph, try to factor out the methods into a custom facade, and pass an instance of that facade to your layout's run method. -
graphLayoutCache
The layout cache to have the layout applied to it. There is no accessor to the graph for the layouts. If you need access to the graph, try to factor out the methods into a custom facade, and pass an instance of that facade to your layout's run method. -
model
The model to have the layout applied to it. There is no accessor to the graph for the layouts. If you need access to the graph, try to factor out the methods into a custom facade, and pass an instance of that facade to your layout's run method. -
attributes
The map of attribute changes made be the layout. Maps from cells to maps. -
order
The default comparator to be used where ordering is required in layouts -
distanceCostFunction
The default cost function used for shortest path search. -
algebra
The default graph algebra used for basic algorithms and functions. -
roots
The root vertex to be used by tree layouts. -
verticesFilter
If instaniated, this set defines which vertices are to be processed in any layouts. Set to null to apply no filtered set -
groupHierarchies
A collection of groups of sibling vertices -
circleRadiusFactor
protected double circleRadiusFactorThe factor by which to multiple the radius of the circle layout
-
-
Constructor Details
-
JGraphFacade
Constructs a JGraphGraphFacade specifying the graph passed in as the input graph- Parameters:
graph- the JGraph to be laid out
-
JGraphFacade
Constructs a JGraphGraphFacade specifying the graph passed in as the input graph- Parameters:
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.
-
JGraphFacade
-
JGraphFacade
public JGraphFacade(JGraph graph, 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. Also configures properties of layout, whether or not edge direction is to be taken into account, whether or not invisible cells are to be considered and whether or not only root cells are to be considered or roots and all their children. A root is only used if the isVertex method returns true.- Parameters:
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 functions- See Also:
-
JGraphFacade
Creates a JGraphFacade specifying the graph passed in as the input graph.- Parameters:
cache- The GraphLayoutCache to be used as input to the layout
-
JGraphFacade
public JGraphFacade(GraphLayoutCache cache, 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. Also configures properties of layout, whether or not edge direction is to be taken into account, whether or not invisible cells are to be considered and whether or not only root cells are to be considered or roots and all their children. A root is only used if the isVertex method returns true.- Parameters:
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 functions- See Also:
-
JGraphFacade
public JGraphFacade(GraphModel model, 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. Also configures properties of layout, whether or not edge direction is to be taken into account, whether or not invisible cells are to be considered and whether or not only root cells are to be considered or roots and all their children. A root is only used if the isVertex method returns true.- Parameters:
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 functions- See Also:
-
JGraphFacade
public JGraphFacade(GraphModel model, GraphLayoutCache cache, 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. Also configures properties of layout, whether or not edge direction is to be taken into account, whether or not invisible cells are to be considered and whether or not only root cells are to be considered or roots and all their children. A root is only used if the isVertex method returns true.- Parameters:
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 functions- See Also:
-
-
Method Details
-
run
The main method to execute layouts- Parameters:
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 on
-
resetControlPoints
public void resetControlPoints()Resets the control points of all moveable edges in the graph. -
resetControlPoints
Resets the control points of all moveable edges in the graph. Also set the routing on the edges to the specified value if the parameter flag indicates to do so- Parameters:
whether- or not to set a new routing style on each edgethe- routing style to set on each edge ifsetRoutingistrue
-
isVertex
Returns whether or not the specified cell is a vertex and should be taken into account by the layout- Parameters:
cell- the cell that is to be classified as a vertex or not- Returns:
- Returns true if
cellis a vertex
-
isEdge
Returns whether or not the specified cell is an edge and should be taken into account by the layout- Parameters:
cell- the cell that is to be classified as an edge or not- Returns:
- Returns true if the cell is an edge
-
getNeighbours
-
getNeighbours
Returns a collection of cells that are connected to the specified cell by edges. Any cells specified in the exclude set will be ignored.- Parameters:
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 currentordercomparator. Be very careful using the default comparator on the default graph model,getIndexOfRoothas linear performance and so sorting the entire model roots will have quadratic performance.- Returns:
- Returns the set of neighbours for
cell
-
getLength
Returns the length of the specified edge wrtdistanceFunction.- Parameters:
edge- the edge whos length is returned- Returns:
- Returns the length of
edge - See Also:
-
getDistance
Returns the length of the shortest path connectingv1andv2wrtdistanceFunction. The path has no more thanmaxHopselements.- Parameters:
v1- the source vertexv2- the target vertexmaxHops- the maximum number of edges the path may have- Returns:
- Returns the length of the shortest path between v1 and v2
- See Also:
-
getPath
Returns the shortest path connectingv1andv2wrtcfwith traverses no more thanstepsedges. The cost function defines the metric that is used as the edges length.- Parameters:
v1- the source vertexv2- the target vertexsteps- the maximum number of edges in the pathcf- the cost function that defines the edge lengths- Returns:
- Returns shortest array of edges connecting v1 and v2
- See Also:
-
getConnectionComponents
Returns a union find structure representing the connection components of G=(E,V). The union find may be used as follows to determine whether two cells are connected:Object[] v = facade.getVertices();
Object[] e = facade.getEdges();
JGraphUnionFind uf = facade.getConnectionComponents(v, e);
boolean connected = uf.differ(vertex1, vertex2);- Parameters:
v- the vertices of the graphe- the edges of the graph- Returns:
- Returns the connection components in G=(E,V)
- See Also:
-
getMinimumSpanningTree
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V). The MST is defined as the set of all vertices with minimal lengths that forms no cycles in G.- Parameters:
v- the vertices of the graph- Returns:
- Returns the MST as an array of edges
- See Also:
-
getVertices
Returns all vertices in the graph.
Note: This returns a linked list, for frequent read operations you should turn this into an array, or at least an array list.- Returns:
- Returns all cells that the layout should take into account
- See Also:
-
getUnconnectedVertices
Returns all unconnected vertices in the graph.- Returns:
- Returns all the unconnected cells that the layout should take into account
-
getEdges
Returns all edges in the graph.
Note: This returns a linked list, for frequent read operations you should turn this into an array, or at least an array list.- Returns:
- Returns all edges that the layout should take into account
- See Also:
-
getEdges
-
getEdges
-
getSource
-
getTarget
-
getSourcePort
-
getTargetPort
-
getAll
Returns all cells including all descendants. -
getCells
Returns a collection of cells in the current graph. Roots are flattened and returned also. It can be specified whether or not to return edges in the graph using the appropriate parameter. If theorderedflag is set totruethe result will be ordered by the current comparator set for this facade.
Note: This returns a set, for frequent read operations you should turn this into an array, or at least an array list.- Parameters:
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 currentordercomparator. Be very careful using the default comparator on the default graph model,getIndexOfRoothas linear performance and so sorting the entire model roots will have quadratic performance.- Returns:
- collection of cells in the graph
-
getCellView
-
getVertices
Returns a collection of vertices found in the specified collection.- Parameters:
cells- the set of potential verticesordered- whether or not to order the returned value in the order of the currentordercomparator. Be very careful using the default comparator on the default graph model,getIndexOfRoothas linear performance and so sorting the entire model roots will have quadratic performance.- Returns:
- Returns the collection of vertices on the collection
- See Also:
-
getOutgoingEdges
Returns the outgoing edges for cell. Cell should be a port or a vertex.- Parameters:
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 list- Returns:
- Returns the list of outgoing edges for
cell
-
getIncomingEdges
Returns the incoming edges for cell. Cell should be a port or a vertex.- Parameters:
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 list- Returns:
- Returns the list of incoming edges for
cell
-
createNestedMap
Deprecated.as of version 1.1Creates and returns nested attribute map specifying what changes the layout made to the input graph. After a layout is run this method should be queried to see what positional changes were made. This method applied snapping to the graph if enabled and only fills the map with the bounds values since these are the only values layout change- Returns:
- a nested
Mapof the changes the layout made upon the input graph - See Also:
-
createNestedMap
Compatibility method to invokecreateNestedMap(boolean, Point2D)with an origin or null depending onflushOrigin.- Parameters:
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)- Returns:
- a nested
Mapof the changes the layout made upon the input graph
-
createNestedMap
Creates and returns nested attribute map specifying what changes the layout made to the input graph. After a layout is run this method should be queried to see what positional changes were made. This method applied snapping to the graph if enabled and only fills the map with the bounds values since these are the only values layout change- Parameters:
ignoreGrid- whether or not the map returned is snapped to the current gridorigin- the new origin to which the graph bounds will be flushed to- Returns:
- a nested
Mapof the changes the layout made upon the input graph
-
getComponents
Calculates a list of non-connected graph components for the current graph.- Returns:
- a collection of seperate graph components
-
norm
Calculates the euklidische Norm for the point p.- Parameters:
p- the point to calculate the norm for- Returns:
- the euklidische Norm for the point p
-
getAttributes
Returns the nested map that specifies what changes the layout has made to the input graph.- Returns:
- The map that stores all attributes.
-
setAttributes
Sets the map that stores all attributes that comprise the changes made by the layout to the input graph- Parameters:
attributes- the new map of cell, map pairs
-
getAttributes
-
isMoveable
Returns true if the cell is moveable. If this returns false then the cells bounds cannot be changed via the facade. The default implementation checks themoveableattribute. Subclassers can override this eg. to check if a cell is not selected in the graph. -
setAttributes
-
getBounds
Returns the minimal rectangular bounds that enclose the specified vertices- Parameters:
vertices- the vertices whose collective bounds are to be determined- Returns:
- the collective bounds of the input vertices
-
getGraphBounds
Returns the minimal rectangular bounds that enclose all the elements in theboundsmap. 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.- Returns:
- the collective bounds of the elements in
bounds
-
getGraphOrigin
Returns the origin of the graph (ie the top left corner of the root cells) for the original geometry.- Returns:
- The origin of the graph.
-
getCellBounds
Returns the minimal rectangular bounds that enclose all the elements in theboundsmap. After a layout has completed this method will return the collective bounds of the new laid out graph.- Returns:
- the collective bounds of the elements in
bounds
-
translateCells
Translates the bounds of the specified cells addingdxanddyto the respective location axes of the cell,- Parameters:
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 applied
-
scale
Scales the graph bounds defined inboundsto fit into the specified frame- Parameters:
frame- the frame theboundsmap colective bounds is to be scaled to
-
scale
Scales the bounds of the specified cells addingdxanddyto the respective location axes of the cell, then by scaling them byscalexandscaley- Parameters:
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 applied
-
randomize
Moves the specified vertices to random locations in the x and y axes directions between zero and a specified maximum. The maximum amounts can be specified seperately for the x and y axes.- Parameters:
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-axis
-
tilt
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. The maximum amounts can be specified seperately for the x and y axes.- Parameters:
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-axis
-
circle
Arrange the specified vertices into a circular shape, with a regular distance between each vertex- Parameters:
vertices- the collection of vertices to be arranged
-
getBounds
Returns the current bounds for the specified cell.- Parameters:
cell- the cell whose bounds are to be determined- Returns:
- the bounds of the specified cell
-
setBounds
Reads the bounds from the nested map for each cell and invokes setBounds for that cell with a clone of the bounds.- Parameters:
nestedMap- A map of (cell, map) pairs- See Also:
-
setBounds
Sets the current bounds for the specified cell.- Parameters:
cell- the cell whose bounds are to be setrect- the new bounds of the specified cell
-
getLocations
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.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); }
- Parameters:
cells- The cells to return the locations for- Returns:
- Returns the locations of the cells as an array of arrays
-
getBounds
Same as getLocations, but with width and height added at index 3 and 4 respectively.- Parameters:
cells- The cells to return the bounds for- Returns:
- Returns the bounds of the cells as an array of arrays
- See Also:
-
getLocation
-
setLocations
Sets the locations of the specified cells according to the arrays specified inlocations. The cells and locations array must contain the same number of elements.- Parameters:
cells- The cells to change the locations forlocations- The new locations as an array of arrays- See Also:
-
setBounds
Same as setLocations, but with width and height added at index 3 and 4 respectively.- Parameters:
cells- The cells to change the bounds forlocations- The new bounds as an array of arrays- See Also:
-
setLocation
Sets the current location of the specified cell. This checks if the cell is moveable.- Parameters:
cell- the cell whose location is to be setx- the new x-axs location of the celly- the new y-axs location of the cell- See Also:
-
setLocation
Sets the current location of the specified cell. This checks if the cell is moveable.- Parameters:
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 cells- See Also:
-
translate
Moved the specified cell by the specified x and y co-ordinate amounts- Parameters:
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-axis
-
getMaxSize
Obtains the maximum width or height dimension of any of the vertices in the specified collection- Parameters:
vertices- collection of vertices to be analysed- Returns:
- the maximum width or height of any of the vertices
-
setSize
Sets the current size of the specified cell.- Parameters:
cell- the cell whose size is to be setwidth- the new width of the cellheight- the new height of the cell
-
getSize
Return the size of the specified cell- Parameters:
cell- the cell whose size is to be returned- Returns:
- Returns the current size of the specified cell.
-
getPoints
Returns the points of the specified edge. The list may contain PortView instances. Do a typecheck when iterating through the elements of this list, and use PortView.getLocation to get the position of the port.- Parameters:
edge- the cell whose points are returned- Returns:
- Returns the points of the specified edge
-
setPoints
-
disableRouting
Disables per-edge on the specified edge- Parameters:
edge- the edge to have per-edge routing disabled
-
getEdgesBetween
Returns the edges between two specified ports or two specified vertices. If directed is true thencell1must be the source of the returned edges.- Parameters:
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 fromcell1tocell2should be returned and not edges in the other direction
-
determineLayoutHierarchies
protected void determineLayoutHierarchies()Divides the graph into groups of sibling vertices, vertices that share the same parent. This is mostly used for layouting of cell relative to their group context. -
populateGroupHierarchies
Creates a set of sibling vertices and adds them to the group hierarchy collection. The list of hierarchies will naturally form in an order- Parameters:
vertex- The parent vertex to the returned vertices
-
getRootCount
public int getRootCount()Returns the number of root vertices to be used by tree layouts for tree traversal.- Returns:
- the number of root vertices to be used by tree layouts
-
getRootAt
Returns the root atindexto be used by tree layouts for tree traversal.- Returns:
- the root vertex to be used by tree layouts
- See Also:
-
isRoot
Returns true ifcellis a root.- Parameters:
cell- the cell to test- Returns:
- Returns true if
cellis a root
-
getRoots
-
setRoots
- Parameters:
roots- The roots to set.
-
isDirected
public boolean isDirected()- Returns:
- Returns the directed.
-
setDirected
public void setDirected(boolean directed) - Parameters:
directed- The directed to set.
-
getOrder
- Returns:
- Returns the order.
-
setOrder
- Parameters:
order- The order to set.
-
IsIgnoresCellsInGroups
public boolean IsIgnoresCellsInGroups()- Returns:
- Returns the ignoresCellsInGroups.
-
setIgnoresCellsInGroups
public void setIgnoresCellsInGroups(boolean ignoresCellsInGroups) - Parameters:
ignoresCellsInGroups- Sets ignoresCellsInGroups.
-
isIgnoresHiddenCells
public boolean isIgnoresHiddenCells()- Returns:
- Returns the ignoresHiddenCells.
-
setIgnoresHiddenCells
public void setIgnoresHiddenCells(boolean ignoresHiddenCells) The GraphLayoutCache instance on the JGraphFacade object must be set correctly in order to change this flag. If the graphLayoutCache is null, this flag will be forced to false- Parameters:
ignoresHiddenCells- The ignoresHiddenCells to set.
-
isIgnoresUnconnectedCells
public boolean isIgnoresUnconnectedCells()- Returns:
- Returns the ignoresUnconnectedCells.
-
setIgnoresUnconnectedCells
public void setIgnoresUnconnectedCells(boolean ignoresUnconnectedCells) - Parameters:
ignoresUnconnectedCells- The ignoresUnconnectedCells to set.
-
isEdgePromotion
public boolean isEdgePromotion()- Returns:
- Returns the edgePromotion.
-
setEdgePromotion
public void setEdgePromotion(boolean edgePromotion) - Parameters:
edgePromotion- The edgePromotion to set.
-
getVerticesFilter
- Returns:
- Returns the verticesFilter.
-
setVerticesFilter
- Parameters:
verticesFilter- The verticesFilter to set.
-
getGroupHierarchies
- Returns:
- the groupHierarchies
-
setGroupHierarchies
- Parameters:
groupHierarchies- the groupHierarchies to set
-
getCircleRadiusFactor
public double getCircleRadiusFactor()- Returns:
- the circleRadiusFactor
-
setCircleRadiusFactor
public void setCircleRadiusFactor(double circleRadiusFactor) - Parameters:
circleRadiusFactor- the minCircleRadius to set
-
dfs
Performs a depth-first search of the input graph from the specified root cell using the specified visitor to extract the tree information. isVertex must return true on the passed-in root cell in order to continue.- Parameters:
root- the node to start the search fromvisitor- the visitor that defines the operations to be performed upon the graph model
-
dfs
public void dfs(Object parent, Object root, Object previousSibling, JGraphFacade.CellVisitor visitor, 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- Parameters:
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 cell
-
dfs
public void dfs(Object parent, Object root, Object previousSibling, JGraphFacade.CellVisitor visitor, Set seen, 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- Parameters:
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 cell
-
bfs
Performs a breath-first search of the input graph from the specified root cell using the specified visitor to extract the tree information.- Parameters:
visitor- the visitor that defines the operations to be performed upon the graph model
-
findTreeRoots
public void findTreeRoots()Utility method to update the array of tree roots in a graph. This sets all cells that have no incoming and one or more outgoing edges, or the cell with the largest difference between outgoing and incoming edges if no root cells exist. -
isOrdered
public boolean isOrdered()- Returns:
- Returns the ordered.
-
setOrdered
public void setOrdered(boolean ordered) - Parameters:
ordered- The ordered to set.
-
setLoggerLevel
Sets the logging level of this class- Parameters:
level- the logging level to set
-