public GraphArc addArc(Object userObject, GraphNode src, GraphNode dest, Object type, Icon icon) { if (userObject == null) { throw new NullPointerException("All graph arcs must have a user object."); } if (!arcs.containsKey(userObject)) { addNodeInternal(src); addNodeInternal(dest); DefaultGraphArc arc = new DefaultGraphArc(userObject, src, dest, icon, type); addArcInternal(arc); arrangeArcs(arc.getSource(), arc.getDestination()); } return arcs.get(userObject); }
@Override public String toString() { GraphNode src = (isInverted() ? getDestination() : getSource()); GraphNode dest = (isInverted() ? getSource() : getDestination()); return src + " -- " + getType() + " --> " + dest; }
protected void addArcInternal(DefaultGraphArc arc) { // this is the ONLY place where arcs are added arcs.put(arc.getUserObject(), arc); if (!arcTypes.contains(arc.getType())) { arcTypes.add(arc.getType()); fireArcTypeAddedEvent(arc.getType()); } // add this arc to the source and destination nodes arc.getSource().addArc(arc); arc.getDestination().addArc(arc); fireArcAddedEvent(arc); }
public void updateArcPath() { reset(); Rectangle2D srcBounds = (isInverted() ? destNode.getBounds() : srcNode.getBounds()); Rectangle2D destBounds = (isInverted() ? srcNode.getBounds() : destNode.getBounds()); double startX = srcBounds.getCenterX(); double startY = srcBounds.getCenterY(); startX = (float) (srcBounds.getX() + srcBounds.getWidth() - 1); endX = startX; moveTo((float) startX, (float) startY); append(new Ellipse2D.Double(startX, startY - diam / 2.0, diam, diam), false); arrowHead.setSlope(segment.getSlope()); moveTo((float) startX, (float) startY); if (curveFactor == 0) { lineTo((float) endX, (float) endY); arrowHead.setPoint(segment.getMidPoint()); } else { quadTo((float) ctrlPointT.getX(), (float) ctrlPointT.getY(), (float) endX, (float) endY); invalidatePaint(); invalidateFullBounds();
if(arc instanceof DefaultGraphArc) { DefaultGraphArc graphArc = (DefaultGraphArc)arc; out.println("\t\"" + graphArc.getSource().getText() + "\" -> \"" + graphArc.getDestination().getText() + "\" [label=\"" + graphArc.getType() + "\"]");
@Override protected void paint(PPaintContext paintContext) { Graphics2D g2 = paintContext.getGraphics(); Stroke stroke = getStroke(); Paint paint = getStrokePaint(); if ((stroke != null) && (paint != null)) { g2.setPaint(paint); g2.setStroke(stroke); g2.draw(getPathReference()); if (showArrowHead) { Shape shape = arrowHead.getShape(); // first fill the arrow head in white g2.setPaint(ArrowHead.FILL); g2.fill(shape); // now draw the outline g2.setPaint(paint); g2.setStroke(ArrowHead.STROKE); g2.draw(shape); } if(image != null) { Point2D p = getIconLocation(arrowHead.getSlope(), arrowHead.isPointRight(), arrowHead.getPoint()); image.setX(p.getX()); image.setY(p.getY()); } } }
@Override public void setVisible(boolean visible) { if (!visible) { // hide the arc super.setVisible(false); } else if (visible && getSource().isVisible() && getDestination().isVisible()) { // only show the arc if both the source and destination nodes are visible super.setVisible(true); } }
private GraphArc addArc(GraphNode src, GraphNode dest) { String arcId = src.getText() + "->" + dest.getText(); DefaultGraphArc arc = (DefaultGraphArc) addArc(arcId, src, dest, IMPORTS); arc.setInverted(false); return arc; }
/** * Creates a GraphArc with the given parameters without actually adding the GraphNodes or * GraphArc to the model. * * @return A GraphArc object. */ protected GraphArc createArc(GraphNode srcNode, GraphNode destNode, String relType, Icon icon) { String key = srcNode.getUserObject().toString() + relType + destNode.getUserObject().toString(); return new DefaultGraphArc(key, srcNode, destNode, icon, relType); }
public DefaultGraphArc(Object userObject, GraphNode src, GraphNode dest, Icon icon, Object type) { super(); this.userObject = userObject; this.src = src; this.dest = dest; setType(type); //this.path = new GeneralPath(); this.curveFactor = 0; this.selected = false; this.highlighted = false; this.showArrowHead = true; this.arrowHead = new ArrowHead(); this.inverted = false; if(icon != null) { this.icon = icon; image = new PImage(((ImageIcon) icon).getImage()); addChild(image); } this.style = new DefaultGraphArcStyle(); }
private GraphArc addArc(GraphNode src, GraphNode dest) { DefaultGraphArc arc = (DefaultGraphArc) addArc(nextArcID(), src, dest, getRandomArcType()); // for this sample the arc types work backworks (is_a, etc) arc.setInverted(true); return arc; }
/** * Adds a GraphArc to the model if it doesn't already exist. * * @return The created or found GraphArc. */ protected GraphArc addArc(OWLEntity srcEntity, OWLEntity destEntity, String relType, Icon icon) { if (!relType.contains(restrictToArcType)) { return null; } boolean newNode = true; if (getNode(destEntity) != null) { newNode = false; } GraphNode srcNode = addNode(srcEntity); GraphNode destNode = addNode(destEntity); if (newNode) { destNode.setLocation(srcNode.getBounds().getX(), srcNode.getBounds().getY()); } String key = srcEntity.toString() + relType + destEntity.toString(); DefaultGraphArc arc = (DefaultGraphArc) addArc(key, srcNode, destNode, relType, icon); //arc.setType(relType); // for this sample the arc types work backworks (is_a, etc) arc.setInverted(true); return arc; }