org.jfree.chart.entity.StandardEntityCollection Java Examples

The following examples show how to use org.jfree.chart.entity.StandardEntityCollection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartRenderingInfoTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #2
Source File: ChartRenderingInfoTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #3
Source File: EESGenerator.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
@Override
public RepresentationResponse producePresentation(DesignOptions options) throws GeneratorException {
    ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
    String chartUrl = createChart(options, renderingInfo);
    
    Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea();
    for (Axis axis : renderer.getAxisMapping().values()) {
        axis.setMaxY(plotArea.getMaxY());
        axis.setMinY(plotArea.getMinY());
    }

    ImageEntity[] entities = {};
    if (!this.isOverview) {
        LOGGER.debug("Produced EES diagram " + chartUrl);
        entities = createImageEntities(renderingInfo.getEntityCollection());
    } else {
        LOGGER.debug("Produced EES Overview diagram " + chartUrl);
    }

    Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(), plotArea.getMaxY());
    return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping());
}
 
Example #4
Source File: ChartRenderingInfoTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #5
Source File: ChartRenderingInfoTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #6
Source File: ChartRenderingInfoTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertTrue(i1.equals(i2));
    
    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(i1.equals(i2));
    
    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertTrue(i1.equals(i2));
    
    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2); 
}
 
Example #7
Source File: ChartRenderingInfoTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #8
Source File: StandardEntityCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));
    
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));        
}
 
Example #9
Source File: StandardEntityCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));

    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));
}
 
Example #10
Source File: ChartRenderingInfoTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertTrue(i1.equals(i2));

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(i1.equals(i2));

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertTrue(i1.equals(i2));

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
 
Example #11
Source File: GetImageService.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private void performChartRendering(DesignOptions options, OutputStream outputStream) {
    try {
        EESGenerator chartGenerator = new EESGenerator();
        ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
        chartGenerator.createChartToOutputStream(options, renderingInfo, outputStream);
    }
    catch (Exception e) {
        LOGGER.error("Could not render timeseries chart.", e);
        throw new InternalServerException("internal error!", e);
    }
}
 
Example #12
Source File: GetImageService.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private ImageDataResult performChartRendering(DesignOptions options) {
    try {
        EESGenerator chartGenerator = new EESGenerator();
        ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
        String chartUrl = chartGenerator.createChart(options, renderingInfo);
        return new ImageDataResult(chartUrl);
    }
    catch (Exception e) {
        LOGGER.error("Could not render time series chart.", e);
        throw new InternalServerException("internal error!", e);
    }
}
 
Example #13
Source File: AdminJFreeChartController.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
private String createXYLineChart(HttpSession session, String title,
		String xtitle, String ytitle, int width, int height, String useMap,
		PrintWriter pw) {
	XYDataset xydataset = getXYDataset();
	String filename = "";

	JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle,
			ytitle, xydataset, PlotOrientation.VERTICAL, true, true, true);
	chart.setTitle(new TextTitle(title, new Font("Calibri",
			Font.ITALIC, 12)));
	chart.getTitle().setFont(new Font("Calibri", Font.PLAIN, 12));
	chart.setBackgroundPaint(Color.white);

	/*
	 
	final XYPlot xyplot = (XYPlot) jfreechart.getPlot();
	xyplot.setBackgroundPaint(Color.lightGray);
	xyplot.setDomainGridlinePaint(Color.white);
	xyplot.setDomainGridlinesVisible(true);
	xyplot.setRangeGridlinePaint(Color.white);
	xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

	final ValueAxis categoryAxis = xyplot.getDomainAxis();
	// categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
	categoryAxis.setLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12));
	categoryAxis.setTickLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12));

	NumberAxis numberAxis = (NumberAxis) xyplot.getRangeAxis();
	numberAxis.setLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12));
	numberAxis.setTickLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12));
	numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
	numberAxis.setAutoRangeIncludesZero(true);

	XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot
			.getRenderer();
	xylineandshaperenderer.setShapesVisible(true);
	xylineandshaperenderer.setShapesFilled(true);

	xylineandshaperenderer.setSeriesLinesVisible(0, false);
	xylineandshaperenderer.setSeriesShapesVisible(1, false);
	xyplot.setRenderer(xylineandshaperenderer);

	xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1,
			1.0F, new float[] { 10F, 6F }, 0.0F));
	xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1,
			1.0F, new float[] { 6F, 6F }, 0.0F));
	xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1,
			1.0F, new float[] { 2.0F, 6F }, 0.0F));

	xylineandshaperenderer
			.setBaseItemLabelGenerator(new IntervalXYItemLabelGenerator(
					"({1},{2})", NumberFormat.getNumberInstance(),
					NumberFormat.getNumberInstance()));
	xylineandshaperenderer.setURLGenerator(new StandardXYURLGenerator(
			"/hrms/admin_charts", "seriesName", "itemName"));

	xylineandshaperenderer.setLegendTextFont(0, new Font("Calibri",
			Font.TYPE1_FONT, 12));
	xylineandshaperenderer.setLegendTextFont(1, new Font("Calibri",
			Font.TYPE1_FONT, 12));
	xylineandshaperenderer.setLegendTextFont(2, new Font("Calibri",
			Font.TYPE1_FONT, 12));
        */
	
      
      final XYPlot plot = chart.getXYPlot( );
      XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( );
      renderer.setSeriesPaint( 0 , Color.RED );
      renderer.setSeriesPaint( 1 , Color.GREEN );
      renderer.setSeriesPaint( 2 , Color.YELLOW );
      renderer.setSeriesStroke( 0 , new BasicStroke( 4.0f ) );
      renderer.setSeriesStroke( 1 , new BasicStroke( 3.0f ) );
      renderer.setSeriesStroke( 2 , new BasicStroke( 2.0f ) );
      plot.setRenderer( renderer );
	ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

	try {
		filename = ServletUtilities.saveChartAsPNG(chart, width,
				height, info, session);
		ChartUtilities.writeImageMap(pw, useMap, info, false);
		pw.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return filename;
}
 
Example #14
Source File: ReportPage.java    From freeacs with MIT License 4 votes vote down vote up
private void displayReportChartWithImageMap(
    Map<String, Object> root,
    int numberOfColumns,
    int averageLengthPrLegend,
    List<String> aggregation,
    HttpSession session) {
  StringWriter stringWriter = new StringWriter();
  PrintWriter writer = new PrintWriter(stringWriter);

  boolean shouldZoom = true;

  switch (reportType) {
    case JOB:
    case UNIT:
      shouldZoom = false;
      break;
    default:
      break;
  }

  String clickablePointUrl = "";
  if (shouldZoom || periodType.getSelected().isLongerThan(PeriodType.HOUR)) {
    clickablePointUrl =
        generateClickablePointUrl(
            periodType.getSelected(),
            reportType.getName(),
            method.getSelected(),
            optionalmethod.getSelected());
  }

  XYPlot plot = (XYPlot) chart.getPlot();
  XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
  XYURLGenerator urls = new ReportURLGenerator(clickablePointUrl, chart, aggregation);
  renderer.setURLGenerator(urls);
  XYSeriesLabelGenerator slg =
      new CustomXYSeriesLabelGenerator("javascript:xAPS.report.updateReport(%d);");
  renderer.setLegendItemURLGenerator(slg);
  renderer.setDefaultShapesVisible(true);
  renderer.setDrawOutlines(true);
  renderer.setUseFillPaint(true);
  renderer.setDefaultFillPaint(Color.white);

  try {
    ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ByteArrayOutputStream image = new ByteArrayOutputStream();

    int chartWidth = 700 + 10 * averageLengthPrLegend * numberOfColumns + 35 * numberOfColumns;

    ChartUtils.writeChartAsPNG(image, chart, chartWidth, 400, info);

    session.setAttribute("JFreeChartPNG" + reportType.getName(), image.toByteArray());

    ImageMapUtils.writeImageMap(
        writer,
        "chart" + reportType.getName(),
        info,
        arg0 -> " title=\"" + arg0 + "\" alt=\"" + arg0 + "\"",
        arg0 -> " href=\"" + arg0 + "\"");

    writer.println(
        "<img src=\""
            + Page.REPORT.getUrl()
            + "&type="
            + reportType.getName()
            + "&image=true&d="
            + new Date().getTime()
            + "\" border=\"0\" usemap=\"#chart"
            + reportType.getName()
            + "\" id=\"ImageMapImg\" alt=\"ReportImage\"/>");
    writer.close();

    root.put("imagemap", stringWriter.toString());
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
Example #15
Source File: ChartRenderingInfo.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #16
Source File: ChartRenderingInfo.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #17
Source File: ChartRenderingInfo.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #18
Source File: ChartRenderingInfo.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to 
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #19
Source File: ChartRenderingInfo.java    From opensim-gui with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to 
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #20
Source File: ChartRenderingInfo.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #21
Source File: ChartRenderingInfo.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #22
Source File: ChartRenderingInfo.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}
 
Example #23
Source File: ChartRenderingInfo.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a new ChartRenderingInfo structure that can be used to
 * collect information about the dimensions of a rendered chart.
 */
public ChartRenderingInfo() {
    this(new StandardEntityCollection());
}