Skip to content

Commit

Permalink
Reorder parameters of drawFixedVertex to be more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
FeldrinH committed Mar 19, 2024
1 parent dcbb4d2 commit a504717
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/main/java/ee/ut/dendroloj/GraphCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public void drawVertex(V vertex, String label, Color color) {
addVertex(new Vertex<>(vertex, label, color));
}

// TODO: Reorder arguments so x and y are before label? This would group all visual parameters that users are likely to tweak (label and color) at the end.

// public void drawFixedVertex(V vertex, double x, double y) {
// if (vertex == null) throw new NullPointerException("Vertex must not be null");
// drawVertex(vertex, vertex.toString(), null);
Expand All @@ -52,19 +50,35 @@ public void drawVertex(V vertex, String label, Color color) {
/**
* Draws a vertex with the given label at the given coordinates.
*/
public void drawFixedVertex(V vertex, String label, double x, double y) {
public void drawFixedVertex(V vertex, double x, double y, String label) {
if (vertex == null) throw new NullPointerException("Vertex must not be null");
addVertex(new Vertex<>(vertex, label, null, x, y));
}

/**
* Draws a vertex with the given label at the given coordinates.
*/
public void drawFixedVertex(V vertex, String label, double x, double y, Color color) {
public void drawFixedVertex(V vertex, double x, double y, String label, Color color) {
if (vertex == null) throw new NullPointerException("Vertex must not be null");
addVertex(new Vertex<>(vertex, label, color, x, y));
}

/**
* @deprecated use {@link #drawFixedVertex(V, double, double, String)} instead
*/
@Deprecated
public void drawFixedVertex(V vertex, String label, double x, double y) {
drawFixedVertex(vertex, x, y, label);
}

/**
* @deprecated use {@link #drawFixedVertex(V, double, double, String, Color)} instead
*/
@Deprecated
public void drawFixedVertex(V vertex, String label, double x, double y, Color color) {
drawFixedVertex(vertex, x, y, label, color);
}

private void addVertex(Vertex<V> vertex) {
String id = IdHelper.getNodeId(vertex.vertex);
if (drawnVertices.contains(id)) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/GraafKatsed.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void main(String[] args) {

GraphCanvas<Tipp> lõuend = new GraphCanvas<>();
for (Tipp tipp : tipud) {
lõuend.drawFixedVertex(tipp, tipp.tähis, tipp.x, tipp.y);
lõuend.drawFixedVertex(tipp, tipp.x, tipp.y, tipp.tähis);
for (Kaar kaar : tipp.kaared) {
lõuend.drawEdge(tipp, kaar.lõppTipp, String.valueOf(kaar.kaal));
}
Expand Down

0 comments on commit a504717

Please sign in to comment.