Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zest 2.0] added getter for ZestRoorLayer ordering constants #532

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,61 @@ public class ZestRootLayer extends FreeformLayer {
*/
private boolean isLayerKnown = false;

protected int getConnectionsLayer() {
return CONNECTIONS_LAYER;
}

protected int getSubgraphsLayer() {
return SUBGRAPHS_LAYER;
}

protected int getNodesLayer() {
return NODES_LAYER;
}

protected int getConnectionsHighlightedLayer() {
return CONNECTIONS_HIGHLIGHTED_LAYER;
}

protected int getNodesHighlightedLayer() {
return NODES_HIGHLIGHTED_LAYER;
}

protected int getTopLayer() {
return TOP_LAYER;
}

/**
* Adds a node to the ZestRootLayer
*
* @param nodeFigure The figure representing the node
*/
public void addNode(IFigure nodeFigure) {
addFigure(nodeFigure, NODES_LAYER);
addFigure(nodeFigure, getNodesLayer());
Copy link
Contributor

@ptziegler ptziegler Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest; I don't like this at all. A getNodesLayer() method should always return NODES_LAYER. Anything else I would consider a conceptual flaw.

Can't you just overwrite the addNode(IFigure) method and then use a different constant? For example:

public void addNode(IFigure nodeFigure) {
	addFigure(nodeFigure, CONNECTIONS_LAYER)
}

You might have to make the changeFigureLayer() method protected to override the highlight methods, but that's fine. It still looks a little weird adding figures to other layers, but at least it's immediately obvious what's happening, when looking at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just overwrite the addNode(IFigure) method and then use a different constant?

Oh... yes that makes a lot more sense. I might have been a bit blinded by the constants, that I missed I don't even have to use them.
Thank you. I will close this PR.

}

public void addConnection(IFigure connectionFigure) {
addFigure(connectionFigure, CONNECTIONS_LAYER);
addFigure(connectionFigure, getConnectionsLayer());
}

public void addSubgraph(IFigure subgraphFigrue) {
addFigure(subgraphFigrue, SUBGRAPHS_LAYER);
addFigure(subgraphFigrue, getSubgraphsLayer());
}

public void highlightNode(IFigure nodeFigure) {
changeFigureLayer(nodeFigure, NODES_HIGHLIGHTED_LAYER);
changeFigureLayer(nodeFigure, getNodesHighlightedLayer());
}

public void highlightConnection(IFigure connectionFigure) {
changeFigureLayer(connectionFigure, CONNECTIONS_HIGHLIGHTED_LAYER);
changeFigureLayer(connectionFigure, getConnectionsHighlightedLayer());
}

public void unHighlightNode(IFigure nodeFigure) {
changeFigureLayer(nodeFigure, NODES_LAYER);
changeFigureLayer(nodeFigure, getNodesLayer());
}

public void unHighlightConnection(IFigure connectionFigure) {
changeFigureLayer(connectionFigure, CONNECTIONS_LAYER);
changeFigureLayer(connectionFigure, getConnectionsLayer());
}

private void changeFigureLayer(IFigure figure, int newLayer) {
Expand Down
Loading