public GLink( GElement source, String sourceAnchorKey, GElement target, String targetAnchorKey, int shape, String pattern, double flateness) { this.source = source; this.target = target; this.sourceAnchorKey = sourceAnchorKey; this.targetAnchorKey = targetAnchorKey; this.shape = shape; this.pattern = pattern; initializeLink(flateness); if (source == target) link.setDirection(new Vector2D(0, 1)); else link.setDirection(source.getPosition().sub(target.getPosition())); setSourceTangentOffset(source.getDefaultAnchorOffset(sourceAnchorKey)); setTargetTangentOffset(target.getDefaultAnchorOffset(targetAnchorKey)); }
public void toggleShape() { switch (shape) { case SHAPE_ARC: shape = SHAPE_ELBOW; break; case SHAPE_ELBOW: shape = SHAPE_ARC; break; case SHAPE_BEZIER: // Cannot toggle a bezier link return; } double flateness = link.getFlateness(); Vector2D direction = link.getDirection(); link = createLinkInstance(); link.setFlateness(flateness); link.setDirection(direction); }
public void setMousePosition(Point mouse) { link.setDirection(Vector2D.vector(mouse).sub(target.getPosition())); link.setMousePosition(Vector2D.vector(mouse)); }