Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » 1. image on a button; 2. SVG support in RAP?
1. image on a button; 2. SVG support in RAP? [message #46661] Wed, 12 September 2007 14:25 Go to next message
Eclipse UserFriend
Originally posted by: s5824917.inf.tu-dresden.de

Hi folks,

1. question:

I got a little RAP-HelloWorld application to run. Now I am trying to set an
image on a button.
I tried the following:

Image img = org.eclipse.rwt.graphics.Graphics.getImage("info.gif");
button2.setImage(img);
but the image doesn't show up, actually I get

"Unable to create view: Argument not valid
Image 'info.gif' cannot be found"

So the image can not be found, but I read the InputStream that is being used
here searches the classpath...

"Note: This method searchs the classpath of the current web-application"
InputStream getResourceAsStream( String name );

Structure and position of the image: (so you can see where I put the
info.gif file)

RAPHelloWorld
/ src
/ src / org.eclipse.rap.hellworld
/...
/icons
/META-INF
/info.gif

Can someone help a newbie like me to get this to work?



2. question:

Is it possible to use other objects inside the views too, like SVG or
external Javascript?
So that I could build two views in a perspective, one view with the
SVG-image and one
with options to manipulate said SVG-image.

how hard would it be to accomplish that?
Re: 1. image on a button; 2. SVG support in RAP? [message #46765 is a reply to message #46661] Wed, 12 September 2007 15:26 Go to previous messageGo to next message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 237
Registered: July 2009
Senior Member
Hi Stefan,

you'll find my answers below...

Stefan Lindner wrote:
> Hi folks,
>
> 1. question:
>
> I got a little RAP-HelloWorld application to run. Now I am trying to set an
> image on a button.
> I tried the following:
>
> Image img = org.eclipse.rwt.graphics.Graphics.getImage("info.gif");
> button2.setImage(img);
> but the image doesn't show up, actually I get
> <snip>

You just need to put your image into a package like src/resources and
then pass the image name and the current classloader to the image like this:

Image img = Graphics.getImage("info.gif", getClass().getClassLoader());

>
>
> 2. question:
>
> Is it possible to use other objects inside the views too, like SVG or
> external Javascript?
> So that I could build two views in a perspective, one view with the
> SVG-image and one
> with options to manipulate said SVG-image.
>
> how hard would it be to accomplish that?
>

Neither RAP nor Qooxdoo support SVG images at the moment (maybe they
never will as there is no API in SWT for that use case). But...

You can create a little custom widget which generates the corresponding
dom node for you (<svg> in FF, <object> in IE if you have the SVG
plugin). This should be straight forward if i didn't forgot something ;)

Hope that helps. Don't hesitate to ask here if you've problems regarding
your custom widget :)

Cheers
Benny
Re: 1. image on a button; 2. SVG support in RAP? [message #46818 is a reply to message #46765] Wed, 12 September 2007 15:54 Go to previous messageGo to next message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 237
Registered: July 2009
Senior Member
Benjamin Muskalla wrote:
> Hi Stefan,
>
> you'll find my answers below...
>
> Stefan Lindner wrote:
>> Hi folks,
>>
>> 1. question:
>>
>> I got a little RAP-HelloWorld application to run. Now I am trying to
>> set an image on a button.
>> I tried the following:
>>
>> Image img = org.eclipse.rwt.graphics.Graphics.getImage("info.gif");
>> button2.setImage(img);
>> but the image doesn't show up, actually I get
>> <snip>
>
> You just need to put your image into a package like src/resources and
> then pass the image name and the current classloader to the image like
> this:
>
> Image img = Graphics.getImage("info.gif", getClass().getClassLoader());
Sorry - typo :)
Image img = Graphics.getImage("resources/info.gif",
getClass().getClassLoader());

>
>>
>>
>> 2. question:
>>
>> Is it possible to use other objects inside the views too, like SVG or
>> external Javascript?
>> So that I could build two views in a perspective, one view with the
>> SVG-image and one
>> with options to manipulate said SVG-image.
>>
>> how hard would it be to accomplish that?
>>
>
> Neither RAP nor Qooxdoo support SVG images at the moment (maybe they
> never will as there is no API in SWT for that use case). But...
>
> You can create a little custom widget which generates the corresponding
> dom node for you (<svg> in FF, <object> in IE if you have the SVG
> plugin). This should be straight forward if i didn't forgot something ;)
>
> Hope that helps. Don't hesitate to ask here if you've problems regarding
> your custom widget :)
>
> Cheers
> Benny
Re: 1. image on a button; 2. SVG support in RAP? [message #48666 is a reply to message #46818] Fri, 21 September 2007 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ingo.kaulbach.bayerbbs.com

Is there an other, easier, way to load the Image?
I am not familar with the ClassLoader-Stuff...
Re: 1. image on a button; 2. SVG support in RAP? [message #48782 is a reply to message #48666] Fri, 21 September 2007 14:53 Go to previous message
Eclipse UserFriend
Originally posted by: jkrause.innoopract.com

It is just those two lines of code, you don't need to know anything
about classloaders:

ClassLoader imageLoader = getClass().getClassLoader();
Image image1 = Graphics.getImage( "icons/info.gif", imageLoader );

And you need to put the image either on the source path, or, like in
this example in the icons folder of the plugin.

Ingo Kaulbach wrote:
> Is there an other, easier, way to load the Image?
> I am not familar with the ClassLoader-Stuff...
>
Previous Topic:workbench problem
Next Topic:1.0 will need to be delayed for a couple of days for process reasons
Goto Forum:
  


Current Time: Fri Dec 13 00:26:41 GMT 2024

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

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

Back to the top