Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Images in tables sometimes cropped to 16px
Images in tables sometimes cropped to 16px [message #1013031] Fri, 22 February 2013 16:25 Go to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
Hi!

I have a problem with setting images (100px wide) in table items (with setImage(index, image)). I have the issue that in some cases it works, and in some it doesn't.

I traced the problem using chromes tools to the point where the information about the GridItem is transfered. the message looks something like this

images: 
0: null
1: null
2: null
3: [rwt-resources/generated/11c1dc7.png, 16, 16]
4: null
5: null
6: null
7: null
8: null
9: null
10: null
11: null
12: null
13: null
14: [rwt-resources/generated/766a45a3.png, 100, 18]


as you can see the 100px is transfered to the client. however looking at the client property handler for the images property:

"images" : function( widget, value ) {
      var images = [];
      for( var i = 0; i < value.length; i++ ) {
        if( value[ i ] === null ) {
          images[ i ] = null;
        } else {
          images[ i ] = value[ i ][ 0 ];
        }
      }
      widget.setImages( images );
    },


it extracts the image paths, and sets them; however sizing information is not set at all. also there is no itemMetrics message coming around, so nobody that would tell it to set the sizes afterwards.

any ideas? am i doing something wrong? i have kind of a master/detail table - selecting a row in the master table (showing the image correctly) causes display of detail data in another table - displaying the same image, but with wrong size.
Re: Images in tables sometimes cropped to 16px [message #1013898 is a reply to message #1013031] Sun, 24 February 2013 16:36 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1839
Registered: July 2009
Senior Member
Hi Markus,
it's a know limitation of the Tree/Table/Grid (same in SWT) where the
image size in the items *must* be the same. The image size is determined
from the first image set on the Table. In your case, this is the
image[3] with size 16x16... all other images will be cropped to that size.
HTH,
Ivan

On 2/22/2013 6:25 PM, Markus Duft wrote:
> Hi!
>
> I have a problem with setting images (100px wide) in table items (with
> setImage(index, image)). I have the issue that in some cases it works,
> and in some it doesn't.
>
> I traced the problem using chromes tools to the point where the
> information about the GridItem is transfered. the message looks
> something like this
>
>
> images: 0: null
> 1: null
> 2: null
> 3: [rwt-resources/generated/11c1dc7.png, 16, 16]
> 4: null
> 5: null
> 6: null
> 7: null
> 8: null
> 9: null
> 10: null
> 11: null
> 12: null
> 13: null
> 14: [rwt-resources/generated/766a45a3.png, 100, 18]
>
>
> as you can see the 100px is transfered to the client. however looking
> at the client property handler for the images property:
>
>
> "images" : function( widget, value ) {
> var images = [];
> for( var i = 0; i < value.length; i++ ) {
> if( value[ i ] === null ) {
> images[ i ] = null;
> } else {
> images[ i ] = value[ i ][ 0 ];
> }
> }
> widget.setImages( images );
> },
>
>
> it extracts the image paths, and sets them; however sizing information
> is not set at all. also there is no itemMetrics message coming around,
> so nobody that would tell it to set the sizes afterwards.
>
> any ideas? am i doing something wrong? i have kind of a master/detail
> table - selecting a row in the master table (showing the image
> correctly) causes display of detail data in another table - displaying
> the same image, but with wrong size.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Images in tables sometimes cropped to 16px [message #1014167 is a reply to message #1013898] Mon, 25 February 2013 09:34 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
damn, any chance to get this fixed? or is there a quick workaround? i'm also ok with javascripting Very Happy
Re: Images in tables sometimes cropped to 16px [message #1014200 is a reply to message #1014167] Mon, 25 February 2013 10:56 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1839
Registered: July 2009
Senior Member
Hi Markus,
probably you could workaround it by enabling the markup support and set
your text (with image) as markup.
Best,
Ivan

On 2/25/2013 11:34 AM, Markus Duft wrote:
> damn, any chance to get this fixed? or is there a quick workaround?
> i'm also ok with javascripting :d

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Images in tables sometimes cropped to 16px [message #1014245 is a reply to message #1013898] Mon, 25 February 2013 12:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Do you really mean cropped? In (Desktop) SWT all images are *resized* to
the initial image size.

Tom

Am 24.02.13 17:36, schrieb Ivan Furnadjiev:
> Hi Markus,
> it's a know limitation of the Tree/Table/Grid (same in SWT) where the
> image size in the items *must* be the same. The image size is determined
> from the first image set on the Table. In your case, this is the
> image[3] with size 16x16... all other images will be cropped to that size.
> HTH,
> Ivan
>
> On 2/22/2013 6:25 PM, Markus Duft wrote:
>> Hi!
>>
>> I have a problem with setting images (100px wide) in table items (with
>> setImage(index, image)). I have the issue that in some cases it works,
>> and in some it doesn't.
>>
>> I traced the problem using chromes tools to the point where the
>> information about the GridItem is transfered. the message looks
>> something like this
>>
>>
>> images: 0: null
>> 1: null
>> 2: null
>> 3: [rwt-resources/generated/11c1dc7.png, 16, 16]
>> 4: null
>> 5: null
>> 6: null
>> 7: null
>> 8: null
>> 9: null
>> 10: null
>> 11: null
>> 12: null
>> 13: null
>> 14: [rwt-resources/generated/766a45a3.png, 100, 18]
>>
>>
>> as you can see the 100px is transfered to the client. however looking
>> at the client property handler for the images property:
>>
>>
>> "images" : function( widget, value ) {
>> var images = [];
>> for( var i = 0; i < value.length; i++ ) {
>> if( value[ i ] === null ) {
>> images[ i ] = null;
>> } else {
>> images[ i ] = value[ i ][ 0 ];
>> }
>> }
>> widget.setImages( images );
>> },
>>
>>
>> it extracts the image paths, and sets them; however sizing information
>> is not set at all. also there is no itemMetrics message coming around,
>> so nobody that would tell it to set the sizes afterwards.
>>
>> any ideas? am i doing something wrong? i have kind of a master/detail
>> table - selecting a row in the master table (showing the image
>> correctly) causes display of detail data in another table - displaying
>> the same image, but with wrong size.
>
Re: Images in tables sometimes cropped to 16px [message #1014251 is a reply to message #1014200] Mon, 25 February 2013 12:56 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
i tried, and it seems that basically it's working. however when i switch on markup support, table items loose all their vertical text alignment Sad
Re: Images in tables sometimes cropped to 16px [message #1014252 is a reply to message #1014251] Mon, 25 February 2013 12:57 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
oh, oversaw your post thomas - and yes, it's cropped in that the /image/ has the correct size but the surrounding container html element is set to a smaller size, ending up in only seeing portions of the image - this however in correct proportions Smile
Re: Images in tables sometimes cropped to 16px [message #1014253 is a reply to message #1014252] Mon, 25 February 2013 12:58 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
actually, maybe to make my problem clearer: i want to draw a progress in the table cell Smile and i want to do it without instanciating progress widgets all over the place if possible.
Re: Images in tables sometimes cropped to 16px [message #1014256 is a reply to message #1014253] Mon, 25 February 2013 13:09 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
hah, i have it, i think. for normal cells i have this:

    private String toSpanHtml(String text) {
        if (!useMarkup)
            return text;

        return "<span style=\"display: table-cell; height: " + table.getItemHeight()
                + "px; vertical-align: middle;\">" + text + "</span>";
    }


and for the progress/gauge, i do this:

String html = toSpanHtml("<img width=\"" + gauge.getBounds().width + "\" height=\""
                        + gauge.getBounds().height + "\" src=\"" + imgUrl + "\"/>")
                        + "<span style=\"display: table-cell; width: "
                        + (col.getWidth() - width - 10)
                        + "px; text-align: right; vertical-align: middle;\">" + perc + "%</span>";


this renders everything correctly Very Happy
Re: Images in tables sometimes cropped to 16px [message #1014270 is a reply to message #1014251] Mon, 25 February 2013 13:25 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1839
Registered: July 2009
Senior Member
Hi Markus,
this issue has been fixed in master - see bug:
373652: [Table][Tree] Vertical cell-padding is not applied correctly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=373652
Best,
Ivan

On 2/25/2013 2:56 PM, Markus Duft wrote:
> i tried, and it seems that basically it's working. however when i
> switch on markup support, table items loose all their vertical text
> alignment :(

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Images in tables sometimes cropped to 16px [message #1014408 is a reply to message #1014270] Mon, 25 February 2013 19:04 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
Ah, thanks for the info. I added a todo in our code to remove the wrapping spans i created once we upgrade rap Wink
Re: Images in tables sometimes cropped to 16px [message #1014656 is a reply to message #1014245] Tue, 26 February 2013 08:22 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

Hi Tom,

On 02/25/2013 01:39 PM, Tom Schindl wrote:
> Do you really mean cropped? In (Desktop) SWT all images are *resized* to
> the initial image size.

not sure if we could do that, however do you think it's worthwhile to
simulate this behavior? It doesn't exactly seem like a feature to me,
correct me if I'm wrong.

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Images in tables sometimes cropped to 16px [message #1014682 is a reply to message #1014656] Tue, 26 February 2013 09:18 Go to previous messageGo to next message
Markus Duft is currently offline Markus Duft
Messages: 135
Registered: February 2013
Senior Member
lol, yeah i also think so. while i'm happy now with the markup style of doing it, i don't see a reason for preventing setImage to work in the way i expected it, especially as all the protocol and APIs in RAP seem already prepared for handling the sizes.

could you also tell me the location where the cropping happens? i'd - just out of curiosity - like to read that code Smile
Re: Images in tables sometimes cropped to 16px [message #1014688 is a reply to message #1014656] Tue, 26 February 2013 09:30 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Hi Ralf,

Yes and no. Naturally you can see it as a feature and bug. Sometimes
people simply rely on the fact to that images are *resized* for them by
the Table/Tree instead of doing it themselves.

I only wanted to correct the statement that images are cropped in SWT
which is simply not correct ;-)

Tom

Am 26.02.13 09:22, schrieb Ralf Sternberg:
> Hi Tom,
>
> On 02/25/2013 01:39 PM, Tom Schindl wrote:
>> Do you really mean cropped? In (Desktop) SWT all images are *resized* to
>> the initial image size.
>
> not sure if we could do that, however do you think it's worthwhile to
> simulate this behavior? It doesn't exactly seem like a feature to me,
> correct me if I'm wrong.
>
> Regards,
> Ralf
>
Re: Images in tables sometimes cropped to 16px [message #1016414 is a reply to message #1014688] Wed, 06 March 2013 11:47 Go to previous message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

Hi Tom,

I just tried again in GTK and yes, images are resized here too. So,
given that it's probably an easy fix, you convinced me that it should be
adjusted in RAP. I've opened bug 402513 [1].

Thanks for pointing out this difference.

Cheers,
Ralf


[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=402513

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Client-side javascript error on session timout
Next Topic:Misaligned Table Column Headers
Goto Forum:
  


Current Time: Sat Oct 25 09:36:06 GMT 2014

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

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