Thumbnail painting [message #188422] |
Wed, 20 July 2005 16:11 |
Eclipse User |
|
|
|
Originally posted by: cheato.gmail.com
I have been messing with the overview code from the logic example, and I
want to get an SWT image from the thumbnail used in the LWS. I can get the
root figure to be painted to an image just fine, but when I try to do the
same for the thumbnail (since it is a small size and what I need), I just
get a white image. I debugged and found out that the thumbnail does not
get painted from its source on the LWS canvas until later when it listens
for the control being resized event. Is it possible to get the thumbnail
to be painted to a specified size on creation, so that it can be put into
an image? This is the code I was looking at:
protected void initializeOverview() {
LightweightSystem lws = new LightweightSystem(overview);
RootEditPart rep = getGraphicalViewer().getRootEditPart();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root =
(ScalableFreeformRootEditPart)rep;
thumbnail = new ScrollableThumbnail((Viewport)root.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_L AYERS));
lws.setContents(thumbnail);
...
}
...
}
Basically after setting the source, I want it to paint to the LWS canvas,
but I can't get it to update. Any ideas?
|
|
|
Re: Thumbnail painting [message #188454 is a reply to message #188422] |
Wed, 20 July 2005 17:46 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
If you are tring to paint a bunch of figures to an Image, you don't need to
use the Thumbnail figure. Just create an Image, a GC, an SWTGraphics, then
scale and paint. It's like 6 lines of code that have been posted numerous
times here.
"Mark Cheatham" <cheato@gmail.com> wrote in message
news:6c8f5e4c7b1cf97bf62ca020cf6af737$1@www.eclipse.org...
>I have been messing with the overview code from the logic example, and I
>want to get an SWT image from the thumbnail used in the LWS. I can get the
>root figure to be painted to an image just fine, but when I try to do the
>same for the thumbnail (since it is a small size and what I need), I just
>get a white image. I debugged and found out that the thumbnail does not get
>painted from its source on the LWS canvas until later when it listens for
>the control being resized event. Is it possible to get the thumbnail to be
>painted to a specified size on creation, so that it can be put into an
>image? This is the code I was looking at:
>
> protected void initializeOverview() {
> LightweightSystem lws = new LightweightSystem(overview);
> RootEditPart rep = getGraphicalViewer().getRootEditPart();
> if (rep instanceof ScalableFreeformRootEditPart) {
> ScalableFreeformRootEditPart root =
> (ScalableFreeformRootEditPart)rep;
> thumbnail = new ScrollableThumbnail((Viewport)root.getFigure());
> thumbnail.setBorder(new MarginBorder(3));
>
> thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_L AYERS));
> lws.setContents(thumbnail);
> ...
> }
> ..
> }
>
> Basically after setting the source, I want it to paint to the LWS canvas,
> but I can't get it to update. Any ideas?
>
|
|
|
Re: Thumbnail painting [message #188466 is a reply to message #188454] |
Wed, 20 July 2005 18:04 |
Eclipse User |
|
|
|
Originally posted by: cheato.gmail.com
>>I can get the root figure to be painted to an image just fine
I am trying to use a thumbnail figure because creating multiple ~700x500
images is VERY slow, and I have a custom selection box that the
thumbnail figure doesn't show. Unfortunately, the root figure does.
I'll see if I can do the scaling first before painting.
Randy Hudson wrote:
> If you are tring to paint a bunch of figures to an Image, you don't need to
> use the Thumbnail figure. Just create an Image, a GC, an SWTGraphics, then
> scale and paint. It's like 6 lines of code that have been posted numerous
> times here.
>
> "Mark Cheatham" <cheato@gmail.com> wrote in message
> news:6c8f5e4c7b1cf97bf62ca020cf6af737$1@www.eclipse.org...
>
>>I have been messing with the overview code from the logic example, and I
>>want to get an SWT image from the thumbnail used in the LWS. I can get the
>>root figure to be painted to an image just fine, but when I try to do the
>>same for the thumbnail (since it is a small size and what I need), I just
>>get a white image. I debugged and found out that the thumbnail does not get
>>painted from its source on the LWS canvas until later when it listens for
>>the control being resized event. Is it possible to get the thumbnail to be
>>painted to a specified size on creation, so that it can be put into an
>>image? This is the code I was looking at:
>>
>>protected void initializeOverview() {
>>LightweightSystem lws = new LightweightSystem(overview);
>>RootEditPart rep = getGraphicalViewer().getRootEditPart();
>>if (rep instanceof ScalableFreeformRootEditPart) {
>>ScalableFreeformRootEditPart root =
>>(ScalableFreeformRootEditPart)rep;
>>thumbnail = new ScrollableThumbnail((Viewport)root.getFigure());
>>thumbnail.setBorder(new MarginBorder(3));
>>
>> thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_L AYERS));
>>lws.setContents(thumbnail);
>> ...
>> }
>>..
>>}
>>
>>Basically after setting the source, I want it to paint to the LWS canvas,
>>but I can't get it to update. Any ideas?
>>
>
>
>
|
|
|
Re: Thumbnail painting [message #188471 is a reply to message #188466] |
Wed, 20 July 2005 18:43 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
> >>I can get the root figure to be painted to an image just fine
>
> I am trying to use a thumbnail figure because creating multiple ~700x500
Reuse the image?
> images is VERY slow, and I have a custom selection box that the thumbnail
> figure doesn't show. Unfortunately, the root figure does.
Paint starting at some figure lower than the root, just like thumbnail does.
>
> I'll see if I can do the scaling first before painting.
|
|
|
Powered by
FUDForum. Page generated in 0.04142 seconds