1 43 44 package org.jfree.chart.renderer; 45 46 import java.awt.Graphics2D ; 47 import java.awt.geom.Rectangle2D ; 48 import java.io.Serializable ; 49 50 import org.jfree.chart.CrosshairInfo; 51 import org.jfree.chart.axis.ValueAxis; 52 import org.jfree.chart.plot.PlotOrientation; 53 import org.jfree.chart.plot.PlotRenderingInfo; 54 import org.jfree.chart.plot.XYPlot; 55 import org.jfree.data.XYDataset; 56 import org.jfree.ui.RectangleEdge; 57 import org.jfree.util.PublicCloneable; 58 59 64 public class XYDotRenderer extends AbstractXYItemRenderer implements XYItemRenderer, 65 Cloneable , 66 PublicCloneable, 67 Serializable { 68 69 72 public XYDotRenderer() { 73 74 } 75 76 92 public void drawItem(Graphics2D g2, 93 XYItemRendererState state, 94 Rectangle2D dataArea, 95 PlotRenderingInfo info, 96 XYPlot plot, 97 ValueAxis domainAxis, 98 ValueAxis rangeAxis, 99 XYDataset dataset, 100 int series, 101 int item, 102 CrosshairInfo crosshairInfo, 103 int pass) { 104 105 Number xn = dataset.getXValue(series, item); 107 Number yn = dataset.getYValue(series, item); 108 if (yn != null) { 109 double x = xn.doubleValue(); 110 double y = yn.doubleValue(); 111 RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); 112 RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); 113 double transX = domainAxis.translateValueToJava2D(x, dataArea, xAxisLocation); 114 double transY = rangeAxis.translateValueToJava2D(y, dataArea, yAxisLocation); 115 116 g2.setPaint(this.getItemPaint(series, item)); 117 PlotOrientation orientation = plot.getOrientation(); 118 if (orientation == PlotOrientation.HORIZONTAL) { 119 g2.drawRect((int) transY, (int) transX, 1, 1); 120 } 121 else if (orientation == PlotOrientation.VERTICAL) { 122 g2.drawRect((int) transX, (int) transY, 1, 1); 123 } 124 125 if (plot.isDomainCrosshairLockedOnData()) { 127 if (plot.isRangeCrosshairLockedOnData()) { 128 crosshairInfo.updateCrosshairPoint(x, y, transX, transY); 130 } 131 else { 132 crosshairInfo.updateCrosshairX(x); 134 } 135 } 136 else { 137 if (plot.isRangeCrosshairLockedOnData()) { 138 crosshairInfo.updateCrosshairY(y); 140 } 141 } 142 } 143 144 } 145 146 153 public Object clone() throws CloneNotSupportedException { 154 return super.clone(); 155 } 156 157 } 158 | Popular Tags |