tesis-dynaware / graph-editor

Eclipse Public License 1.0
132 stars 42 forks source link

Restrict GJoint Position to stay in visible area #22

Closed eckig closed 9 years ago

eckig commented 9 years ago

Look at the following situation:

1

If I know connect the left output to the top input, I get the following:

2

They are connected, but the most part of the connection is outside the viewport and thus can not be modified with mouse gestures.

It would be nice if the framework would restrict the maximum / minimum GJoiunt Position so they stay within the visible area and thus can be moved.

rmfisher commented 9 years ago

The method that's responsible for drawing this path is in the DefaultTailSkin class:

public void draw(Point2D start, Point2D end, GConnector target, boolean valid)

The simplest way I can think of to implement what you need is to create a custom tail skin class that extends DefaultTailSkin, override this method, call super.draw(...), then do the additional logic to move the points inside the viewport.

I wouldn't implement this in the default skin class myself, because I prefer the current behaviour. I don't think the position of the viewport should have any influence on the initial connection layout. If the user wants to reposition some joints after the connection's created, they simply have to pan the window upwards.

eckig commented 9 years ago

And if the window is already maximized?

rmfisher commented 9 years ago

I meant to pan the window upwards by right-clicking-and-dragging, or using the mouse-wheel. But of course if the viewport is already at the top and the joints are outside the bounds of the view itself, this would be a problem. Is this what you're referring to?

eckig commented 9 years ago

This is what I meant, yes.

rmfisher commented 9 years ago

Hrm well the problem in this case is that there is just no 'nice-looking' connection shape you can draw. There isn't enough room to draw one. So then I would just say, the user should drag the node down first so that there is enough room. Or drag a selection box around the new joints and target node afterwards (this is possible in the demo even if it's full-screen) and move everything down.

If you want to enforce that the new joint positions are within the boundaries, you can extend the default tail skin like I mentioned above. I hope it's only a few lines of code. But I won't change the default tail skin right now because neither approach leads to great behaviour, and when in doubt I leave the simpler implementation as it is.

eckig commented 9 years ago

Yes you are right, that it is hard to draw a connection right with so little space available, but its still better than "no" connection.

Most of our application works without the need for our users to study the manual in depth. That' s why I would prefer an automatic solution... So I will check the TailSkin implementation.

eckig commented 9 years ago

You once again, pointed me in the right direction: Just a little minor change in our GTailSkin did the trick - thanks.