Example usage for org.jfree.chart.util RelativeDateFormat RelativeDateFormat

List of usage examples for org.jfree.chart.util RelativeDateFormat RelativeDateFormat

Introduction

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

Prototype

public RelativeDateFormat() 

Source Link

Document

Creates a new instance with base milliseconds set to zero.

Usage

From source file:org.jfree.chart.demo.RelativeDateFormatDemo2.java

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("RelativeDateFormat Demo 2", "Date ", true,
            "Time To Complete", intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);
    DateAxis dateaxis = new DateAxis();
    RelativeDateFormat relativedateformat = new RelativeDateFormat();
    relativedateformat.setShowZeroDays(false);
    relativedateformat.setSecondFormatter(new DecimalFormat("00"));
    dateaxis.setDateFormatOverride(relativedateformat);
    xyplot.setRangeAxis(dateaxis);/*  w  ww.j  a va2 s.c  o m*/
    return jfreechart;
}

From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java

private void createChartPanel(String title, long time) {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    chart = ChartFactory.createTimeSeriesChart(title, X_AXIS_TITLE, "", dataset, true, true, true);
    XYPlot plot = (XYPlot) chart.getPlot();

    DeviationRenderer errorRenderer = new DeviationRenderer();
    errorRenderer.setShapesVisible(false);
    errorRenderer.setLinesVisible(true);
    errorRenderer.setAlpha(0.0f);// w w w . j a v a 2 s . c o  m
    // errorRenderer.setDrawYError(false);
    // errorRenderer.setDrawXError(false);
    plot.setRenderer(errorRenderer);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.DARK_GRAY);
    plot.setDomainGridlinePaint(Color.DARK_GRAY);
    upperDomainBound = (time / 1000) + ((interval - 1) * step / 1000);
    DateAxis domain = (DateAxis) plot.getDomainAxis();
    domain.setAutoRange(false);
    domain.setRange((time / 1000), upperDomainBound);
    RelativeDateFormat rdf = new RelativeDateFormat();
    rdf.setHourSuffix(":");
    rdf.setMinuteSuffix(":");
    rdf.setSecondSuffix("");
    rdf.setSecondFormatter(new DecimalFormat("0"));
    domain.setDateFormatOverride(rdf);
    plot.setDomainAxis(domain);
    plotPanel = new ChartPanel(chart, true);
    setSizeOfComponent(plotPanel, new Dimension(plotWidth, plotHeight));
    container.add(plotPanel, BorderLayout.CENTER);
    container.add(createRadioBoxes(visType == VisualizationType.Metric), BorderLayout.SOUTH);
    setSizeOfComponent(container, new Dimension(plotWidth, plotHeight + boxOffset));
}