private void createArrow(K source, K target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells.get(source).getChildAt(0)); edge.setTarget(stateCells.get(target).getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); Set<K> targetSet = arrows.get(source); if (targetSet == null) { targetSet = EnumSet.noneOf(keyType); arrows.put(source, targetSet); } targetSet.add(target); } }
public static NAryEdge getNAryEdgeExtreme(DefaultEdge de, ingenias.editor.Model m) { DefaultGraphCell target = (DefaultGraphCell) ((DefaultPort) de .getTarget()).getParent(); DefaultGraphCell source = (DefaultGraphCell) ((DefaultPort) de .getSource()).getParent(); NAryEdge nary = null; if (NAryEdge.class.isAssignableFrom(target.getClass())) { nary = (NAryEdge) target; } if (NAryEdge.class.isAssignableFrom(source.getClass())) { nary = (NAryEdge) source; } return nary; }
protected DefaultEdge createRelationshipCell(Relationship rel) { if (!relCells.containsKey(getQualifiedName(rel))) { Relationship reverse = rel.getReverseRelationship(); DefaultEdge edge = new DefaultEdge(); // GraphConstants.setLineStyle(edge.getAttributes(), // GraphConstants.STYLE_ORTHOGONAL); // GraphConstants.setRouting(edge.getAttributes(), // GraphConstants.ROUTING_SIMPLE); GraphConstants.setEditable(edge.getAttributes(), false); GraphConstants.setLabelAlongEdge(edge.getAttributes(), true); GraphConstants.setSelectable(edge.getAttributes(), false); GraphConstants.setFont(edge.getAttributes(), EDGE_FONT); updateRelationshipLabels(edge, rel, reverse); relCells.put(getQualifiedName(rel), edge); if (reverse != null) { relCells.put(getQualifiedName(reverse), edge); } return edge; } return null; }
private DefaultEdge GXLEdge(Map ids, org.w3c.dom.Node node) { DefaultEdge edge = new DefaultEdge(); // Fetch Map attributes. Map attrMap = getMap(node); // Create Edge with label String label = (String) attrMap.get("id"); // Fetch type String type = (String) attrMap.get("type"); // id and type are not valid JGraph attributes. attrMap.remove("id"); attrMap.remove("type"); return edge; }
public java.awt.Component getRendererComponent(JGraph jg, boolean b1, boolean b2, boolean b3) { CellViewRenderer renderer=null; try { ingenias.editor.entities.AGOSubordinationRelationshipOrg ent=(ingenias.editor.entities.AGOSubordinationRelationshipOrg)((DefaultGraphCell)this.getCell()).getUserObject(); this.renderer1.setEntity(ent,jg.getModel().getAttributes(this.getCell())); JPanel uop=(JPanel)this.renderer1.getRendererComponent(null,null,false,false,false); if (ent.getPrefs(jg.getModel().getAttributes(this.getCell())).getView()==ingenias.editor.entities.ViewPreferences.ViewType.LABEL){ NAryEdge naryedge=(NAryEdge)this.getCell(); DefaultEdge[] edge=naryedge.getRepresentation(); AttributeMap am=edge[0].getAttributes(); GraphConstants.setLabelAlongEdge(am,true); GraphConstants.setExtraLabels(am,new Object[]{ent.getLabel()}); GraphConstants.setExtraLabelPositions(am,new Point2D[]{new Point2D.Double(GraphConstants.PERMILLE*7/8, -20)}); edge[0].setAttributes(am); } return (Component)uop; } catch (Exception e) { e.printStackTrace(); ingenias.editor.Log.getInstance().log("WARNING!!!"+e.getMessage()); } return super.getRendererComponent(jg,b1,b2,b3); } // Default size with entity ent inside
/** * Updates relationship labels for specified relationship edge. */ protected void updateRelationshipLabels(DefaultEdge edge, Relationship rel, Relationship reverse) { DefaultGraphCell sourceCell = entityCells.get(rel.getSourceEntity().getName()); DefaultGraphCell targetCell = entityCells.get(rel.getTargetEntity().getName()); edge.setSource(sourceCell != null ? sourceCell.getChildAt(0) : null); edge.setTarget(targetCell != null ? targetCell.getChildAt(0) : null); Object[] labels = { rel.getName() + " " + getRelationshipLabel(rel), reverse == null ? "" : reverse.getName() + " " + getRelationshipLabel(reverse) }; GraphConstants.setExtraLabels(edge.getAttributes(), labels); Point2D[] labelPositions = { new Point2D.Double(GraphConstants.PERMILLE * (0.1 + 0.2 * Math.random()), 10), new Point2D.Double(GraphConstants.PERMILLE * (0.9 - 0.2 * Math.random()), -10) }; GraphConstants.setExtraLabelPositions(edge.getAttributes(), labelPositions); }
DefaultPort targetPort = (DefaultPort) ( (DefaultEdge) selected[k] ).getTarget(); object = targetPort.getParent();
DefaultEdge de=(DefaultEdge)edges.next(); if (!alreadyconsidered.contains(de)){ Map atts=de.getAttributes(); DefaultGraphCell source=(DefaultGraphCell)((DefaultPort)de.getSource()).getParent(); DefaultGraphCell target=(DefaultGraphCell)((DefaultPort)de.getTarget()).getParent();
public void objEntityChanged(EntityEvent e) { remapEntity(e); updateEntityCell(e.getEntity()); // maybe super entity was changed ObjEntity entity = (ObjEntity) e.getEntity(); DefaultEdge inheritanceEdge = inheritanceEdges.get(entity); if (inheritanceEdge != null) { if (entity.getSuperEntity() == null) { graph.getGraphLayoutCache().remove(new Object[] { inheritanceEdge }); inheritanceEdges.remove(entity); } else { inheritanceEdge.setTarget(entityCells.get( entity.getSuperEntity().getName()).getChildAt(0)); Map nested = new HashMap(); nested.put(inheritanceEdge, inheritanceEdge.getAttributes()); graph.getGraphLayoutCache().edit(nested); } } else { if (entity.getSuperEntity() != null) { DefaultEdge edge = createInheritanceEdge(entity); graph.getGraphLayoutCache().insert(edge); } } }
@Override protected DefaultEdge createRelationshipCell(Relationship rel) { DefaultEdge edge = super.createRelationshipCell(rel); if (edge != null) { GraphConstants.setDashPattern(edge.getAttributes(), new float[] { 10, 3 }); } return edge; }
/** * Get the relationships in which this cell participates. * @return */ public DefaultGraphCell[] getRelationships() { // Temporal container. Vector relationContainer = new Vector(); // Search for relationships connected with cell ports. DefaultPort port = (DefaultPort)this.getChildAt(0); int k=0; while (k<this.getChildCount() && port != null) { if (port.edges().hasNext()) { DefaultEdge edge = (DefaultEdge) port.edges().next(); NAryEdge relation = (NAryEdge) ((DefaultPort) edge.getSource()).getParent(); relationContainer.add(relation); } port = (DefaultPort) this.getChildAt(k); k=k+1; } // Convert the Vector to DefaultGraphCell[]. DefaultGraphCell[] result = new DefaultGraphCell[relationContainer.size()]; for (int i = 0; i < relationContainer.size(); i++) result[i] = (NAryEdge) relationContainer.get(i); return result; }
public DefaultEdge[] connectionsEdges(GraphCell[] selected, String[] roles) { // Temporal container for edges that will be inserted into the Model. Vector edges = new Vector(); // Create connections between related objects using this n-edge. for (int i = 0; i < selected.length; i++) if ( ! (selected[i] instanceof DefaultEdge || selected[i] instanceof NAryEdge || selected[i] instanceof DefaultPort) ){ if (roles[i].equalsIgnoreCase("AHasMSManagersource")){ edges.add( new DefaultEdge( new AHasMSManagersourceRole() ) ); } if (roles[i].equalsIgnoreCase("AHasMSManagertarget")){ edges.add( new DefaultEdge( new AHasMSManagertargetRole() ) ); } } DefaultEdge[] edgesSet = new DefaultEdge[edges.size()]; for (int i = 0; i < edges.size(); i++) edgesSet[i] = (DefaultEdge) edges.get(i); return edgesSet; }
public java.awt.Component getRendererComponent(JGraph jg, boolean b1, boolean b2, boolean b3) { CellViewRenderer renderer=null; try { ingenias.editor.entities.Contribute ent=(ingenias.editor.entities.Contribute)((DefaultGraphCell)this.getCell()).getUserObject(); this.renderer1.setEntity(ent,jg.getModel().getAttributes(this.getCell())); JPanel uop=(JPanel)this.renderer1.getRendererComponent(null,null,false,false,false); if (ent.getPrefs(jg.getModel().getAttributes(this.getCell())).getView()==ingenias.editor.entities.ViewPreferences.ViewType.LABEL){ NAryEdge naryedge=(NAryEdge)this.getCell(); DefaultEdge[] edge=naryedge.getRepresentation(); AttributeMap am=edge[0].getAttributes(); GraphConstants.setLabelAlongEdge(am,true); GraphConstants.setExtraLabels(am,new Object[]{ent.getLabel()}); GraphConstants.setExtraLabelPositions(am,new Point2D[]{new Point2D.Double(GraphConstants.PERMILLE*7/8, -20)}); edge[0].setAttributes(am); } return (Component)uop; } catch (Exception e) { e.printStackTrace(); ingenias.editor.Log.getInstance().log("WARNING!!!"+e.getMessage()); } return super.getRendererComponent(jg,b1,b2,b3); } // Default size with entity ent inside
DefaultPort targetPort = (DefaultPort) ( (DefaultEdge) selected[k] ).getTarget(); object = targetPort.getParent();
protected void updateRelationshipCell(Relationship rel) { if (rel.getSourceEntity() != null && rel.getTargetEntity() != null) { DefaultEdge edge = relCells.get(getQualifiedName(rel)); if (edge != null) { updateRelationshipLabels(edge, rel, rel.getReverseRelationship()); Map nested = new HashMap(); nested.put(edge, edge.getAttributes()); edit(nested); } else { insertRelationshipCell(rel); } } }
private void createArrow(int source, int target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells[source].getChildAt(0)); edge.setTarget(stateCells[target].getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); sourceArrows[sourceArrowIndex] = source; sourceArrowIndex++; targetArrows[targetArrowIndex] = target; targetArrowIndex++; } }
public DefaultEdge[] connectionsEdges(GraphCell[] selected, String[] roles) { // Temporal container for edges that will be inserted into the Model. Vector edges = new Vector(); // Create connections between related objects using this n-edge. for (int i = 0; i < selected.length; i++) if ( ! (selected[i] instanceof DefaultEdge || selected[i] instanceof NAryEdge || selected[i] instanceof DefaultPort) ){ if (roles[i].equalsIgnoreCase("DefinesDeploymentsource")){ edges.add( new DefaultEdge( new DefinesDeploymentsourceRole() ) ); } if (roles[i].equalsIgnoreCase("DefinesDeploymenttarget")){ edges.add( new DefaultEdge( new DefinesDeploymenttargetRole() ) ); } } DefaultEdge[] edgesSet = new DefaultEdge[edges.size()]; for (int i = 0; i < edges.size(); i++) edgesSet[i] = (DefaultEdge) edges.get(i); return edgesSet; }
public java.awt.Component getRendererComponent(JGraph jg, boolean b1, boolean b2, boolean b3) { CellViewRenderer renderer=null; try { ingenias.editor.entities.ApplicationBelongsTo ent=(ingenias.editor.entities.ApplicationBelongsTo)((DefaultGraphCell)this.getCell()).getUserObject(); this.renderer1.setEntity(ent,jg.getModel().getAttributes(this.getCell())); JPanel uop=(JPanel)this.renderer1.getRendererComponent(null,null,false,false,false); if (ent.getPrefs(jg.getModel().getAttributes(this.getCell())).getView()==ingenias.editor.entities.ViewPreferences.ViewType.LABEL){ NAryEdge naryedge=(NAryEdge)this.getCell(); DefaultEdge[] edge=naryedge.getRepresentation(); AttributeMap am=edge[0].getAttributes(); GraphConstants.setLabelAlongEdge(am,true); GraphConstants.setExtraLabels(am,new Object[]{ent.getLabel()}); GraphConstants.setExtraLabelPositions(am,new Point2D[]{new Point2D.Double(GraphConstants.PERMILLE*7/8, -20)}); edge[0].setAttributes(am); } return (Component)uop; } catch (Exception e) { e.printStackTrace(); ingenias.editor.Log.getInstance().log("WARNING!!!"+e.getMessage()); } return super.getRendererComponent(jg,b1,b2,b3); } // Default size with entity ent inside
private boolean evaluateIfDefaultGraphCellHasToBeHighlighted( DefaultGraphCell dgc, boolean found, DefaultGraphCell toPaint) { if (dgc.getChildCount() > 0) { for (Object objectport : dgc.getChildren()) { if (objectport instanceof DefaultPort) { DefaultPort port = (DefaultPort) objectport; Iterator<DefaultEdge> edges = graph.getModel().edges(port); while (edges.hasNext() && !found) { DefaultEdge next = edges.next(); found = found || ((DefaultPort) (next.getTarget())) .getParent().equals(toPaint) || ((DefaultPort) (next.getSource())) .getParent().equals(toPaint); } } } } return found; }
DefaultPort targetPort = (DefaultPort) ( (DefaultEdge) selected[k] ).getTarget(); object = targetPort.getParent();