Package research.connection

Examples of research.connection.LineConnection


     * return p1.x == p2.x;
     * }
     */

    public Point locate() {
        LineConnection line = ownerConnection();
        int segment = Math.min(fSegment, line.pointCount() - 2);
        Point p1 = line.pointAt(segment);
        Point p2 = line.pointAt(segment + 1);
        return new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
    }
View Full Code Here


        g.setColor(Color.black);
        g.drawOval(r.x, r.y, r.width, r.height);
    }

    private int constrainX(int x) {
        LineConnection line = ownerConnection();
        Figure startFigure = line.getStartConnector().owner();
        Figure endFigure = line.getEndConnector().owner();
        Rectangle start = startFigure.getDisplayBox();
        Rectangle end = endFigure.getDisplayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1x, r1width, r2x, r2width;
        r1x = start.x + i1.left;
        r1width = start.width - i1.left - i1.right - 1;

        r2x = end.x + i2.left;
        r2width = end.width - i2.left - i2.right - 1;

        if (fSegment == 0) {
            x = Geom.range(r1x, r1x + r1width, x);
        }
        if (fSegment == line.pointCount() - 2) {
            x = Geom.range(r2x, r2x + r2width, x);
        }
        return x;
    }
View Full Code Here

        }
        return x;
    }

    private int constrainY(int y) {
        LineConnection line = ownerConnection();
        Figure startFigure = line.getStartConnector().owner();
        Figure endFigure = line.getEndConnector().owner();
        Rectangle start = startFigure.getDisplayBox();
        Rectangle end = endFigure.getDisplayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1y, r1height, r2y, r2height;
        r1y = start.y + i1.top;
        r1height = start.height - i1.top - i1.bottom - 1;
        r2y = end.y + i2.top;
        r2height = end.height - i2.top - i2.bottom - 1;

        if (fSegment == 0) {
            y = Geom.range(r1y, r1y + r1height, y);
        }
        if (fSegment == line.pointCount() - 2) {
            y = Geom.range(r2y, r2y + r2height, y);
        }
        return y;
    }
View Full Code Here

        toolAction = new ConnectionToolAction();
        toolIcon = new ImageIcon(getClass().getResource("image/line_connection.png"));
        toolAction.putValue(Action.SMALL_ICON, toolIcon);
        toolAction.putValue(Action.SHORT_DESCRIPTION, "Create a Line Connection Figure");
        toolAction.putValue(CreationToolAction.PROTOTYPE_FIGURE, new LineConnection());
        toolAction.putValue(ToolAction.TOOL, new ConnectionTool());
        controller.addToolAction(toolAction);
        toolAction.setSelected(false);
        tooButton = new ToolButton(toolAction);
        this.add(tooButton);
View Full Code Here

            fLastY = y;
        }
    }

    public Point locate() {
        LineConnection line = ownerConnection();
        int segment = Math.min(fSegment, line.pointCount() - 2);
        Point p1 = line.pointAt(segment);
        Point p2 = line.pointAt(segment + 1);
        return new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
    }
View Full Code Here

        g.setColor(Color.black);
        g.drawOval(r.x, r.y, r.width, r.height);
    }

    private int constrainX(int x) {
        LineConnection line = ownerConnection();
        Figure startFigure = line.getStartConnector().owner();
        Figure endFigure = line.getEndConnector().owner();
        Rectangle start = startFigure.getDisplayBox();
        Rectangle end = endFigure.getDisplayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1x, r1width, r2x, r2width;
        r1x = start.x + i1.left;
        r1width = start.width - i1.left - i1.right - 1;

        r2x = end.x + i2.left;
        r2width = end.width - i2.left - i2.right - 1;

        if (fSegment == 0) {
            x = Geom.range(r1x, r1x + r1width, x);
        }
        if (fSegment == line.pointCount() - 2) {
            x = Geom.range(r2x, r2x + r2width, x);
        }
        return x;
    }
View Full Code Here

        }
        return x;
    }

    private int constrainY(int y) {
        LineConnection line = ownerConnection();
        Figure startFigure = line.getStartConnector().owner();
        Figure endFigure = line.getEndConnector().owner();
        Rectangle start = startFigure.getDisplayBox();
        Rectangle end = endFigure.getDisplayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1y, r1height, r2y, r2height;
        r1y = start.y + i1.top;
        r1height = start.height - i1.top - i1.bottom - 1;
        r2y = end.y + i2.top;
        r2height = end.height - i2.top - i2.bottom - 1;

        if (fSegment == 0) {
            y = Geom.range(r1y, r1y + r1height, y);
        }
        if (fSegment == line.pointCount() - 2) {
            y = Geom.range(r2y, r2y + r2height, y);
        }
        return y;
    }
View Full Code Here

TOP

Related Classes of research.connection.LineConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.