private void createRoundArrow ( final Figure figure ) { final PolylineConnection c = new PolylineConnection (); c.setSourceAnchor ( new ChopboxAnchor ( this.sourceRect ) ); c.setTargetAnchor ( new ChopboxAnchor ( this.targetRect ) ); final PolygonDecoration dec = new PolygonDecoration (); dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP ); c.setTargetDecoration ( dec ); final MidpointLocator typeLocator = new MidpointLocator ( c, 0 ); typeLocator.setRelativePosition ( PositionConstants.NORTH ); this.typeLabel = new Label ( "" ); //$NON-NLS-1$ c.add ( this.typeLabel, typeLocator ); figure.add ( c ); this.roundConnection = c; }
public void createConnections ( final Layer layer, final SymbolController controller, final EList<Connection> connections ) { if ( connections == null ) { return; } for ( final Connection connection : connections ) { final Controller start = AdapterHelper.adapt ( controller.getElement ( connection.getStart () ), Controller.class ); final Controller end = AdapterHelper.adapt ( controller.getElement ( connection.getEnd () ), Controller.class ); if ( start != null && end != null ) { final PolylineConnection c = new PolylineConnection (); c.setSourceAnchor ( new ChopboxAnchor ( start.getFigure () ) ); c.setTargetAnchor ( new ChopboxAnchor ( end.getFigure () ) ); c.setAntialias ( SWT.ON ); layer.add ( c ); } } }
private void refresh(RuntimeModel model, RuntimeModel.Event<?> event) { PandionJUI.executeUpdate(() -> { if(event.type == RuntimeModel.Event.Type.NEW_STACK) rebuildStack(model); else if(event.type == RuntimeModel.Event.Type.REMOVE_FRAME) { StackFrameModel f = (StackFrameModel) event.arg; stackFig.removeFrame(f); List<?> children = rootFig.getChildren(); for (IReferenceModel v : f.getReferenceVariables()) { PolylineConnection c = pointersMap.remove(v); if(c != null && children.contains(c)) rootFig.remove(c); } } else if(event.type == RuntimeModel.Event.Type.NEW_FRAME) { StackFrameModel frame = (StackFrameModel) event.arg; if(!frame.isInstance()) stackFig.addFrame(frame, this, objectContainer, false); } stackFig.getLayoutManager().layout(stackFig); updateLayout(); clearItem.setEnabled(model.isTerminated()); }); }
private void addPointerObserver(IReferenceModel ref, PolylineConnection pointer) { ref.registerDisplayObserver(new ModelObserver<IEntityModel>() { @Override public void update(IEntityModel arg) { IEntityModel target = ref.getModelTarget(); Point prevLoc = pointer.getTargetAnchor().getOwner().getBounds().getLocation(); PandionJFigure<?> targetFig = figProvider.getFigure(target); if(!containsChild(pane, targetFig)) { addEntityFigure(ref, targetFig, prevLoc); y += targetFig.getPreferredSize().height + Constants.OBJECT_PADDING; updateSize(); } pointer.setTargetAnchor(new ChopboxAnchor(targetFig)); setPointerDecoration(target, pointer); } }); }
private PolylineConnection makeConnection(IFigure contents, IFigure source, NodeFigure target, Color color) { PolylineConnection c = new PolylineConnection(); ConnectionAnchor targetAnchor = new ChopboxAnchor(target); c.setTargetAnchor(targetAnchor); c.setSourceAnchor(new ChopboxAnchor(source)); PolygonDecoration decoration = new PolygonDecoration(); decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP); c.setTargetDecoration(decoration); c.setForegroundColor(color); ConnectionMouseListener listener = new ConnectionMouseListener(c); c.addMouseMotionListener(listener); c.addMouseListener(listener); c.setCursor(Cursors.HAND); contents.add(c); connections.add(c); return c; }
/** * {@inheritDoc} */ // @Override // public void refreshVisuals() { // super.refreshVisuals(); // // } @Override protected void decorateRelation() { final ERDiagram diagram = getDiagram(); if (diagram != null) { final Relation relation = (Relation) getModel(); final PolylineConnection connection = (PolylineConnection) getConnectionFigure(); final String notation = diagram.getDiagramContents().getSettings().getNotation(); final Decoration decoration = DecorationFactory.getDecoration(notation, relation.getParentCardinality(), relation.getChildCardinality()); connection.setSourceDecoration(decoration.getSourceDecoration()); connection.setTargetDecoration(decoration.getTargetDecoration()); targetLabel.setText(Format.null2blank(decoration.getTargetLabel())); } }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractDiagramConnectionEditPart#setNameLabel(nexcore.tool.uml.model.umldiagram.Relation, * java.lang.String) */ @Override protected IFigure setNameLabel(Relation relation, String name) { PolylineConnection connection = (PolylineConnection) figure; if (nameLabel != null) { getFigure().remove(nameLabel); } nameLabel = new Label(name); MessageLabelLocator nameLabelLocator = new MessageLabelLocator(connection, LabelType.LABEL, true); figure.add(nameLabel, nameLabelLocator); return figure; }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractDiagramConnectionEditPart#createFigure() */ @Override protected IFigure createFigure() { PolylineConnection connection = new PolylineConnection() { @Override public void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.ON); super.paintFigure(graphics); } }; connection.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); PolygonDecoration polygonDecoreation = new PolygonDecoration(); polygonDecoreation.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); polygonDecoreation.setScale(10, 5); connection.setTargetDecoration(polygonDecoreation); connection.addRoutingListener(RoutingAnimator.getDefault()); connection.setConnectionRouter(new BendpointConnectionRouter()); return connection; }
@Override protected void refreshVisuals() { super.refreshVisuals(); final ERDiagram diagram = getDiagram(); if (diagram != null) { final Relationship relation = (Relationship) getModel(); final PolylineConnection connection = (PolylineConnection) getConnectionFigure(); final String notation = diagram.getDiagramContents().getSettings().getNotation(); final Decoration decoration = DecorationFactory.getDecoration(notation, relation.getParentCardinality(), relation.getChildCardinality()); connection.setSourceDecoration(decoration.getSourceDecoration()); connection.setTargetDecoration(decoration.getTargetDecoration()); targetLabel.setText(Format.null2blank(decoration.getTargetLabel())); } calculateAnchorLocation(); refreshBendpoints(); }
/** * This method creates and returns the figure for {@link Relation}s from type cyclic, total, acyclic, reflexive and * irreflexive, which differs from relationshipConstraint to relationshipConstraint only in the * text of the {@link Label}. A cyclic, total, acyclic, reflexive or irreflexive figure is dashed line with a * {@link Label}. * * @return conn org.eclipse.draw2d.PolylineConnection * */ private static Figure createRelationshipConstraintFigure(Relation relation, EditPart editpart) { ORMRelationshipConstraintEditPart editP = (ORMRelationshipConstraintEditPart) editpart; editP.getLabel().setText(relation.getName()); editP.setTextInitial(relation.getName()); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setConnectionRouter(new BendpointConnectionRouter()); // add label to the connection ConnectionLocator loc = new ConnectionLocator(conn, ConnectionLocator.MIDDLE); loc.setRelativePosition(PositionConstants.SOUTH); loc.setGap(5); // this is needed, because when the label would be just added the label text could be seen in // the rootModel if (editP.getRoot().getContents() instanceof ORMCompartmentEditPart) { conn.add(editP.getLabel(), loc); } return conn; }
/** * {@link Relation}s from type roleequivalence have as figure a dashed line with a white arrow * tips at both connection ends. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleEquivalenceFigure() { // create white arrow tip 1 PolygonDecoration poly1 = new PolygonDecoration(); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.white); poly1.setScale(5, 5); // create white arrow tip 2 PolygonDecoration poly2 = new PolygonDecoration(); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.white); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); // add white arrow tip 1 conn.setTargetDecoration(poly1); // add white arrow tip 2 conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * {@link Relations}s from type roleimplication and relationshipimplication have as figure a * dashed line with a white arrow tip at target end of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleRelationshipImplicationFigure() { // create white arrow tip PolygonDecoration poly = new PolygonDecoration(); poly.setAntialias(SWT.ON); poly.setBackgroundColor(ColorConstants.white); poly.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * * {@link Relations}s from type roleprohibition and relationshipexclusion have as figure a * dashed line with a white arrow tip at target end of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection * */ private static Figure createRoleRelationshipExclusionFigure() { // create white arrow tip PolylineDecoration poly1 = new PolylineDecoration(); poly1.setTemplate(INVERTED_TRIANGLE_TIP); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.black); poly1.setScale(5, 5); PolylineDecoration poly2 = new PolylineDecoration(); poly2.setTemplate(INVERTED_TRIANGLE_TIP); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.black); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly1); conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * {@link Relation}s from type roleprohibition have as figure a dased line with two inverted and * open arrow tips at both ends of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleProhibitonFigure() { PolylineDecoration poly1 = new PolylineDecoration(); poly1.setTemplate(INVERTED_TRIANGLE_TIP); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.black); poly1.setScale(5, 5); PolylineDecoration poly2 = new PolylineDecoration(); poly2.setTemplate(INVERTED_TRIANGLE_TIP); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.black); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly1); conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
public void setSelected(int value) { super.setSelected(value); if (value != EditPart.SELECTED_NONE) { ((PolylineConnection) getFigure()).setLineWidth(2); FunctionColumnModelEditPart source=(FunctionColumnModelEditPart) this.getSource(); source.getFigure().setBackgroundColor(ColorConstants.titleGradient); FunctionColumnModelEditPart target=(FunctionColumnModelEditPart) this.getTarget(); target.getFigure().setBackgroundColor(ColorConstants.titleGradient); } else { ((PolylineConnection) getFigure()).setLineWidth(1); source=(FunctionColumnModelEditPart) this.getSource(); target=(FunctionColumnModelEditPart) this.getTarget(); if(source!=null&&target!=null) { target.getFigure().setBackgroundColor(ColorConstants.white); source.getFigure().setBackgroundColor(ColorConstants.white); } } }
@Override protected IFigure createFigure() { Link link = (Link) getModel(); link.editPart = this; SankeyDiagram editor = ((ProductSystemNode) link.sourceNode.parent).editor; PolylineConnection conn = new LinkFigure(link.getWidth(), editor); if (editor.isRouted()) { conn.setConnectionRouter(ROUTER); } else { conn.setConnectionRouter(ConnectionRouter.NULL); } link.figure = conn; conn.setTolerance(0); conn.setForegroundColor(link.getColor()); return conn; }
private void createConnection ( final Figure connLayer, final Label label, final Figure figure ) { final Connection c = new PolylineConnection (); c.setSourceAnchor ( new ChopboxAnchor ( label ) ); c.setTargetAnchor ( new ChopboxAnchor ( figure ) ); c.setConnectionRouter ( new BendpointConnectionRouter () ); connLayer.add ( c ); }
private PolylineConnection createConnection ( final IFigure source, final IFigure target ) { final PolylineConnection c = new PolylineConnection (); final ChopboxAnchor sourceAnchor = new ChopboxAnchor ( source ); final ChopboxAnchor targetAnchor = new ChopboxAnchor ( target ); c.setSourceAnchor ( sourceAnchor ); c.setTargetAnchor ( targetAnchor ); return c; }
/** * Set graphics attribute according to the connection state * * @param connection * the connection to change * @param state * the state */ protected void setConnectionState ( final PolylineConnection connection, final boolean state ) { final PolygonDecoration dec = new PolygonDecoration (); dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP ); connection.setLineStyle ( state ? Graphics.LINE_SOLID : Graphics.LINE_DOT ); connection.setLineWidth ( state ? 2 : 1 ); connection.setTargetDecoration ( state ? dec : null ); }
private void connect ( final IFigure figure, final IFigure source, final IFigure target ) { final PolylineConnection c = new PolylineConnection (); c.setSourceAnchor ( new ChopboxAnchor ( source ) ); c.setTargetAnchor ( new ChopboxAnchor ( target ) ); final PolygonDecoration dec = new PolygonDecoration (); dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP ); dec.setBackgroundColor ( ColorConstants.black ); c.setTargetDecoration ( dec ); figure.add ( c ); }
@Override protected IFigure createFigure() { final PolylineConnection res = (PolylineConnection)super.createFigure(); res.setLineWidth(1); // PolygonDecoration decoration = new PolygonDecoration(); // decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP); // res.setTargetDecoration(decoration); res.setLineStyle(SWT.LINE_SOLID); res.setBackgroundColor(ColorConstants.listForeground); return res; }
@Override protected IFigure createFigure() { PolylineConnection connection = (PolylineConnection) super .createFigure(); connection.addRoutingListener(RoutingAnimator.getDefault()); connection.setTargetDecoration(new PolygonDecoration()); connection.setLineStyle(getCastedModel().getLineStyle()); return connection; }
@Override protected void refreshVisuals() { TransitionLabel transitionLabel = (TransitionLabel)getModel(); Label figure = (Label) getFigure(); figure.setText(transitionLabel.getText()); Point offset=transitionLabel.getOffset(); AbstractConnectionEditPart parent = (AbstractConnectionEditPart) getParent(); PolylineConnection connection = (PolylineConnection) parent.getFigure(); if(offset==null){ offset=this.calculateInitialOffset(connection); transitionLabel.setOffset(offset); } TransitionLabelLocator constraint = new TransitionLabelLocator(transitionLabel.getText(),offset,connection); parent.setLayoutConstraint(this, getFigure(), constraint); }
private Point calculateInitialOffset(PolylineConnection polyline) { Point result = new Point(5, -10); Point start = polyline.getStart(); Point end = polyline.getEnd(); Point mid = start.getNegated().getTranslated(end).getScaled(0.5); if (mid.x < -10) { result.y = 10; } return result; }
@Override protected IFigure createFigure() { final PolylineConnection connection = new PolylineConnection(); connection.setConnectionRouter(new BendpointConnectionRouter()); PolygonDecoration decoration = new PolygonDecoration(); decoration.setTemplate(new PointList(new int[]{0, 0, -2, 2, -2, 0, -2, -2, 0, 0})); RGB rgb=Activator.getPreference().getTransitionColor(); decoration.setBackgroundColor(new Color(null,rgb)); connection.setTargetDecoration(decoration); connection.setAntialias(SWT.ON); connection.setForegroundColor(new Color(null,rgb)); return connection; }
private void clear() { for(PolylineConnection p : pointersMap.values()) rootFig.remove(p); pointersMap.clear(); pointersMapOwners.clear(); stackFig.removeAll(); objectContainer.removeAll(); }
private void addPointer(IReferenceModel ref, PolylineConnection pointer, Object owner) { assert pointer != null; rootFig.add(pointer); pointersMap.put(ref, pointer); pointersMapOwners.put(owner, pointer); // pointer.setToolTip(new Label(ref.toString())); }
static void addPointerObserver(IReferenceModel ref, PolylineConnection pointer, ObjectContainer container) { ref.registerDisplayObserver(new ModelObserver<IEntityModel>() { @Override public void update(IEntityModel arg) { IEntityModel target = ref.getModelTarget(); pointer.setVisible(!target.isNull()); if(!target.isNull()) { PandionJFigure<?> targetFig = container.addObject(target, ref.getIndex()); pointer.setTargetAnchor(targetFig.getIncommingAnchor()); Utils.addArrowDecoration(pointer); } } }); }
static void addArrowDecoration(PolylineConnection pointer) { PolylineDecoration decoration = new PolylineDecoration(); PointList points = new PointList(); points.addPoint(-1, -1); points.addPoint(0, 0); points.addPoint(-1, 1); decoration.setTemplate(points); decoration.setScale(PandionJConstants.ARROW_EDGE, PandionJConstants.ARROW_EDGE); decoration.setLineWidth(PandionJConstants.ARROW_LINE_WIDTH); decoration.setOpaque(true); pointer.setTargetDecoration(decoration); }
private void addPointer(PandionJFigure<?> figure, IReferenceModel ref, IEntityModel target, PandionJFigure<?> targetFig) { PolylineConnection pointer = new PolylineConnection(); pointer.setSourceAnchor(new ChopboxAnchor(figure)); pointer.setTargetAnchor(new PositionAnchor(targetFig, PositionAnchor.Position.LEFT)); setPointerDecoration(target, pointer); addPointerObserver(ref, pointer); pane.add(pointer); }
private void addPointer2D(ArrayReferenceFigure figure, IReferenceModel ref, int index, IEntityModel target, PandionJFigure<?> targetFig) { PolylineConnection pointer = new PolylineConnection(); pointer.setSourceAnchor(figure.getAnchor(index)); pointer.setTargetAnchor(new PositionAnchor(targetFig, PositionAnchor.Position.LEFT)); setPointerDecoration(target, pointer); addPointerObserver(ref, pointer); pane.add(pointer); }
private void addArrowDecoration(PolylineConnection pointer) { PolylineDecoration decoration = new PolylineDecoration(); PointList points = new PointList(); points.addPoint(-1, -1); points.addPoint(0, 0); points.addPoint(-1, 1); decoration.setTemplate(points); decoration.setScale(Constants.ARROW_EDGE, Constants.ARROW_EDGE); decoration.setLineWidth(Constants.ARROW_LINE_WIDTH); decoration.setOpaque(true); pointer.setTargetDecoration(decoration); }
private void addNullDecoration(PolylineConnection pointer) { PolygonDecoration decoration = new PolygonDecoration(); PointList points = new PointList(); points.addPoint(0,-1); // 1 points.addPoint(0, 1); // -1 decoration.setTemplate(points); decoration.setScale(Constants.ARROW_EDGE, Constants.ARROW_EDGE); decoration.setLineWidth(Constants.ARROW_LINE_WIDTH); decoration.setOpaque(true); pointer.setTargetDecoration(decoration); }
public void setConnectionVisibility() { Iterator iter = connections.iterator(); while (iter.hasNext()) { PolylineConnection con = (PolylineConnection)iter.next(); boolean show = false; if (!store.getBoolean(RevisionGraphEditor.FILTER_CONNECTIONS)) show = true; else { IFigure source =con.getSourceAnchor().getOwner(); IFigure target = con.getTargetAnchor().getOwner(); if (source instanceof NodeFigure && ((NodeFigure)source).isSelected()) show = true; else if (target instanceof NodeFigure && ((NodeFigure)target).isSelected()) show = true; } con.setVisible(show); } }
/** * {@inheritDoc} */ // @Override // public void refreshVisuals() { // super.refreshVisuals(); // // } @Override protected void decorateRelation() { ERDiagram diagram = this.getDiagram(); if (diagram != null) { Relation relation = (Relation) this.getModel(); PolylineConnection connection = (PolylineConnection) this .getConnectionFigure(); String notation = diagram.getDiagramContents().getSettings() .getNotation(); Decoration decoration = DecorationFactory.getDecoration(notation, relation.getParentCardinality(), relation.getChildCardinality()); connection.setSourceDecoration(decoration.getSourceDecoration()); connection.setTargetDecoration(decoration.getTargetDecoration()); this.targetLabel.setText(Format.null2blank(decoration.getTargetLabel())); } }
/** * ConnectionLabelLocator * @param connection * @param type * @param isEnd */ public ConnectionLabelLocator(PolylineConnection connection, LabelType type, boolean isEnd) { super(connection, isEnd); this.connection = connection; this.type = type; }
/** * * @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure() */ @Override protected IFigure createFigure() { PolylineConnection connection = new PolylineConnection(); connection.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); PolygonDecoration polygonDecoreation = new PolygonDecoration(); polygonDecoreation.setScale(10, 5); connection.setTargetDecoration(polygonDecoreation); return connection; }
/** * setNameLabel * * @param relation * @param name * void */ protected IFigure setNameLabel(Relation relation, String name) { PolylineConnection connection = (PolylineConnection) figure; if (nameLabel != null) { getFigure().remove(nameLabel); } nameLabel = new Label(name); ConnectionLabelLocator nameLabelLocator = new ConnectionLabelLocator(connection, LabelType.LABEL, true); figure.add(nameLabel, nameLabelLocator); return figure; }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractDiagramConnectionEditPart#createFigure() */ @Override protected IFigure createFigure() { PolylineConnection connection = new PolylineConnection() { @Override public void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.ON); super.paintFigure(graphics); } }; connection.setLineStyle(SWTGraphics.LINE_DASH); connection.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); return connection; }
/** * MessageLabelLocator * @param connection * @param type * @param isEnd */ public MessageLabelLocator(PolylineConnection connection, LabelType type, boolean isEnd) { super(connection, isEnd); this.connection = connection; this.type = type; }