Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ViewportPolicy fitToSize method reloads css
ViewportPolicy fitToSize method reloads css [message #1795644] Wed, 26 September 2018 11:27 Go to next message
Shenwei Zheng is currently offline Shenwei ZhengFriend
Messages: 22
Registered: December 2016
Junior Member
The method fitToSize in ViewportPolicy in my case is aimed to place the view in the center without zooming and it indeed works fine.
ViewportPolicy viewportPolicy = viewer.getRootPart().getAdapter(ViewportPolicy.class);
viewportPolicy.init();
viewportPolicy.fitToSize(1, 1);
ITransactionalOperation commit = viewportPolicy.commit();
try
{
  viewer.getDomain().execute(commit, null);
}
catch (ExecutionException e)
{
  e.printStackTrace();
}

But I noticed a side effect: it seems the styling for javafx.scene.text.Text node is reloaded. I have the following style definition for Text.
.text{
	-fx-font-family: 'Roboto';
	-fx-font-size: 14.0;	
	-fx-text-alignment: center;
}

I have registered a listener on the width property of its parent (Region) to handle something when the text is changed. The listener is triggered twice during the fitTosize without changing any text. For example, the width of text "Karlsruhe HBF" is changed: 89.23 -> 73.81 -> 89.23.
I guess the styling for Text is first set to default and then set to my defintion again. Is it true? This behavior is not desired since the listener is triggered twice for nothing. Is there other way to place the view in the middle? Thank you in Advance.

Best regards
Shenwei Zheng
Re: ViewportPolicy fitToSize method reloads css [message #1802134 is a reply to message #1795644] Fri, 01 February 2019 17:37 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Shenwei,

thank you for reporting this behavior. I am not currently aware of the logic w.r.t. width changes. It would be interesting to see what happens if CSS is not applied.

However, you can always disable listeners, perform changes, and enable listeners again (+ manual execution of work depending on the performed changes). Thus solving the performance aspect of this issue.

There are alternatives for centering contents, for example, ScrollCenterAction [1] provided by GEF for integration into Eclipse UI. Unfortunately, you would need to copy the logic for a standalone application.

[1] https://github.com/eclipse/gef/blob/5135440577a6c3381e139591b3dd88dd79c43871/org.eclipse.gef.mvc.fx.ui/src/org/eclipse/gef/mvc/fx/ui/actions/ScrollCenterAction.java#L31

Best regards,
Matthias
Previous Topic:How can i set the initial zoom factor to the InfiniteCanvas?
Next Topic:GEF5 And Drag And Drop
Goto Forum:
  


Current Time: Sun Sep 19 22:33:00 GMT 2021

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

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

Back to the top