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 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; }
/** * getCenterPoint * * @param nodeLabel * @return Point */ private Point getCenterPoint(LabelNode nodeLabel) { AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getOwner(); AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource(); AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget(); RectangleFigure sourceFigure = new RectangleFigure(); sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight()); sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY())); RectangleFigure targetFigure = new RectangleFigure(); targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight()); targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY())); ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure); ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure); Point source = new Point(sourceAnchor.getReferencePoint().x, sourceAnchor.getReferencePoint().y); Point target = new Point(targetAnchor.getReferencePoint().x, targetAnchor.getReferencePoint().y); Point centerPoint = new Point((source.x + target.x) / 2, (source.y + target.y) / 2); return centerPoint; }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart) */ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { if (connection instanceof AttachementEditPart) { return new ChopboxAnchor(getFigure()); } if (connection.getTarget() != null && connection.getSource() != null) { LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel()); LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel()); if (sourceNode.equals(targetNode)) { Point point = new Point(sourceNode.getX() + sourceNode.getWidth() / 2, ((AbstractView) connection.getModel()).getY()); connection.getFigure().translateToAbsolute(point); return new XYAnchor(point); } else { return new MessageOutgoingConnectionAnchor(getFigure(), connection); } } else { return new MessageOutgoingConnectionAnchor(getFigure(), connection); } }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart) */ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { if (connection instanceof AttachementEditPart) { return new ChopboxAnchor(getFigure()); } if (connection.getTarget() != null && connection.getSource() != null) { LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel()); LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel()); if (sourceNode.equals(targetNode)) { Point point = new Point(targetNode.getX() + targetNode.getWidth() / 2, ((AbstractView) connection.getModel()).getY() + 10); connection.getFigure().translateToAbsolute(point); return new XYAnchor(point); } else { return new MessageIncommingConnectionAnchor(getFigure(), connection); } } else { return new MessageIncommingConnectionAnchor(getFigure(), connection); } }
@Override public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) { // source for a found message if (connection instanceof InitiatorMessageEditPart) { return new ChopboxAnchor(getFigure()) { @Override public Point getLocation(final Point reference) { final Rectangle bounds = Rectangle.SINGLETON; bounds.setBounds(getBox()); getOwner().translateToAbsolute(bounds); final Point result = bounds.getTopLeft(); result.y = reference.y; return result; } }; } throw new IllegalArgumentException("Unsupported connection: " + connection); }
@Override public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) { // target for a lost message if (connection instanceof TerminatorMessageEditPart) { return new ChopboxAnchor(getFigure()) { @Override public Point getLocation(final Point reference) { final Rectangle bounds = Rectangle.SINGLETON; bounds.setBounds(getBox()); getOwner().translateToAbsolute(bounds); final Point result = bounds.getBottomLeft(); // bounds.getTopRight(); result.y = reference.y; return result; } }; } throw new IllegalArgumentException("Unsupported connection: " + connection); }
public RemoteLinkage(IFigure ownerFigure, FrameElement ownerElement, GraphicalWidget<?> labelFigure) { super(); ownerFig = ownerFigure; owner = ownerElement; remoteLabelFig = labelFigure; setSourceAnchor(new EllipseAnchor(ownerFig)); setTargetAnchor(new ChopboxAnchor(remoteLabelFig)); setLineWidth(3); setLineStyle(SWT.LINE_DOT); setCursor(WindowUtil.getCursor(WindowUtil.RESIZE_ALL_CURSOR)); }
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; }
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 public ConnectionAnchor getTargetConnectionAnchor(Request request) { if (request instanceof CreateConnectionRequest) { CreateConnectionRequest crequest = (CreateConnectionRequest) request; Table table = (Table) crequest.getSourceEditPart().getModel(); Column c = table.getFirstPkColumn(); if (c == null) { MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "提示", "此表没有主键,请先设置主键!"); crequest.setStartCommand(null); } } return new ChopboxAnchor(getFigure()); }
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); }
/** * getCenterPoint * * @param nodeLabel * @return Point */ private Point getCenterPoint(LabelNode nodeLabel) { AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getParent(); AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource(); AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget(); RectangleFigure sourceFigure = new RectangleFigure(); if (sourceNode != null) { sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight()); sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY())); } RectangleFigure targetFigure = new RectangleFigure(); if (targetNode != null) { targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight()); targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY())); } ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure); ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure); Point source = new Point(sourceAnchor.getReferencePoint().x, sourceAnchor.getReferencePoint().y); Point target = new Point(targetAnchor.getReferencePoint().x, targetAnchor.getReferencePoint().y); Point centerPoint = new Point((source.x + target.x) / 2, (source.y + target.y) / 2); return centerPoint; }
/** * getTargetPoint * * @param nodeLabel * @return Point */ private Point getTargetPoint(LabelNode nodeLabel) { AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getParent(); AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource(); AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget(); RectangleFigure sourceFigure = new RectangleFigure(); sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight()); sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY())); RectangleFigure targetFigure = new RectangleFigure(); targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight()); targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY())); ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure); ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure); Point sourceAnchorLocation = new Point(); Point targetAnchorLocation = new Point(); sourceAnchorLocation = sourceAnchor.getLocation(targetAnchor.getReferencePoint()); targetAnchorLocation = targetAnchor.getLocation(sourceAnchor.getReferencePoint()); // sourceAnchorLocation = sourceAnchor.getReferencePoint(); // targetAnchorLocation = targetAnchor.getReferencePoint(); Point source = new Point(sourceAnchorLocation.x, sourceAnchorLocation.y); Point target = new Point(targetAnchorLocation.x, targetAnchorLocation.y); if (nodeLabel.getType().equals(LabelType.SOURCE_ROLE) || nodeLabel.getType().equals(LabelType.SOURCE_MULTIPLEX)) { return source; } else if (nodeLabel.getType().equals(LabelType.TARGET_ROLE) || nodeLabel.getType().equals(LabelType.TARGET_MULTIPLEX)) { return target; } else { return new Point((source.x + target.x) / 2, (source.y + target.y) / 2); } }
@Override protected IFigure createFigure() { IFigure fig = new PinFigure(); fig.setOpaque(false); setupFigure(fig); m_anchor = new ChopboxAnchor(fig); return fig; }
@Override protected IFigure createFigure() { ANode model = getModel(); IFigure rect = FigureFactory.createFigure(model); setupFigure(rect); m_anchor = new ChopboxAnchor(rect); return rect; }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { if (connection.getModel() instanceof TemporalBoundLink) { return new ChopboxAnchor(getFigure()); } return null; }
/** * Returns the <code>ConnectionAnchor</code> for the <i>source</i> end of * the connection. If the source is an instance of {@link NodeEditPart}, * that interface will be used to determine the proper ConnectionAnchor. If * the source is not an instance of <code>NodeEditPart</code>, this method * should be overridden to return the correct ConnectionAnchor. Failure to * do this will cause a default anchor to be used so that the connection * figure will be made visible to the developer. * * @return ConnectionAnchor for the source end of the Connection */ protected ConnectionAnchor getSourceConnectionAnchor() { if (getSource() != null) { if (getSource() instanceof NodeEditPart) { NodeEditPart editPart = (NodeEditPart) getSource(); return editPart.getSourceConnectionAnchor(this); } IFigure f = ((GraphicalEditPart) getSource()).getFigure(); return new ChopboxAnchor(f); } return DEFAULT_SOURCE_ANCHOR; }
/** * Returns the <code>ConnectionAnchor</code> for the <i>target</i> end of * the connection. If the target is an instance of {@link NodeEditPart}, * that interface will be used to determine the proper ConnectionAnchor. If * the target is not an instance of <code>NodeEditPart</code>, this method * should be overridden to return the correct ConnectionAnchor. Failure to * do this will cause a default anchor to be used so that the connection * figure will be made visible to the developer. * * @return ConnectionAnchor for the target end of the Connection */ protected ConnectionAnchor getTargetConnectionAnchor() { if (getTarget() != null) { if (getTarget() instanceof NodeEditPart) { NodeEditPart editPart = (NodeEditPart) getTarget(); return editPart.getTargetConnectionAnchor(this); } IFigure f = ((GraphicalEditPart) getTarget()).getFigure(); return new ChopboxAnchor(f); } return DEFAULT_TARGET_ANCHOR; }
private PolylineConnection generateConnection(Figure source, Figure target) { PolylineConnection newconnection = new PolylineConnection(); newconnection.setSourceAnchor(new ChopboxAnchor(source)); newconnection.setTargetAnchor(new ChopboxAnchor(target)); return newconnection; }
/** * Apply a rotation to the edges PointList and set the rotated point list as the mainFigure's PointList. * * Rotation takes into consideration the fact that the center moves when the number of branches changes. */ public void rotate(double angle) { if (this.angle != angle) { this.angle = angle; // build the transformation Transform t = new Transform(); t.setRotation(angle); // build the new point list PointList newEdges = new PointList(); // this is the center of the figure in the edges pointlist. Point center = new Point(DEFAULT_WIDTH / 2, DEFAULT_HEIGHT * branchCount / 2); // this is the center of the figure in the rotated, real size, point list. Point centerScaledRotated = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2); // rotate edges points around center to generate newEdges for (int i = 0; i < edges.size(); i++) { Point newPoint = t.getTransformed(new Point(edges.getPoint(i).x - center.x, edges.getPoint(i).y - center.y)); newEdges.addPoint(newPoint); } // move them to the center of the rotated figure newEdges.translate(centerScaledRotated.x, centerScaledRotated.y); mainFigure.setPoints(newEdges); // inform the edit part that we've rotated via anchor listeners. ((ChopboxAnchor) outgoingAnchor).ancestorMoved(this); } }
@Override public ConnectionAnchor getSourceConnectionAnchor( ConnectionEditPart connection) { return new ChopboxAnchor(this.getFigure()); }
@Override public ConnectionAnchor getTargetConnectionAnchor( ConnectionEditPart connection) { return new ChopboxAnchor(this.getFigure()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(Request request) { return new ChopboxAnchor(this.getFigure()); }
@Override public ConnectionAnchor getTargetConnectionAnchor(Request request) { return new ChopboxAnchor(this.getFigure()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { return new ChopboxAnchor(getFigure()); }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { return new ChopboxAnchor(getFigure()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(Request request) { return new ChopboxAnchor(getFigure()); }
private static void createDiagram(IFigure root) { // Array com iteradores MockArray array = new MockArray("Integer", 1,2,3,4,5); // MockVariable var = new MockVariable("int[]", "v", null, array); MockReference ref = new MockReference("int[]", "v", array, false); MockValue i1 = new MockValue("int", "i1", null, 0, false); MockArrayIndex ii1 = new MockArrayIndex(i1, ref, Direction.NONE); MockValue i2 = new MockValue("int", "i2", null, 1, false); MockArrayIndex ii2 = new MockArrayIndex(i2, ref, Direction.FORWARD); MockValue i3 = new MockValue("int", "i3", null, 5, false); MockArrayIndex ii3 = new MockArrayIndex(i3, ref, Direction.FORWARD, new MyBound(-1, BoundType.OPEN, "-1")); // array.addIndexVariable(ii1); // array.addIndexVariable(ii2); // array.addIndexVariable(ii3); List<IArrayIndexModel> vars = new ArrayList<>(); vars.add(ii1); vars.add(ii2); ArrayReferenceFigure fig = new ArrayReferenceFigure(array); fig.setLocation(new Point(100, 100)); root.add(fig); // IllustrationBorder b = new IllustrationBorder(vars, fig); // MarginBorder b = new MarginBorder(15); // fig.setBorder(b); // Array com lenght maior que o tamanho maximo da figura MockArray array2 = new MockArray("int", 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25); ArrayPrimitiveFigure fig2 = new ArrayPrimitiveFigure(array2); fig2.setLocation(new Point(250, 300)); root.add(fig2); // Array vazia MockArray array3 = new MockArray("int"); ArrayPrimitiveFigure fig3 = new ArrayPrimitiveFigure(array3); fig3.setLocation(new Point(400, 200)); root.add(fig3); Connection c = new PolylineConnection(); ChopboxAnchor a = new ChopboxAnchor(fig); ChopboxAnchor b = new ChopboxAnchor(fig2); c.setSourceAnchor(a); c.setTargetAnchor(b); root.add(c); Button but = new Button("test"); but.setLocation(new Point(5, 5)); but.setSize(but.getPreferredSize()); but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { i1.set(ii1.getCurrentIndex()+1); try { if(ii3.getBound().getValue() != ii3.getCurrentIndex()) { i3.set(ii3.getCurrentIndex() - 1); } array.set(ii3.getCurrentIndex(), 9); } catch(IndexOutOfBoundsException e) { e.printStackTrace(); } fig.repaint(); } }); root.add(but); }
public ConnectionAnchor getIncommingAnchor() { // TODO fig.getInsets() return new ChopboxAnchor(fig); }
public ConnectionAnchor getIncommingAnchor() { return new ChopboxAnchor(this); }
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) { return new ChopboxAnchor(getFigure()); }
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) { return new ChopboxAnchor(getFigure()); }
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) { return new ChopboxAnchor(getFigure()); }
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) { return new ChopboxAnchor(getFigure()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart arg0) { return new ChopboxAnchor(getFigure()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(final Request arg0) { return new ChopboxAnchor(getFigure()); }