当前位置: 首页>>代码示例>>Java>>正文


Java ChartRenderingInfo类代码示例

本文整理汇总了Java中org.jfree.chart.ChartRenderingInfo的典型用法代码示例。如果您正苦于以下问题:Java ChartRenderingInfo类的具体用法?Java ChartRenderingInfo怎么用?Java ChartRenderingInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ChartRenderingInfo类属于org.jfree.chart包,在下文中一共展示了ChartRenderingInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Draws the content of the canvas and updates the 
 * {@code renderingInfo} attribute with the latest rendering 
 * information.
 */
public final void draw() {
    GraphicsContext ctx = getGraphicsContext2D();
    ctx.save();
    double width = getWidth();
    double height = getHeight();
    if (width > 0 && height > 0) {
        ctx.clearRect(0, 0, width, height);
        this.info = new ChartRenderingInfo();
        if (this.chart != null) {
            this.chart.draw(this.g2, new Rectangle((int) width, 
                    (int) height), this.anchor, this.info);
        }
    }
    ctx.restore();
    for (OverlayFX overlay : this.overlays) {
        overlay.paintOverlay(g2, this);
    }
    this.anchor = null;
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:25,代码来源:ChartCanvas.java

示例2: getTooltipText

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Returns the tooltip text.
 * 
 * @param canvas  the canvas that is displaying the chart.
 * @param x  the x-coordinate of the mouse pointer.
 * @param y  the y-coordinate of the mouse pointer.
 * 
 * @return String The tooltip text (possibly {@code null}).
  */
private String getTooltipText(ChartCanvas canvas, double x, double y) {
    ChartRenderingInfo info = canvas.getRenderingInfo();
    if (info == null) {
        return null;
    }
    EntityCollection entities = info.getEntityCollection();
    if (entities == null) {
        return null;
    }
    ChartEntity entity = entities.getEntity(x, y);
    if (entity == null) {
        return null;
    }
    return entity.getToolTipText();
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:25,代码来源:TooltipHandlerFX.java

示例3: handleZoomable

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:32,代码来源:ScrollHandlerFX.java

示例4: saveChartAsPNG

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Saves the chart as a PNG format file in the temporary directory and
 * populates the ChartRenderingInfo object which can be used to generate
 * an HTML image map.
 *
 * @param chart  the chart to be saved (<code>null</code> not permitted).
 * @param width  the width of the chart.
 * @param height  the height of the chart.
 * @param info  the ChartRenderingInfo object to be populated (<code>null</code> permitted).
 * @param session  the HttpSession of the client.
 *
 * @return the filename of the chart saved in the temporary directory.
 *
 * @throws IOException if there is a problem saving the file.
 */
public static String saveChartAsPNG(JFreeChart chart, int width, int height,
                                    ChartRenderingInfo info, HttpSession session)
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");   
    }
    ServletUtilities.createTempDir();
    File tempFile = File.createTempFile(
        ServletUtilities.tempFilePrefix, ".png", 
        new File(System.getProperty("java.io.tmpdir"))
    );
    ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);
    ServletUtilities.registerChartForDeletion(tempFile, session);
    return tempFile.getName();

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:ServletUtilities.java

示例5: saveChartAsJPEG

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Saves the chart as a JPEG format file in the temporary directory and
 * populates the ChartRenderingInfo object which can be used to generate
 * an HTML image map.
 *
 * @param chart  the chart to be saved (<code>null</code> not permitted).
 * @param width  the width of the chart
 * @param height  the height of the chart
 * @param info  the ChartRenderingInfo object to be populated
 * @param session  the HttpSession of the client
 *
 * @return the filename of the chart saved in the temporary directory
 *
 * @throws IOException if there is a problem saving the file.
 */
public static String saveChartAsJPEG(JFreeChart chart, int width, int height,
                                     ChartRenderingInfo info, HttpSession session)
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");   
    }
    
    ServletUtilities.createTempDir();
    File tempFile = File.createTempFile(
        ServletUtilities.tempFilePrefix, 
        ".jpeg", new File(System.getProperty("java.io.tmpdir"))
    );
    ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);
    ServletUtilities.registerChartForDeletion(tempFile, session);

    return tempFile.getName();

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:ServletUtilities.java

示例6: writeImageMap

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Writes an image map to an output stream.
 *
 * @param writer  the writer (<code>null</code> not permitted).
 * @param name  the map name (<code>null</code> not permitted).
 * @param info  the chart rendering info (<code>null</code> not permitted).
 * @param useOverLibForToolTips  whether to use OverLIB for tooltips
 *                               (http://www.bosrup.com/web/overlib/).
 *
 * @throws java.io.IOException if there are any I/O errors.
 */
public static void writeImageMap(PrintWriter writer,
                                 String name,
                                 ChartRenderingInfo info,
                                 boolean useOverLibForToolTips) throws IOException {

    ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null;
    if (useOverLibForToolTips) {
        toolTipTagFragmentGenerator = new OverLIBToolTipTagFragmentGenerator();
    }
    else {
        toolTipTagFragmentGenerator = new StandardToolTipTagFragmentGenerator();
    }
    ImageMapUtil.writeImageMap(
        writer, name, info, toolTipTagFragmentGenerator, new StandardURLTagFragmentGenerator()
    );

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:ImageMapUtil.java

示例7: getImageMap

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Creates an HTML image map.
 *
 * @param name  the map name (<code>null</code> not permitted).
 * @param info  the chart rendering info (<code>null</code> not permitted).
 * @param toolTipTagFragmentGenerator  the tool tip generator.
 * @param urlTagFragmentGenerator  the url generator.
 *
 * @return the map tag.
 */
public static String getImageMap(String name,
                                 ChartRenderingInfo info,
                                 ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
                                 URLTagFragmentGenerator urlTagFragmentGenerator) {

    StringBuffer sb = new StringBuffer();
    sb.append("<MAP NAME=\"" + name + "\">");
    sb.append(System.getProperty("line.separator"));
    EntityCollection entities = info.getEntityCollection();
    if (entities != null) {
        Iterator iterator = entities.iterator();
        while (iterator.hasNext()) {
            ChartEntity entity = (ChartEntity) iterator.next();
            String area = entity.getImageMapAreaTag(toolTipTagFragmentGenerator,
                                                    urlTagFragmentGenerator);
            if (area.length() > 0) {
                sb.append(area);
                sb.append(System.getProperty("line.separator"));
            }
        }
    }
    sb.append("</MAP>");

    return sb.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:ImageMapUtil.java

示例8: testEquals

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * 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); 
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:ChartRenderingInfoTests.java

示例9: saveChartAsPNG

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Saves the chart as a PNG format file in the temporary directory and
 * populates the {@link ChartRenderingInfo} object which can be used to 
 * generate an HTML image map.
 *
 * @param chart  the chart to be saved (<code>null</code> not permitted).
 * @param width  the width of the chart.
 * @param height  the height of the chart.
 * @param info  the ChartRenderingInfo object to be populated 
 *              (<code>null</code> permitted).
 * @param session  the HttpSession of the client (if <code>null</code>, the
 *                 temporary file is marked as "one-time" and deleted by 
 *                 the {@link DisplayChart} servlet right after it is
 *                 streamed to the client).
 *
 * @return The filename of the chart saved in the temporary directory.
 *
 * @throws IOException if there is a problem saving the file.
 */
public static String saveChartAsPNG(JFreeChart chart, int width, int height,
        ChartRenderingInfo info, HttpSession session) throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");   
    }
    ServletUtilities.createTempDir();
    String prefix = ServletUtilities.tempFilePrefix;
    if (session == null) {
        prefix = ServletUtilities.tempOneTimeFilePrefix;
    }
    File tempFile = File.createTempFile(prefix, ".png", 
            new File(System.getProperty("java.io.tmpdir")));
    ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);
    if (session != null) {
        ServletUtilities.registerChartForDeletion(tempFile, session);
    }
    return tempFile.getName();

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:ServletUtilities.java

示例10: writeImageMap

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Writes an image map to an output stream.
 *
 * @param writer  the writer (<code>null</code> not permitted).
 * @param name  the map name (<code>null</code> not permitted).
 * @param info  the chart rendering info (<code>null</code> not permitted).
 * @param useOverLibForToolTips  whether to use OverLIB for tooltips
 *                               (http://www.bosrup.com/web/overlib/).
 *
 * @throws java.io.IOException if there are any I/O errors.
 */
public static void writeImageMap(PrintWriter writer,
                                 String name,
                                 ChartRenderingInfo info,
                                 boolean useOverLibForToolTips) 
    throws IOException {

    ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null;
    if (useOverLibForToolTips) {
        toolTipTagFragmentGenerator 
                = new OverLIBToolTipTagFragmentGenerator();
    }
    else {
        toolTipTagFragmentGenerator 
                = new StandardToolTipTagFragmentGenerator();
    }
    ImageMapUtilities.writeImageMap(writer, name, info, 
            toolTipTagFragmentGenerator, 
            new StandardURLTagFragmentGenerator());

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:ImageMapUtilities.java

示例11: testNoDisplayedItem

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:29,代码来源:StandardXYItemRendererTest.java

示例12: testDrawWithNullMean

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Draws a chart where the dataset contains a null mean value.
 */
@Test
public void testDrawWithNullMean() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(null, new Double(2.0),
                new Double(0.0), new Double(4.0), new Double(0.5),
                new Double(4.5), new Double(-0.5), new Double(5.5),
                null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset,
                new CategoryAxis("Category"), new NumberAxis("Value"),
                new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                info);
        success = true;
    }
    catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:28,代码来源:BoxAndWhiskerRendererTest.java

示例13: testDrawWithNullMedian

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Draws a chart where the dataset contains a null median value.
 */
@Test
public void testDrawWithNullMedian() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), null,
                new Double(0.0), new Double(4.0), new Double(0.5),
                new Double(4.5), new Double(-0.5), new Double(5.5),
                null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset,
                new CategoryAxis("Category"), new NumberAxis("Value"),
                new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                info);
        success = true;
    }
    catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:28,代码来源:BoxAndWhiskerRendererTest.java

示例14: testDrawWithNullQ1

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Draws a chart where the dataset contains a null Q1 value.
 */
@Test
public void testDrawWithNullQ1() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),
                null, new Double(4.0), new Double(0.5),
                new Double(4.5), new Double(-0.5), new Double(5.5),
                null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset,
                new CategoryAxis("Category"), new NumberAxis("Value"),
                new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                info);
        success = true;
    }
    catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:28,代码来源:BoxAndWhiskerRendererTest.java

示例15: testDrawWithNullQ3

import org.jfree.chart.ChartRenderingInfo; //导入依赖的package包/类
/**
 * Draws a chart where the dataset contains a null Q3 value.
 */
@Test
public void testDrawWithNullQ3() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),
                new Double(3.0), null, new Double(0.5),
                new Double(4.5), new Double(-0.5), new Double(5.5),
                null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset,
                new CategoryAxis("Category"), new NumberAxis("Value"),
                new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                info);
        success = true;
    }
    catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:28,代码来源:BoxAndWhiskerRendererTest.java


注:本文中的org.jfree.chart.ChartRenderingInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。