Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Part+Visuals
Part+Visuals [message #1795097] Fri, 14 September 2018 13:45 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 162
Registered: July 2009
Senior Member
Hi,

i want to build a switch component, that can have 2 or more positions.
In the end, the user shall be able to
- directly hover over the position, he wants to activate and click to do it
- or hover over the remaining body , on click the position is toggled/incremented.

index.php/fa/33891/0/

Now my question is, how shall i partition this?

one content part for the whole switch and 2-N visualparts for the clickable positions?
One visual for the switch and also one for the position (only the circle) and another visual that draws the line?

What is the recommended design here?

regards
Frank

Re: Part+Visuals [message #1795190 is a reply to message #1795097] Tue, 18 September 2018 07:19 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 162
Registered: July 2009
Senior Member
I implemented this now with 3 parts and 2 visuals

class SwitchNodePart extends AbstractContentPart<Group>
groups the 2 other parts.

class SwitchBkgdNodePart extends AbstractContentPart<SwitchBkgdVisual>
Draws the background and handles the body hover and click

class SwitchSelectNodePart extends AbstractContentPart<SwitchSelectVisual>
draws the circles and as well implements hover and click

This works so far. I can implement the hovering and the click changes.
My questions refined:

1.
However I wonder if the child parts need to be content-parts.
They do not need to have new model parts. Could they just extend AbstractVisualPart?

2.
Can i have only 2 part classes?
The background drawing one having children for the select circles?
I encountered problems and concluded that only a "Group" node can have childs.
Is this correct?

Frank
Re: Part+Visuals [message #1802119 is a reply to message #1795190] Fri, 01 February 2019 14:36 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Frank,

I believe your implementation should be fine so far :-)

1) Maybe the part abstraction is cumbersome here so you might want to implement a specific JavaFX visual instead. You could also provide a gesture if complicated interaction is desired (and troublesome to implement via clickdrag, and other default gestures).

Using a mix of content-parts and non-content-parts should be possible. However, I have no experience with such a setup, and the default synchronisation mechanism will only construct parts based-on content-children and content-anchorages.

2) Every JavaFX Parent can have children. Some parent nodes allow the addition and removal of children, e.g. Group or Pane, while other parent nodes maintain their children only internally.

Group is a good default. In some cases, I believe, Region/Pane can also be a very nice "base" visual due to CSS styling options.

W.r.t. two part classes: You can have a transformation between your actual model and the "content-children" and "content-anchorages" reported by the content-parts. Therefore, you can always "split" contents across multiple parts. This is done by Zest, for example, for the edge labels.

Best regards,
Matthias
Re: Part+Visuals [message #1802126 is a reply to message #1802119] Fri, 01 February 2019 15:32 Go to previous messageGo to next message
João Pedro is currently offline João PedroFriend
Messages: 52
Registered: December 2014
Member
Frank Benoit, would you be kind enough to share part of your code? I'm trying to group 2 visuals (which then will be part of the parent Part) and I'm having difficulties understanding what to do.

Thanks ;)
Re: Part+Visuals [message #1802276 is a reply to message #1802126] Tue, 05 February 2019 17:50 Go to previous messageGo to next message
João Pedro is currently offline João PedroFriend
Messages: 52
Registered: December 2014
Member
@Matthias In this case, what shall one do with the doCreateVisual() function?

@Override
	protected Group doCreateVisual() {
		// the visual is just a container for our child visuals (model and io of the models)
		return new Group();
	}
Re: Part+Visuals [message #1802905 is a reply to message #1802276] Mon, 18 February 2019 18:55 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Joao,

the implementation of doCreateVisual() that you have given does look fine to me.

However, when your parent part should have children, then you need to implement doAddChildVisual() and doRemoveChildVisual() with logic similar to group.getChildren.add(...) and .remove(...). If you want to be able to create/delete via default CreationPolicy and DeletionPolicy, then you also need to implement doAddContentChild() and doRemoveContentChild(), respectively.

Moreover, the part needs to announce its content children via doGetContentChildren() so that controllers for these will be created during content-sync (same with anchorages, doAttachToAnchorageVisual(), doAttachToContentAnchorage(), etc.).

However, if you just want to have a complex visual that does not need to be split w.r.t. its controller(s), then you can simply create a complex visual with a single controller (part).

h2h,
Matthias
Previous Topic:Need guidance porting connection router from Zest 1.7 to current
Next Topic:Selection Behaviour of edges
Goto Forum:
  


Current Time: Fri Sep 24 19:37:44 GMT 2021

Powered by FUDForum. Page generated in 0.02464 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top