Package org.jfree.chart.entity

Examples of org.jfree.chart.entity.StandardEntityCollection


    }

    public static String renderChart(JFreeChart chart, String fileName) {
        String imageFile = "";
        try {
            final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            TempDir tempDir = TempDirUtils.createTempDir();
            File file1 = tempDir.createFile(fileName);
            imageFile = "<IMG SRC=\"file:" + file1.getAbsolutePath() + "\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>";
            ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
        } catch (IOException e) {
View Full Code Here


     * @return An instance of {@link EntityBlockResult}, or <code>null</code>.
     */
    public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
        // check if we need to collect chart entities from the container
        EntityBlockParams ebp = null;
        StandardEntityCollection sec = null;
        if (params instanceof EntityBlockParams) {
            ebp = (EntityBlockParams) params;
            if (ebp.getGenerateEntities()) {
                sec = new StandardEntityCollection();
            }
        }
        Rectangle2D contentArea = (Rectangle2D) area.clone();
        contentArea = trimMargin(contentArea);
        drawBorder(g2, contentArea);
        contentArea = trimBorder(contentArea);
        contentArea = trimPadding(contentArea);
        Iterator iterator = this.blocks.iterator();
        while (iterator.hasNext()) {
            Block block = (Block) iterator.next();
            Rectangle2D bounds = block.getBounds();
            Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX()
                    + area.getX(), bounds.getY() + area.getY(),
                    bounds.getWidth(), bounds.getHeight());
            Object r = block.draw(g2, drawArea, params);
            if (sec != null) {
                if (r instanceof EntityBlockResult) {
                    EntityBlockResult ebr = (EntityBlockResult) r;
                    EntityCollection ec = ebr.getEntityCollection();
                    sec.addAll(ec);
                }
            }
        }
        BlockResult result = null;
        if (sec != null) {
View Full Code Here

        area = trimBorder(area);
        area = trimPadding(area);

        // check if we need to collect chart entities from the container
        EntityBlockParams ebp = null;
        StandardEntityCollection sec = null;
        Shape entityArea = null;
        if (params instanceof EntityBlockParams) {
            ebp = (EntityBlockParams) params;
            if (ebp.getGenerateEntities()) {
                sec = new StandardEntityCollection();
                entityArea = (Shape) area.clone();
            }
        }
        g2.setPaint(this.paint);
        g2.setFont(this.font);
        Point2D pt = RectangleAnchor.coordinates(area, this.textAnchor);
        this.label.draw(g2, (float) pt.getX(), (float) pt.getY(),
                this.contentAlignmentPoint);
        BlockResult result = null;
        if (ebp != null && sec != null) {
            if (this.toolTipText != null || this.urlText != null) {
                ChartEntity entity = new ChartEntity(entityArea,
                        this.toolTipText, this.urlText);
                sec.add(entity);
                result = new BlockResult();
                result.setEntityCollection(sec);
            }
        }
        return result;
View Full Code Here

    /**
     * Constructs a new ChartRenderingInfo structure that can be used to
     * collect information about the dimensions of a rendered chart.
     */
    public ChartRenderingInfo() {
        this(new StandardEntityCollection());
    }
View Full Code Here

            // the entire chart at the beginning of the list.  This will
            // make it appear last in the image map (which is important,
            // because browsers process the image map areas in the order that
            // they appear; having the entire chart area listed first would
            // obscure all of the other image map areas).
            EntityCollection entities = new StandardEntityCollection();
            entities.add(new ChartEntity(info.getChartArea(), tooltip, href));
            if (info.getEntityCollection() != null)
                entities.addAll(info.getEntityCollection());
           
            // Next: most of our chart entities will not have URLs. URL values
            // don't inherit in the imagemap, so if we want the entire image
            // to have a single URL, we need to assign that URL to every
            // area in the chart.
            for (Iterator i = entities.iterator(); i.hasNext();) {
                ChartEntity ce = (ChartEntity) i.next();
                // check for no-op chart entity - these won't appear in the
                // image map anyway, so they don't need to be adjusted
                if (ce.getToolTipText() == null && ce.getURLText() == null)
                    continue;
View Full Code Here

   * @throws CewolfException
   */
  private static RenderedImage renderChart(ChartImage cd, Object chart) throws CewolfException {
    try {
      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
      final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
      final String mimeType = cd.getMimeType();
      if (MIME_PNG.equals(mimeType)) {
        handlePNG(baos, (JFreeChart)chart, cd.getWidth(), cd.getHeight(), info);
      } else if (MIME_JPEG.equals(mimeType)) {
          handleJPEG(baos, (JFreeChart)chart, cd.getWidth(), cd.getHeight(), info);
View Full Code Here

      // chart in the state we received it.
      if (!haslegend) {
        removeLegend(chart);
      }

      return new RenderedImage(out.toByteArray(), "image/jpeg", new ChartRenderingInfo(new StandardEntityCollection()));
    } catch (IOException ioex) {
      log.error("Renderer.renderLegend: "+ioex.getMessage());
      throw new ChartRenderingException(ioex.getMessage(), ioex);
    }
  }
View Full Code Here

        }

        chart.setBackgroundPaint(java.awt.Color.white);

        try {
            final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            ChartUtilities.saveChartAsPNG(tempTestSummaryFile, chart, 600, 400, info);
        } catch (IOException e) {
            logger.error("Problem saving png chart", e);
        }
View Full Code Here

    if (chart == null) return null;   
   
    chart.setBackgroundPaint(Color.WHITE);
   
    ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

    BufferedImage bufferedImage =  chart.createBufferedImage(reportChart.getWidth(), reportChart.getHeight(),info);
    byte[] image = null;
   
    try
View Full Code Here

    protected static String writeImageMap(JFreeChart chart, OutputElement outputElement, HttpSession session, PrintWriter pw) {
        String filename;
        try {
            //  Write the chart image to the temporary directory
            ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            filename = ServletUtilities.saveChartAsPNG(chart,
                    outputElement.getChart().getWidth().intValue(),
                    outputElement.getChart().getHeight().intValue(),
                    info, session);
View Full Code Here

TOP

Related Classes of org.jfree.chart.entity.StandardEntityCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.