Documentation of 'org.jgraph.graph.GraphLayoutCache' Java class
GraphLayoutCache
org.jgraph.graph

Class GraphLayoutCache

  • All Implemented Interfaces:
    java.io.Serializable, CellMapper


    public class GraphLayoutCache
    extends java.lang.Object
    implements CellMapper, java.io.Serializable
    An object that defines the view of a graphmodel. This object maps between model cells and views and provides a set of methods to change these views. The view may also contain its own set of attributes and is therefore an extension of an Observable, which may be observed by the GraphUI. It uses the model to send its changes to the command history.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      void addGraphLayoutCacheListener(GraphLayoutCacheListener l)
      Adds a listener for the GraphLayoutCacheEvent posted after the graph layout cache changes.
      void cellViewsChanged(CellView[] cellViews)
      Invoke this method after you've changed how the cells are to be represented in the graph.
      void collapse(java.lang.Object[] groups)
      Collapses all groups by hiding all their descendants.
      java.util.Map createNestedMap()
      Returns a nested map of (cell, map) pairs that represent all attributes of all cell views in this view.
      void edit(java.util.Map attributes)
      A shortcut method that takes a nested map and passes it to the edit method.
      void edit(java.util.Map attributes, ConnectionSet cs, ParentMap pm, javax.swing.undo.UndoableEdit[] e)
      Applies the propertyMap and the connection changes to the model.
      void edit(java.lang.Object[] cells, java.util.Map attributes)
      Applies the attributes to all cells by creating a map that contains the attributes for each cell and passing it to edit on this layout cache.
      void editCell(java.lang.Object cell, java.util.Map attributes)
      Applies the attributes to a single cell by creating a map that contains the attributes for this cell and passing it to edit on this layout cache.
      void expand(java.lang.Object[] cells)
      Expands all groups by showing all children.
      CellView[] getAllDescendants(CellView[] views)
      Returns all views, including descendants that have a parent in views, especially the PortViews.
      CellView[] getAllViews()
      Returns all views, shortcut to getAllDescendants(getRoots())
      static java.awt.geom.Rectangle2D getBounds(CellView[] views)
      Returns the bounding box for the specified cell views.
      java.lang.Object[] getCells(boolean groups, boolean vertices, boolean ports, boolean edges)
      A helper method to return various arrays of cells that are visible in this cache.
      java.lang.Object[] getCells(CellView[] views)
      Takes an array of views and returns the array of the corresponding cells by using getCell for each view.
      CellView[] getCellViews() 
      double getCollapseXScale() 
      double getCollapseYScale() 
      CellViewFactory getFactory()
      Returns the factory that was passed to the constructor.
      GraphLayoutCacheListener[] getGraphLayoutCacheListeners()
      Return an array of all GraphLayoutCacheListener that were added to this model.
      CellView[] getHiddenCellViews() 
      java.util.Map getHiddenMapping()
      Returns the hiddenMapping.
      java.util.List getIncomingEdges(java.lang.Object cell, java.util.Set exclude, boolean visibleCells, boolean selfLoops)
      Returns the incoming edges for cell.
      java.util.Set getLocalAttributes() 
      CellView[] getMapping(java.lang.Object[] cells)
      Returns the views for the specified array of cells without creating these views on the fly.
      CellView[] getMapping(java.lang.Object[] cells, boolean create)
      Returns the views for the specified array of cells.
      CellView getMapping(java.lang.Object cell, boolean create)
      Returns the view for the specified cell.
      GraphModel getModel()
      Returns the current model.
      java.util.List getNeighbours(java.lang.Object cell, java.util.Set exclude, boolean directed, boolean visibleCells)
      Returns a collection of cells that are connected to the specified cell by edges.
      java.util.List getOutgoingEdges(java.lang.Object cell, java.util.Set exclude, boolean visibleCells, boolean selfLoops)
      Returns the outgoing edges for cell.
      boolean getPartial()
      Required for XML persistence
      PortView[] getPorts()
      Returns the ports of the view.
      CellView[] getRoots()
      Returns the roots of the view.
      CellView[] getRoots(java.awt.geom.Rectangle2D clip)
      Return all root cells that intersect the given rectangle.
      java.lang.Object[] getVisibleCells(java.lang.Object[] cells)
      Returns a an array with the visible cells in cells.
      java.util.Set getVisibleSet()
      Returns the set of visible sets in this view.
      void graphChanged(GraphModelEvent.GraphModelChange change)
      Called from BasicGraphUI.ModelHandler to update the view based on the specified GraphModelEvent.
      void hideCells(java.lang.Object[] cells, boolean descandants)
      Hides the specified cells with all children if descandants is true.
      void insert(java.lang.Object cell)
      Inserts the specified vertex into the graph model.
      void insert(java.lang.Object[] cells)
      Inserts the specified cells into the graph model.
      void insert(java.lang.Object[] cells, java.util.Map nested, ConnectionSet cs, ParentMap pm)
      Variant of the insert method that allows to pass a default connection set and parent map and nested map.
      void insert(java.lang.Object[] roots, java.util.Map attributes, ConnectionSet cs, ParentMap pm, javax.swing.undo.UndoableEdit[] e)
      Inserts the cells and connections into the model, and absorbs the local attributes.
      java.lang.Object[] insertClones(java.lang.Object[] cells, java.util.Map clones, java.util.Map nested, ConnectionSet cs, ParentMap pm, double dx, double dy)
      Inserts the cloned cells from the clone map and clones the passed-in arguments according to the clone map before insertion and returns the clones in order of the cells.
      void insertEdge(java.lang.Object edge, java.lang.Object source, java.lang.Object target)
      Inserts the specified edge into the graph model.
      void insertGroup(java.lang.Object group, java.lang.Object[] children)
      Inserts the specified cell as a parent of children.
      void insertViews(CellView[] views)
      Adds the specified model root cells to the view.
      boolean isAllAttributesLocal() 
      boolean isAutoSizeOnValueChange()
      Returns true if cells should be auto-sized when their values change
      boolean isHidesDanglingConnections()
      Returns the hidesDanglingConnections.
      boolean isHidesExistingConnections()
      Returns the hidesExistingConnections.
      boolean isMovesChildrenOnExpand() 
      boolean isMovesParentsOnCollapse() 
      boolean isPartial() 
      boolean isReconnectsEdgesToVisibleParent()
      Deprecated. 
      edges are moved to parent view and back automatically
      boolean isRemembersCellViews()
      Returns the remembersCellViews.
      boolean isResizesParentsOnCollapse() 
      boolean isSelectsAllInsertedCells() 
      boolean isSelectsLocalInsertedCells() 
      boolean isShowsChangedConnections() 
      boolean isShowsExistingConnections()
      Returns the showsExistingConnections.
      boolean isShowsInsertedConnections()
      Returns the showsInsertedConnections.
      boolean isShowsInvisibleEditedCells() 
      boolean isVisible(java.lang.Object cell)
      Whether or not the specified cell is visible.
      void putMapping(java.lang.Object cell, CellView view)
      Associates the specified model cell with the specified view.
      void refresh(CellView[] views, boolean create) 
      void refresh(CellView view, boolean create) 
      void reload()
      Remaps all existing views using the CellViewFactory and replaces the respective root views.
      void remove(java.lang.Object[] cells)
      Removes cells from the model.
      void remove(java.lang.Object[] cells, boolean descendants, boolean edges)
      Removes cells from the model, including all children and connected edges if children or edges is true, respectively.
      CellView[] removeCells(java.lang.Object[] cells)
      Removes the specified model root cells from the view by removing the mapping between the cell and its view and makes the cells invisible.
      void removeGraphLayoutCacheListener(GraphLayoutCacheListener l)
      Removes a listener previously added with addGraphLayoutCacheListener() .
      CellView removeMapping(java.lang.Object cell)
      Removes the association for the specified model cell and returns the view that was previously associated with the cell.
      boolean removeViewLocalAttribute(java.lang.Object key, boolean addToModel, boolean override)
      Handles the removal of view local attributes.
      void setAllAttributesLocal(boolean allAttributesLocal) 
      void setAutoSizeOnValueChange(boolean flag)
      Determines whether cells should be auto-sized when their values change.
      void setCollapsedState(java.lang.Object[] collapse, java.lang.Object[] expand)
      Collapses and/or expands the specified cell(s) NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
      void setCollapseXScale(double collapseXScale) 
      void setCollapseYScale(double collapseYScale) 
      void setFactory(CellViewFactory factory)
      Sets the factory that creates the cell views.
      void setHiddenSet(java.util.Map hiddenSet)
      Sets the hiddenSet.
      void setHidesDanglingConnections(boolean hidesDanglingConnections)
      Sets the hidesDanglingConnections
      void setHidesExistingConnections(boolean hidesExistingConnections)
      Sets the hidesExistingConnections
      void setLocalAttributes(java.util.Set localAttributes) 
      void setModel(GraphModel model)
      Sets the current model.
      void setMovesChildrenOnExpand(boolean moveChildrenOnExpand) 
      void setMovesParentsOnCollapse(boolean movesParentsOnCollapse) 
      void setReconnectsEdgesToVisibleParent(boolean reconnectsEdgesToVisibleParent)
      Deprecated. 
      edges are moved to parent view and back automatically
      void setRemembersCellViews(boolean rememberCellViews)
      Sets the rememberCellViews.
      void setResizesParentsOnCollapse(boolean resizesParentsOnCollapse) 
      void setSelectsAllInsertedCells(boolean selectsAllInsertedCells) 
      void setSelectsLocalInsertedCells(boolean selectsLocalInsertedCells) 
      void setShowsChangedConnections(boolean showsChangedConnections) 
      void setShowsExistingConnections(boolean showsExistingConnections)
      Sets the showsExistingConnections
      void setShowsInsertedConnections(boolean showsInsertedConnections)
      Sets the showsInsertedConnections
      void setShowsInvisibleEditedCells(boolean showsInvisibleEditedCells) 
      void setVisible(java.lang.Object[] cells, boolean visible)
      Makes the specified cells visible or invisible depending on the flag passed in.
      void setVisible(java.lang.Object[] visible, java.lang.Object[] invisible)
      Changes the visibility state of the cells passed in.
      void setVisible(java.lang.Object[] visible, java.lang.Object[] invisible, ConnectionSet cs)
      Changes the visibility state of the cells passed in.
      void setVisible(java.lang.Object[] visible, java.lang.Object[] invisible, java.util.Map attributes, ConnectionSet cs)
      Changes the visibility state of the cells passed in.
      void setVisible(java.lang.Object cell, boolean visible)
      Makes the specified cell visible or invisible depending on the flag passed in.
      boolean setVisibleImpl(java.lang.Object[] cells, boolean visible)
      The actual implementation of changing cells' visibility state.
      void setVisibleSet(java.util.Set visible)
      Applies the specified set of cells as being those visible
      void showCells(java.lang.Object[] cells, boolean descandants)
      Shows the specified cells with all children if descandants is true.
      void toBack(java.lang.Object[] cells)
      Sends cells to back.
      void toFront(java.lang.Object[] cells)
      Brings cells to front.
      void toggleCollapsedState(java.lang.Object[] cells, boolean collapseOnly, boolean expandOnly)
      Toggles the collapsed state of the specified cells.
      static void translateViews(CellView[] views, double dx, double dy)
      Translates the specified views by the given amount.
      java.lang.Object[] ungroup(java.lang.Object[] cells)
      Ungroups all groups in cells and returns the children that are not ports.
      void update()
      Sets the current model.
      void update(CellView view) 
      void update(CellView[] views) 
      void valueForCellChanged(java.lang.Object cell, java.lang.Object newValue)
      Messaged when the user has altered the value for the item identified by cell to newValue.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphLayoutCache

        public GraphLayoutCache()
        Constructs a graph layout cache.
      • GraphLayoutCache

        public GraphLayoutCache(GraphModel model,
                                CellViewFactory factory)
        Constructs a view for the specified model that uses factory to create its views.
        Parameters:
        model - the model that constitues the data source
      • GraphLayoutCache

        public GraphLayoutCache(GraphModel model,
                                CellViewFactory factory,
                                boolean partial)
        Constructs a view for the specified model that uses factory to create its views.
        Parameters:
        model - the model that constitues the data source
      • GraphLayoutCache

        public GraphLayoutCache(GraphModel model,
                                CellViewFactory factory,
                                CellView[] cellViews,
                                CellView[] hiddenCellViews,
                                boolean partial)
        Constructs a view for the specified model that uses factory to create its views.
        Parameters:
        model - the model that constitues the data source
    • Method Detail

      • cellViewsChanged

        public void cellViewsChanged(CellView[] cellViews)
        Invoke this method after you've changed how the cells are to be represented in the graph.
      • getGraphLayoutCacheListeners

        public GraphLayoutCacheListener[] getGraphLayoutCacheListeners()
        Return an array of all GraphLayoutCacheListener that were added to this model.
      • setFactory

        public void setFactory(CellViewFactory factory)
        Sets the factory that creates the cell views.
      • getFactory

        public CellViewFactory getFactory()
        Returns the factory that was passed to the constructor.
      • setModel

        public void setModel(GraphModel model)
        Sets the current model.
      • update

        public void update()
        Sets the current model.
      • getCellViews

        public CellView[] getCellViews()
        Returns:
        Returns an unordered array of all visible cellviews.
      • getBounds

        public static java.awt.geom.Rectangle2D getBounds(CellView[] views)
        Returns the bounding box for the specified cell views.
      • getCells

        public java.lang.Object[] getCells(boolean groups,
                                           boolean vertices,
                                           boolean ports,
                                           boolean edges)
        A helper method to return various arrays of cells that are visible in this cache. For example, to get all selected vertices in a graph, do graph.getSelectionCells(graph.getGraphLayoutCache().getCells(false, true, false, false));
      • createNestedMap

        public java.util.Map createNestedMap()
        Returns a nested map of (cell, map) pairs that represent all attributes of all cell views in this view.
        See Also:
        getCellViews()
      • getHiddenCellViews

        public CellView[] getHiddenCellViews()
        Returns:
        Returns an unordered array of all hidden cellviews.
      • reload

        public void reload()
        Remaps all existing views using the CellViewFactory and replaces the respective root views.
      • getModel

        public GraphModel getModel()
        Returns the current model.
      • getRoots

        public CellView[] getRoots()
        Returns the roots of the view.
      • getRoots

        public CellView[] getRoots(java.awt.geom.Rectangle2D clip)
        Return all root cells that intersect the given rectangle.
      • getVisibleCells

        public java.lang.Object[] getVisibleCells(java.lang.Object[] cells)
        Returns a an array with the visible cells in cells.
      • getPorts

        public PortView[] getPorts()
        Returns the ports of the view.
      • refresh

        public void refresh(CellView[] views,
                            boolean create)
      • refresh

        public void refresh(CellView view,
                            boolean create)
      • update

        public void update(CellView[] views)
      • update

        public void update(CellView view)
      • graphChanged

        public void graphChanged(GraphModelEvent.GraphModelChange change)
        Called from BasicGraphUI.ModelHandler to update the view based on the specified GraphModelEvent.
      • insertViews

        public void insertViews(CellView[] views)
        Adds the specified model root cells to the view. Do not add a view that is already in roots.
      • removeCells

        public CellView[] removeCells(java.lang.Object[] cells)
        Removes the specified model root cells from the view by removing the mapping between the cell and its view and makes the cells invisible.
      • getCells

        public java.lang.Object[] getCells(CellView[] views)
        Takes an array of views and returns the array of the corresponding cells by using getCell for each view.
      • getMapping

        public CellView getMapping(java.lang.Object cell,
                                   boolean create)
        Returns the view for the specified cell. If create is true and no view is found then a view is created using createView(Object).
        Specified by:
        getMapping in interface CellMapper
        create - whether a new view should created if a view does not already exist
      • getMapping

        public CellView[] getMapping(java.lang.Object[] cells)
        Returns the views for the specified array of cells without creating these views on the fly.
      • getMapping

        public CellView[] getMapping(java.lang.Object[] cells,
                                     boolean create)
        Returns the views for the specified array of cells. Returned array may contain null pointers if the respective cell is not mapped in this view and create is false.
      • putMapping

        public void putMapping(java.lang.Object cell,
                               CellView view)
        Associates the specified model cell with the specified view.
        Specified by:
        putMapping in interface CellMapper
        Parameters:
        cell - the cell that constitutes the model element
        view - the view that constitutes the view element
      • removeMapping

        public CellView removeMapping(java.lang.Object cell)
        Removes the association for the specified model cell and returns the view that was previously associated with the cell. Updates the portlist if necessary.
      • isVisible

        public boolean isVisible(java.lang.Object cell)
        Whether or not the specified cell is visible. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc. null is always visible
        Parameters:
        cell - the whose visibility to determine
        Returns:
        whether or not the cell is visible
      • getVisibleSet

        public java.util.Set getVisibleSet()
        Returns the set of visible sets in this view.
        Returns:
        the set of visible sets in this view.
      • setVisibleSet

        public void setVisibleSet(java.util.Set visible)
        Applies the specified set of cells as being those visible
        Parameters:
        visible - the set of visible cells
      • setVisible

        public void setVisible(java.lang.Object cell,
                               boolean visible)
        Makes the specified cell visible or invisible depending on the flag passed in. Note the cell really is a cell, not a cell view. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        cell - the cell whose visibility is to be changed
        visible - true if cell is to be made visible
      • setVisible

        public void setVisible(java.lang.Object[] cells,
                               boolean visible)
        Makes the specified cells visible or invisible depending on the flag passed in. Note the cells really are cells, not cell views. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        cells - the cells whose visibility is to be changed
        visible - true if the cells are to be made visible
      • setVisible

        public void setVisible(java.lang.Object[] visible,
                               java.lang.Object[] invisible)
        Changes the visibility state of the cells passed in. Note that the arrays must contain cells, not cell views. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        visible - cells to be made visible
        invisible - cells to be made invisible
      • setVisible

        public void setVisible(java.lang.Object[] visible,
                               java.lang.Object[] invisible,
                               ConnectionSet cs)
        Changes the visibility state of the cells passed in. Note that the arrays must contain cells, not cell views. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        visible - cells to be made visible
        invisible - cells to be made invisible
        cs - a ConnectionSet describing the new state of edge connections in the graph
      • setVisible

        public void setVisible(java.lang.Object[] visible,
                               java.lang.Object[] invisible,
                               java.util.Map attributes,
                               ConnectionSet cs)
        Changes the visibility state of the cells passed in. Note that the arrays must contain cells, not cell views. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        visible - cells to be made visible
        invisible - cells to be made invisible
        attributes - a nested attribute map of cells/attribute maps
        cs - a ConnectionSet describing the new state of edge connections in the graph
      • setVisibleImpl

        public boolean setVisibleImpl(java.lang.Object[] cells,
                                      boolean visible)
        The actual implementation of changing cells' visibility state. This method does not deal with creating the undo or updating the GraphLayoutCache correctly. The setVisible methods in this class are intended to be the main public way to change visiblilty. However, if you do not require the undo to be formed, this method is much quicker, just note that you must call updatePorts if this method returns true. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        cells -
        visible -
        Returns:
        whether or not the ports needed updating in the calling method
      • isPartial

        public boolean isPartial()
      • getPartial

        public boolean getPartial()
        Required for XML persistence
        Returns:
        whether or not the cache is partial
      • valueForCellChanged

        public void valueForCellChanged(java.lang.Object cell,
                                        java.lang.Object newValue)
        Messaged when the user has altered the value for the item identified by cell to newValue. If newValue signifies a truly new value the model should post a graphCellsChanged event. This calls augmentNestedMapForValueChange.
      • insert

        public void insert(java.lang.Object[] roots,
                           java.util.Map attributes,
                           ConnectionSet cs,
                           ParentMap pm,
                           javax.swing.undo.UndoableEdit[] e)
        Inserts the cells and connections into the model, and absorbs the local attributes. This implementation sets the inserted cells visible and selects the new roots depending on graph.selectNewCells.
      • insertClones

        public java.lang.Object[] insertClones(java.lang.Object[] cells,
                                               java.util.Map clones,
                                               java.util.Map nested,
                                               ConnectionSet cs,
                                               ParentMap pm,
                                               double dx,
                                               double dy)
        Inserts the cloned cells from the clone map and clones the passed-in arguments according to the clone map before insertion and returns the clones in order of the cells. This example shows how to clone the current selection and get a reference to the clones:
         Object[] cells = graph.getDescendants(graph.order(graph.getSelectionCells()));
         ConnectionSet cs = ConnectionSet.create(graphModel, cells, false);
         ParentMap pm = ParentMap.create(graphModel, cells, false, true);
         cells = graphLayoutCache.insertClones(cells, graph.cloneCells(cells),
                        attributes, cs, pm, 0, 0);
         
      • insert

        public void insert(java.lang.Object cell)
        Inserts the specified vertex into the graph model. This method does in fact nothing, it calls insert edge with the vertex and the source and target port set to null. This example shows how to add a vertex with a port and a black border:
         DefaultGraphCell vertex = new DefaultGraphCell("Hello, world!");
         Map attrs = vertex.getAttributes();
         GraphConstants.setOpaque(attrs, false);
         GraphConstants.setBorderColor(attrs, Color.black);
         DefaultPort port = new DefaultPort();
         vertex.add(port);
         port.setParent(vertex);
         graph.getGraphLayoutCache().insert(vertex);
         
        Parameters:
        cell - inserts the specified cell in the cache
      • insertEdge

        public void insertEdge(java.lang.Object edge,
                               java.lang.Object source,
                               java.lang.Object target)
        Inserts the specified edge into the graph model. This method does in fact nothing, it calls insert with a default connection set.
        Parameters:
        edge - the edge to be inserted
        source - the source port this edge is connected to
        target - the target port this edge is connected to
      • insert

        public void insert(java.lang.Object[] cells)
        Inserts the specified cells into the graph model. This method is a general implementation of cell insertion. If the source and target port are null, then no connection set is created. The method uses the attributes from the specified edge and the egdge's children to construct the insert call. This example shows how to insert an edge with a special arrow between two known vertices:
         Object source = graph.getDefaultPortForCell(sourceVertex).getCell();
         Object target = graph.getDefaultPortForCell(targetVertex).getCell();
         DefaultEdge edge = new DefaultEdge("Hello, world!");
         edge.setSource(source);
         edge.setTarget(target);
         Map attrs = edge.getAttributes();
         GraphConstants.setLineEnd(attrs, GraphConstants.ARROW_TECHNICAL);
         graph.getGraphLayoutCache().insert(edge);
         
      • insert

        public void insert(java.lang.Object[] cells,
                           java.util.Map nested,
                           ConnectionSet cs,
                           ParentMap pm)
        Variant of the insert method that allows to pass a default connection set and parent map and nested map.
      • insertGroup

        public void insertGroup(java.lang.Object group,
                                java.lang.Object[] children)
        Inserts the specified cell as a parent of children. Note: All cells that are not yet in the model will be inserted. This example shows how to group the current selection and pass the group default bounds in case it is later collapsed:
         DefaultGraphCell group = new DefaultGraphCell("Hello, world!");
         Object[] cells = DefaultGraphModel.order(graph.getModel(), graph
                        .getSelectionCells());
         Rectangle2D bounds = graph.getCellBounds(cells);
         if (bounds != null) {
                bounds = new Rectangle2D.Double(bounds.getX() + bounds.getWidth() / 4,
                                bounds.getY() + bounds.getHeight() / 4, bounds.getWidth() / 2,
                                bounds.getHeight() / 2);
                GraphConstants.setBounds(group.getAttributes(), bounds);
         }
         graph.getGraphLayoutCache().insertGroup(group, cells);
         
      • remove

        public void remove(java.lang.Object[] cells)
        Removes cells from the model.
      • remove

        public void remove(java.lang.Object[] cells,
                           boolean descendants,
                           boolean edges)
        Removes cells from the model, including all children and connected edges if children or edges is true, respectively.
        Parameters:
        cells - The cells to remove.
        descendants - Whether to remove all descendants as well.
        edges - Whether to remove all connected edges as well.
      • hideCells

        public void hideCells(java.lang.Object[] cells,
                              boolean descandants)
        Hides the specified cells with all children if descandants is true. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
      • showCells

        public void showCells(java.lang.Object[] cells,
                              boolean descandants)
        Shows the specified cells with all children if descandants is true. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
      • ungroup

        public java.lang.Object[] ungroup(java.lang.Object[] cells)
        Ungroups all groups in cells and returns the children that are not ports. Note: This replaces the parents with their group cells in the group structure.
      • toggleCollapsedState

        public void toggleCollapsedState(java.lang.Object[] cells,
                                         boolean collapseOnly,
                                         boolean expandOnly)
        Toggles the collapsed state of the specified cells. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        cells - The cells to toggle the collapsed state for.
        collapseOnly - Whether cells should only be collapsed.
        expandOnly - Whether cells should only be expanded.
      • collapse

        public void collapse(java.lang.Object[] groups)
        Collapses all groups by hiding all their descendants. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        groups -
      • expand

        public void expand(java.lang.Object[] cells)
        Expands all groups by showing all children. (Note: This does not show all descandants, but only the first generation of children.) NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
      • setCollapsedState

        public void setCollapsedState(java.lang.Object[] collapse,
                                      java.lang.Object[] expand)
        Collapses and/or expands the specified cell(s) NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        collapse - the cells to be collapsed
        expand - the cells to be expanded
      • edit

        public void edit(java.util.Map attributes,
                         ConnectionSet cs,
                         ParentMap pm,
                         javax.swing.undo.UndoableEdit[] e)
        Applies the propertyMap and the connection changes to the model. The initial edits that triggered the call are considered to be part of this transaction. Notifies the model- and undo listeners of the change. Note: The passed in attributes may contain PortViews.
      • edit

        public void edit(java.util.Map attributes)
        A shortcut method that takes a nested map and passes it to the edit method.
      • edit

        public void edit(java.lang.Object[] cells,
                         java.util.Map attributes)
        Applies the attributes to all cells by creating a map that contains the attributes for each cell and passing it to edit on this layout cache. Example:
         Map attrs = new java.util.Hashtable();
         GraphConstants.setBackground(attrs, Color.RED);
         graph.getGraphLayoutCache().edit(graph.getSelectionCells(), attrs);
         
      • editCell

        public void editCell(java.lang.Object cell,
                             java.util.Map attributes)
        Applies the attributes to a single cell by creating a map that contains the attributes for this cell and passing it to edit on this layout cache. Example:
         Map attrs = new java.util.Hashtable();
         GraphConstants.setBackground(attrs, Color.RED);
         graph.getGraphLayoutCache().editCell(graph.getSelectionCell(), attrs);
         
      • toBack

        public void toBack(java.lang.Object[] cells)
        Sends cells to back. Note: This expects an array of cells!
      • toFront

        public void toFront(java.lang.Object[] cells)
        Brings cells to front. Note: This expects an array of cells!
      • removeViewLocalAttribute

        public boolean removeViewLocalAttribute(java.lang.Object key,
                                                boolean addToModel,
                                                boolean override)
        Handles the removal of view local attributes. Since these attributes are only being stored in the view, the option is provided to copy the values for that key into the model. Without this, those values are lost.
        Parameters:
        key - the key of the view local attribute
        addToModel - whether or not to move the attribute values to the graph model
        override - whether or not to override the key's value in the model cell's attribute map if it exists
        Returns:
        whether or not the operation completed sucessfully
      • translateViews

        public static void translateViews(CellView[] views,
                                          double dx,
                                          double dy)
        Translates the specified views by the given amount.
        Parameters:
        views - an array of cell view to each be translated
        dx - the amount to translate the views in the x-axis
        dy - the amount to translate the views in the x-axis
      • getNeighbours

        public java.util.List getNeighbours(java.lang.Object cell,
                                            java.util.Set exclude,
                                            boolean directed,
                                            boolean visibleCells)
        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 determined
        exclude - The set of cells to ignore when searching
        directed - whether or not direction of edges should be taken into account
        visibleCells - whether or not to only consider visible cells
        Returns:
        Returns the list of neighbours for cell
      • getOutgoingEdges

        public java.util.List getOutgoingEdges(java.lang.Object cell,
                                               java.util.Set exclude,
                                               boolean visibleCells,
                                               boolean selfLoops)
        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 determined
        exclude - The set of edges to ignore when searching
        visibleCells - whether or not only visible cells should be processed
        selfLoops - whether or not to include self loops in the returned list
        Returns:
        Returns the list of outgoing edges for cell
      • getIncomingEdges

        public java.util.List getIncomingEdges(java.lang.Object cell,
                                               java.util.Set exclude,
                                               boolean visibleCells,
                                               boolean selfLoops)
        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 determined
        exclude - The set of edges to ignore when searching
        visibleCells - whether or not only visible cells should be processed
        selfLoops - whether or not to include self loops in the returned list
        Returns:
        Returns the list of incoming edges for cell
      • getAllViews

        public CellView[] getAllViews()
        Returns all views, shortcut to getAllDescendants(getRoots())
      • getAllDescendants

        public CellView[] getAllDescendants(CellView[] views)
        Returns all views, including descendants that have a parent in views, especially the PortViews. Note: Iterative Implementation using model.getChild and getMapping on this cell mapper.
      • getHiddenMapping

        public java.util.Map getHiddenMapping()
        Returns the hiddenMapping.
        Returns:
        Map
      • setShowsExistingConnections

        public void setShowsExistingConnections(boolean showsExistingConnections)
        Sets the showsExistingConnections
        Parameters:
        showsExistingConnections -
      • isShowsExistingConnections

        public boolean isShowsExistingConnections()
        Returns the showsExistingConnections.
        Returns:
        boolean
      • setShowsInsertedConnections

        public void setShowsInsertedConnections(boolean showsInsertedConnections)
        Sets the showsInsertedConnections
        Parameters:
        showsInsertedConnections -
      • isShowsInsertedConnections

        public boolean isShowsInsertedConnections()
        Returns the showsInsertedConnections.
        Returns:
        boolean
      • setHidesExistingConnections

        public void setHidesExistingConnections(boolean hidesExistingConnections)
        Sets the hidesExistingConnections
        Parameters:
        hidesExistingConnections -
      • isHidesExistingConnections

        public boolean isHidesExistingConnections()
        Returns the hidesExistingConnections.
        Returns:
        boolean
      • setHidesDanglingConnections

        public void setHidesDanglingConnections(boolean hidesDanglingConnections)
        Sets the hidesDanglingConnections
        Parameters:
        hidesDanglingConnections -
      • isHidesDanglingConnections

        public boolean isHidesDanglingConnections()
        Returns the hidesDanglingConnections.
        Returns:
        boolean
      • setRemembersCellViews

        public void setRemembersCellViews(boolean rememberCellViews)
        Sets the rememberCellViews.
        Parameters:
        rememberCellViews - The rememberCellViews to set
      • isRemembersCellViews

        public boolean isRemembersCellViews()
        Returns the remembersCellViews.
        Returns:
        boolean
      • setHiddenSet

        public void setHiddenSet(java.util.Map hiddenSet)
        Sets the hiddenSet. NOTE: Your GraphLayoutCache must be partial (set partial to true in the constructor) in order to use the visibility functionality of expand/collapse, setVisible, etc.
        Parameters:
        hiddenSet - The hiddenSet to set
      • getLocalAttributes

        public java.util.Set getLocalAttributes()
        Returns:
        Returns the localAttributes.
      • setLocalAttributes

        public void setLocalAttributes(java.util.Set localAttributes)
        Parameters:
        localAttributes - The localAttributes to set.
      • isAllAttributesLocal

        public boolean isAllAttributesLocal()
        Returns:
        Returns the askLocalAttribute.
      • setAllAttributesLocal

        public void setAllAttributesLocal(boolean allAttributesLocal)
        Parameters:
        allAttributesLocal - The allAttributesLocal to set.
      • isAutoSizeOnValueChange

        public boolean isAutoSizeOnValueChange()
        Returns true if cells should be auto-sized when their values change
        Returns:
        true if cells should be auto-sized when their values change
      • setAutoSizeOnValueChange

        public void setAutoSizeOnValueChange(boolean flag)
        Determines whether cells should be auto-sized when their values change. Fires a property change event if the new setting is different from the existing setting.
        Parameters:
        flag - a boolean value, true if cells should be auto-sized when their values change
      • isSelectsAllInsertedCells

        public boolean isSelectsAllInsertedCells()
        Returns:
        Returns the selectsAllInsertedCells.
      • setSelectsAllInsertedCells

        public void setSelectsAllInsertedCells(boolean selectsAllInsertedCells)
        Parameters:
        selectsAllInsertedCells - The selectsAllInsertedCells to set.
      • isSelectsLocalInsertedCells

        public boolean isSelectsLocalInsertedCells()
        Returns:
        Returns the selectsLocalInsertedCells.
      • setSelectsLocalInsertedCells

        public void setSelectsLocalInsertedCells(boolean selectsLocalInsertedCells)
        Parameters:
        selectsLocalInsertedCells - The selectsLocalInsertedCells to set.
      • isReconnectsEdgesToVisibleParent

        public boolean isReconnectsEdgesToVisibleParent()
        Deprecated. edges are moved to parent view and back automatically
        Returns:
        Returns the reconnectsEdgesToVisibleParent.
      • setReconnectsEdgesToVisibleParent

        public void setReconnectsEdgesToVisibleParent(boolean reconnectsEdgesToVisibleParent)
        Deprecated. edges are moved to parent view and back automatically
        Parameters:
        reconnectsEdgesToVisibleParent - The reconnectsEdgesToVisibleParent to set.
      • isShowsChangedConnections

        public boolean isShowsChangedConnections()
        Returns:
        Returns the showsChangedConnections.
      • setShowsChangedConnections

        public void setShowsChangedConnections(boolean showsChangedConnections)
        Parameters:
        showsChangedConnections - The showsChangedConnections to set.
      • isMovesChildrenOnExpand

        public boolean isMovesChildrenOnExpand()
        Returns:
        Returns the moveChildrenOnExpand.
      • setMovesChildrenOnExpand

        public void setMovesChildrenOnExpand(boolean moveChildrenOnExpand)
        Parameters:
        moveChildrenOnExpand - The moveChildrenOnExpand to set.
      • isShowsInvisibleEditedCells

        public boolean isShowsInvisibleEditedCells()
      • setShowsInvisibleEditedCells

        public void setShowsInvisibleEditedCells(boolean showsInvisibleEditedCells)
      • getCollapseXScale

        public double getCollapseXScale()
        Returns:
        Returns the collapseXScale.
      • setCollapseXScale

        public void setCollapseXScale(double collapseXScale)
        Parameters:
        collapseXScale - The collapseXScale to set.
      • getCollapseYScale

        public double getCollapseYScale()
        Returns:
        Returns the collapseYScale.
      • setCollapseYScale

        public void setCollapseYScale(double collapseYScale)
        Parameters:
        collapseYScale - The collapseYScale to set.
      • isMovesParentsOnCollapse

        public boolean isMovesParentsOnCollapse()
        Returns:
        Returns the movesParentsOnCollapse.
      • setMovesParentsOnCollapse

        public void setMovesParentsOnCollapse(boolean movesParentsOnCollapse)
        Parameters:
        movesParentsOnCollapse - The movesParentsOnCollapse to set.
      • isResizesParentsOnCollapse

        public boolean isResizesParentsOnCollapse()
        Returns:
        Returns the resizesParentsOnCollapse.
      • setResizesParentsOnCollapse

        public void setResizesParentsOnCollapse(boolean resizesParentsOnCollapse)
        Parameters:
        resizesParentsOnCollapse - The resizesParentsOnCollapse to set.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.