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

ToolTips #9

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

ToolTips #9

wants to merge 1 commit into from

Conversation

hoijui
Copy link

@hoijui hoijui commented Jun 1, 2020

This works, but really is only a proof of concept.

one needs to activate it with:
(view as DefaultView).setToolTips(true)

And one needs to use gs-ui-swing of course.

Then, the String attributes "ui.tooltip" set on nodes, edges and sprites
are shown as Swing JToolTips.

(I do not think this should be merges as is)

This works, but is *really* only a proof of concept.

one needs to activate it with:
`(view as DefaultView).setToolTips(true)`

And one needs to use gs-ui-swing of course.

Then, the `String` attributes "ui.tooltip" set on nodes, edges and sprites
are shown as Swing `JToolTip`s.
@hichbra
Copy link
Contributor

hichbra commented Jun 3, 2020

Thanks for your contribution.
I haven't tested it yet, but the code in itself looks pretty good to me.

However, is this code need to be in DefaultView ? I see it more in DefaultMouseManager, with the InteractiveElement defined in the constructor. What do you think ?

@hoijui
Copy link
Author

hoijui commented Jun 3, 2020

the main code is in two methods that are part of JComponent, just overriden here. they need to be overridden here, it would not work in DefaultMouseManager.
I actually first reid to go that way too, doing it through the mouse manager/mouse events, and it works, until where you want to actually display the tooltip. Because JToolTip -- or generally how tool-tips work in Swing -- is fixed on ToolTipManager and these methods in JComponent.
Of course, one could create a kind of Swing modal dialog without window decorations, without buttons, without a window border and many other special settings, and it might look the same like tooltips, and work more or less similarly (on the systems we are able to test on), but I would guess it would be 5+ times the amount of code and complexity, and might come with problems we can't imagine yet.
... it would probably be more modular though.

@hoijui
Copy link
Author

hoijui commented Jun 3, 2020

I have to say... while many things in Java and also Swing are more or less well designed, the tool-tip system looks like quite an exception to that. ;-)
so.. might make sense to go more the way of reinventing the wheel.
... or maybe others did that already?

@hoijui
Copy link
Author

hoijui commented Jun 3, 2020

sounds like even inside the JDK itsself, other methods are sometimes used:
https://stackoverflow.com/a/9522754/586229

@hichbra
Copy link
Contributor

hichbra commented Jun 3, 2020

A custom JDialog seems to be a good idea. You can use the mouseOverElement and mouseLeftElement methods of the MouseOverMouseManager class to create and remove the tooltip.

To use this class, the addition of viewer.getDefaultView().enableMouseOptions(); will be required for the user though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants