本文整理汇总了Java中org.jfree.chart.renderer.category.CategoryItemRendererState.getBarWidth方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryItemRendererState.getBarWidth方法的具体用法?Java CategoryItemRendererState.getBarWidth怎么用?Java CategoryItemRendererState.getBarWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.renderer.category.CategoryItemRendererState
的用法示例。
在下文中一共展示了CategoryItemRendererState.getBarWidth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: initialise
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot,
int rendererIndex, PlotRenderingInfo info) {
CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);
if (state.getBarWidth() > maxBarWidth) {
state.setBarWidth(maxBarWidth);
}
return state;
}
示例4: drawRectangles
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入方法依赖的package包/类
private RectangleEdge drawRectangles(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
CategoryPlot plot, ValueAxis rangeAxis, int row, int column, BoxAndWhiskerCategoryDataset bawDataset,
double xx) {
RectangleEdge location = plot.getRangeAxisEdge();
Number yQ1 = bawDataset.getQ1Value(row, column);
Number yQ3 = bawDataset.getQ3Value(row, column);
Number yMax = bawDataset.getMaxRegularValue(row, column);
Number yMin = bawDataset.getMinRegularValue(row, column);
Shape box = null;
if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {
double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);
double xxmid = xx + state.getBarWidth() / 2.0;
// draw the upper shadow...
g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax));
// draw the lower shadow...
g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin));
// draw the body...
box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3));
if (getFillBox()) {
g2.fill(box);
}
g2.draw(box);
}
return location;
}
示例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) {
super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row,
column, pass);
// after the stacked bar is completely rendered draw the glow text into it.
if((pass == 2) && isSeriesComplete(dataset, row) && renderBarLabel(dataset, row, column)) {
GraphUtils g = new GraphUtils(g2);
String rowKey = dataset.getRowKey(row).toString();
String colKey = dataset.getColumnKey(column).toString();
String label = String.format("%s %s", colKey, getSeries(rowKey));
double barW0 = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis,
state, row, column);
// centre the label
double labelx = barW0 + state.getBarWidth()/2;
double labely = (dataArea.getMinY()+dataArea.getHeight() / 2) -
(g.getBounds(label).getWidth() / 2);
AffineTransform saveT = g2.getTransform();
AffineTransform transform = new AffineTransform();
// jfree chart seem to be using the transform on the Graphics2D object
// for scaling when the window gets very small or large
// therefore we can not just overwrite the transform but have to factor it into
// our rotation and translation transformations.
transform.concatenate(saveT);
transform.concatenate(AffineTransform.getRotateInstance(-Math.PI/2, labelx, labely));
g2.setTransform(transform);
g2.setFont(LEGEND_FONT);
g2.setColor(Color.black);
g.drawGlowString(label, Color.white, 6, (int)labelx, (int)labely);
g2.setTransform(saveT);
}
if((pass == 2) && isLastRow(dataset, row)) {
// 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());
}
}
示例6: initialise
import org.jfree.chart.renderer.category.CategoryItemRendererState; //导入方法依赖的package包/类
/**
* Initialises the renderer. This method gets called once at the start of
* the process of drawing a chart.
*
* @param g2 the graphics device.
* @param dataArea the area in which the data is to be plotted.
* @param plot the plot.
* @param rendererIndex the renderer index.
* @param info collects chart rendering information for return to caller.
*
* @return The renderer state.
*/
public CategoryItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
CategoryPlot plot,
int rendererIndex,
PlotRenderingInfo info) {
CategoryItemRendererState state = super.initialise(
g2, dataArea, plot, rendererIndex, info
);
// calculate the box width
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
CategoryDataset dataset = plot.getDataset(rendererIndex);
if (dataset != null) {
int columns = dataset.getColumnCount();
int rows = dataset.getRowCount();
double space = 0.0;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.getHeight();
}
else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.getWidth();
}
double categoryMargin = 0.0;
double currentItemMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
if (rows > 1) {
currentItemMargin = getItemMargin();
}
double used = space * (1 - domainAxis.getLowerMargin()
- domainAxis.getUpperMargin()
- categoryMargin - currentItemMargin);
if ((rows * columns) > 0) {
state.setBarWidth(
used / (dataset.getColumnCount() * dataset.getRowCount())
);
}
else {
state.setBarWidth(used);
}
}
if (state.getBarWidth() > maxBarWidth)
state.setBarWidth(maxBarWidth);
return state;
}