use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class AreaChartTest method testSetSeriesToolTipGenerator.
/**
* Check that setting a tool tip generator for a series does override the
* default generator.
*/
@Test
public void testSetSeriesToolTipGenerator() {
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
renderer.setSeriesToolTipGenerator(0, tt);
CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
assertSame(tt2, tt);
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class AreaChartTest method testSetSeriesURLGenerator.
/**
* Check that setting a URL generator for a series does override the
* default generator.
*/
@Test
public void testSetSeriesURLGenerator() {
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
renderer.setSeriesItemURLGenerator(0, url1);
CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
assertSame(url2, url1);
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method drawDomainCrosshair.
/**
* Draws a domain crosshair.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param orientation the plot orientation.
* @param datasetIndex the dataset index.
* @param rowKey the row key.
* @param columnKey the column key.
* @param stroke the stroke used to draw the crosshair line.
* @param paint the paint used to draw the crosshair line.
*
* @see #drawRangeCrosshair(Graphics2D, Rectangle2D, PlotOrientation,
* double, ValueAxis, Stroke, Paint)
*
* @since 1.0.11
*/
protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, int datasetIndex, Comparable rowKey, Comparable columnKey, Stroke stroke, Paint paint) {
CategoryDataset dataset = getDataset(datasetIndex);
CategoryAxis axis = getDomainAxisForDataset(datasetIndex);
CategoryItemRenderer renderer = getRenderer(datasetIndex);
Line2D line;
if (orientation == PlotOrientation.VERTICAL) {
double xx = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, dataArea, RectangleEdge.BOTTOM);
line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY());
} else {
double yy = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, dataArea, RectangleEdge.LEFT);
line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer 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.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method drawRangeGridlines.
/**
* Draws the range gridlines for the plot, if they are visible.
*
* @param g2 the graphics device ({@code null} not permitted).
* @param dataArea the area inside the axes ({@code null} not permitted).
* @param ticks the ticks.
*
* @see #drawDomainGridlines(Graphics2D, Rectangle2D)
*/
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
// draw the range grid lines, if any...
if (!isRangeGridlinesVisible() && !isRangeMinorGridlinesVisible()) {
return;
}
// no axis, no gridlines...
ValueAxis axis = getRangeAxis();
if (axis == null) {
return;
}
// no renderer, no gridlines...
CategoryItemRenderer r = getRenderer();
if (r == null) {
return;
}
Stroke gridStroke = null;
Paint gridPaint = null;
boolean paintLine;
Iterator iterator = ticks.iterator();
while (iterator.hasNext()) {
paintLine = false;
ValueTick tick = (ValueTick) iterator.next();
if ((tick.getTickType() == TickType.MINOR) && isRangeMinorGridlinesVisible()) {
gridStroke = getRangeMinorGridlineStroke();
gridPaint = getRangeMinorGridlinePaint();
paintLine = true;
} else if ((tick.getTickType() == TickType.MAJOR) && isRangeGridlinesVisible()) {
gridStroke = getRangeGridlineStroke();
gridPaint = getRangeGridlinePaint();
paintLine = true;
}
if (((tick.getValue() != 0.0) || !isRangeZeroBaselineVisible()) && paintLine) {
// interface...
if (r instanceof AbstractCategoryItemRenderer) {
AbstractCategoryItemRenderer aci = (AbstractCategoryItemRenderer) r;
aci.drawRangeLine(g2, this, axis, dataArea, tick.getValue(), gridPaint, gridStroke);
} else {
// we'll have to use the method in the interface, but
// this doesn't have the paint and stroke settings...
r.drawRangeGridline(g2, this, axis, dataArea, tick.getValue());
}
}
}
}
Aggregations