Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem with picture using plugin
Problem with picture using plugin [message #161284] Sat, 11 December 2004 05:09 Go to next message
Eclipse UserFriend
Originally posted by: pengfai81.mail.yahoo.com

hello, i'm beginner of java eclipse tools. Currentl i am using in this
tool.I have a problem of inserting pictures using this function as below:

InputStream in = getClass().getResourceAsStream("map.gif");
Label nodeLabel1 = new Label("Node4", new
Image(getViewSite().getShell().getDisplay(), in));
final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
panel.add(nodeFigure1, BorderLayout.CENTER);

This is the function that I found but seem like not working. Do you have
other suggestion in term to insert pictures? Thanks...
Re: Problem with picture using plugin [message #161364 is a reply to message #161284] Mon, 13 December 2004 16:08 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Are you adding the label to nodeFigure1 somewhere? What is NodeFigure's
layout?

"Michael" <pengfai81@mail.yahoo.com> wrote in message
news:cpdve2$ivf$1@www.eclipse.org...
> hello, i'm beginner of java eclipse tools. Currentl i am using in this
> tool.I have a problem of inserting pictures using this function as below:
>
> InputStream in = getClass().getResourceAsStream("map.gif");
> Label nodeLabel1 = new Label("Node4", new
> Image(getViewSite().getShell().getDisplay(), in));
> final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
> panel.add(nodeFigure1, BorderLayout.CENTER);
>
> This is the function that I found but seem like not working. Do you have
> other suggestion in term to insert pictures? Thanks...
>
>
>
Re: Problem with picture using plugin [message #161496 is a reply to message #161364] Tue, 14 December 2004 04:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pengfai81.mail.yahoo.com

Pratik Shah wrote:

> Are you adding the label to nodeFigure1 somewhere? What is NodeFigure's
> layout?

> "Michael" <pengfai81@mail.yahoo.com> wrote in message
> news:cpdve2$ivf$1@www.eclipse.org...
>> hello, i'm beginner of java eclipse tools. Currentl i am using in this
>> tool.I have a problem of inserting pictures using this function as below:
>>
>> InputStream in = getClass().getResourceAsStream("map.gif");
>> Label nodeLabel1 = new Label("Node4", new
>> Image(getViewSite().getShell().getDisplay(), in));
>> final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
>> panel.add(nodeFigure1, BorderLayout.CENTER);
>>
>> This is the function that I found but seem like not working. Do you have
>> other suggestion in term to insert pictures? Thanks...
>>
Here is the NodeFigure's code ...

public class NodeFigure extends Figure {

public NodeFigure(Label name) {
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
layout.setStretchMinorAxis(false);
layout.setSpacing(2);
setLayoutManager(layout);
add(name);
}
}

thanks in advance ...
Re: Problem with picture using plugin [message #161502 is a reply to message #161496] Tue, 14 December 2004 17:05 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Try setting some text on the label (or maybe a LineBorder) and see if it's
visible. Maybe the problem is with loading the image.

"Jack" <pengfai81@mail.yahoo.com> wrote in message
news:cplp7a$qo9$1@www.eclipse.org...
> Pratik Shah wrote:
>
> > Are you adding the label to nodeFigure1 somewhere? What is NodeFigure's
> > layout?
>
> > "Michael" <pengfai81@mail.yahoo.com> wrote in message
> > news:cpdve2$ivf$1@www.eclipse.org...
> >> hello, i'm beginner of java eclipse tools. Currentl i am using in this
> >> tool.I have a problem of inserting pictures using this function as
below:
> >>
> >> InputStream in = getClass().getResourceAsStream("map.gif");
> >> Label nodeLabel1 = new Label("Node4", new
> >> Image(getViewSite().getShell().getDisplay(), in));
> >> final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
> >> panel.add(nodeFigure1, BorderLayout.CENTER);
> >>
> >> This is the function that I found but seem like not working. Do you
have
> >> other suggestion in term to insert pictures? Thanks...
> >>
> Here is the NodeFigure's code ...
>
> public class NodeFigure extends Figure {
>
> public NodeFigure(Label name) {
> ToolbarLayout layout = new ToolbarLayout();
> layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
> layout.setStretchMinorAxis(false);
> layout.setSpacing(2);
> setLayoutManager(layout);
> add(name);
> }
> }
>
> thanks in advance ...
>
>
Re: Problem with picture using plugin [message #161534 is a reply to message #161502] Wed, 15 December 2004 07:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pengfai81.mail.yahoo.com

Pratik Shah wrote:

> Try setting some text on the label (or maybe a LineBorder) and see if it's
> visible. Maybe the problem is with loading the image.

>>I tried it before ...And the text label is visible. But,the problems occured
when loading the picture. Any suggestion instead of the code i have written
before?
Re: Problem with picture using plugin [message #161698 is a reply to message #161534] Wed, 15 December 2004 21:59 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
I'm assuming that the image is not blank or transparent and that you're
properly loading it (you might want to double-check that by using an image
that already exists elsewhere in the workbench).

What do you see? Do you see space allocated for the Image? Can you please
attach a screenshot (with a red LineBorder around the label)?

Keep in mind that you have a ToolbarLayout located centrally inside a
BorderLayout. So, if the ToolbarLayout doesn't get enough height, part of
it will be hidden. Make the panel larger to see if it reveals anything.
What layout does it have?

"Jack" <pengfai81@mail.yahoo.com> wrote in message
news:cpopc9$khn$1@www.eclipse.org...
> Pratik Shah wrote:
>
> > Try setting some text on the label (or maybe a LineBorder) and see if
it's
> > visible. Maybe the problem is with loading the image.
>
> >>I tried it before ...And the text label is visible. But,the problems
occured
> when loading the picture. Any suggestion instead of the code i have
written
> before?
>
>
>
Re: Problem with picture using plugin [message #162535 is a reply to message #161698] Wed, 22 December 2004 08:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pengfai81.mail.yahoo.com

I am not clear abt why my application window can display the .gif picture
but not to plugin project.Is that different mechanism to implement it?
The node text alone is visible but if i include with image together, the
error "An error has occurred when creating this view" came out when
running the pugin project.

plugin code:
InputStream in = getClass().getResourceAsStream("map.gif");
Label nodeLabel1 = new Label("Node4", new
Image(getViewSite().getShell().getDisplay(), in));
final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
panel.add(nodeFigure1, BorderLayout.CENTER);

I get stucked here.Or i calling the wrong image method..
Thanks...
Re: Problem with picture using plugin [message #162704 is a reply to message #162535] Thu, 23 December 2004 19:21 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Probably. Look at what exception is logged in the error log. That will
tell you what the problem is.

Try creating your Image like this and see if that works:

Image img = new Image(null, ImageDescriptor.createFromFile(getClass(),
"map.gif").getImageData());

This is assuming that the file map.gif is in the same package as the class
which invokes the above code.

"Jack" <pengfai81@mail.yahoo.com> wrote in message
news:cqbajn$n29$1@www.eclipse.org...
> I am not clear abt why my application window can display the .gif picture
> but not to plugin project.Is that different mechanism to implement it?
> The node text alone is visible but if i include with image together, the
> error "An error has occurred when creating this view" came out when
> running the pugin project.
>
> plugin code:
> InputStream in = getClass().getResourceAsStream("map.gif");
> Label nodeLabel1 = new Label("Node4", new
> Image(getViewSite().getShell().getDisplay(), in));
> final NodeFigure nodeFigure1 = new NodeFigure(nodeLabel1);
> panel.add(nodeFigure1, BorderLayout.CENTER);
>
> I get stucked here.Or i calling the wrong image method..
> Thanks...
>
>
>
>
>
Re: Problem with picture using plugin [message #162755 is a reply to message #162704] Mon, 27 December 2004 05:27 Go to previous message
Eclipse UserFriend
Originally posted by: pengfai81.mail.yahoo.com

thanks ,it solved the problem ...
:)
Previous Topic:When getCreateCommand() will be called?
Next Topic:Selection in outline view and editor
Goto Forum:
  


Current Time: Fri Apr 19 09:38:48 GMT 2024

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

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

Back to the top