Example usage for org.jfree.chart.axis TickUnit valueToString

List of usage examples for org.jfree.chart.axis TickUnit valueToString

Introduction

In this page you can find the example usage for org.jfree.chart.axis TickUnit valueToString.

Prototype

public String valueToString(double value) 

Source Link

Document

Converts the supplied value to a string.

Usage

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * @return the timeAxis// w w w  .  java  2 s .co  m
 */
private NumberAxis getTimeAxis() {
    if (timeAxis == null) {
        timeAxis = new NumberAxis(ResourceBundleHelper.getMessageString("waterfall.time")) {
            private static final long serialVersionUID = 1L;

            /**
             * This override prevents the tick units from changing
             * as the timeline is scrolled to numbers with more digits
             */
            @Override
            protected double estimateMaximumTickLabelWidth(Graphics2D g2d, TickUnit unit) {

                if (isVerticalTickLabels()) {
                    return super.estimateMaximumTickLabelWidth(g2d, unit);
                } else {
                    RectangleInsets tickLabelInsets = getTickLabelInsets();
                    double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight();

                    // look at lower and upper bounds...
                    FontMetrics fMetrics = g2d.getFontMetrics(getTickLabelFont());
                    double upper = traceDuration;
                    String upperStr = "";
                    NumberFormat formatter = getNumberFormatOverride();
                    if (formatter == null) {
                        upperStr = unit.valueToString(upper);
                    } else {
                        upperStr = formatter.format(upper);
                    }
                    double width2 = fMetrics.stringWidth(upperStr);
                    result += width2;
                    return result;
                }

            }

        };
        timeAxis.setRange(new Range(0, DEFAULT_TIMELINE));
        timeAxis.setStandardTickUnits(units);
    }
    return timeAxis;
}