use of org.eclipse.zest.core.widgets.internal.PolylineArcConnection in project archi by archimatetool.
the class GraphConnection method doCreateFigure.
private PolylineArcConnection doCreateFigure() {
PolylineArcConnection connectionFigure = cachedOrNewConnectionFigure();
ChopboxAnchor sourceAnchor = null;
ChopboxAnchor targetAnchor = null;
this.connectionLabel = new Label();
Locator labelLocator = null;
if (getSource() == getDestination()) {
// If this is a self loop, create a looped arc and put the locator
// at the top
// of the connection
sourceAnchor = new LoopAnchor(getSource().getNodeFigure());
targetAnchor = new LoopAnchor(getDestination().getNodeFigure());
labelLocator = new MidpointLocator(connectionFigure, 0) {
@Override
protected Point getReferencePoint() {
Point p = Point.SINGLETON;
p.x = getConnection().getPoints().getPoint(getIndex()).x;
p.y = (int) (getConnection().getPoints().getPoint(getIndex()).y - (curveDepth * 1.5));
getConnection().translateToAbsolute(p);
return p;
}
};
} else {
if (curveDepth != 0) {
connectionFigure.setDepth(this.curveDepth);
}
sourceAnchor = new RoundedChopboxAnchor(getSource().getNodeFigure(), 8);
targetAnchor = new RoundedChopboxAnchor(getDestination().getNodeFigure(), 8);
labelLocator = new MidpointLocator(connectionFigure, 0);
}
connectionFigure.setSourceAnchor(sourceAnchor);
connectionFigure.setTargetAnchor(targetAnchor);
connectionFigure.add(this.connectionLabel, labelLocator);
doUpdateFigure(connectionFigure);
return connectionFigure;
}
use of org.eclipse.zest.core.widgets.internal.PolylineArcConnection in project archi by archimatetool.
the class GraphConnection method doUpdateFigure.
private void doUpdateFigure(Connection connection) {
if (connection == null || this.isDisposed()) {
return;
}
Shape connectionShape = (Shape) connection;
connectionShape.setLineStyle(getLineStyle());
if (this.getText() != null || this.getImage() != null) {
// Label l = new Label(this.getText(), this.getImage());
if (this.getImage() != null) {
this.connectionLabel.setIcon(this.getImage());
}
if (this.getText() != null) {
this.connectionLabel.setText(this.getText());
}
this.connectionLabel.setFont(this.getFont());
}
if (highlighted) {
connectionShape.setForegroundColor(getHighlightColor());
connectionShape.setLineWidth(getLineWidth() * 2);
} else {
connectionShape.setForegroundColor(getLineColor());
connectionShape.setLineWidth(getLineWidth());
}
if (connection instanceof PolylineArcConnection) {
PolylineArcConnection arcConnection = (PolylineArcConnection) connection;
arcConnection.setDepth(curveDepth);
}
if ((connectionStyle & ZestStyles.CONNECTIONS_DIRECTED) > 0) {
PolygonDecoration decoration = new PolygonDecoration();
if (getLineWidth() < 3) {
decoration.setScale(9, 3);
} else {
double logLineWith = getLineWidth() / 2.0;
decoration.setScale(7 * logLineWith, 3 * logLineWith);
}
((PolylineConnection) connection).setTargetDecoration(decoration);
}
IFigure toolTip;
if (this.getTooltip() == null && getText() != null && getText().length() > 0 && hasCustomTooltip == false) {
toolTip = new Label();
((Label) toolTip).setText(getText());
} else {
toolTip = this.getTooltip();
}
connection.setToolTip(toolTip);
}
Aggregations