/** * Method getGraph. * * @return IDotGraph */ public final IDotGraph getGraph() { if (startNode != null) { startNode.accept(this); } for (final Iterator<Node> iter = graph.getNodes(); iter.hasNext(); ) { final Node node = iter.next(); if ("".equals(node.getName()) || (node == startNode)) { continue; } node.accept(this); } // Update width and height in nodes. Display.getDefault() .syncExec( new Runnable() { public void run() { final Font systemFont = Application.getInstance().getFont(Application.NODE_FONT); for (final Entry<String, IVertex> entry : nameDimensions.entrySet()) { final String name = entry.getKey(); final IVertex vertex = entry.getValue(); final Dimension dim = FigureUtilities.getTextExtents(name, systemFont); vertex.setAttr(MINWIDTH_ATTR, Math.max(dim.width, 50)); vertex.setAttr(MINHEIGHT_ATTR, Math.max(dim.height, 25)); } } }); for (final Iterator<Node> iter = graph.getNodes(); iter.hasNext(); ) { final Node node = iter.next(); final Collection<Link> deps = node.getLinks(); int index = 1; final int numDeps = deps.size(); for (final Link link : deps) { currentLinkName = ""; if (numDeps > 1) { currentLinkName += index++; } link.accept(this); } } return dotGraph; }
/** * Creates a basic link. * * @param link Link * @return IEdge */ private IEdge addLink(final Link link) { final IEdge edge = dotGraph.newEdge( vertexLUT.get(link.getStartNode().getName()), vertexLUT.get(link.getEndNode().getName()), currentLinkName, link); final GrandUiPrefStore preferenceStore = Application.getInstance().getPreferenceStore(); if (link.hasAttributes(Link.ATTR_WEAK_LINK)) { edge.setAttr(DRAW2DFGCOLOR_ATTR, preferenceStore.getColor(PreferenceKeys.LINK_WEAK_COLOR)); edge.setAttr( DRAW2DLINEWIDTH_ATTR, preferenceStore.getInt(PreferenceKeys.LINK_WEAK_LINEWIDTH)); } else { edge.setAttr(DRAW2DFGCOLOR_ATTR, preferenceStore.getColor(PreferenceKeys.LINK_DEFAULT_COLOR)); edge.setAttr( DRAW2DLINEWIDTH_ATTR, preferenceStore.getInt(PreferenceKeys.LINK_DEFAULT_LINEWIDTH)); } return edge; }