hmm wheres the page where you create the image?

please see this : http://www.wicket-library.com/wicket-examples/images/

Manuel Corrales wrote:
Hey, great!! But still having issues, sorry to bother you again. Now i added
the svg to the page, but the browser do not display it. The image is there,
because when i right click the broken image that is displayed by the broser
and press save as, i can save the svg and is good. Should my html tag be
different, or should i set something else on my code:

    ....
    private byte[] image;

    public JFreeChartImage(String id, JFreeChart chart, int width, int
height) {
        setFormat("svg");
        try {
            this.width = width;
            this.height = height;
            this.chart = chart;
            DOMImplementation domImpl = GenericDOMImplementation
                    .getDOMImplementation();
            Document document = domImpl.createDocument(null, "svg", null);
            SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
            chart.draw(svgGenerator,
                    new Rectangle2D.Double(0, 0, 1024, 768), null);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Writer svgOutput;
            svgOutput = new OutputStreamWriter(baos, "UTF-8");
            svgGenerator.stream(svgOutput, true);
            image = baos.toByteArray();
        } catch (Exception e) {
            image = new byte[0];
        }
    }

    @Override
    protected byte[] getImageData() {
        return image;
    }


and the html:

<img class="centrada" wicket:id="image" />

Thank you very much!!

On Sun, Jun 29, 2008 at 4:35 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

instantiate a wicket image, with the resource.. It will not change the
format.. Just set the format to svg..


Manuel Corrales wrote:

Thanks, but still dont get it. I did that, but now how can i add this
image
to a page? The add method on page does not accept this
DynamicImageResource.
Also, this will render the svg directly to the page? Or will transform it
to
other format? (the documentation on DynamicImageResource only mention PNG,
JPG and GIF).

Thanks!

On Sun, Jun 29, 2008 at 5:40 AM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:



somewhat like this, and then just add the image as an image...:




import org.apache.wicket.markup.html.image.resource.DynamicImageResource;

public class ImageResource extends DynamicImageResource {

 // has to save this. or get the image another way!
 private byte[] image;

 public ImageResource(byte[] image, String format) {
     this.image = image;
     setFormat(format);
 }

 public ImageResource(BufferedImage image) {
     this.image = toImageData(image);
 }

 @Override
 protected byte[] getImageData() {
     if (image != null) {
         return image;
     } else {
         return new byte[0];

     }

 }

}


Manuel Corrales wrote:



Hi, i have some jfreechart generated images on my application. I did
this
using an example on the wicket wiki. I wonder if i can do the same
thing,
but sending an SVG image to the client. I have the svg generated by
jfreechar but now i dont know how can i use this on the html and on the
Page
with wicket. Can anyone help me?

Thanks in advance.

Best regards.

Manuel.





--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to