1 49 50 package org.jfree.chart.axis; 51 52 import java.awt.Graphics2D ; 53 import java.awt.geom.Rectangle2D ; 54 import java.io.Serializable ; 55 56 import org.jfree.chart.Effect3D; 57 import org.jfree.chart.plot.CategoryPlot; 58 import org.jfree.chart.plot.PlotRenderingInfo; 59 import org.jfree.chart.renderer.category.CategoryItemRenderer; 60 import org.jfree.ui.RectangleEdge; 61 62 68 public class CategoryAxis3D extends CategoryAxis 69 implements Cloneable , Serializable { 70 71 72 private static final long serialVersionUID = 4114732251353700972L; 73 74 77 public CategoryAxis3D() { 78 this(null); 79 } 80 81 86 public CategoryAxis3D(String label) { 87 super(label); 88 } 89 90 106 public AxisState draw(Graphics2D g2, 107 double cursor, 108 Rectangle2D plotArea, 109 Rectangle2D dataArea, 110 RectangleEdge edge, 111 PlotRenderingInfo plotState) { 112 113 if (!isVisible()) { 115 return new AxisState(cursor); 116 } 117 118 CategoryPlot plot = (CategoryPlot) getPlot(); 122 123 Rectangle2D adjustedDataArea = new Rectangle2D.Double (); 124 if (plot.getRenderer() instanceof Effect3D) { 125 Effect3D e3D = (Effect3D) plot.getRenderer(); 126 double adjustedX = dataArea.getMinX(); 127 double adjustedY = dataArea.getMinY(); 128 double adjustedW = dataArea.getWidth() - e3D.getXOffset(); 129 double adjustedH = dataArea.getHeight() - e3D.getYOffset(); 130 131 if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { 132 adjustedY += e3D.getYOffset(); 133 } 134 else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { 135 adjustedX += e3D.getXOffset(); 136 } 137 adjustedDataArea.setRect( 138 adjustedX, adjustedY, adjustedW, adjustedH 139 ); 140 } 141 else { 142 adjustedDataArea.setRect(dataArea); 143 } 144 145 AxisState state = new AxisState(cursor); 147 state = drawCategoryLabels( 148 g2, adjustedDataArea, edge, state, plotState 149 ); 150 state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); 151 152 return state; 153 154 } 155 156 167 public double getCategoryJava2DCoordinate(CategoryAnchor anchor, 168 int category, 169 int categoryCount, 170 Rectangle2D area, 171 RectangleEdge edge) { 172 173 double result = 0.0; 174 Rectangle2D adjustedArea = area; 175 CategoryPlot plot = (CategoryPlot) getPlot(); 176 CategoryItemRenderer renderer = plot.getRenderer(); 177 if (renderer instanceof Effect3D) { 178 Effect3D e3D = (Effect3D) renderer; 179 double adjustedX = area.getMinX(); 180 double adjustedY = area.getMinY(); 181 double adjustedW = area.getWidth() - e3D.getXOffset(); 182 double adjustedH = area.getHeight() - e3D.getYOffset(); 183 184 if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { 185 adjustedY += e3D.getYOffset(); 186 } 187 else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { 188 adjustedX += e3D.getXOffset(); 189 } 190 adjustedArea = new Rectangle2D.Double ( 191 adjustedX, adjustedY, adjustedW, adjustedH 192 ); 193 } 194 195 if (anchor == CategoryAnchor.START) { 196 result = getCategoryStart( 197 category, categoryCount, adjustedArea, edge 198 ); 199 } 200 else if (anchor == CategoryAnchor.MIDDLE) { 201 result = getCategoryMiddle( 202 category, categoryCount, adjustedArea, edge 203 ); 204 } 205 else if (anchor == CategoryAnchor.END) { 206 result = getCategoryEnd( 207 category, categoryCount, adjustedArea, edge 208 ); 209 } 210 return result; 211 212 } 213 214 222 public Object clone() throws CloneNotSupportedException { 223 return super.clone(); 224 } 225 226 } 227 | Popular Tags |