org.netbeans.api.visual.anchor.AnchorShape Java Examples

The following examples show how to use org.netbeans.api.visual.anchor.AnchorShape. 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: RuleScene.java    From jlibs with Apache License 2.0 6 votes vote down vote up
@Override
protected Widget attachEdgeWidget(Edge edge){
    EdgeWidget connection = new EdgeWidget(this);
    connection.setStroke(Util.STROKE_2);
    connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);

    LabelWidget label = createEdgeLabel(edge);
    connection.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_CENTER, 0.5f);

    connection.addChild(label);
    connections.addChild(connection);

    connection.setRouter(router);
    connection.highLight(false);
    
    connection.getActions().addAction(hoverAction);
    connection.getActions().addAction(editAction);
    connection.getActions().addAction(edgePopupAction);
    return connection;
}
 
Example #2
Source File: ConnectionWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a connection widget.
 * @param scene the scene
 */
public ConnectionWidget (Scene scene) {
    super (scene);
    sourceAnchorShape = AnchorShape.NONE;
    targetAnchorShape = AnchorShape.NONE;
    controlPointShape = PointShape.NONE;
    endPointShape = PointShape.NONE;
    router = RouterFactory.createDirectRouter ();
    routingRequired = true;
    connectionWidgetLayout = new ConnectionWidgetLayout ();
    setLayout (connectionWidgetLayout);
    stroke = STROKE_DEFAULT;
    paintControlPoints = false;
    controlPointCutDistance = 0;
    sourceEntry = new ConnectionEntry (true);
    targetEntry = new ConnectionEntry (false);

    routingPolicy = RoutingPolicy.ALWAYS_ROUTE;
}
 
Example #3
Source File: ControlFlowScene.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #4
Source File: CustomConnectionWidget.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setTargetAnchorShape(AnchorShape targetAnchorShape) {
    if (!targetAnchorShapeHidden) {
        super.setTargetAnchorShape(targetAnchorShape);
    } else {
        super.setTargetAnchorShape(AnchorShape.NONE);
    }
}
 
Example #5
Source File: AbegoTreeLayoutForNetbeansDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Widget attachEdgeWidget(String e) {
	ConnectionWidget connectionWidget = new ConnectionWidget(this);
	connectionWidget.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
	connectionLayer.addChild(connectionWidget);
	return connectionWidget;
}
 
Example #6
Source File: ControlFlowScene.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #7
Source File: ControlFlowScene.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #8
Source File: ControlFlowScene.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #9
Source File: ControlFlowScene.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    BlockConnectionWidget w = new BlockConnectionWidget(this, edge);
    switch (edge.getState()) {
        case NEW:
            w.setBold(true);
            break;
        case DELETED:
            w.setDashed(true);
            break;
    }
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #10
Source File: ControlFlowScene.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #11
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(String edge) {
    ConnectionWidget connection = new ConnectionWidget(this);
    connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    connection.setEndPointShape(PointShape.SQUARE_FILLED_BIG);
    connection.getActions().addAction(createObjectHoverAction());
    connection.getActions().addAction(createSelectAction());
    connection.getActions().addAction(reconnectAction);
    connectionLayer.addChild(connection);
    return connection;
}
 
Example #12
Source File: ConnectionWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the anchor shape of the target of the connection widget.
 * @param targetAnchorShape the target anchor shape
 */
public void setTargetAnchorShape (AnchorShape targetAnchorShape) {
    assert targetAnchorShape != null;
    boolean repaintOnly = this.targetAnchorShape.getRadius () == targetAnchorShape.getRadius ();
    this.targetAnchorShape = targetAnchorShape;
    revalidate (repaintOnly);
}
 
Example #13
Source File: ConnectionWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the anchor shape of the source of the connection widget.
 * @param sourceAnchorShape the source anchor shape
 */
public void setSourceAnchorShape (AnchorShape sourceAnchorShape) {
    assert sourceAnchorShape != null;
    boolean repaintOnly = this.sourceAnchorShape.getRadius () == sourceAnchorShape.getRadius ();
    this.sourceAnchorShape = sourceAnchorShape;
    revalidate (repaintOnly);
}
 
Example #14
Source File: DiagramConnectionWidget.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #15
Source File: ControlFlowScene.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #16
Source File: ControlFlowScene.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #17
Source File: EdgeWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
EdgeWidget(DependencyGraphScene<I> scene, GraphEdge<I> edge) {
    super(scene);
    this.edge = edge;
    origStroke = getStroke();
    setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    
    if(scene.supportsVersions()) {
        isConflict = scene.isConflict(edge.getTarget());
        edgeConflictType = getConflictType();

        updateVersionW(isConflict);
    }
}
 
Example #18
Source File: VMDNetBeans60ColorScheme.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void installUI (VMDConnectionWidget widget) {
    widget.setSourceAnchorShape (AnchorShape.NONE);
    widget.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
    widget.setPaintControlPoints (true);
}
 
Example #19
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void installUI(VMDConnectionWidget widget) {
    widget.setSourceAnchorShape(AnchorShape.NONE);
    widget.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    widget.setPaintControlPoints(true);
}
 
Example #20
Source File: ModelGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
protected Widget attachEdgeWidget (String edge) {
    ConnectionWidget connection = new ConnectionWidget (this);
    connection.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
    connectionLayer.addChild (connection);
    return connection;
}
 
Example #21
Source File: DiagramConnectionWidget.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #22
Source File: DiagramConnectionWidget.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #23
Source File: DiagramConnectionWidget.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #24
Source File: DiagramConnectionWidget.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #25
Source File: DiagramConnectionWidget.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #26
Source File: VMDOriginalColorScheme.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void installUI (VMDConnectionWidget widget) {
    widget.setSourceAnchorShape (AnchorShape.NONE);
    widget.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
    widget.setPaintControlPoints (true);
}
 
Example #27
Source File: AttachableAnchorShape.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public AnchorShape getShape()
{
    return shape;
}
 
Example #28
Source File: DiagramConnectionWidget.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void paintWidget() {
    Graphics2D g = this.getGraphics();

    if (xPoints.length == 0 || Math.abs(xPoints[0] - xPoints[xPoints.length - 1]) > 2000) {
        return;
    }

    //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    //g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

    DiagramScene ds = (DiagramScene) this.getScene();
    boolean shouldHide = false;//ds.getShouldHide(this);

    Composite oldComposite = null;
    if (shouldHide) {
        Color c = new Color(255 - (255 - color.getRed()) / WHITE_FACTOR, 255 - (255 - color.getGreen()) / WHITE_FACTOR, 255 - (255 - color.getBlue()) / WHITE_FACTOR);
        g.setPaint(c);
    } else {
        g.setPaint(color);
    }

    if (split) {
        for (int i = 1; i < controlPoints.size(); i++) {
            Point prev = controlPoints.get(i - 1);
            Point cur = controlPoints.get(i);
            if (cur == null || prev == null) {
                continue;
            }

            g.drawLine(prev.x, prev.y, cur.x, cur.y);
        }
    } else {
        g.drawPolyline(xPoints, yPoints, pointCount);
    }

    /*for(int i=0; i<xPoints.length; i++) {
    int x = xPoints[i];
    int y = yPoints[i];
    g.fillOval(x - 2, y - 2, 4, 4);
    }*/

    if (xPoints.length >= 2) {
        Graphics2D g2 = (Graphics2D) g.create();
        int xOff = xPoints[xPoints.length - 2] - xPoints[xPoints.length - 1];
        int yOff = yPoints[yPoints.length - 2] - yPoints[yPoints.length - 1];
        if (xOff == 0 && yOff == 0 && yPoints.length >= 3) {
            xOff = xPoints[xPoints.length - 3] - xPoints[xPoints.length - 1];
            yOff = yPoints[yPoints.length - 3] - yPoints[yPoints.length - 1];
        }
        g2.translate(xPoints[xPoints.length - 1], yPoints[yPoints.length - 1]);
        g2.rotate(Math.atan2(yOff, xOff));

        g2.scale(0.55, 0.80);
        AnchorShape.TRIANGLE_FILLED.paint(g2, false);
    }
}
 
Example #29
Source File: QueryBuilderGraphFrame.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void insertGraphEdge(QBNodeComponent node1, QBNodeComponent node2,
		 String fullTableName1, String fullTableName2,
		 String tableSpec1, String tableSpec2,
		 String colName1, String colName2,
		 String[] fk, String joinType)
   {
System.out.println("Entering insertGraphEdge, tableSpec1: " + tableSpec1 + "  tableSpec2: " + tableSpec2);

       // Create the node object for the edge (for the Property Sheet)
       AbstractNode an;
       if (colName1==null) {
           // We are adding the edge interactively, based on the FK
           // Use the columns specified in the FK
           if (fullTableName1.equalsIgnoreCase(fk[0]))
               an = createPropertyNode(tableSpec1, fk[1], tableSpec2, fk[3], joinType, _queryBuilder); // NOI18N
           else
               an = createPropertyNode(tableSpec2, fk[1], tableSpec1, fk[3], joinType, _queryBuilder); // NOI18N
       } else {
           // Adding an edge from the model, based on join condition
           an = createPropertyNode(tableSpec1, colName1, tableSpec2, colName2, joinType, _queryBuilder); // NOI18N
       }

// Now, add an edge to the graph scene, containing the AbstractNode
Widget widget = _scene.addEdge(an);
_scene.setEdgeSource (an, node1);
_scene.setEdgeTarget (an, node2);

ConnectionWidget connWidget = (ConnectionWidget)widget;

// widget.getActions().addAction(ActionFactory.createSelectAction(new ObjectSelectProvider()));
connWidget.getActions().addAction(_scene.createSelectAction());

       AnchorShape triangle = AnchorShapeFactory.createTriangleAnchorShape(18, true, false, 17);
       connWidget.setStroke (new BasicStroke (1.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
       // If we have an FK, draw the appropriate arrowhead, otherwise don't do anything
       if (fk!=null) {
           if (fk[0].equalsIgnoreCase(fullTableName1)) {
	// ((ConnectionWidget)widget).setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
	connWidget.setTargetAnchorShape (triangle);
           } else {
	connWidget.setSourceAnchorShape (triangle);
           }
       }
       
       // Mark the edge as activated (updates property sheet)
       _queryBuilder.setActivatedNodes(new Node[] {an});
       
_scene.validate();
   }
 
Example #30
Source File: PFENotModifiableScheme.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void installUI (VMDConnectionWidget widget) {
    widget.setSourceAnchorShape (AnchorShape.NONE);
    widget.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
    widget.setPaintControlPoints (true);
}