Example usage for org.jfree.chart.plot XYPlot setDomainAxes

List of usage examples for org.jfree.chart.plot XYPlot setDomainAxes

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setDomainAxes.

Prototype

public void setDomainAxes(ValueAxis[] axes) 

Source Link

Document

Sets the domain axes for this plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * some jFreeChart Axis settings for TimeValueDiagram
 * @param plot            jFreeChart plot instance
 * @param rangeAxisLabel   Label of rangeAxis
 *//*from  ww  w  .  j av  a  2  s  .  c  o m*/
private void buildTimeValueDiagramAxisFormat(XYPlot plot, String rangeAxisLabel) {
    System.out.println("StatisticGrafic.buildTimeValueDiagramAxisFormat");
    ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis();
    double a = 0.1 * Math.max(Math.abs(statistic.getValueLow()), Math.abs(statistic.getValueHigh()));
    rangeAxis.setLowerBound(statistic.getValueLow() - a);
    rangeAxis.setUpperBound(statistic.getValueHigh() + a);
    rangeAxis.setLabel(rangeAxisLabel);
    rangeAxis.setLabelFont(FONT_DEFAULT);

    DateAxis dateAxis = new DateAxis();
    DateAxis[] domainAxisArray = new DateAxis[1];
    domainAxisArray[0] = dateAxis;
    plot.setDomainAxes(domainAxisArray);

    dateAxis.setLowerBound(statistic.getTimeLow());
    dateAxis.setUpperBound(statistic.getTimeHigh());

    long diff = statistic.getTimeHigh() - statistic.getTimeLow();
    String format, unit;
    if (diff > 24 * 60 * 60 * 1000) {
        format = "d.MM.yyyy";
        unit = "[day]";
    } else if (diff > 60 * 60 * 1000) {
        format = "H:mm";
        unit = "[h]";
    } else if (diff > 60 * 1000) {
        format = "m:ss";
        unit = "[min]";
    } else if (diff > 1000) {
        format = "s.S";
        unit = "[sec]";
    } else {
        format = "S";
        unit = "[millisec]";
    }
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    dateAxis.setDateFormatOverride(sdf);
    SimpleDateFormat sdf1 = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS");
    String von = sdf1.format(dateAxis.getMinimumDate());
    String bis = sdf1.format(dateAxis.getMaximumDate());
    dateAxis.setLabel(von + "    Time " + unit + "   " + bis);
    dateAxis.setLabelFont(FONT_DEFAULT);

}