This is my sample code to to show jfreechart tooltip on the image. 
The key is to override onComponentTagBody() and use
replaceComponentTagBody(). 
the parameter imageMapId used in ChartUtilities.getImageMap(imageMapId,
info); should also 
markded in html file ,for example :imageMapId="tooltip",then  </img>

remember that the  </img> tag must leave open tag,not close tag( ,
else replaceComponentTagBody() will not work.

Just post my tried code to share. 
There should be better way to tune the performance. 

--source code  here-- 
public class JFreeChartImage extends NonCachingImage { 

        private String imageMapId; 
        private int width; 
        private int height; 
        private JFreeChart chart; 
        private ChartRenderingInfo info = new ChartRenderingInfo( 
                        new StandardEntityCollection()); 

        public JFreeChartImage(String id, String imageMapId, 
                        int width, int height) { 
                // super(id, new Model(defaultImage)); 
                super(id); 
                this.imageMapId = imageMapId; 
                this.width = width; 
                this.height = height; 
        } 

        @Override 
        protected Resource getImageResource() { 
                Resource imageResource = null; 
                final JFreeChart chart = getChart(); 
                imageResource = new DynamicImageResource() { 
                        @Override 
                        protected byte[] getImageData() { 
                                ByteArrayOutputStream stream = new
ByteArrayOutputStream(); 
                                try { 
                                        if (chart != null) { 
                                                info.clear(); 
                                               
ChartUtilities.writeChartAsPNG(stream, chart, width, 
                                                                height,
info); 
                                        } 
                                } catch (IOException e) { 
                                        System.out.println("IOException: " +
e.getMessage()); 
                                } 
                                return stream.toByteArray(); 
                        } 
                }; return imageResource; 
        } 

        @Override 
        protected void onComponentTagBody(MarkupStream markupStream, 
                        ComponentTag openTag) { 
                JFreeChart chart = getChart(); 
                if (chart == null) 
                        return; 
                ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
                try { 
                        if (chart != null) { 
                                info.clear(); 
                                ChartUtilities.writeChartAsPNG(stream,
chart, width, height, 
                                                info); 
                        } 
                } catch (IOException e) { 
                        System.out.println("IOException: " +
e.getMessage()); 
                } 
                System.out.println(ChartUtilities.getImageMap(imageMapId,
info)); 
                replaceComponentTagBody(markupStream, openTag,
ChartUtilities 
                                .getImageMap(imageMapId, info)); 
        } 

        public JFreeChart getChart() { 
                return chart; 
        } 

        public void setChart(JFreeChart chart) { 
                this.chart = chart; 
        } 

} 
-- 
View this message in context: 
http://www.nabble.com/a-way-to-show-jfreechart-tooltip-on-the-image-tp19873571p19873571.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to