为什么我不能旋转2点画在同一条线上

时间:2018-01-05 00:45:06

标签: java javafx javafx-8 javafx-2

我有这个代码来绘制一些顶点和边,和 我已经尝试了几乎所有我可以实现的可能性,但我相信这个bug在方法旋转中或在construtor中 但我不确定

zzzzzz

在2点之间进行旋转的方法

public static int CONFIG_NODE_DIAMETER = 20; //pixels

    //construtor
    public GraphDraw(Graph<V, E> graph) {

        //count of vertex
        int N = graph.numVertex();

        double width = this.getWidth();
        double height = this.getHeight();

        Point2D center = new Point2D(width / 2, height / 2);

        double angleIncrement = 360f / N;

        //get all vertex from graph
        ArrayList<Vertex<V>> vertex = graph.getVertex();

         //draw the line and point
        boolean first = true;
        Point2D p = null;

        for (Vertex<V> v : vertex ) { {
            if (first) {
                if (width > height) {
                    p = new Point2D(center.getX(),
                            center.getY() - height / 2 + CONFIG_NODE_DIAMETER * 2);
                } else {
                    p = new Point2D(center.getX(),
                            center.getY() - width / 2 + CONFIG_NODE_DIAMETER * 2);
                }

                first = false;
            } else {
                p = rotate(p, center, angleIncrement);
            }

        }
    }
}

enter image description here

我想要像下面的图像一样,我试图旋转,但它无法正常工作

enter image description here

任何建议?

in this link, you can check all method in class GraphDraw, and I dont put because the post would be extensive

0 个答案:

没有答案