|
Re: Problems with Thumbnail [message #133634 is a reply to message #133616] |
Fri, 21 May 2004 20:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: none.us.ibm.com
Some figure have to have a font obviously. If you don't put them in a
canvas, they won't have one because they won't inherit it from their parent
chain.
You can set the font to avoid having to put them in a canvas.
"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 #133913 is a reply to message #133616] |
Mon, 24 May 2004 18:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Pratik Shah![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ppshah%40us.ibm.com) Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
> 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 18:58 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Jose M Beleta![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=jose%40beleta.net) Messages: 70 Registered: July 2009 |
Member |
|
|
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 20:53 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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.03633 seconds