本文整理汇总了Java中org.jfree.chart.renderer.category.CategoryItemRendererState类的典型用法代码示例。如果您正苦于以下问题:Java CategoryItemRendererState类的具体用法?Java CategoryItemRendererState怎么用?Java CategoryItemRendererState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CategoryItemRendererState类属于org.jfree.chart.renderer.category包,在下文中一共展示了CategoryItemRendererState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state,
Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
ValueAxis rangeAxis, CategoryDataset dataset, int row, int column,
int pass) {
super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis,dataset,row, column,pass);
//Draw label
if (dataset.getRowCount() - 1 == row) { //last row
Number value = dataset.getValue(row, column);
double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(),
dataArea, plot.getDomainAxisEdge());
double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea,
plot.getRangeAxisEdge());
g2.setFont(new Font("SansSerif", Font.BOLD, 14));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
String name = dataset.getColumnKey(column).toString();
int width = g2.getFontMetrics().stringWidth(name);
g2.drawString(name, (int) y1 - width, (int) x1 - 12);
}
}
示例2: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
/**
* Draws the bar with its standard deviation line range for a single (series, category) data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the data area.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param data the data.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
* @param pass the pass index.
*/
@Override
public void drawItem(final Graphics2D g2, final CategoryItemRendererState state, final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis, final ValueAxis rangeAxis, final CategoryDataset data, final int row, final int column, final int pass) {
// defensive check
if (!(data instanceof StatisticalCategoryDataset)) {
throw new IllegalArgumentException("Requires StatisticalCategoryDataset.");
}
final StatisticalCategoryDataset statData = (StatisticalCategoryDataset) data;
final PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, statData, row, column);
} else if (orientation == PlotOrientation.VERTICAL) {
drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, statData, row, column);
}
}
示例3: drawTasks
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
/**
* Draws the tasks/subtasks for one item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the data plot area.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the data.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*/
protected void drawTasks (Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
TrackTaskSeriesCollection dataset,
int row,
int column,
int pass) {
int count = dataset.getSubIntervalCount (row, column);
if (count == 0) {
drawTask (g2, state, dataArea, plot, domainAxis,
rangeAxis, dataset, row, column, pass);
}
// rendering for subtasks is actually obsolete since we have a tree structure and
// do not use subtasks in the class Task (JFreechart Task)
else{ // just in case... we let the superclass handle it...
super.drawTasks (g2, state, dataArea, plot, domainAxis,
rangeAxis, dataset, row, column);
}
}
示例4: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state,
Rectangle2D dataArea, CategoryPlot plot,
CategoryAxis domainAxis, ValueAxis rangeAxis,
CategoryDataset dataset, int row, int column, int pass) {
super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row,
column, pass);
double barW0 = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis,
state, state.getVisibleSeriesIndex(row), column);
Number dataValue = dataset.getValue(row, column);
if (dataValue == null) {
return;
}
final double value = dataValue.doubleValue();
if(rangeAxis instanceof PartitionedNumberAxis) {
Range r = new Range(0, value);
((PartitionedNumberAxis)rangeAxis).drawPatitionBoundaries(
g2, r, dataArea, state.getBarWidth(), barW0);
}
}
示例5: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
public void drawItem(Graphics2D g2,
CategoryItemRendererState state, Rectangle2D dataArea,
CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis,
CategoryDataset dataset, int row, int column, int pass) {
if(column == 0) {
Shape shape = createShape(state, dataArea, plot, domainAxis, rangeAxis, dataset, row);
if(shape != null) {
if(pass == 0) {
// render all drop shadows first (pass 0)
Graphics2D g0 = (Graphics2D)g2.create();
g0.translate(2, 2);
g0.setPaint(Color.darkGray);
g0.fill(shape);
g0.dispose();
} else if(pass == 1) {
g2.setPaint(getSeriesPaint(row));
g2.fill(shape);
}
}
}
}
示例6: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state,
Rectangle2D dataArea, CategoryPlot plot,
CategoryAxis domainAxis, ValueAxis rangeAxis,
CategoryDataset dataset, int row, int column, int pass) {
drawItemInternal(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row,
column, pass);
// System.out.println(String.format("row %s, column %s, pass %s", row, column, pass));
if((pass == 0) && (row == 1)&& (column == 3)) {
// Workaround: because the dataArea sits on the the Axis the 0% gridline gets drawn
// over the category axis making it gray. To fix this as we draw another black line
// to restore the black axis.
g2.setColor(Color.black);
g2.setStroke(new BasicStroke(2));
g2.drawLine((int)dataArea.getMinX(), (int)dataArea.getMaxY(), (int)dataArea.getMaxX(), (int)dataArea.getMaxY());
g2.drawLine((int)dataArea.getMinX(), (int)dataArea.getMinY(), (int)dataArea.getMinX(), (int)dataArea.getMaxY());
}
}
示例7: drawMean
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
private double drawMean(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, ValueAxis rangeAxis,
int row, int column, BoxAndWhiskerCategoryDataset bawDataset, double xx, double aRadius,
RectangleEdge location) {
double yyAverage;
double newARadius = aRadius;
// draw mean - SPECIAL AIMS REQUIREMENT...
Number yMean = bawDataset.getMeanValue(row, column);
if (yMean != null) {
yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
newARadius = state.getBarWidth() / 4;
Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, yyAverage - aRadius, aRadius * 2,
aRadius * 2);
g2.fill(avgEllipse);
g2.draw(avgEllipse);
}
return newARadius;
}
示例8: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
/**
* Draws the bar for a single (series, category) data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the data area.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*/
@Override
public void drawItem (Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryDataset dataset,
int row,
int column,
int pass) {
if (dataset instanceof TrackTaskSeriesCollection) {
log.debug ("Drawing Item in TrackTaskSeriesCollection.");
TrackTaskSeriesCollection ttsc = (TrackTaskSeriesCollection) dataset;
drawTasks (g2, state, dataArea, plot, domainAxis, rangeAxis, ttsc, row, column, pass);
}
else { // let the superclass handle it...
log.debug ("Drawing item in CategoryDataset.");
super.drawItem (g2, state, dataArea, plot, domainAxis,
rangeAxis, dataset, row, column, 0);
}
}
示例9: calculateBarWidth
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) {
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
double usedArea = dataArea.getWidth() * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - domainAxis.getCategoryMargin());
double barWidth = usedArea / plot.getDataset(rendererIndex).getColumnCount();
state.setBarWidth(barWidth);
}
示例10: select
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
/**
* Perform a select for the item(s) at the specified (x, y) coordinates
* in Java2D space.
*
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param dataArea the data area.
* @param source the rendering source.
*
* @since 1.2.0
*/
public void select(double x, double y, Rectangle2D dataArea,
RenderingSource source) {
int datasetCount = this.datasets.size();
for (int d = 0; d < datasetCount; d++) {
CategoryDataset dataset = (CategoryDataset) this.datasets.get(d);
if (dataset == null) {
continue;
}
CategoryDatasetSelectionState state = findSelectionStateForDataset(
dataset, source);
if (state == null) {
continue;
}
Graphics2D g2 = source.createGraphics2D();
CategoryItemRenderer renderer = getRendererForDataset(dataset);
CategoryItemRendererState rs = renderer.initialise(g2, dataArea,
this, dataset, null);
int rowCount = dataset.getRowCount();
int columnCount = dataset.getColumnCount();
for (int r = 0; r < rowCount; r++) {
for (int c = 0; c < columnCount; c++) {
if (renderer.hitTest(x, y, null, dataArea, this,
getDomainAxisForDataset(d),
getRangeAxisForDataset(d), dataset, r, c, false,
rs)) {
state.setSelected(r, c, !state.isSelected(r, c));
}
}
}
}
}
示例11: calculateBarWidth
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
protected void calculateBarWidth(CategoryPlot plot,
Rectangle2D dataArea,
int rendererIndex,
CategoryItemRendererState state) {
CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex);
if(xAxis instanceof AutoSubCategoryAxis) {
state.setBarWidth(((AutoSubCategoryAxis)xAxis).calculateCategorySize(dataArea));
} else {
super.calculateBarWidth(plot, dataArea, rendererIndex, state);
}
}
示例12: calculateBarW0
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
@Override
protected double calculateBarW0(CategoryPlot plot,
PlotOrientation orientation, Rectangle2D dataArea,
CategoryAxis domainAxis, CategoryItemRendererState state,
int row, int column) {
return domainAxis.getCategoryMiddle(column, getColumnCount(),
dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0;
}
示例13: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset,
int row, int column, int pass) {
super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
_drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
// draw the legend last and only if the chart contains the subtidal series (row == 1)
if((row == 1) && (pass == 1) && (column == dataset.getColumnCount()-1)) {
drawLegend(g2, dataArea);
}
}
示例14: getPoints
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
private List<Point2D> getPoints(int row, Rectangle2D dataArea, CategoryDataset dataset,
CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRendererState state) {
List<Point2D> points = Lists.newArrayList();
for(int column = 0; true; column++) {
Number v = null;
try {
v = dataset.getValue(row, column);
} catch(Exception e) {}
if (v == null) {
break;
}
int visibleRow = state.getVisibleSeriesIndex(row);
if (visibleRow < 0) {
break;
}
int visibleRowCount = state.getVisibleSeriesCount();
double x1;
if (this.getUseSeriesOffset()) {
x1 = domainAxis.getCategorySeriesMiddle(column,
dataset.getColumnCount(), visibleRow, visibleRowCount,
getItemMargin(), dataArea, plot.getDomainAxisEdge());
}
else {
x1 = domainAxis.getCategoryMiddle(column, getColumnCount(),
dataArea, plot.getDomainAxisEdge());
}
double value = v.doubleValue();
double y1 = rangeAxis.valueToJava2D(value, dataArea,
plot.getRangeAxisEdge());
points.add(new Point2D.Double(x1, y1));
}
return points;
}
示例15: drawItem
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入依赖的package包/类
/**
* Draw a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area in which the data is drawn.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the data.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
* @param pass the pass index.
*/
public void drawItem(Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryDataset dataset,
int row,
int column,
int pass) {
if (!(dataset instanceof BoxAndWhiskerCategoryDataset)) {
throw new IllegalArgumentException(
"BoxAndWhiskerRenderer.drawItem() : the data should be of type "
+ "BoxAndWhiskerCategoryDataset only."
);
}
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
drawHorizontalItem(
g2, state, dataArea, plot, domainAxis, rangeAxis,
dataset, row, column
);
}
else if (orientation == PlotOrientation.VERTICAL) {
drawVerticalItem(
g2, state, dataArea, plot, domainAxis, rangeAxis,
dataset, row, column
);
}
}