Search in sources :

Example 1 with PolylineDecoration

use of org.eclipse.draw2d.PolylineDecoration in project archi by archimatetool.

the class AssociationConnectionFigure method createFigureTargetDecoration.

/**
 * @return Decoration to use on Target Node
 */
public static RotatableDecoration createFigureTargetDecoration() {
    PolylineDecoration dec = new PolylineDecoration();
    dec.setTemplate(POINTS);
    dec.setScale(9, 4);
    return dec;
}
Also used : PolylineDecoration(org.eclipse.draw2d.PolylineDecoration)

Example 2 with PolylineDecoration

use of org.eclipse.draw2d.PolylineDecoration in project archi by archimatetool.

the class LineConnectionFigure method createArrowheadLine.

protected PolylineDecoration createArrowheadLine() {
    PolylineDecoration poly = new PolylineDecoration();
    poly.setScale(8, 5);
    return poly;
}
Also used : PolylineDecoration(org.eclipse.draw2d.PolylineDecoration)

Example 3 with PolylineDecoration

use of org.eclipse.draw2d.PolylineDecoration in project whole by wholeplatform.

the class DecoratedConnectionPartFactory method createDecoration.

public RotatableDecoration createDecoration(final int type) {
    switch(type) {
        case ARROW:
            return new PolylineDecoration();
        case FILLED_ARROW:
            return new PolygonDecoration();
        case RHOMB:
            PolygonDecoration p = new PolygonDecoration();
            p.setTemplate(ArrowFactory.RHOMB_TIP);
            p.setFill(false);
            return p;
        case FILLED_RHOMB:
            p = new PolygonDecoration();
            p.setTemplate(ArrowFactory.RHOMB_TIP);
            p.setFill(true);
            return p;
        default:
            return null;
    }
}
Also used : PolygonDecoration(org.eclipse.draw2d.PolygonDecoration) PolylineDecoration(org.eclipse.draw2d.PolylineDecoration)

Example 4 with PolylineDecoration

use of org.eclipse.draw2d.PolylineDecoration in project netxms by netxms.

the class MapLabelProvider method selfStyleConnection.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.gef4.zest.core.viewers.ISelfStyleProvider#selfStyleConnection(java
	 * .lang.Object, org.eclipse.gef4.zest.core.widgets.GraphConnection)
	 */
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
    connection.setVisible(connectionsVisible);
    NetworkMapLink link = (NetworkMapLink) connection.getData();
    if (link.getType() == NetworkMapLink.VPN) {
        connection.setLineStyle(Graphics.LINE_DOT);
    }
    if (link.hasConnectorName1() && connectionLabelsVisible) {
        ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), false);
        sourceEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName1());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, sourceEndpointLocator);
    }
    if (link.hasConnectorName2() && connectionLabelsVisible) {
        ConnectionEndpointLocator targetEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), true);
        targetEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName2());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, targetEndpointLocator);
    }
    if (showLinkDirection)
        ((PolylineConnection) connection.getConnectionFigure()).setSourceDecoration(new PolylineDecoration());
    IFigure owner = ((PolylineConnection) connection.getConnectionFigure()).getTargetAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setTargetAnchor(new MultiConnectionAnchor(owner, link));
    owner = ((PolylineConnection) connection.getConnectionFigure()).getSourceAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setSourceAnchor(new MultiConnectionAnchor(owner, link));
    boolean hasDciData = link.hasDciData();
    boolean hasName = link.hasName();
    if (link.getStatusObject() != null && link.getStatusObject().size() != 0) {
        ObjectStatus status = ObjectStatus.UNKNOWN;
        for (Long id : link.getStatusObject()) {
            AbstractObject object = session.findObjectById(id);
            if (object != null) {
                ObjectStatus s = object.getStatus();
                if ((s.compareTo(ObjectStatus.UNKNOWN) < 0) && ((status.compareTo(s) < 0) || (status == ObjectStatus.UNKNOWN))) {
                    status = s;
                    if (status == ObjectStatus.CRITICAL)
                        break;
                }
            }
        }
        connection.setLineColor(StatusDisplayInfo.getStatusColor(status));
    } else if (link.getColor() >= 0) {
        connection.setLineColor(colors.create(ColorConverter.rgbFromInt(link.getColor())));
    } else if (link.getType() == NetworkMapLink.AGENT_TUNEL) {
        connection.setLineColor(COLOR_AGENT_TUNNEL);
    } else if (link.getType() == NetworkMapLink.AGENT_PROXY) {
        connection.setLineColor(COLOR_AGENT_PROXY);
    } else if (link.getType() == NetworkMapLink.ICMP_PROXY) {
        connection.setLineColor(COLOR_ICMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SNMP_PROXY) {
        connection.setLineColor(COLOR_SNMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SSH_PROXY) {
        connection.setLineColor(COLOR_SSH_PROXY);
    } else if (link.getType() == NetworkMapLink.ZONE_PROXY) {
        connection.setLineColor(COLOR_ZONE_PROXY);
    } else if (defaultLinkColor != null) {
        connection.setLineColor(defaultLinkColor);
    }
    if ((hasName || hasDciData) && connectionLabelsVisible) {
        MultiLabelConnectionLocator nameLocator = new MultiLabelConnectionLocator(connection.getConnectionFigure(), link);
        // $NON-NLS-1$
        String labelString = "";
        if (hasName)
            labelString += link.getName();
        if (hasName && hasDciData)
            // $NON-NLS-1$
            labelString += "\n";
        if (hasDciData) {
            labelString += dciValueProvider.getDciDataAsString(link);
        }
        final Label label;
        if (link.getType() == NetworkMapLink.AGENT_TUNEL || link.getType() == NetworkMapLink.AGENT_PROXY || link.getType() == NetworkMapLink.ICMP_PROXY || link.getType() == NetworkMapLink.SNMP_PROXY || link.getType() == NetworkMapLink.SSH_PROXY || link.getType() == NetworkMapLink.ZONE_PROXY)
            label = new ConnectorLabel(labelString, connection.getLineColor());
        else
            label = new ConnectorLabel(labelString);
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, nameLocator);
    }
    switch(link.getRouting()) {
        case NetworkMapLink.ROUTING_DIRECT:
            connection.setRouter(ConnectionRouter.NULL);
            break;
        case NetworkMapLink.ROUTING_MANHATTAN:
            connection.setRouter(manhattanRouter);
            break;
        case NetworkMapLink.ROUTING_BENDPOINTS:
            connection.setRouter(bendpointRouter);
            // $NON-NLS-1$
            connection.setData("ROUTER", bendpointRouter);
            Object bp = getConnectionPoints(link);
            bendpointRouter.setConstraint(connection.getConnectionFigure(), bp);
            connection.getConnectionFigure().setRoutingConstraint(bp);
            break;
        default:
            connection.setRouter(null);
            break;
    }
    connection.setLineWidth(2);
}
Also used : Label(org.eclipse.draw2d.Label) PolylineDecoration(org.eclipse.draw2d.PolylineDecoration) PolylineConnection(org.eclipse.draw2d.PolylineConnection) ObjectStatus(org.netxms.client.constants.ObjectStatus) AbstractObject(org.netxms.client.objects.AbstractObject) ConnectionEndpointLocator(org.eclipse.draw2d.ConnectionEndpointLocator) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) UnknownObject(org.netxms.client.objects.UnknownObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with PolylineDecoration

use of org.eclipse.draw2d.PolylineDecoration in project yamcs-studio by yamcs.

the class WidgetConnectionEditPart method updateDecoration.

private void updateDecoration(PolylineConnection connection) {
    switch(getWidgetModel().getArrowType()) {
        case None:
            // if(targetDecoration != null)
            // connection.remove(targetDecoration);
            targetDecoration = null;
            // if(sourceDecoration != null)
            // connection.remove(sourceDecoration);
            sourceDecoration = null;
            break;
        case From:
            // if(targetDecoration != null)
            // connection.remove(targetDecoration);
            targetDecoration = null;
            if (getWidgetModel().isFillArrow()) {
                sourceDecoration = new PolygonDecoration();
            } else {
                sourceDecoration = new PolylineDecoration();
            }
            break;
        case To:
            // if(sourceDecoration != null)
            // connection.remove(sourceDecoration);
            sourceDecoration = null;
            if (getWidgetModel().isFillArrow()) {
                targetDecoration = new PolygonDecoration();
            } else {
                targetDecoration = new PolylineDecoration();
            }
            break;
        case Both:
            if (getWidgetModel().isFillArrow()) {
                sourceDecoration = new PolygonDecoration();
                targetDecoration = new PolygonDecoration();
            } else {
                sourceDecoration = new PolylineDecoration();
                targetDecoration = new PolylineDecoration();
            }
            break;
        default:
            break;
    }
    if (targetDecoration != null) {
        ((Shape) targetDecoration).setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
    }
    if (sourceDecoration != null) {
        ((Shape) sourceDecoration).setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
    }
    connection.setTargetDecoration(targetDecoration);
    connection.setSourceDecoration(sourceDecoration);
}
Also used : Shape(org.eclipse.draw2d.Shape) PolygonDecoration(org.eclipse.draw2d.PolygonDecoration) PolylineDecoration(org.eclipse.draw2d.PolylineDecoration)

Aggregations

PolylineDecoration (org.eclipse.draw2d.PolylineDecoration)5 PolygonDecoration (org.eclipse.draw2d.PolygonDecoration)2 ConnectionEndpointLocator (org.eclipse.draw2d.ConnectionEndpointLocator)1 IFigure (org.eclipse.draw2d.IFigure)1 Label (org.eclipse.draw2d.Label)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Shape (org.eclipse.draw2d.Shape)1 ObjectStatus (org.netxms.client.constants.ObjectStatus)1 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)1 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 UnknownObject (org.netxms.client.objects.UnknownObject)1