本文整理匯總了Java中org.jfree.chart.renderer.category.LineAndShapeRenderer類的典型用法代碼示例。如果您正苦於以下問題:Java LineAndShapeRenderer類的具體用法?Java LineAndShapeRenderer怎麽用?Java LineAndShapeRenderer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LineAndShapeRenderer類屬於org.jfree.chart.renderer.category包,在下文中一共展示了LineAndShapeRenderer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setLineRender
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
public static void setLineRender(CategoryPlot plot, boolean isShowDataLabels, boolean isShapesVisible) {
plot.setNoDataMessage(NO_DATA_MSG);
plot.setInsets(new RectangleInsets(10, 10, 0, 10), false);
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setStroke(new BasicStroke(1.5F));
if (isShowDataLabels) {
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING,
NumberFormat.getInstance()));
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
}
renderer.setBaseShapesVisible(isShapesVisible);
setXAixs(plot);
setYAixs(plot);
}
示例2: createPlot
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* Creates a sample plot.
*
* @return A sample plot.
*/
private CombinedDomainCategoryPlot createPlot() {
CategoryDataset dataset1 = createDataset1();
NumberAxis rangeAxis1 = new NumberAxis("Value");
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
subplot1.setDomainGridlinesVisible(true);
CategoryDataset dataset2 = createDataset2();
NumberAxis rangeAxis2 = new NumberAxis("Value");
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer2 = new BarRenderer();
renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
subplot2.setDomainGridlinesVisible(true);
CategoryAxis domainAxis = new CategoryAxis("Category");
CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
plot.add(subplot1, 2);
plot.add(subplot2, 1);
return plot;
}
示例3: createPlot
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* Creates a sample plot.
*
* @return A plot.
*/
private CombinedRangeCategoryPlot createPlot() {
CategoryDataset dataset1 = createDataset1();
NumberAxis rangeAxis1 = new NumberAxis("Value");
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
subplot1.setDomainGridlinesVisible(true);
CategoryDataset dataset2 = createDataset2();
NumberAxis rangeAxis2 = new NumberAxis("Value");
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer2 = new BarRenderer();
renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
subplot2.setDomainGridlinesVisible(true);
NumberAxis rangeAxis = new NumberAxis("Value");
CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(rangeAxis);
plot.add(subplot1, 2);
plot.add(subplot2, 1);
return plot;
}
示例4: test1654215
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRenderer(1, new LineAndShapeRenderer());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例5: testCloning2
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* A check for cloning.
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
r1.setBasePaint(Color.blue);
r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red,
3.0f, 4.0f, Color.blue));
LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone();
assertTrue(r1 != r2);
assertTrue(r1.getClass() == r2.getClass());
assertTrue(r1.equals(r2));
MyRendererChangeListener listener = new MyRendererChangeListener();
r2.addChangeListener(listener);
r2.setBasePaint(Color.red);
assertTrue(listener.lastEvent.getRenderer() == r2);
assertFalse(r1.hasListener(listener));
}
示例6: testBug2817504
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* Renderers that belong to the plot are being cloned but they are
* retaining a reference to the original plot.
*/
@Test
public void testBug2817504() {
CategoryPlot p1 = new CategoryPlot();
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
p1.setRenderer(r1);
CategoryPlot p2;
try {
p2 = (CategoryPlot) p1.clone();
}
catch (CloneNotSupportedException e) {
fail("Cloning failed.");
return;
}
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
// check for independence
LineAndShapeRenderer r2 = (LineAndShapeRenderer) p2.getRenderer();
assertTrue(r2.getPlot() == p2);
}
示例7: test1654215
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
@Test
public void test1654215() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRenderer(1, new LineAndShapeRenderer());
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
}
catch (Exception e) {
fail("No exception should be thrown.");
}
}
示例8: testRendererIndices
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
@Test
public void testRendererIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
assertEquals(renderer, plot.getRenderer(0));
// we should be able to give a renderer an arbitrary index
CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(20, renderer2);
assertEquals(2, plot.getRendererCount());
assertEquals(renderer2, plot.getRenderer(20));
assertEquals(20, plot.getIndexOf(renderer2));
}
示例9: testGetRendererForDataset2
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
@Test
public void testGetRendererForDataset2() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset2);
// by default, the renderer with index 0 is used
assertEquals(renderer, plot.getRendererForDataset(dataset2));
// add a second renderer with the same index as dataset2, now it will
// be used
CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
示例10: testDomainMarkerIndices
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
@Test
public void testDomainMarkerIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second x axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
CategoryAxis xAxis2 = new CategoryAxis("X2");
plot.setDomainAxis(1, xAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToDomainAxis(99, 1);
CategoryMarker xMarker1 = new CategoryMarker(123);
plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
xMarker1));
}
示例11: testRangeMarkerIndices
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
@Test
public void testRangeMarkerIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToRangeAxis(99, 1);
ValueMarker yMarker1 = new ValueMarker(123);
plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(
yMarker1));
}
示例12: testCloning2
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* A check for cloning.
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
r1.setDefaultPaint(Color.BLUE);
r1.setDefaultLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone();
assertTrue(r1 != r2);
assertTrue(r1.getClass() == r2.getClass());
assertTrue(r1.equals(r2));
MyRendererChangeListener listener = new MyRendererChangeListener();
r2.addChangeListener(listener);
r2.setDefaultPaint(Color.RED);
assertTrue(listener.lastEvent.getRenderer() == r2);
assertFalse(r1.hasListener(listener));
}
示例13: createLineChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
@Override
protected JFreeChart createLineChart() throws JRException
{
JFreeChart jfreeChart = super.createLineChart();
CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
lineRenderer.setBaseStroke(new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
// Stroke stroke = new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
for (int i = 0; i < lineRenderer.getRowCount(); i++)
{
lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
lineRenderer.setSeriesShapesVisible(i,true);
//it isn't applied at the moment
//lineRenderer.setSeriesStroke(i,stroke);
//line3DRenderer.setSeriesLinesVisible(i,lineRenderer.getSeriesVisible(i));
}
// configureChart(jfreeChart, getPlot());
return jfreeChart;
}
示例14: createCategoryItemRenderer
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* TODO
*
* @param c
* @param k
* @return
*/
@SuppressWarnings("deprecation")
private static CategoryItemRenderer createCategoryItemRenderer(Paint c, int k) {
CategoryItemRenderer renderer = new LineAndShapeRenderer();
renderer.setPaint(Color.black);
renderer.setShape(new Ellipse2D.Double(0, 0, 0, 0));
if (k == 3)
{
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
}
if (k == 2)
{
renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.JOIN_MITER, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f,
5.0f }, 0.0f));
}
if (k == 1)
{
renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 5.0f,
10.0f }, 0.0f));
}
return renderer;
}
示例15: styleChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入依賴的package包/類
/**
* TODO Documentation
*
* @param chart
* @return
*/
protected JFreeChart styleChart(JFreeChart chart) {
chart.setBackgroundPaint(Color.white);
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);
legend.setVisible(false);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.lightGray);
final LineAndShapeRenderer renderer = new LineAndShapeRenderer();
renderer.setSeriesLinesVisible(0,true);
renderer.setSeriesShapesVisible(1, true);
renderer.setBaseLinesVisible(true);
renderer.setBaseShapesFilled(true);
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.lightGray);
plot.setRenderer(renderer);
// customise the range axis...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
rangeAxis.setStandardTickUnits(rangeAxis.getStandardTickUnits());
return chart;
}