You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Manuel Corrales <ma...@gmail.com> on 2008/06/28 17:42:05 UTC

Wikcet Freechart and SVG

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.

Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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 <
> nino.martinez@jayway.dk> 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 <
>>> nino.martinez@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Ahh okay, then you need to create a panel or something(maybe do it like 
image itself just copy the source and make it attachable to embed) that 
contains the embed...

Manuel Corrales wrote:
> Sorry for my stupidity :(
>
> Ive tried your code, and as said before, the svg is being generated 
> ok, but it is not displayed on the browser (attached an image of the 
> page). When i right click on the broken image icon, and press save as, 
> i can download the svg.
>
> For what i was reading, i dont think it is possible to include a svg 
> image in a <img> tag, i think only <embed> <object> and <iframe> can 
> have an svg image.
>
> Anyway, i will keep looking for a solution.
>
> Thanks!
>
> On Mon, Jun 30, 2008 at 5:36 PM, Manuel Corrales 
> <manuelcorrales@gmail.com <ma...@gmail.com>> wrote:
>
>     I am going to try your code as soon as i can, but i still don't
>     understand where are you generating the svg image on this code.
>
>
>     On Mon, Jun 30, 2008 at 1:59 PM, Nino Saturnino Martinez Vazquez
>     Wael <nino.martinez@jayway.dk <ma...@jayway.dk>> wrote:
>
>         hmm whats JFreeChart image?
>
>
>         I usually do this, in my domain classes :
>
>               JFreeChart chart = ChartFactory
>                       .createTimeSeriesChart(
>                              
>         Messages.getString("ReportWeightChart.5", locale),
>         Messages.getString("ReportWeightChart.6", locale),
>         Messages.getString("ReportWeightChart.7", locale), dataset,
>         true, true, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
>               return chart.createBufferedImage(500, 270);
>
>         And this in the wicket page :
>
>                       Report simpleReport = (Report)
>         item.getModelObject();
>
>                       BufferedImage report =
>         simpleReport.getReport(getLocale());
>                       ImageResource imageResource = new
>         ImageResource(report);
>                       item.add(new Image("image", imageResource));
>
>
>         Ahh, I see you are mixing things(found the JFreeChart on the
>         wiki).. You cant do it like that it should be like
>         this(although the otherway can also be done):
>
>
>         JFreeChart chart = ChartFactory.createPieChart("Resumen de
>         gastos",
>                       dataSet, true, true, false);
>               PiePlot plot = (PiePlot) chart.getPlot();
>               plot.setSectionOutlinesVisible(false);
>               add(new Image("image",chart.createBufferedImage(640,
>         480)));
>
>
>
>
>
>         Manuel Corrales wrote:
>
>             Here is the page code: (this is all prototype code, just
>             messing around with
>             graphics on wicket)
>
>             JFreeChart chart = ChartFactory.createPieChart("Resumen de
>             gastos",
>                            dataSet, true, true, false);
>                    PiePlot plot = (PiePlot) chart.getPlot();
>                    plot.setSectionOutlinesVisible(false);
>                    add(new Image("image",new JFreeChartImage("image",
>             chart, 640,
>             480)));
>
>             Thanks a lot!!
>
>             On Mon, Jun 30, 2008 at 11:36 AM, Nino Saturnino Martinez
>             Vazquez Wael <
>             nino.martinez@jayway.dk <ma...@jayway.dk>>
>             wrote:
>
>              
>
>                 Manuel Corrales wrote:
>
>                    
>
>                     Yes, i know, but i have tried with firefox and
>                     opera. Also to implement
>                     the
>                     <object> solution i have to write the image to the
>                     disc first and then
>                     dynamically set the data attribute on the object tag.
>
>                     Nino: what do you mean by where is the page? If i
>                     can see a non SVG image
>                     with exactly the same page, shouldn't i be able to
>                     see an SVG image?
>
>
>
>                          
>
>                 I just wanted to see how you implemented it in the
>                 page... Both java and
>                 html (just to double check)... And I saw the part
>                 about some browsers not
>                 handling svg very good.
>
>                    
>
>                     Best regards.
>
>                     On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton
>                     <ffanton@ibc.it <ma...@ibc.it>> wrote:
>
>
>
>                          
>
>                         On Sun, 29 Jun 2008 21:03:29 -0300
>                         "Manuel Corrales" <manuelcorrales@gmail.com
>                         <ma...@gmail.com>> 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:
>
>
>                                      
>
>                         Not every browser handles SVGs directly, some
>                         need a plugin (guess which
>                         one :) ).. In our project I use the <object
>                         .../> tag, so for example
>                         when
>                         the page is rendered it has a
>
>                         <object style="height: 32px; width: 32px;"
>                         data="images/logo.svg"/>
>
>                         Bye!
>
>
>                         ---------------------------------------------------------------------
>                         To unsubscribe, e-mail:
>                         users-unsubscribe@wicket.apache.org
>                         <ma...@wicket.apache.org>
>                         For additional commands, e-mail:
>                         users-help@wicket.apache.org
>                         <ma...@wicket.apache.org>
>
>
>
>
>                                
>
>
>                          
>
>                 --
>                 -Wicket for love
>
>                 Nino Martinez Wael
>                 Java Specialist @ Jayway DK
>                 http://www.jayway.dk
>                 +45 2936 7684
>
>
>                 ---------------------------------------------------------------------
>                 To unsubscribe, e-mail:
>                 users-unsubscribe@wicket.apache.org
>                 <ma...@wicket.apache.org>
>                 For additional commands, e-mail:
>                 users-help@wicket.apache.org
>                 <ma...@wicket.apache.org>
>
>
>                    
>
>
>              
>
>
>         -- 
>         -Wicket for love
>
>         Nino Martinez Wael
>         Java Specialist @ Jayway DK
>         http://www.jayway.dk
>         +45 2936 7684
>
>
>         ---------------------------------------------------------------------
>         To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>         <ma...@wicket.apache.org>
>         For additional commands, e-mail: users-help@wicket.apache.org
>         <ma...@wicket.apache.org>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
Sorry for my stupidity :(

Ive tried your code, and as said before, the svg is being generated ok, but
it is not displayed on the browser (attached an image of the page). When i
right click on the broken image icon, and press save as, i can download the
svg.

For what i was reading, i dont think it is possible to include a svg image
in a <img> tag, i think only <embed> <object> and <iframe> can have an svg
image.

Anyway, i will keep looking for a solution.

Thanks!

On Mon, Jun 30, 2008 at 5:36 PM, Manuel Corrales <ma...@gmail.com>
wrote:

> I am going to try your code as soon as i can, but i still don't understand
> where are you generating the svg image on this code.
>
>
> On Mon, Jun 30, 2008 at 1:59 PM, Nino Saturnino Martinez Vazquez Wael <
> nino.martinez@jayway.dk> wrote:
>
>> hmm whats JFreeChart image?
>>
>>
>> I usually do this, in my domain classes :
>>
>>       JFreeChart chart = ChartFactory
>>               .createTimeSeriesChart(
>>                       Messages.getString("ReportWeightChart.5", locale),
>> Messages.getString("ReportWeightChart.6", locale),
>> Messages.getString("ReportWeightChart.7", locale), dataset, true, true,
>> false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
>>       return chart.createBufferedImage(500, 270);
>>
>> And this in the wicket page :
>>
>>               Report simpleReport = (Report) item.getModelObject();
>>
>>               BufferedImage report = simpleReport.getReport(getLocale());
>>               ImageResource imageResource = new ImageResource(report);
>>               item.add(new Image("image", imageResource));
>>
>>
>> Ahh, I see you are mixing things(found the JFreeChart on the wiki).. You
>> cant do it like that it should be like this(although the otherway can also
>> be done):
>>
>> JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
>>               dataSet, true, true, false);
>>       PiePlot plot = (PiePlot) chart.getPlot();
>>       plot.setSectionOutlinesVisible(false);
>>       add(new Image("image",chart.createBufferedImage(640, 480)));
>>
>>
>>
>>
>>
>> Manuel Corrales wrote:
>>
>>> Here is the page code: (this is all prototype code, just messing around
>>> with
>>> graphics on wicket)
>>>
>>> JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
>>>                dataSet, true, true, false);
>>>        PiePlot plot = (PiePlot) chart.getPlot();
>>>        plot.setSectionOutlinesVisible(false);
>>>        add(new Image("image",new JFreeChartImage("image", chart, 640,
>>> 480)));
>>>
>>> Thanks a lot!!
>>>
>>> On Mon, Jun 30, 2008 at 11:36 AM, Nino Saturnino Martinez Vazquez Wael <
>>> nino.martinez@jayway.dk> wrote:
>>>
>>>
>>>
>>>> Manuel Corrales wrote:
>>>>
>>>>
>>>>
>>>>> Yes, i know, but i have tried with firefox and opera. Also to implement
>>>>> the
>>>>> <object> solution i have to write the image to the disc first and then
>>>>> dynamically set the data attribute on the object tag.
>>>>>
>>>>> Nino: what do you mean by where is the page? If i can see a non SVG
>>>>> image
>>>>> with exactly the same page, shouldn't i be able to see an SVG image?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> I just wanted to see how you implemented it in the page... Both java and
>>>> html (just to double check)... And I saw the part about some browsers
>>>> not
>>>> handling svg very good.
>>>>
>>>>
>>>>
>>>>> Best regards.
>>>>>
>>>>> On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> On Sun, 29 Jun 2008 21:03:29 -0300
>>>>>> "Manuel Corrales" <ma...@gmail.com> 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:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Not every browser handles SVGs directly, some need a plugin (guess
>>>>>> which
>>>>>> one :) ).. In our project I use the <object .../> tag, so for example
>>>>>> when
>>>>>> the page is rendered it has a
>>>>>>
>>>>>> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>>>>>>
>>>>>> Bye!
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> -Wicket for love
>>>>
>>>> Nino Martinez Wael
>>>> Java Specialist @ Jayway DK
>>>> http://www.jayway.dk
>>>> +45 2936 7684
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
I am going to try your code as soon as i can, but i still don't understand
where are you generating the svg image on this code.

On Mon, Jun 30, 2008 at 1:59 PM, Nino Saturnino Martinez Vazquez Wael <
nino.martinez@jayway.dk> wrote:

> hmm whats JFreeChart image?
>
>
> I usually do this, in my domain classes :
>
>       JFreeChart chart = ChartFactory
>               .createTimeSeriesChart(
>                       Messages.getString("ReportWeightChart.5", locale),
> Messages.getString("ReportWeightChart.6", locale),
> Messages.getString("ReportWeightChart.7", locale), dataset, true, true,
> false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
>       return chart.createBufferedImage(500, 270);
>
> And this in the wicket page :
>
>               Report simpleReport = (Report) item.getModelObject();
>
>               BufferedImage report = simpleReport.getReport(getLocale());
>               ImageResource imageResource = new ImageResource(report);
>               item.add(new Image("image", imageResource));
>
>
> Ahh, I see you are mixing things(found the JFreeChart on the wiki).. You
> cant do it like that it should be like this(although the otherway can also
> be done):
>
> JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
>               dataSet, true, true, false);
>       PiePlot plot = (PiePlot) chart.getPlot();
>       plot.setSectionOutlinesVisible(false);
>       add(new Image("image",chart.createBufferedImage(640, 480)));
>
>
>
>
>
> Manuel Corrales wrote:
>
>> Here is the page code: (this is all prototype code, just messing around
>> with
>> graphics on wicket)
>>
>> JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
>>                dataSet, true, true, false);
>>        PiePlot plot = (PiePlot) chart.getPlot();
>>        plot.setSectionOutlinesVisible(false);
>>        add(new Image("image",new JFreeChartImage("image", chart, 640,
>> 480)));
>>
>> Thanks a lot!!
>>
>> On Mon, Jun 30, 2008 at 11:36 AM, Nino Saturnino Martinez Vazquez Wael <
>> nino.martinez@jayway.dk> wrote:
>>
>>
>>
>>> Manuel Corrales wrote:
>>>
>>>
>>>
>>>> Yes, i know, but i have tried with firefox and opera. Also to implement
>>>> the
>>>> <object> solution i have to write the image to the disc first and then
>>>> dynamically set the data attribute on the object tag.
>>>>
>>>> Nino: what do you mean by where is the page? If i can see a non SVG
>>>> image
>>>> with exactly the same page, shouldn't i be able to see an SVG image?
>>>>
>>>>
>>>>
>>>>
>>>>
>>> I just wanted to see how you implemented it in the page... Both java and
>>> html (just to double check)... And I saw the part about some browsers not
>>> handling svg very good.
>>>
>>>
>>>
>>>> Best regards.
>>>>
>>>> On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it>
>>>> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> On Sun, 29 Jun 2008 21:03:29 -0300
>>>>> "Manuel Corrales" <ma...@gmail.com> 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:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Not every browser handles SVGs directly, some need a plugin (guess
>>>>> which
>>>>> one :) ).. In our project I use the <object .../> tag, so for example
>>>>> when
>>>>> the page is rendered it has a
>>>>>
>>>>> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>>>>>
>>>>> Bye!
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
hmm whats JFreeChart image?


I usually do this, in my domain classes :

        JFreeChart chart = ChartFactory
                .createTimeSeriesChart(
                        Messages.getString("ReportWeightChart.5", 
locale), Messages.getString("ReportWeightChart.6", locale), 
Messages.getString("ReportWeightChart.7", locale), dataset, true, true, 
false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return chart.createBufferedImage(500, 270);

And this in the wicket page :

                Report simpleReport = (Report) item.getModelObject();

                BufferedImage report = simpleReport.getReport(getLocale());
                ImageResource imageResource = new ImageResource(report);
                item.add(new Image("image", imageResource));


Ahh, I see you are mixing things(found the JFreeChart on the wiki).. You 
cant do it like that it should be like this(although the otherway can 
also be done):

JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
                dataSet, true, true, false);
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        add(new Image("image",chart.createBufferedImage(640, 480)));




Manuel Corrales wrote:
> Here is the page code: (this is all prototype code, just messing around with
> graphics on wicket)
>
> JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
>                 dataSet, true, true, false);
>         PiePlot plot = (PiePlot) chart.getPlot();
>         plot.setSectionOutlinesVisible(false);
>         add(new Image("image",new JFreeChartImage("image", chart, 640,
> 480)));
>
> Thanks a lot!!
>
> On Mon, Jun 30, 2008 at 11:36 AM, Nino Saturnino Martinez Vazquez Wael <
> nino.martinez@jayway.dk> wrote:
>
>   
>> Manuel Corrales wrote:
>>
>>     
>>> Yes, i know, but i have tried with firefox and opera. Also to implement
>>> the
>>> <object> solution i have to write the image to the disc first and then
>>> dynamically set the data attribute on the object tag.
>>>
>>> Nino: what do you mean by where is the page? If i can see a non SVG image
>>> with exactly the same page, shouldn't i be able to see an SVG image?
>>>
>>>
>>>
>>>       
>> I just wanted to see how you implemented it in the page... Both java and
>> html (just to double check)... And I saw the part about some browsers not
>> handling svg very good.
>>
>>     
>>> Best regards.
>>>
>>> On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it> wrote:
>>>
>>>
>>>
>>>       
>>>> On Sun, 29 Jun 2008 21:03:29 -0300
>>>> "Manuel Corrales" <ma...@gmail.com> 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:
>>>>>
>>>>>
>>>>>           
>>>> Not every browser handles SVGs directly, some need a plugin (guess which
>>>> one :) ).. In our project I use the <object .../> tag, so for example
>>>> when
>>>> the page is rendered it has a
>>>>
>>>> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>>>>
>>>> Bye!
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
Here is the page code: (this is all prototype code, just messing around with
graphics on wicket)

JFreeChart chart = ChartFactory.createPieChart("Resumen de gastos",
                dataSet, true, true, false);
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        add(new Image("image",new JFreeChartImage("image", chart, 640,
480)));

Thanks a lot!!

On Mon, Jun 30, 2008 at 11:36 AM, Nino Saturnino Martinez Vazquez Wael <
nino.martinez@jayway.dk> wrote:

>
>
> Manuel Corrales wrote:
>
>> Yes, i know, but i have tried with firefox and opera. Also to implement
>> the
>> <object> solution i have to write the image to the disc first and then
>> dynamically set the data attribute on the object tag.
>>
>> Nino: what do you mean by where is the page? If i can see a non SVG image
>> with exactly the same page, shouldn't i be able to see an SVG image?
>>
>>
>>
> I just wanted to see how you implemented it in the page... Both java and
> html (just to double check)... And I saw the part about some browsers not
> handling svg very good.
>
>> Best regards.
>>
>> On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it> wrote:
>>
>>
>>
>>> On Sun, 29 Jun 2008 21:03:29 -0300
>>> "Manuel Corrales" <ma...@gmail.com> 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:
>>>>
>>>>
>>> Not every browser handles SVGs directly, some need a plugin (guess which
>>> one :) ).. In our project I use the <object .../> tag, so for example
>>> when
>>> the page is rendered it has a
>>>
>>> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>>>
>>> Bye!
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Manuel Corrales wrote:
> Yes, i know, but i have tried with firefox and opera. Also to implement the
> <object> solution i have to write the image to the disc first and then
> dynamically set the data attribute on the object tag.
>
> Nino: what do you mean by where is the page? If i can see a non SVG image
> with exactly the same page, shouldn't i be able to see an SVG image?
>
>   
I just wanted to see how you implemented it in the page... Both java and 
html (just to double check)... And I saw the part about some browsers 
not handling svg very good.
> Best regards.
>
> On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it> wrote:
>
>   
>> On Sun, 29 Jun 2008 21:03:29 -0300
>> "Manuel Corrales" <ma...@gmail.com> 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:
>>>       
>> Not every browser handles SVGs directly, some need a plugin (guess which
>> one :) ).. In our project I use the <object .../> tag, so for example when
>> the page is rendered it has a
>>
>> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>>
>> Bye!
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
Yes, i know, but i have tried with firefox and opera. Also to implement the
<object> solution i have to write the image to the disc first and then
dynamically set the data attribute on the object tag.

Nino: what do you mean by where is the page? If i can see a non SVG image
with exactly the same page, shouldn't i be able to see an SVG image?

Best regards.

On Mon, Jun 30, 2008 at 9:24 AM, Federico Fanton <ff...@ibc.it> wrote:

> On Sun, 29 Jun 2008 21:03:29 -0300
> "Manuel Corrales" <ma...@gmail.com> 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:
>
> Not every browser handles SVGs directly, some need a plugin (guess which
> one :) ).. In our project I use the <object .../> tag, so for example when
> the page is rendered it has a
>
> <object style="height: 32px; width: 32px;" data="images/logo.svg"/>
>
> Bye!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wikcet Freechart and SVG

Posted by Federico Fanton <ff...@ibc.it>.
On Sun, 29 Jun 2008 21:03:29 -0300
"Manuel Corrales" <ma...@gmail.com> 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:

Not every browser handles SVGs directly, some need a plugin (guess which one :) ).. In our project I use the <object .../> tag, so for example when the page is rendered it has a

<object style="height: 32px; width: 32px;" data="images/logo.svg"/>

Bye!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
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 <
nino.martinez@jayway.dk> 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 <
>> nino.martinez@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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 <
> nino.martinez@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wikcet Freechart and SVG

Posted by Manuel Corrales <ma...@gmail.com>.
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 <
nino.martinez@jayway.dk> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wikcet Freechart and SVG

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org