Skip to content

Commit

Permalink
Cleaning up GraphNodeEditor and GraphNodeEditorPart
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinSc committed Apr 16, 2023
1 parent 15880a8 commit 8e6ba65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
2 changes: 0 additions & 2 deletions gdx-gemp-ui/src/com/gempukku/libgdx/ui/graph/GraphEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class GraphEditor extends VisTable implements NavigableCanvas {

private ObjectSet<String> selectedNodes = new ObjectSet<>();
private boolean movingSelected = false;
private boolean hasErrors = false;

private final DefaultGraph<GraphNodeWindow, DrawnGraphConnection, RectangleNodeGroup> editedGraph;

Expand Down Expand Up @@ -330,7 +329,6 @@ private void updateCanvas(boolean adjustPosition) {
}

public void setValidationResult(GraphValidationResult validationResult) {
hasErrors = validationResult.hasErrors();
for (GraphNodeWindow window : editedGraph.getNodes()) {
window.clearConnectorErrors();
if (validationResult.getErrorNodes().contains(window.getId())) {
Expand Down
19 changes: 10 additions & 9 deletions gdx-gemp-ui/src/com/gempukku/libgdx/ui/graph/GraphNodeWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import com.kotcrab.vis.ui.widget.VisWindow;

public class GraphNodeWindow extends VisWindow implements GraphNode, Disposable {
private String nodeId;
private GraphNodeEditor graphNodeEditor;
private ObjectSet<String> connectorsWithError = new ObjectSet<>();
private Vector2 position;
private final String nodeId;
private final GraphNodeEditor graphNodeEditor;
private final ObjectSet<String> connectorsWithError = new ObjectSet<>();
private Vector2 lastPosition;

public GraphNodeWindow(String nodeId, GraphNodeEditor graphNodeEditor, String title, WindowStyle windowStyle) {
super(title, windowStyle);
Expand All @@ -36,12 +36,12 @@ public boolean isConnectorError(String fieldId) {

@Override
protected final void positionChanged() {
if (position != null) {
positionChanged(position.x, position.y, getX(), getY());
if (lastPosition != null) {
positionChanged(lastPosition.x, lastPosition.y, getX(), getY());
} else {
position = new Vector2();
lastPosition = new Vector2();
}
position.set(getX(), getY());
lastPosition.set(getX(), getY());
}

protected void positionChanged(float fromX, float fromY, float toX, float toY) {
Expand Down Expand Up @@ -69,6 +69,7 @@ public NodeConfiguration getConfiguration() {

@Override
public void dispose() {
graphNodeEditor.dispose();
if (graphNodeEditor instanceof Disposable)
((Disposable) graphNodeEditor).dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,4 @@ public JsonValue getData() {
return null;
return result;
}

@Override
public void dispose() {
for (GraphNodeEditorPart part : editorParts) {
if (part instanceof Disposable) {
((Disposable) part).dispose();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.gempukku.libgdx.ui.graph.editor;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.JsonValue;
import com.gempukku.libgdx.ui.graph.data.NodeConfiguration;

import java.util.Map;

public interface GraphNodeEditor extends Disposable {
public interface GraphNodeEditor {
Actor getActor();

JsonValue getData();
Expand Down

0 comments on commit 8e6ba65

Please sign in to comment.