Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » JavaFX Interoperability with e4/swt/osgi
JavaFX Interoperability with e4/swt/osgi [message #1724471] Wed, 24 February 2016 07:02 Go to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
Hey Community.

I have a larger runnig e4 Application and want to use JavaFX inside one Part. The Dream would be something simple like:

public class MyFXPart {

	@PostConstruct
	private void postConstruct(Composite composite) {
		final FXCanvas fxCanvas = new FXCanvas(composite, SWT.NONE);

		//build fx scene here
		
		fxCanvas.setScene(scene);
	}
}


I found the following pieces of the puzzle:

1. Add the access rule: Accessible "javafx/**" under Buildpath/Libraries
2. Add VM Argument -Dorg.osgi.framework.bundle.parent=ext to launch config.
3. Somehow make use of javafx.embed.swt.FXCanvas

When i try to do this ill get errors like :javafx.embed.swt.FXCanvas cannot be found by [my bundle]

I read that there are some problems with osgi and fx and that e(fx)clipse has tools to deal with it. Is there a chance to use some bundles from e(fx)clipse and use them in an e4(swt based) eclispe?

I'm happy for every idea/hint.

Alex

[Updated on: Fri, 26 February 2016 09:25]

Report message to a moderator

Re: JavaFX Interoperability with e4/swt/osgi [message #1724473 is a reply to message #1724471] Wed, 24 February 2016 07:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I wrote a blog post about that a while ago: https://blog.codecentric.de/en/2015/04/add-javafx-controls-swt-eclipse-4-application-eclipse-rcp-cookbook/
Re: JavaFX Interoperability with e4/swt/osgi [message #1724489 is a reply to message #1724471] Wed, 24 February 2016 08:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
a) Install e(fx)clipse tooling this will fix your compile problems in
eclipse
b) Modify your target and add
http://download.eclipse.org/efxclipse/runtime-released/2.2.0/site/ and
select org.eclipse.fx.target.rcp4.feature.feature.group
c) Add the above feature to your launch config

In your code there's no NEED to use FXCanvas you can simply write

public class MyFXPart {
@PostConstruct
private void postConstruct(BorderPane parent) {
// ...
}
}

Tom

On 24.02.16 08:02, Alexander Bunkowski wrote:
> Hey Community.
>
> I have a larger runnig e4 Application and want to use JavaFX inside one
> Part. The Dream would be something simple like:
>
>
> public class MyFXPart {
>
> @PostConstruct
> private void postConstruct(Composite composite) {
> final FXCanvas fxCanvas = new FXCanvas(composite, SWT.NONE);
>
> //build fx scene here
>
> fxCanvas.setScene(scene);
> }
> }
>
>
> I found the following pieces of the puzzle:
>
> 1. Add the access rule: Accessible "javafx/**" under
> Buildpath/Libraries 2. Add VM Argument
> -Dorg.osgi.framework.bundle.parent=ext to launch config.
> 3. Somehow make use of javafx.embed.swt.FXCanvas
>
> When i try to do this ill get errors like :javafx.embed.swt.FXCanvas
> cannot be found by [my bundle]
>
> I read that there are some problems with osgi and fx and that
> e(fx)clipse has tools to deal with it. Is there a chance to use some
> bundles from e(fx)clipse and use them in an e4(swt based) eclispe?
>
> I'm happy for every idea/hint.
>
> Alex
>
>
>
>
>
>
>
>
>
>
>
Re: JavaFX Interoperability with e4/swt/osgi [message #1725178 is a reply to message #1724489] Tue, 01 March 2016 12:02 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
Thx! Works really well.

I only got one major problem yet with mouse location and zooming.
I followed examples from the link below (PannableCanvas or AnimatedZoomOperator) but it only works precisely if the view is maximized. Otherwise the zoom in and out locations are always a bit off. Any idea what's the difference there between "native" fx panes and the eclipse integrated ones?

http://stackoverflow.com/questions/29506156/javafx-8-zooming-relative-to-mouse-pointer


Re: JavaFX Interoperability with e4/swt/osgi [message #1725181 is a reply to message #1725178] Tue, 01 March 2016 12:29 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Not really.

The e(fx)clipse interop function does nothing more than createing an
FXCanvas on the basic SWT-Composite provided for each view.

http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.ui.di.interopt/src/org/eclipse/fx/ui/di/interopt/InteroptContextFunction.java

SWT<=>FX-Bridge works in the way that javafx is drawn offscreen, the
framebuffer is grabbed from your graphics card, gets translated into a
SWT-Image and drawn. On the other hand SWT-Events are grabbed and
forwarded to your offscreen JavaFX component.

The only reason i can think this is happening is because swt uses int
coords and javafx double but I doubt that events provided by the system
are really doubles.

Tom

On 01.03.16 13:02, Alexander Bunkowski wrote:
> Thx! Works really well.
> I only got one major problem yet with mouse location and zooming. I
> followed examples from the link below (PannableCanvas or
> AnimatedZoomOperator) but it only works precisely if the view is
> maximized. Otherwise the zoom in and out locations are always a bit off.
> Any idea what's the difference there between "native" fx panes and the
> eclipse integrated ones?
>
> http://stackoverflow.com/questions/29506156/javafx-8-zooming-relative-to-mouse-pointer
>
>
>
>
Re: JavaFX Interoperability with e4/swt/osgi [message #1726308 is a reply to message #1725181] Fri, 11 March 2016 09:40 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
Sometimes the background pane becomes black and can only be fixed by resizing the ui.
Any known issues or hints for such behaviour? Seems to occur when the client runs a while in
background an gets reactivated.
Re: JavaFX Interoperability with e4/swt/osgi [message #1726327 is a reply to message #1726308] Fri, 11 March 2016 13:29 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I think there was a (or maybe more) GPU acceleration issue and could be worked around by using the software renderer instead (if you do not have performance problems using the software renderer):

-Dprism.order=j2d



Alexander Bunkowski wrote on Fri, 11 March 2016 10:40
Sometimes the background pane becomes black and can only be fixed by resizing the ui.
Any known issues or hints for such behaviour? Seems to occur when the client runs a while in
background an gets reactivated.

Re: JavaFX Interoperability with e4/swt/osgi [message #1727069 is a reply to message #1726327] Fri, 18 March 2016 14:51 Go to previous message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
Thx, no longer have problems with black panes.

Anyone else tried zooming inside an FXCanvas? I still have problems with it.
If the part is maximized within eclipse the zooming is only off by a nearly
unrecognisable shift. But when I use the part together with other parts
in a perspective the shift is a few centimetres, depending on the size
and position of the part.

(I tried PannableCanvas and AnimatedZoomOperator from here:
http://stackoverflow.com/questions/29506156/javafx-8-zooming-relative-to-mouse-pointer)
Previous Topic:Karel Screen Shots
Next Topic:Presenting an MPart in a dialog
Goto Forum:
  


Current Time: Fri Apr 19 00:36:45 GMT 2024

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

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

Back to the top