Example usage for org.jfree.chart JFreeChart JFreeChart

List of usage examples for org.jfree.chart JFreeChart JFreeChart

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart JFreeChart.

Prototype

public JFreeChart(Plot plot) 

Source Link

Document

Creates a new chart based on the supplied plot.

Usage

From source file:org.tsho.dmc2.managers.AbstractManager.java

protected AbstractManager(ManagerListener2 frame) {

    this.frame = frame;

    xAxis = new NumberAxis();
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setAutoRangeStickyZero(false);
    xAxis.setLowerMargin(0);/*from   www  . j  av  a2  s  .  com*/
    xAxis.setUpperMargin(0);

    yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRangeStickyZero(false);
    yAxis.setLowerMargin(0);
    yAxis.setUpperMargin(0);

    plot = new DmcRenderablePlot(xAxis, yAxis);
    plot.setNoDataMessage("No data.");

    chart = new JFreeChart(plot);
    chart.setNotify(false);

    chartPanel = new DmcChartPanel(chart);
    //chartPanel.setDataset(frame.getDataset());
    chartPanel.setMouseZoomable(true, false);
    chartPanel.setPopupMenu(null);

    chartPanel.setStatusBarFrame((AbstractPlotComponent) frame);
}

From source file:org.cds06.speleograph.GraphPanel.java

/**
 * Construct a new GraphPanel for an application instance.
 *
 * @param app The instance which should be linked with this Chart.
 *//*from   w  ww.ja va 2s .c  om*/
public GraphPanel(SpeleoGraphApp app) {
    Validate.notNull(app);
    application = app;
    setLayout(new BorderLayout());
    dateAxis = new DateAxis();
    plot = new SpeleoXYPlot();
    chart = new JFreeChart(plot);
    new StandardChartTheme("JFree").apply(chart); // NON-NLS
    chartPanel = new ChartPanel(chart, false, true, false, true, true);
    chartPanel.addChartMouseListener(this);
    setupEmptyChart();
    Series.setGraphPanel(this);
    chartPanel.setPopupMenu(null);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setMouseZoomable(false);
    chartPanel.setDomainZoomable(true);
    add(chartPanel);
    log.info("GraphPanel is initialized");
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.ui.panel.FoldChangeViewPanel.java

/**
 * Creates new form Chromatogram1DViewPanel
 *//*ww  w  .  j  a  v a2  s.c om*/
public FoldChangeViewPanel(InstanceContent topComponentInstanceContent, Lookup tcLookup,
        ADataset1D<StatisticsContainer, FoldChangeElement> ds) {
    initComponents();
    this.content = topComponentInstanceContent;
    this.lookup = tcLookup;
    chart = new JFreeChart(new XYPlot());
    chartPanel = new ContextAwareChartPanel(chart, true, true, true, true, true);
    Cursor crosshairCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
    chartPanel.setCursor(crosshairCursor);
    chartPanel.setInitialDelay(100);
    chartPanel.setDismissDelay(30000);
    chartPanel.setReshowDelay(0);
    chartPanel.setFocusable(true);
    chartPanel.setMouseWheelEnabled(true);
    add(chartPanel, BorderLayout.CENTER);
    content.add(chartPanel);
}

From source file:de.bund.bfr.knime.nls.chart.ChartCreator.java

public ChartCreator(Map<String, Plotable> plotables, Map<String, String> legend) {
    this.plotables = plotables;
    this.legend = legend;
    colors = new LinkedHashMap<>();
    shapes = new LinkedHashMap<>();

    chartPanel = new ChartPanel(new JFreeChart(new XYPlot())) {

        private static final long serialVersionUID = 1L;

        @Override//from w  w w  .  ja va  2 s. c om
        public void mouseReleased(MouseEvent e) {
            ValueAxis domainAxis = ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis();
            ValueAxis rangeAxis = ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis();

            Range xRange1 = domainAxis.getRange();
            Range yRange1 = rangeAxis.getRange();
            super.mouseReleased(e);
            Range xRange2 = domainAxis.getRange();
            Range yRange2 = rangeAxis.getRange();

            if (!xRange1.equals(xRange2) || !yRange1.equals(yRange2)) {
                minX = xRange2.getLowerBound();
                maxX = xRange2.getUpperBound();
                minY = yRange2.getLowerBound();
                maxY = yRange2.getUpperBound();
                fireZoomChanged();
            }
        }
    };
    chartPanel.getPopupMenu().removeAll();

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastUDial.java

/**
 * Processes requests for both HTTP/*from www . j a  va 2  s . c om*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorHumidity());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    //plot.setView(0.1, 0.1, 0.9, 0.9);
    // plot.set
    plot.setDataset(0, dataset);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setBackground(db);

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(0);
    scale.setUpperBound(100);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);
    plot.setInsets(RectangleInsets.ZERO_INSETS);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Humidity %");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelDetailAggr.java

public boolean loadData() {
    super.loadData();

    AggregationTableModel m = new AggregationTableModel(app.getXmlClient());
    m.load(objektNode, t, a);/*from  www  . j  a  va2 s.c  o  m*/
    panelAggr.setModel(m);
    panelAggr.setObjektNode(objektNode);

    // Grafik

    XYDataset xyDataset = new TableModelXYDataset(m, true);

    DateAxis domainAxis = new DateAxis("Time");

    StringBuffer buf = new StringBuffer();
    buf.append(hashf.get(a.getFunctionId()));
    buf.append(" per ");
    buf.append(hashi.get(a.getIntervallId()));
    buf.append(" of ");
    buf.append(ChartUtils.getNumberAxisLabel(app.getXmlClient(), objektNode.getId()));
    NumberAxis rangeAxis = new NumberAxis(buf.toString());
    int rend = pref.getInt("xyitemrenderer", DefaultXYItemRenderer.LINES);

    Plot plot = new StatusXYPlot(xyDataset, domainAxis, rangeAxis, new DefaultItemRenderer());
    panelChart.setChart(new JFreeChart(plot));

    return true;
}

From source file:com.bdb.weather.display.freeplot.FreePlot.java

/**
 * Constructor.// w w  w  .  j a v a2  s  . c  om
 * 
 * @param seriesFactory The factory for creating the series
 * @param controlFactory The factory for creating the controls
 */

@SuppressWarnings("LeakingThisInConstructor")
FreePlot(SeriesCollectionFactory seriesFactory) {
    controls = seriesFactory.createSeriesGroupControls(this);
    factory = seriesFactory;
    this.setTop(createDataRangeSelectionPanel());
    this.setLeft(createDataSelectionPanel(controls.values()));

    ChartViewer chartViewer = new ChartViewer(new JFreeChart(plot));
    chartViewer.setMaxHeight(20000);
    chartViewer.setMaxWidth(20000);
    this.setCenter(chartViewer);

    //
    // Create a default Y Axis
    //
    DateAxis dateAxis = new DateAxis("Date/Time");
    plot.setDomainAxis(dateAxis);
    plot.setRangeAxis(new NumberAxis("Data"));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    buildStrokes();
}

From source file:org.vast.stt.renderer.JFreeChart.JFreeChartRenderer.java

@Override
public void drawScene(ChartScene sc) {
    if (composite.isDisposed())
        return;//  w ww .ja va  2  s.c o  m

    // initialize plot builder
    plotBuilder.createPlot(sc);

    // draw all items
    ChartScene scene = (ChartScene) sc;
    List<SceneItem> sceneItems = scene.getSceneItems();
    for (int i = 0; i < sceneItems.size(); i++) {
        SceneItem nextItem = sceneItems.get(i);

        if (!nextItem.isVisible())
            continue;

        if (!nextItem.getDataItem().isEnabled())
            continue;

        drawItem(nextItem);
    }

    // create a new chart and assign to panel
    if (plotBuilder.isReady()) {
        JFreeChart chart = new JFreeChart(plotBuilder.getPlot());
        chart.setTitle(scene.getName());
        chartPanel.setChart(chart);
    } else {
        chartPanel.setChart(null);
    }
    //chart.draw((Graphics2D)img1.getGraphics(), img1.getGraphics().getClipBounds());
    //BufferedImage img = chart.createBufferedImage(800, 600);
    //byte[] data = ((DataBufferByte)img1.getData().getDataBuffer()).getData();
    //ImageData imgData = new ImageData(img1.getWidth(), img1.getHeight(), img1.getColorModel().getPixelSize(), palette);
    //imgData.setPixels(0, 0, img1.getWidth(), data, 0);
    //chartImg = new Image(composite.getDisplay(), imgData);
}

From source file:net.sf.maltcms.common.charts.api.XYChartBuilder.java

/**
 *
 *///w ww .j  a va  2s.c om
public XYChartBuilder() {
    plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
    chart = new JFreeChart(plot);
    renderingHints = new RenderingHints(null);
    renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
    renderingHints.put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    renderingHints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    renderingHints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
    renderingHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    renderingHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    renderingHints.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
}

From source file:com.tonbeller.jpivot.chart.ChartFactory.java

/**
 * Creates a sample dataset for the demo.
 * //from   ww w  .j  ava  2 s  .c  om
 * @return A sample dataset.
 */
public static JFreeChart create3DPieChart(String title, java.awt.Font titleFont, CategoryDataset data,
        TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) {

    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    //plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot();
    pp.setBackgroundPaint(null);
    //pp.setInsets(new Insets(0, 5, 5, 5));

    // no outline around each piechart
    pp.setOutlineStroke(null);

    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
        tooltipGenerator = new StandardPieToolTipGenerator();
    }

    if (!urls) {
        urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}