org.eclipse.draw2d.ChopboxAnchor Java Examples

The following examples show how to use org.eclipse.draw2d.ChopboxAnchor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicViewElementFactory.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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 );
        }
    }
}
 
Example #2
Source File: RoundDetailsPart.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 );
}
 
Example #4
Source File: ManualOverride.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: InputScaleDetails.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 );
}
 
Example #6
Source File: NodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #7
Source File: NodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #8
Source File: NodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #9
Source File: NodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #10
Source File: RemovedNodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #11
Source File: RemovedNodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #12
Source File: RemovedNodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #13
Source File: RemovedNodeElementEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(this.getFigure());
}
 
Example #14
Source File: DiagramWalkerEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #15
Source File: DiagramWalkerEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #16
Source File: DiagramWalkerEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #17
Source File: DiagramWalkerEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #18
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getTargetConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getTarget())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure targetFigure = ((AbstractModelEditPart) connectionEditPart.getTarget()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = targetFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, targetFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
Example #19
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getSourceConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getSource())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = sourceFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, sourceFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
Example #20
Source File: RemovedNodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(final Request arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #21
Source File: RemovedNodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #22
Source File: RemovedNodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(final Request arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #23
Source File: RemovedNodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart arg0) {
    return new ChopboxAnchor(getFigure());
}
 
Example #24
Source File: CFGNodeEditPart.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(getFigure());
}
 
Example #25
Source File: CFGNodeEditPart.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
	return new ChopboxAnchor(getFigure());
}
 
Example #26
Source File: CFGNodeEditPart.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(getFigure());
}
 
Example #27
Source File: CFGNodeEditPart.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) {
	return new ChopboxAnchor(getFigure());
}