Hacking on GraphHopper - a Java road routing engine. Peter has posted 62 posts at DZone. You can read more from them at their website. View Full User Profile

Scaled Linked Image in Vaadin

05.31.2010
| 9483 views |
  • submit to reddit

In vaadin you can easily embed images either via:

Embedded logoEmbed = new Embedded("yourText",new ThemeResource("../yourtheme/img/logo.png"));
logoEmbed.setType(Embedded.TYPE_IMAGE);

or if you need a linked image do the following:

Link iconLink = new Link();
iconLink.setIcon(new ExternalResource(urlAsString));
iconLink.setResource(new ThemeResource("../yourtheme/img/logo.png"));

But how can you scale that external image? This is simple if you let the browser do it for you. In Java do:

iconLink.setStyleName("mylogo");

and then you will need to change the following style in your custom style.css to your needs:

.mylogo a img { width: 67px; 

From http://karussell.wordpress.com/2010/05/31/scaled-linked-image-in-vaadin/

0
Your rating: None
Published at DZone with permission of its author, Peter Karussell.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: