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 |
|
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 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
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 #1014245 is a reply to message #1013898] |
Mon, 25 February 2013 12:39 |
Thomas Schindl Messages: 6651 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 #1014256 is a reply to message #1014253] |
Mon, 25 February 2013 13:09 |
|
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
|
|
| | | |
Re: Images in tables sometimes cropped to 16px [message #1014682 is a reply to message #1014656] |
Tue, 26 February 2013 09:18 |
|
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
|
|
| | |
Goto Forum:
Current Time: Wed Sep 25 14:03:24 GMT 2024
Powered by FUDForum. Page generated in 0.10149 seconds
|