簡體   English   中英

JUNG2:將頂點放置在固定點

[英]JUNG2: put vertex at fixed point

我想問一下是否有辦法在畫布上的特定點(x,y)處放置頂點。 我想用已構建的圖形啟動一個應用程序,但是使用g.addVertex(1)將頂點添加到圖形中,但是將其放置在畫布上的隨機點處。

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;
    }

}

也許對您有幫助? 我在項目中使用了它,效果很好!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM