/** * Obtains the cell view corresponding the cell passed in * @param cell the cell whose view is to be obtained * @return the cell view, if any, assoicated with this cell */ public Object getCellView(Object cell) { if (graphLayoutCache != null){ Object view = graphLayoutCache.getMapping(cell, false); return view; } return null; }
/** * Returns the views for the specified array of cells without creating these * views on the fly. */ public CellView[] getMapping(Object[] cells) { return getMapping(cells, false); }
/** * 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 <code>create</code> is <code>false</code>. */ public CellView[] getMapping(Object[] cells, boolean create) { if (cells != null) { CellView[] result = new CellView[cells.length]; for (int i = 0; i < cells.length; i++) result[i] = getMapping(cells[i], create); return result; } return null; }
/** * Returns the bounding rectangle of the specified cell. */ public Rectangle2D getCellBounds(Object cell) { CellView view = graphLayoutCache.getMapping(cell, false); if (view != null) return view.getBounds(); return null; }
/** * Returns the cell at the specified location that is "behind" the * <code>current</code> cell. Returns the topmost cell if there are no * more cells behind <code>current</code>. Note: This does only return * visible cells. */ public Object getNextCellForLocation(Object current, double x, double y) { CellView cur = graphLayoutCache.getMapping(current, false); CellView cell = getNextViewAt(cur, x, y); if (cell != null) return cell.getCell(); return null; }
public void startEdge(JGraph graph, Port startPort) { this.graph = graph; this.startPort = startPort; CellView view = graph.getGraphLayoutCache().getMapping(startPort, false); startView = getVertexView(view); }
/** * Gets the group attribute of the GraphSave class * *@param graph Description of Parameter *@param cell Description of Parameter *@return The group value */ private static boolean isGroup(JGraph graph, Object cell) { // Map the Cell to its View CellView view = graph.getGraphLayoutCache().getMapping(cell, false); if (view != null) { return !view.isLeaf(); } return false; }
/** * Sets the current model. */ public void setModel(GraphModel model) { roots.clear(); mapping.clear(); hiddenMapping.clear(); visibleSet.clear(); graphModel = model; if (!isPartial()) { Object[] cells = DefaultGraphModel.getRoots(getModel()); CellView[] cellViews = getMapping(cells, true); insertViews(cellViews); } // Update PortView Cache and Notify Observers update(); }
/** * Gets the group attribute of the Editor object * *@param cell Description of Parameter *@return The group value */ public boolean isGroup(Object cell) { // Map the Cell to its View CellView view = getGraph().getGraphLayoutCache().getMapping(cell, false); if (view != null) { return!view.isLeaf(); } return false; }
/** * Returns <code>true</code> if the graph and the cell are editable. This * is invoked from the UI before editing begins to ensure that the given * cell can be edited. * * @return true if the specified cell is editable * @see #isEditable * */ public boolean isCellEditable(Object cell) { if (cell != null) { CellView view = graphLayoutCache.getMapping(cell, false); if (view != null) { return isEditable() && GraphConstants.isEditable(view.getAllAttributes()); } } return false; }
/** * Note: Arguments are not expected to be scaled (they are scaled in here). */ public CellView getNextSelectableViewAt(CellView current, double x, double y) { CellView[] selectables = getGraphLayoutCache().getMapping( getSelectionModel().getSelectables(), false); return getNextViewAt(selectables, current, x, y); }
/** * Returns the attributes for the specified cell. If the layout cache * returns a view for the cell then this method returns allAttributes, * otherwise the method returns model.getAttributes(cell). */ public AttributeMap getAttributes(Object cell) { AttributeMap attrs; CellView cellView = getGraphLayoutCache().getMapping(cell, false); if (cellView != null) { attrs = cellView.getAllAttributes(); } else { attrs = getModel().getAttributes(cell); } return attrs; }
/** * Description of the Method * *@param c Description of Parameter */ public void toFront(Object[] c) { if (c != null && c.length > 0) { getGraph().getGraphLayoutCache().toFront(getGraph().getGraphLayoutCache().getMapping(c)); } }
/** * Returns the <code>CellView</code> that is mapped to <code>cell</code> * in the graph context. New views are created based on whether cell is * contained in the context. The <code>create</code>-flag is ignored. */ public CellView getMapping(Object cell, boolean create) { if (cell != null) { CellView view = (CellView) views.get(cell); if (view != null) return view; else if (contains(cell) || (graph.getModel().isPort(cell) && create && graph .getGraphLayoutCache().isVisible(cell))) return createMapping(cell); else return graphLayoutCache.getMapping(cell, false); } return null; }
/** * Adds the specified model root cells to the view. Do not add a view that * is already in roots. */ public void insertViews(CellView[] views) { if (views != null) { refresh(views, true); for (int i = 0; i < views.length; i++) { if (views[i] != null && getMapping(views[i].getCell(), false) != null) { CellView parentView = views[i].getParentView(); Object parent = (parentView != null) ? parentView.getCell() : null; if (!graphModel.isPort(views[i].getCell()) && parent == null) { roots.add(views[i]); } } } } }
/** * Configures the editor. Passed onto the realEditor. */ public Component getGraphCellEditorComponent( JGraph graph, Object cell, boolean isSelected) { setGraph(graph); editingComponent = realEditor.getGraphCellEditorComponent(graph, cell, isSelected); determineOffset(graph, cell, isSelected); canEdit = (lastCell != null && cell != null && lastCell.equals(cell)); CellView view = graph.getGraphLayoutCache().getMapping(cell, false); if (view != null) setFont(GraphConstants.getFont(view.getAllAttributes())); editingContainer.setFont(font); return editingContainer; }
public EdgeHandle(EdgeView edge, GraphContext ctx) { this.graph = ctx.getGraph(); this.edge = edge; editing = graph.getEditingCell() == edge.getCell(); loc = new Rectangle(); Object[] labels = GraphConstants.getExtraLabels(edge .getAllAttributes()); if (labels != null) { extraLabelLocations = new Rectangle[labels.length]; for (int i = 0; i < extraLabelLocations.length; i++) extraLabelLocations[i] = new Rectangle(); } orig = (EdgeView) graph.getGraphLayoutCache().getMapping( edge.getCell(), false); reloadPoints(orig); isEdgeConnectable = GraphConstants.isConnectable(edge .getAllAttributes()); // Configures the panel for highlighting ports highlight = createHighlight(); }
/** * Returns the topmost cell view at the specified location using the view's * bounds on non-leafs to check for containment. If reverse is true this * will return the innermost view. */ public CellView getTopmostViewAt(double x, double y, boolean reverse, boolean leafsOnly) { Rectangle2D r = new Rectangle2D.Double(x, y, 1, 1); Object[] cells = getDescendants(getRoots()); for (int i = (reverse) ? cells.length - 1 : 0; i >= 0 && i < cells.length; i += (reverse) ? -1 : +1) { CellView view = getGraphLayoutCache().getMapping(cells[i], false); if (view != null && (!leafsOnly || view.isLeaf()) && ((view.isLeaf() && view.intersects(this, r)) || (!view .isLeaf() && view.getBounds().contains(x, y)))) return view; } return null; }
/** * Used for move into group to find the target group. */ protected CellView findUnselectedInnermostGroup(double x, double y) { Object[] cells = graph.getDescendants(graph.getRoots()); for (int i = cells.length - 1; i >= 0; i--) { CellView view = graph.getGraphLayoutCache().getMapping( cells[i], false); if (view != null && !view.isLeaf() && !context.contains(view.getCell()) && view.getBounds().contains(x, y)) return view; } return null; }
public CellView createMapping(Object cell) { CellView view = graphLayoutCache.getFactory().createView( graph.getModel(), cell); putMapping(cell, view); view.refresh(graph.getGraphLayoutCache(), this, true); // Create Dependent Views // Fetch Attributes From Original View CellView src = graphLayoutCache.getMapping(cell, false); if (src != null) { view.changeAttributes(graphLayoutCache, (AttributeMap) src.getAttributes().clone()); // Inserts portviews into points list view.refresh(graph.getGraphLayoutCache(), this, false); } return view; }