Example usage for org.jfree.chart.axis NumberTickUnit equals

List of usage examples for org.jfree.chart.axis NumberTickUnit equals

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberTickUnit equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Tests this formatter for equality with an arbitrary object.

Usage

From source file:fr.inria.soctrace.framesoc.ui.histogram.view.HistogramView.java

/**
 * Prepare the plot//from   www.j  ava2s.  co m
 * 
 * @param chart
 *            jfreechart chart
 * @param displayed
 *            displayed time interval
 */
private void preparePlot(boolean first, JFreeChart chart, TimeInterval displayed) {
    // Plot customization
    plot = chart.getXYPlot();
    // Grid and background colors
    plot.setBackgroundPaint(BACKGROUND_PAINT);
    plot.setDomainGridlinePaint(DOMAIN_GRIDLINE_PAINT);
    plot.setRangeGridlinePaint(RANGE_GRIDLINE_PAINT);
    // Tooltip
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(TOOLTIP_GENERATOR);
    // Disable bar white stripes
    XYBarRenderer barRenderer = (XYBarRenderer) plot.getRenderer();
    barRenderer.setBarPainter(new StandardXYBarPainter());
    // X axis
    X_FORMAT.setTimeUnit(TimeUnit.getTimeUnit(currentShownTrace.getTimeUnit()));
    X_FORMAT.setContext(displayed.startTimestamp, displayed.endTimestamp, true);
    NumberAxis xaxis = (NumberAxis) plot.getDomainAxis();
    xaxis.setTickLabelFont(TICK_LABEL_FONT);
    xaxis.setLabelFont(LABEL_FONT);
    xaxis.setNumberFormatOverride(X_FORMAT);
    TickDescriptor des = X_FORMAT.getTickDescriptor(displayed.startTimestamp, displayed.endTimestamp,
            numberOfTicks);
    xaxis.setTickUnit(new NumberTickUnit(des.delta));
    xaxis.addChangeListener(new AxisChangeListener() {
        @Override
        public void axisChanged(AxisChangeEvent arg) {
            long max = ((Double) plot.getDomainAxis().getRange().getUpperBound()).longValue();
            long min = ((Double) plot.getDomainAxis().getRange().getLowerBound()).longValue();
            TickDescriptor des = X_FORMAT.getTickDescriptor(min, max, numberOfTicks);
            NumberTickUnit newUnit = new NumberTickUnit(des.delta);
            NumberTickUnit currentUnit = ((NumberAxis) arg.getAxis()).getTickUnit();
            // ensure we don't loop
            if (!currentUnit.equals(newUnit)) {
                ((NumberAxis) arg.getAxis()).setTickUnit(newUnit);
            }
        }
    });
    // Y axis
    NumberAxis yaxis = (NumberAxis) plot.getRangeAxis();
    yaxis.setTickLabelFont(TICK_LABEL_FONT);
    yaxis.setLabelFont(LABEL_FONT);
    // remove the marker, if any
    if (marker != null) {
        plot.removeDomainMarker(marker);
        marker = null;
    }
}