문제

I would like to ask if is there any way to put vertex at specific point (x,y) at canvas. I would like to start an app with graph already built, however using g.addVertex(1) adds vertex to graph but it is being put at canvas at random points.

도움이 되었습니까?

해결책

public static class MyVertex  {
    private String name;
    private int vIndex;
    private boolean visited = false;
    private int distance = 0;

    private double x;
    private double y;

    public MyVertex(String name, int vIndex) {
        this.name = name;
        this.vIndex = vIndex;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getX() {
        return x;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getY() {
        return y;
    }

    public String getName() {
        return name;
    }

}

Maybe this will help you? I used it for my project, and it works great!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top