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) { 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 (connectionFigure != null) { applyConnectionRouter(connectionFigure); } 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); }
protected void showHighlight() { // remove previous highlight removeHighlight(); // determine new highlight-values Color newForeground = GFColorConstants.HANDLE_BG; int newLineStyle = Graphics.LINE_DASH; if (getHost() != null && getHost().getModel() instanceof Connection) { Connection connection = (Connection) getHost().getModel(); IToolBehaviorProvider tbp = getConfigurationProvider().getDiagramTypeProvider().getCurrentToolBehaviorProvider(); ISelectionInfo selectionInfo = tbp.getSelectionInfoForConnection(connection); if (selectionInfo != null) { IColorConstant selectionColor = selectionInfo.getColor(); if (selectionColor != null) { newForeground = DataTypeTransformation.toSwtColor( getConfigurationProvider().getResourceRegistry(), selectionColor); } LineStyle selectionLineStyle = selectionInfo.getLineStyle(); if (selectionLineStyle != null) { newLineStyle = DataTypeTransformation.toDraw2dLineStyle(selectionLineStyle); } } } // store old highlight-values and set new highlight-values // important: get old colors via getLocalForeGround() to ignore parent Collection<Shape> connectionFigures = getConnectionFigures(); for (Shape connectionFigure : connectionFigures) { figureToColor.put(connectionFigure, connectionFigure.getLocalForegroundColor()); connectionFigure.setForegroundColor(newForeground); shapeToLineStyle.put(connectionFigure, connectionFigure.getLineStyle()); connectionFigure.setLineStyle(newLineStyle); if (connectionFigure instanceof GFPolylineConnection) { GFPolylineConnection polylineConnection = (GFPolylineConnection) connectionFigure; List<IFigure> allDecorations = polylineConnection.getAllDecorations(); for (IFigure decoration : allDecorations) { if (decoration != null) { figureToColor.put(decoration, decoration.getLocalForegroundColor()); decoration.setForegroundColor(newForeground); if (decoration instanceof Shape) { Shape decorationShape = (Shape) decoration; shapeToLineStyle.put(decorationShape, new Integer(decorationShape.getLineStyle())); decorationShape.setLineStyle(newLineStyle); } } } } } }