/** * Move the source graph into the destination graph using a specified offset. * * @param destGraph the destination graph. * @param sourceGraph the source graph. * @param offsetx x coordinate offset. * @param offsety y coordinate offset. */ private void moveGraph( final FGraph destGraph, final FGraph sourceGraph, final double offsetx, final double offsety) { KVector graphOffset = new KVector(offsetx, offsety); graphOffset.sub(sourceGraph.getProperty(Properties.BB_UPLEFT)); for (FNode node : sourceGraph.getNodes()) { node.getPosition().add(graphOffset); destGraph.getNodes().add(node); } for (FEdge edge : sourceGraph.getEdges()) { for (FBendpoint bendpoint : edge.getBendpoints()) { bendpoint.getPosition().add(graphOffset); } destGraph.getEdges().add(edge); } for (FLabel label : sourceGraph.getLabels()) { label.getPosition().add(graphOffset); destGraph.getLabels().add(label); } }
/** * Places the given end label below the edge. * * @param node source node of the edge the label belongs to. * @param label the label to place. * @param port the end port of the edge the label is nearest to. * @param labelSpacing space between objects and labels. */ private void placeEndLabelUpwards( final LNode node, final LLabel label, final LPort port, final double labelSpacing) { // Remember some stuff KVector labelPosition = label.getPosition(); KVector absolutePortPosition = KVector.sum(port.getPosition(), port.getNode().getPosition()); KVector absolutePortAnchor = port.getAbsoluteAnchor(); LMargin portMargin = port.getMargin(); // Actually calculate the coordinates switch (port.getSide()) { case WEST: labelPosition.x = Math.min(absolutePortPosition.x, absolutePortAnchor.x) - portMargin.left - label.getSize().x - labelSpacing; labelPosition.y = port.getAbsoluteAnchor().y - label.getSize().y - labelSpacing; break; case EAST: labelPosition.x = Math.max(absolutePortPosition.x + port.getSize().x, absolutePortAnchor.x) + portMargin.right + labelSpacing; labelPosition.y = port.getAbsoluteAnchor().y - label.getSize().y - labelSpacing; break; case NORTH: labelPosition.x = port.getAbsoluteAnchor().x + labelSpacing; labelPosition.y = Math.min(absolutePortPosition.y, absolutePortAnchor.y) - portMargin.top - label.getSize().y - labelSpacing; break; case SOUTH: labelPosition.x = port.getAbsoluteAnchor().x + labelSpacing; labelPosition.y = Math.max(absolutePortPosition.y + port.getSize().y, absolutePortAnchor.y) + portMargin.bottom + labelSpacing; break; } }