use of org.jfree.chart.Effect3D in project SIMVA-SoS by SESoS.
the class CategoryAxis3D method getCategoryJava2DCoordinate.
/**
* Returns the Java 2D coordinate for a category.
*
* @param anchor the anchor point.
* @param category the category index.
* @param categoryCount the category count.
* @param area the data area.
* @param edge the location of the axis.
*
* @return The coordinate.
*/
@Override
public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, Rectangle2D area, RectangleEdge edge) {
double result = 0.0;
Rectangle2D adjustedArea = area;
CategoryPlot plot = (CategoryPlot) getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
if (renderer instanceof Effect3D) {
Effect3D e3D = (Effect3D) renderer;
double adjustedX = area.getMinX();
double adjustedY = area.getMinY();
double adjustedW = area.getWidth() - e3D.getXOffset();
double adjustedH = area.getHeight() - e3D.getYOffset();
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
adjustedY += e3D.getYOffset();
} else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
adjustedX += e3D.getXOffset();
}
adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH);
}
if (anchor == CategoryAnchor.START) {
result = getCategoryStart(category, categoryCount, adjustedArea, edge);
} else if (anchor == CategoryAnchor.MIDDLE) {
result = getCategoryMiddle(category, categoryCount, adjustedArea, edge);
} else if (anchor == CategoryAnchor.END) {
result = getCategoryEnd(category, categoryCount, adjustedArea, edge);
}
return result;
}
use of org.jfree.chart.Effect3D in project SIMVA-SoS by SESoS.
the class NumberAxis3D method draw.
/**
* Draws the axis on a Java 2D graphics device (such as the screen or a
* printer).
*
* @param g2 the graphics device.
* @param cursor the cursor.
* @param plotArea the area for drawing the axes and data.
* @param dataArea the area for drawing the data (a subset of the
* plotArea).
* @param edge the axis location.
* @param plotState collects information about the plot (<code>null</code>
* permitted).
*
* @return The updated cursor value.
*/
@Override
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) {
// if the axis is not visible, don't draw it...
if (!isVisible()) {
AxisState state = new AxisState(cursor);
// even though the axis is not visible, we need ticks for the
// gridlines...
List ticks = refreshTicks(g2, state, dataArea, edge);
state.setTicks(ticks);
return state;
}
// calculate the adjusted data area taking into account the 3D effect...
double xOffset = 0.0;
double yOffset = 0.0;
Plot plot = getPlot();
if (plot instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) plot;
CategoryItemRenderer r = cp.getRenderer();
if (r instanceof Effect3D) {
Effect3D e3D = (Effect3D) r;
xOffset = e3D.getXOffset();
yOffset = e3D.getYOffset();
}
}
double adjustedX = dataArea.getMinX();
double adjustedY = dataArea.getMinY();
double adjustedW = dataArea.getWidth() - xOffset;
double adjustedH = dataArea.getHeight() - yOffset;
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
adjustedY += yOffset;
} else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
adjustedX += xOffset;
}
Rectangle2D adjustedDataArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH);
// draw the tick marks and labels...
AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea, adjustedDataArea, edge);
if (getAttributedLabel() != null) {
info = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, info);
} else {
info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info);
}
return info;
}
use of org.jfree.chart.Effect3D in project SIMVA-SoS by SESoS.
the class CategoryAxis3D method draw.
/**
* Draws the axis on a Java 2D graphics device (such as the screen or a
* printer).
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param cursor the cursor location.
* @param plotArea the area within which the axis should be drawn
* (<code>null</code> not permitted).
* @param dataArea the area within which the plot is being drawn
* (<code>null</code> not permitted).
* @param edge the location of the axis (<code>null</code> not permitted).
* @param plotState collects information about the plot (<code>null</code>
* permitted).
*
* @return The axis state (never <code>null</code>).
*/
@Override
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) {
// if the axis is not visible, don't draw it...
if (!isVisible()) {
return new AxisState(cursor);
}
// calculate the adjusted data area taking into account the 3D effect...
// this assumes that there is a 3D renderer, all this 3D effect is a
// bit of an ugly hack...
CategoryPlot plot = (CategoryPlot) getPlot();
Rectangle2D adjustedDataArea = new Rectangle2D.Double();
if (plot.getRenderer() instanceof Effect3D) {
Effect3D e3D = (Effect3D) plot.getRenderer();
double adjustedX = dataArea.getMinX();
double adjustedY = dataArea.getMinY();
double adjustedW = dataArea.getWidth() - e3D.getXOffset();
double adjustedH = dataArea.getHeight() - e3D.getYOffset();
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
adjustedY += e3D.getYOffset();
} else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
adjustedX += e3D.getXOffset();
}
adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW, adjustedH);
} else {
adjustedDataArea.setRect(dataArea);
}
if (isAxisLineVisible()) {
drawAxisLine(g2, cursor, adjustedDataArea, edge);
}
// draw the category labels and axis label
AxisState state = new AxisState(cursor);
if (isTickMarksVisible()) {
drawTickMarks(g2, cursor, adjustedDataArea, edge, state);
}
state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, state, plotState);
if (getAttributedLabel() != null) {
state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state);
} else {
state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state);
}
return state;
}
Aggregations