Hi,
Can someone please explain how to use the drawItem method in the VerticalXYBarRenderer class:
drawItem (java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset data, int series, int item, CrosshairInfo crosshairInfo)
I'm not really sure how to make a graphics2D object with out using the paint method. It would be a big help if you could elaborate on each of the parameters of the method.
VerticalXYBarRenderer class
Re: VerticalXYBarRenderer class
drawItem will render the item onto the given Graphics2D object. The size, co-ordinates, appearance, etc are determined by the other parameters.
Normally, you just let JFreechart do the drawing, why exactly do you need to call this method yourself?
Dan
Normally, you just let JFreechart do the drawing, why exactly do you need to call this method yourself?
Dan
Re: VerticalXYBarRenderer class
Hi,
As Daniel correctly pointed out, this method is called by JFreeChart (the call is made inside the XYPlot class) each time it draws an item in the plot. You normally won't call it yourself.
Regards,
DG.
As Daniel correctly pointed out, this method is called by JFreeChart (the call is made inside the XYPlot class) each time it draws an item in the plot. You normally won't call it yourself.
Regards,
DG.
Re: VerticalXYBarRenderer class
What I'm trying to do is draw a red vertical bar on different charts (a bar chart and a line chart), using the drawitem method in the StandardXYItemRenderer class. What I did was make an object like the following:
XYItemRenderer renderer1 = new StandardXYItemRenderer();
then using the drawItem method (renderer1.drawItem(g2, etc...) from the StandardXYItemRenderer class is how I'm trying to achieve this. Also, this is being done from my createCombinedChart() method.
I guess what I'm really having trouble with is, what exactly is that I'm suppose to send the drawItem method as arguments and where and how to envoke it.
public void drawItem(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
ChartRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset data,
int series,
int item,
CrosshairInfo crosshairInfo)
thanks,
Hostos
XYItemRenderer renderer1 = new StandardXYItemRenderer();
then using the drawItem method (renderer1.drawItem(g2, etc...) from the StandardXYItemRenderer class is how I'm trying to achieve this. Also, this is being done from my createCombinedChart() method.
I guess what I'm really having trouble with is, what exactly is that I'm suppose to send the drawItem method as arguments and where and how to envoke it.
public void drawItem(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
ChartRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset data,
int series,
int item,
CrosshairInfo crosshairInfo)
thanks,
Hostos
Re: VerticalXYBarRenderer class
I think you are going about it the wrong way. The drawItem(...) method is designed to be called once-per-item for all the data items in an XYPlot. The XYPlot takes care of passing in the correct arguments, the renderer just draws the item onto the supplied Graphics2D device.
What is the vertical bar you want to draw? Is it part of your data, or are you just trying to represent some threshold on your chart? If you just want to mark some value, you can use the addDomainMarker(...) and addRangeMarker(...) methods in the XYPlot class.
Regards,
DG.
What is the vertical bar you want to draw? Is it part of your data, or are you just trying to represent some threshold on your chart? If you just want to mark some value, you can use the addDomainMarker(...) and addRangeMarker(...) methods in the XYPlot class.
Regards,
DG.
Re: VerticalXYBarRenderer class
Thats exactly what I want to do, my red vertical bar will represent a particular day on the x-axis (so, it will be a threshold representing a certain value). Could you please elaborate on your suggestion and on the argument of the addDomainMarker(Marker marker) method. thanks again...
thanks,
HM
thanks,
HM