|
|
|
Re: Problems with Thumbnail [message #133913 is a reply to message #133616] |
Mon, 24 May 2004 14:59   |
Eclipse User |
|
|
|
> 1) When the editor comes up the correct Icon is not shown in the palette
> entry until I hover the mouse cursor over the corresponding entry, until
> that only a white square is shown. See attached Fig1.jpg.
There are certain triggers (repainting of the original figure might be
one....you can look at Thumbnail and figure it out) that cause the thumbnail
to update. My conjecture is that no such trigger is fired once the
Thumbnail is created, and hence the image is not yet painted upon. You can
simply try invoking thumbnail.repaint() once it is created, or you can
manually set off one of those triggers that would cause the thumbnail to
update.
"Jose M Beleta" <beleta@attglobal.net> wrote in message
news:c8lhta$9k3$1@eclipse.org...
> I want to setp up a palette with Icons representing a small image of a
> Figure. For doing so I use an ImageDescriptor that returns the image built
> by a Thumbnail.
>
> This is the class I wrote:
>
> public class FigureThumbnailImageDescriptor extends ImageDescriptor
> {
> private class MyThumbnail extends Thumbnail
> {
> public MyThumbnail(IFigure figure, int size)
> {
> setSize(size, size);
> if (figure.getFont() == null)
> figure.setFont(JFaceResources.getDefaultFont());
> setSource(figure);
> }
>
> protected IFigure getSource()
> {
> return super.getSource();
> }
>
> protected Image getThumbnailImage()
> {
> return super.getThumbnailImage();
> }
> }
>
> private MyThumbnail thumbnail;
>
> public FigureThumbnailImageDescriptor(IFigure figure, int icon)
> {
> thumbnail = new MyThumbnail(figure, (icon == SMALL_ICON) ? 16 : 24);
> }
>
> public ImageData getImageData()
> {
> return thumbnail.getThumbnailImage().getImageData();
> }
>
> public IFigure getSource()
> {
> return thumbnail.getSource();
> }
>
> public Image createImage(boolean returnMissingImageOnError, Device
device)
> {
> return thumbnail.getThumbnailImage();
> }
> }
>
>
> Things go quite well but I have some very anoying problems:
>
> 1) When the editor comes up the correct Icon is not shown in the palette
> entry until I hover the mouse cursor over the corresponding entry, until
> that only a white square is shown. See attached Fig1.jpg.
>
> 2) The background color of the source figure fills all the image not
simply
> the figure. See attached Fig2.jpg.
>
> 3) If the figure has a null font a NullPointerException is thown.
>
> Any hint to solve at least the first problem.
>
> Thank you in advance
>
> Jose M Beleta
>
>
>
>
|
|
|
Re: Problems with Thumbnail [message #134143 is a reply to message #133913] |
Tue, 25 May 2004 14:58   |
Eclipse User |
|
|
|
Thank you Pratik for your response, but after looking at your code It seems
that your Thumbnail class is clearly intented to setup a dynamic miniature
overview and not to simply make a static image from a IFigure, that was what
I thought after reading the docs.
Now my class looks this way:
public class FigureThumbnailImageDescriptor extends ImageDescriptor
{
private ImageData imageData;
public FigureThumbnailImageDescriptor(IFigure figure, int size)
{
Image thumbnailImage = new Image(Display.getDefault(), size, size);
GC thumbnailGC = new GC(thumbnailImage);
SWTGraphics thumbnailGraphics = new SWTGraphics(thumbnailGC);
thumbnailGraphics.setBackgroundColor(ColorConstants.button);
thumbnailGraphics.fillRectangle(new Rectangle(0, 0, size, size));
int margin = (size - figure.getSize().width) / 2;
thumbnailGraphics.translate(margin, margin);
figure.paint(thumbnailGraphics);
imageData = thumbnailImage.getImageData();
imageData.transparentPixel = imageData.getPixel(0, 0);
thumbnailGraphics.dispose();
thumbnailGC.dispose();
}
public ImageData getImageData()
{
return imageData;
}
}
By the way calling: image.setBackground(someValue) on the image created from
the descriptor throws an java.lang.ArrayIndexOutOfBoundsException because
the transparent pixel.
Best regards,
Jose M Beleta
"Pratik Shah" <ppshah@us.ibm.com> escribi
|
|
|
Re: Problems with Thumbnail [message #134194 is a reply to message #134143] |
Tue, 25 May 2004 16:53  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Jose M Beleta" <beleta@attglobal.net> wrote in message
news:c904is$dgo$1@eclipse.org...
> Thank you Pratik for your response, but after looking at your code It
seems
> that your Thumbnail class is clearly intented to setup a dynamic miniature
> overview and not to simply make a static image from a IFigure, that was
what
Good point. You should probably just create your own ScaledGraphics and
paint directly onto an Image rather than reusing a figure which isn't even
in a lightweight system. Feel free to open enhancement bugzillas if you
have utility suggestions.
|
|
|
Powered by
FUDForum. Page generated in 0.05833 seconds