本文整理汇总了Java中org.jfree.chart.plot.CategoryPlot.getRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryPlot.getRenderer方法的具体用法?Java CategoryPlot.getRenderer怎么用?Java CategoryPlot.getRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.CategoryPlot
的用法示例。
在下文中一共展示了CategoryPlot.getRenderer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Performance: JFreeSVG vs Batik", null /* x-axis label*/,
"Milliseconds" /* y-axis label */, dataset);
chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG "
+ "format (lower bars = better performance)"));
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
chart.getLegend().setFrame(BlockBorder.NONE);
return chart;
}
示例2: visualizarSerieChartAsignRescateVict
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public void visualizarSerieChartAsignRescateVict(Color color,CategoryDataset dataset) {
ChartPanel chartPanel = new ChartPanel(chartNotifAsigResc);
chartNotifAsigResc.setBackgroundPaint(Color.white);
CategoryPlot plot = (CategoryPlot) chartNotifAsigResc.getPlot();
plot.setBackgroundPaint(color);
plot.setDataset(dataset);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new LabelGenerator(50.0));
renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
renderer.setItemLabelsVisible(true);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
this.pack();
RefineryUtilities.centerFrameOnScreen(this);
this.setVisible(true);
}
示例3: visualizarSeriesTiemposRescateVictPorRobots
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public void visualizarSeriesTiemposRescateVictPorRobots(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Tiempos de Rescate de Victimas por cada robot ", // chart title
"Robots en el entorno", // domain axis label
"Tiempo milisegundos", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
ChartPanel chartPanel = new ChartPanel(chart);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new LabelGenerator(50.0));
renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
renderer.setItemLabelsVisible(true);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
this.visualizar(chartPanel);
}
示例4: testSetSeriesURLGenerator
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* Check that setting a URL generator for a series does override the
* default generator.
*/
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);
assertTrue(url2 == url1);
}
示例5: testSetSeriesToolTipGenerator
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* Check that setting a tool tip generator for a series does override the
* default generator.
*/
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);
assertTrue(tt2 == tt);
}
示例6: setStackBarRender
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public static void setStackBarRender(CategoryPlot plot) {
plot.setNoDataMessage(NO_DATA_MSG);
plot.setInsets(new RectangleInsets(10, 10, 5, 10));
StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
plot.setRenderer(renderer);
setXAixs(plot);
setYAixs(plot);
}
示例7: createDayOfWeekBreakageDistributionChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public static void createDayOfWeekBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Integer dayOfWeek = (Integer) entry.getKey();
final BuildStatistics bst = (BuildStatistics) entry.getValue();
dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", new ComparableDayOfWeek(dayOfWeek));
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createStackedBarChart(null,
categoryLabel, "Builds", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// set bar colors
final BarRenderer bar = (BarRenderer) plot.getRenderer();
bar.setItemMargin(0); // reduce the width between the bars.
bar.setSeriesPaint(0, Color.RED); // first bar
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例8: crearBarChartCosteEnergiaRescateVictimas
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public void crearBarChartCosteEnergiaRescateVictimas(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Energ�a consumida para salvar las victimas ", // chart title
"Victimas ordenadas por tiempo de rescate", // domain axis label
"Energ�a consumida", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
ChartPanel chartPanel = new ChartPanel(chart);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new LabelGenerator(50.0));
renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
renderer.setItemLabelsVisible(true);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
this.pack();
RefineryUtilities.centerFrameOnScreen(this);
this.setVisible(true);
// return chart;
}
示例9: createChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* Creates a chart for recent time to fix.
*
*/
public void createChart(final SortedMap time, final String valueKey, final Color lineColor, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
addTimeToDataSet(dataset, time, valueKey);
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createLineChart(null,
"Recent builds", "Time", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setStandardTickUnits(StatisticsUtils.createWordedTimeTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
line.setSeriesPaint(0, lineColor);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
}
示例10: createHourlyBreakageDistributionChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public static void createHourlyBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Integer hour = (Integer) entry.getKey();
final BuildStatistics bst = (BuildStatistics) entry.getValue();
dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", hour);
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createStackedBarChart(null,
categoryLabel, "Builds", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// set bar colors
final BarRenderer bar = (BarRenderer) plot.getRenderer();
bar.setItemMargin(0); // reduce the width between the bars.
bar.setSeriesPaint(0, Color.RED); // first bar
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例11: generate
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public ImmutableImage generate(final List samples) {
try {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int i = 0; i < samples.size(); i++) {
final AgentStatusSample sample = (AgentStatusSample) samples.get(i);
dataset.addValue(sample.getBusyCounter(), "Load", new ColumnKey(i));
}
final JFreeChart chart = ChartFactory.createLineChart(null,
"Last 24 Hours", "Builds", dataset,
PlotOrientation.VERTICAL,
false, false, false);
chart.setBackgroundPaint(Color.white);
// Change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// Rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// Set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
line.setSeriesPaint(0, Color.BLUE);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// Write to byte array
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
ChartUtilities.writeChartAsPNG(out, chart, width, height, info);
out.flush();
out.close();
// Return result
return new ImmutableImage(out.toByteArray(), width, height);
} catch (IOException e) {
final ErrorManager errorManager = ErrorManagerFactory.getErrorManager();
final Error error = new Error("Error generating agent status chart: " + StringUtils.toString(e), e);
errorManager.reportSystemError(error);
return ImmutableImage.ZERO_SIZE_IMAGE;
}
}
示例12: draw
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* 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.
*/
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);
// draw the axis label...
info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info);
return info;
}
示例13: draw
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* 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.
*/
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, plotArea, dataArea, edge);
state.setTicks(ticks);
return state;
}
// calculate the adjusted data area taking into account the 3D effect...
CategoryPlot plot = (CategoryPlot) getPlot();
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();
}
Rectangle2D adjustedDataArea = new Rectangle2D.Double(adjustedX, adjustedY,
adjustedW, adjustedH);
// draw the tick marks and labels...
AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea, adjustedDataArea, edge);
// draw the axis label...
info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info);
return info;
}
示例14: createChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.white);
// set the range axis to display integers only...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// disable bar outlines...
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
);
// OPTIONAL CUSTOMISATION COMPLETED.
return chart;
}