Search in sources :

Example 16 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project jbosstools-hibernate by jbosstools.

the class ConnectionEditPart method createFigure.

protected IFigure createFigure() {
    PolylineConnection connection = new RoundPolylineConnection();
    connection.setForegroundColor(getColor());
    connection.setTargetDecoration(new PolygonDecoration());
    connection.setVisible(getModelConnection().isVisible());
    return connection;
}
Also used : PolygonDecoration(org.eclipse.draw2d.PolygonDecoration) RoundPolylineConnection(org.jboss.tools.hibernate.ui.diagram.editors.figures.RoundPolylineConnection) RoundPolylineConnection(org.jboss.tools.hibernate.ui.diagram.editors.figures.RoundPolylineConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 17 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project jbosstools-hibernate by jbosstools.

the class DirectedGraphLayoutVisitor method applyResults.

// ******************* RelationshipPart apply methods **********/
protected void applyResults(AssociationEditPart relationshipPart) {
    Edge e = (Edge) partToNodesMap.get(relationshipPart);
    PolylineConnection conn = (PolylineConnection) relationshipPart.getConnectionFigure();
    if (e == null) {
        // conn.setConnectionRouter(new ShortestPathConnectionRouter(diagram.getFigure()));
        return;
    }
    NodeList nodes = e.vNodes;
    if (nodes != null) {
        List<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
        for (int i = 0; i < nodes.size(); i++) {
            Node vn = nodes.getNode(i);
            int x = vn.x;
            int y = vn.y;
            if (e.isFeedback()) {
                bends.add(new AbsoluteBendpoint(x, y + vn.height));
                bends.add(new AbsoluteBendpoint(x, y));
            } else {
                bends.add(new AbsoluteBendpoint(x, y));
                bends.add(new AbsoluteBendpoint(x, y + vn.height));
            }
        }
        conn.setRoutingConstraint(bends);
    } else {
        conn.setRoutingConstraint(Collections.EMPTY_LIST);
    }
}
Also used : AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) NodeList(org.eclipse.draw2d.graph.NodeList) Node(org.eclipse.draw2d.graph.Node) ArrayList(java.util.ArrayList) Edge(org.eclipse.draw2d.graph.Edge) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 18 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project gemoc-studio by eclipse.

the class ConnectionEditPart method createFigure.

@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;
}
Also used : PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 19 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection 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 20 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project dbeaver by dbeaver.

the class DummyEdgePart method createFigure.

/**
 * @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure()
 */
protected IFigure createFigure() {
    PolylineConnection conn = new PolylineConnection();
    conn.setConnectionRouter(new BendpointConnectionRouter());
    conn.setVisible(true);
    return conn;
}
Also used : BendpointConnectionRouter(org.eclipse.draw2d.BendpointConnectionRouter) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Aggregations

PolylineConnection (org.eclipse.draw2d.PolylineConnection)43 Point (org.eclipse.draw2d.geometry.Point)11 PolygonDecoration (org.eclipse.draw2d.PolygonDecoration)10 IFigure (org.eclipse.draw2d.IFigure)8 BendpointConnectionRouter (org.eclipse.draw2d.BendpointConnectionRouter)6 Label (org.eclipse.draw2d.Label)6 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)5 Edge (org.eclipse.draw2d.graph.Edge)3 ArrayList (java.util.ArrayList)2 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)2 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 Node (org.eclipse.draw2d.graph.Node)2 NodeList (org.eclipse.draw2d.graph.NodeList)2 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)2 CurveConnectionRouter (org.talend.designer.gefabstractmap.figures.routers.CurveConnectionRouter)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)2 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)2