Example usage for org.jfree.chart.axis NumberTick NumberTick

List of usage examples for org.jfree.chart.axis NumberTick NumberTick

Introduction

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

Prototype

public NumberTick(Number number, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) 

Source Link

Document

Creates a new tick.

Usage

From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java

/**
 * Calculates the positions of the tick labels for the axis, storing the
 * results in the tick label list (ready for drawing).
 *
 * @param g2  the graphics device.//from   ww  w .j  a  va 2  s.c om
 * @param dataArea  the area in which the plot should be drawn.
 * @param edge  the location of the axis.
 *
 * @return A list of ticks.
 */
protected List logRefreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {

    List ticks = new java.util.ArrayList();
    Range range = getRange();

    //get lower bound value:
    double lowerBoundVal = range.getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }

    //get upper bound value
    double upperBoundVal = range.getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    double currentTickValue;
    String tickLabel;
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each power of 10 value; create ten ticks
        for (int j = 0; j < 10; ++j) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use; create numeric value for tick
                currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) {
                    //showing "1e#"-style ticks or negative exponent
                    // generating tick value between 0 & 1; show fewer
                    if (j == 0 || (i > -4 && j < 2) || currentTickValue >= upperBoundVal) {
                        //first tick of series, or not too small a value and
                        // one of first 3 ticks, or last tick to be displayed
                        // set exact number of fractional digits to be shown
                        // (no effect if showing "1e#"-style ticks):
                        this.numberFormatterObj.setMaximumFractionDigits(-i);
                        //create tick label (force use of fmt obj):
                        tickLabel = makeTickLabel(currentTickValue, true);
                    } else { //no tick label to be shown
                        tickLabel = "";
                    }
                } else { //tick value not between 0 & 1
                         //show tick label if it's the first or last in
                         // the set, or if it's 1-5; beyond that show
                         // fewer as the values get larger:
                    tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal)
                            ? makeTickLabel(currentTickValue)
                            : "";
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j; //decrement to do 1.0 tick now
                } //calculate power-of-ten value for tick:
                currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (!zeroTickFlag) { // did not do zero tick last iteration
                    if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0
                            && upperBoundVal >= 0.0) {
                        //tick value is 1.0 and 0.0 is within data range
                        currentTickValue = 0.0; //set tick value to zero
                        zeroTickFlag = true; //indicate zero tick
                    }
                } else { //did zero tick last iteration
                    zeroTickFlag = false; //clear flag
                } //create tick label string:
                //show tick label if "1e#"-style and it's one
                // of the first two, if it's the first or last
                // in the set, or if it's 1-5; beyond that
                // show fewer as the values get larger:
                tickLabel = ((this.expTickLabelsFlag && j < 2) || j < 1 || (i < 1 && j < 5) || (j < 4 - i)
                        || currentTickValue >= upperBoundVal) ? makeTickLabel(currentTickValue) : "";
            }

            if (currentTickValue > upperBoundVal) {
                return ticks; // if past highest data value then exit
                              // method
            }

            if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                    if (edge == RectangleEdge.TOP) {
                        angle = Math.PI / 2.0;
                    } else {
                        angle = -Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.TOP) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    } else {
                        anchor = TextAnchor.TOP_CENTER;
                        rotationAnchor = TextAnchor.TOP_CENTER;
                    }
                }

                Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor,
                        angle);
                ticks.add(tick);
            }
        }
    }
    return ticks;

}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

public static List refreshTicks(LabelData[] labels, TextAnchor anchor, TextAnchor rotationAnchor, double width,
        double angle) {
    Tick tick;//  www .java 2 s  . c o m
    int len = (labels == null) ? 0 : labels.length;
    List result = new ArrayList((len == 0) ? 1 : len);
    int mod = getLabelsMod(labels, (float) width, LABELS_PADDING);

    for (int i = 0; i < len; i++) {
        LabelData l = labels[i];

        if ((mod == 0) || (i % mod == 0)) {
            tick = new NumberTick(new Double(l.position), l.label, anchor, rotationAnchor, angle);
        } else {
            tick = new NumberTick(TickType.MINOR, new Double(l.position), "", TextAnchor.TOP_CENTER,
                    TextAnchor.CENTER, 0.0);
        }

        result.add(tick);
    }

    return result;
}

From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java

protected List newRefreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new java.util.ArrayList();

    //get lower bound value:
    double lowerBoundVal = getRange().getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }/*  w w  w. j  a v a  2  s .  co m*/
    //get upper bound value
    double upperBoundVal = getRange().getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    //      nxi@ansto: check how many ticks get produced. Put more if less than 4
    int numberOfGrids = 0;
    int numberOfTicks = 0;
    NumberTick lastTick = null;

    double tickVal;
    String tickLabel;
    //        tickVal = lowerBoundVal;
    //        
    //        tickLabel = Long.toString((long) Math.rint(tickVal));
    //        ticks.add(new NumberTick(new Double(tickVal), tickLabel,
    //              TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0));
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each tick with a label to be displayed
        int jEndCount = 10;
        if (i == iEndCount) {
            //                jEndCount = 1;
        }

        for (int j = 0; j < jEndCount; j++) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use
                tickVal = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (j == 0 || j == 1 || j == 4) {
                    //first tick of group; create label text
                    if (this.log10TickLabelsFlag) {
                        //if flag then
                        tickLabel = "10^" + i; //create "log10"-type label
                    } else { //not "log10"-type label
                        if (this.expTickLabelsFlag) {
                            //if flag then
                            tickLabel = "1e" + i; //create "1e#"-type label
                        } else { //not "1e#"-type label
                            if (i >= 0) { // if positive exponent then
                                          // make integer
                                NumberFormat format = getNumberFormatOverride();
                                if (format != null) {
                                    tickLabel = format.format(tickVal);
                                } else {
                                    tickLabel = Long.toString((long) Math.rint(tickVal));
                                }
                            } else {
                                //negative exponent; create fractional value
                                //set exact number of fractional digits to
                                // be shown:
                                this.numberFormatterObj.setMaximumFractionDigits(-i);
                                //create tick label:
                                tickLabel = this.numberFormatterObj.format(tickVal);
                            }
                        }
                    }
                } else { //not first tick to be displayed
                    if (numberOfTicks == 0)
                        tickLabel = createTickLabel(tickVal, i);
                    else
                        tickLabel = ""; //no label
                    //                        tickLabel = "";     //no tick label
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j;
                } //decrement to do 1.0 tick now
                tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (j == 0 || j == 1 || j == 4) { //first tick of group
                    if (!zeroTickFlag) { // did not do zero tick last
                                         // iteration
                        if (i > iBegCount && i < iEndCount && Math.abs(tickVal - 1.0) < 0.0001) {
                            // not first or last tick on graph and value
                            // is 1.0
                            tickVal = 0.0; //change value to 0.0
                            zeroTickFlag = true; //indicate zero tick
                            tickLabel = "0"; //create label for tick
                        } else {
                            //first or last tick on graph or value is 1.0
                            //create label for tick:
                            tickLabel = createTickLabel(tickVal, i);
                        }
                    } else { // did zero tick last iteration
                        if (numberOfTicks == 0)
                            tickLabel = createTickLabel(tickVal, i);
                        else
                            tickLabel = ""; //no label
                        zeroTickFlag = false; //clear flag
                    }
                } else { // not first tick of group
                    if (numberOfTicks == 0)
                        tickLabel = createTickLabel(tickVal, i);
                    else
                        tickLabel = ""; //no label
                    zeroTickFlag = false; //make sure flag cleared
                }
            }

            if (tickVal > upperBoundVal) {
                if (lastTick != null) {
                    String lastTickText = lastTick.getText();
                    double value = lastTick.getValue();
                    if (numberOfTicks < 8 || getFirstDigit(value) != 6)
                        if (lastTickText == null || lastTickText.trim().length() == 0) {
                            ticks.remove(lastTick);
                            ticks.add(new NumberTick(lastTick.getValue(),
                                    createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(),
                                    lastTick.getRotationAnchor(), lastTick.getAngle()));
                        }
                }
                if (numberOfTicks < 4) {
                    return getAllTicksVertical(g2, dataArea, edge);
                }
                return ticks; //if past highest data value then exit method
            }

            if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = -Math.PI / 2.0;
                    } else {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                    } else {
                        anchor = TextAnchor.CENTER_LEFT;
                        rotationAnchor = TextAnchor.CENTER_LEFT;
                    }
                }
                // nxi@ansto: create tick object and add to list:
                lastTick = new NumberTick(new Double(tickVal), tickLabel, anchor, rotationAnchor, angle);
                ticks.add(lastTick);
                if (tickLabel != null && tickLabel.trim().length() > 0)
                    numberOfTicks++;
                numberOfGrids++;
            }
        }
    }
    if (numberOfTicks < 4) {
        return getAllTicksVertical(g2, dataArea, edge);
    }
    return ticks;
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.ComparisonsSelectionOverviewBubbleChart.java

private JFreeChart updateBubbleChartChartWithCustUserData(
        Set<QuantDiseaseGroupsComparison> selectedComparisonList) {

    tooltipsProtNumberMap.clear();//from   ww w.j  a  v  a 2  s .  c o  m
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    int counter = 0;
    int upper = -1;
    boolean significantOnly = this.Quant_Central_Manager.isSignificantOnly();

    if (userCustomizedComparison.getComparProtsMap().size() > upper) {
        upper = userCustomizedComparison.getComparProtsMap().size();
    }

    for (QuantDiseaseGroupsComparison qc : selectedComparisonList) {
        if (significantOnly) {
            int upperCounter = 0;
            for (DiseaseGroupsComparisonsProteinLayout qp : qc.getComparProtsMap().values()) {
                if (qp == null) {
                    continue;
                }

                if (qp.getSignificantTrindCategory() == 2) {
                    continue;
                }

                upperCounter++;
            }
            if (upperCounter > upper) {
                upper = upperCounter;
            }

        } else {
            if (qc.getComparProtsMap() == null) {
                System.out.println("null qc " + qc.getComparisonHeader());

            }
            if (qc.getComparProtsMap().size() > upper) {
                upper = qc.getComparProtsMap().size();
            }
        }

    }

    final Map<Integer, Color[]> seriousColorMap = new HashMap<Integer, Color[]>();
    Color[] dataColor = new Color[] { Color.WHITE, new Color(0, 153, 0), new Color(0, 229, 132), stableColor,
            new Color(247, 119, 119), new Color(204, 0, 0), Color.WHITE };
    double[] tempWidthValue = new double[8];

    double[] yAxisValueI = new double[] { 0, 0, 0, 0, 0, 0, 0 };
    double[] xAxisValueI = new double[] { 0, 0, 0, 0, 0, 0, 0 };
    double[] widthValueI = new double[] { 0, 0, 0, 0, 0, 0, 0 };
    double[][] seriesValuesI = { yAxisValueI, xAxisValueI, widthValueI };
    seriousColorMap.put(0, new Color[] { Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE,
            Color.WHITE, Color.WHITE });
    defaultxyzdataset.addSeries("   ", seriesValuesI);

    for (String key : userCustomizedComparison.getComparProtsMap().keySet()) {
        userCustomizedComparison.getComparProtsMap().get(key).updateLabelLayout();

        {
            tempWidthValue[userCustomizedComparison.getComparProtsMap().get(key).getSignificantTrindCategory()
                    + 1] = tempWidthValue[userCustomizedComparison.getComparProtsMap().get(key)
                            .getSignificantTrindCategory() + 1] + 1;
        }
    }
    int length = 0;
    if (upper < 10) {
        upper = 10;
    }
    double[] tooltipNumbess = new double[tempWidthValue.length];
    System.arraycopy(tempWidthValue, 0, tooltipNumbess, 0, tempWidthValue.length);
    this.tooltipsProtNumberMap.put(userCustomizedComparison.getComparisonHeader(), tooltipNumbess);
    for (int z = 0; z < tempWidthValue.length; z++) {
        if (tempWidthValue[z] > 0) {
            tempWidthValue[z] = scaleValues(tempWidthValue[z], upper, 2.5, 0.05);//Math.max(tempWidthValue[z] * 1.5 / upper, 0.05);
            length++;
        }

    }
    double[] yAxisValue = new double[length];
    double[] xAxisValue = new double[length];
    double[] widthValue = new double[length];
    Color[] serColorArr = new Color[length];
    length = 0;

    for (int z = 0; z < tempWidthValue.length; z++) {
        if (tempWidthValue[z] > 0) {
            xAxisValue[length] = z;
            yAxisValue[length] = counter + 1;
            widthValue[length] = tempWidthValue[z];
            serColorArr[length] = dataColor[z];
            length++;
        }

    }

    if (length == 1 && selectedComparisonList.size() == 1) {
        widthValue[0] = 1;
    }
    seriousColorMap.put(++counter, serColorArr);

    double[][] seriesValues = { yAxisValue, xAxisValue, widthValue };
    defaultxyzdataset.addSeries(userCustomizedComparison.getComparisonHeader(), seriesValues);

    for (QuantDiseaseGroupsComparison qc : selectedComparisonList) {

        tempWidthValue = new double[8];
        if (qc.getComparProtsMap() == null) {
            continue;
        }

        for (String key : qc.getComparProtsMap().keySet()) {
            qc.getComparProtsMap().get(key).updateLabelLayout();

            if (significantOnly && (qc.getComparProtsMap().get(key).getSignificantTrindCategory() == 2
                    || qc.getComparProtsMap().get(key).getSignificantTrindCategory() == 5)) {
                tempWidthValue[3] = 0;
                tempWidthValue[6] = 0;
            } else {
                tempWidthValue[qc.getComparProtsMap().get(key).getSignificantTrindCategory()
                        + 1] = tempWidthValue[qc.getComparProtsMap().get(key).getSignificantTrindCategory() + 1]
                                + 1;
            }
        }
        if (tempWidthValue[3] > 0 && tempWidthValue[6] >= 0) {
            stableColor = new Color(1, 141, 244);

        } else {
            stableColor = Color.decode("#b5babb");
        }
        tempWidthValue[3] = tempWidthValue[3] + tempWidthValue[6];
        tempWidthValue[6] = 0;
        dataColor[3] = stableColor;
        length = 0;
        if (upper < 10) {
            upper = 10;
        }
        tooltipNumbess = new double[tempWidthValue.length];
        System.arraycopy(tempWidthValue, 0, tooltipNumbess, 0, tempWidthValue.length);
        this.tooltipsProtNumberMap.put(qc.getComparisonHeader(), tooltipNumbess);
        for (int x = 0; x < tempWidthValue.length; x++) {
            if (tempWidthValue[x] > 0) {
                tempWidthValue[x] = scaleValues(tempWidthValue[x], upper, 2.5, 0.05);//Math.max(tempWidthValue[z] * 1.5 / upper, 0.05);
                length++;
            }

        }
        yAxisValue = new double[length];
        xAxisValue = new double[length];
        widthValue = new double[length];
        serColorArr = new Color[length];
        length = 0;

        for (int x = 0; x < tempWidthValue.length; x++) {
            if (tempWidthValue[x] > 0) {
                xAxisValue[length] = x;
                yAxisValue[length] = counter + 1;
                widthValue[length] = tempWidthValue[x];
                serColorArr[length] = dataColor[x];
                length++;
            }

        }

        if (length == 1 && selectedComparisonList.size() == 1) {
            widthValue[0] = 1;
        }
        seriousColorMap.put(counter + 1, serColorArr);

        seriesValues = new double[][] { yAxisValue, xAxisValue, widthValue };
        defaultxyzdataset.addSeries(qc.getComparisonHeader(), seriesValues);

        counter++;
    }

    double[] yAxisValueII = new double[0];
    double[] xAxisValueII = new double[0];
    double[] widthValueII = new double[0];
    seriousColorMap.put(counter + 1, new Color[] {});
    double[][] seriesValuesII = { yAxisValueII, xAxisValueII, widthValueII };
    defaultxyzdataset.addSeries(" ", seriesValuesII);

    final Color[] labelsColor = new Color[] { Color.WHITE, new Color(80, 183, 71), Color.LIGHT_GRAY,
            new Color(1, 141, 244), Color.LIGHT_GRAY, new Color(204, 0, 0), Color.WHITE };
    Font font = new Font("Verdana", Font.BOLD, 13);
    SymbolAxis yAxis = new SymbolAxis(null,
            new String[] { "  ", "Decreased", " ", "Equal", " ", "Increased", "  " }) {
        int x = 0;

        @Override
        public Paint getTickLabelPaint() {
            if (x >= labelsColor.length) {
                x = 0;
            }
            return labelsColor[x++];
        }
    };

    yAxis.setAutoRangeStickyZero(true);
    yAxis.setFixedAutoRange(8);
    yAxis.setTickLabelFont(font);
    yAxis.setGridBandsVisible(false);
    yAxis.setAxisLinePaint(Color.LIGHT_GRAY);
    yAxis.setTickMarksVisible(false);
    yAxis.setUpperBound(6);

    String[] xAxisLabels = new String[selectedComparisonList.size() + 3];
    xAxisLabels[0] = "  ";
    final Color[] diseaseGroupslabelsColor = new Color[selectedComparisonList.size() + 3];
    int x = 0;
    int maxLength = -1;
    //init labels color

    String updatedHeader = userCustomizedComparison.getComparisonHeader().split(" / ")[0].split("\n")[0] + " / "
            + userCustomizedComparison.getComparisonHeader().split(" / ")[1].split("\n")[0] + "";
    diseaseGroupslabelsColor[0] = Color.WHITE;
    diseaseGroupslabelsColor[x + 1] = diseaseColorMap.get("UserData");
    xAxisLabels[x + 1] = updatedHeader + " (" + userCustomizedComparison.getDatasetIndexes().length + ")    ";
    if (xAxisLabels[x + 1].length() > maxLength) {
        maxLength = xAxisLabels[++x].length();
    }

    for (QuantDiseaseGroupsComparison comp : selectedComparisonList) {
        String header = comp.getComparisonHeader();
        updatedHeader = header.split(" / ")[0].split("\n")[0] + " / " + header.split(" / ")[1].split("\n")[0]
                + "";

        xAxisLabels[x + 1] = updatedHeader + " (" + comp.getDatasetIndexes().length + ")    ";
        if (xAxisLabels[x + 1].length() > maxLength) {
            maxLength = xAxisLabels[x + 1].length();
        }
        diseaseGroupslabelsColor[x + 1] = diseaseColorMap.get(header.split(" / ")[0].split("\n")[1]);
        x++;

    }
    xAxisLabels[x + 1] = "   ";

    SymbolAxis xAxis;
    final boolean finalNum;
    finalNum = maxLength > 30 && selectedComparisonList.size() > 4;

    xAxis = new SymbolAxis(null, xAxisLabels) {

        int x = 0;

        @Override
        public Paint getTickLabelPaint() {
            if (x >= diseaseGroupslabelsColor.length) {
                x = 0;
            }
            return diseaseGroupslabelsColor[x++];
        }

        private final boolean localfinal = finalNum;

        @Override
        protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {

            if (localfinal) {
                setVerticalTickLabels(localfinal);
                return super.refreshTicksHorizontal(g2, dataArea, edge);
            }
            List ticks = new java.util.ArrayList();
            Font tickLabelFont = getTickLabelFont();
            g2.setFont(tickLabelFont);
            double size = getTickUnit().getSize();
            int count = calculateVisibleTickCount();
            double lowestTickValue = calculateLowestVisibleTickValue();
            double previousDrawnTickLabelPos = 0.0;
            double previousDrawnTickLabelLength = 0.0;
            if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
                for (int i = 0; i < count; i++) {
                    double currentTickValue = lowestTickValue + (i * size);
                    double xx = valueToJava2D(currentTickValue, dataArea, edge);
                    String tickLabel;
                    NumberFormat formatter = getNumberFormatOverride();
                    if (formatter != null) {
                        tickLabel = formatter.format(currentTickValue) + "  ";
                    } else {
                        tickLabel = valueToString(currentTickValue) + "  ";
                    }
                    // avoid to draw overlapping tick labels
                    Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics());
                    double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth();
                    boolean tickLabelsOverlapping = false;
                    if (i > 0) {
                        double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0;
                        if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength) {
                            tickLabelsOverlapping = true;
                        }
                    }
                    if (tickLabelsOverlapping) {
                        setVerticalTickLabels(true);
                    } else {
                        // remember these values for next comparison
                        previousDrawnTickLabelPos = xx;
                        previousDrawnTickLabelLength = tickLabelLength;
                    }
                    TextAnchor anchor;
                    TextAnchor rotationAnchor;
                    double angle = 0.0;
                    if (isVerticalTickLabels()) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                        if (edge == RectangleEdge.TOP) {
                            angle = 76.5;
                        } else {
                            angle = -76.5;
                        }
                    } else {
                        if (edge == RectangleEdge.TOP) {
                            anchor = TextAnchor.BOTTOM_CENTER;
                            rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        } else {
                            anchor = TextAnchor.TOP_CENTER;
                            rotationAnchor = TextAnchor.TOP_CENTER;
                        }
                    }
                    Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor,
                            angle);

                    ticks.add(tick);
                }
            }
            return ticks;
        }
    };

    //        }
    xAxis.setTickLabelFont(font);
    xAxis.setTickLabelInsets(new RectangleInsets(2, 20, 2, 20));
    xAxis.setAutoRangeStickyZero(true);
    xAxis.setAutoRangeStickyZero(true);
    xAxis.setTickMarksVisible(false);
    xAxis.setUpperBound(diseaseGroupslabelsColor.length - 1);
    xAxis.setGridBandsVisible(false);
    xAxis.setAxisLinePaint(Color.LIGHT_GRAY);
    int scale = XYBubbleRenderer.SCALE_ON_RANGE_AXIS;

    XYItemRenderer xyitemrenderer = new XYBubbleRenderer(scale) {
        private int counter = 0;
        private int localSerious = -1;
        private final Map<Integer, Color[]> localSeriousColorMap = seriousColorMap;

        @Override
        public Paint getSeriesPaint(int series) {
            if (series != localSerious || isNewImge || localSeriousColorMap.get(series).length == counter) {
                counter = 0;
                isNewImge = false;
            }
            localSerious = series;
            Color c = localSeriousColorMap.get(series)[counter];
            counter++;

            return c;
        }

    };

    XYPlot xyplot = new XYPlot(defaultxyzdataset, xAxis, yAxis, xyitemrenderer) {
        @Override
        protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area, List ticks) {
            try {
                if (!ticks.isEmpty()) {
                    ticks.remove(0);
                }
                if (!ticks.isEmpty()) {
                    ticks.remove(ticks.size() - 1);
                }
            } catch (Exception e) {
            }
            super.drawRangeGridlines(g2, area, ticks); //To change body of generated methods, choose Tools | Templates.
        }

        //            private final Color[] labelsColor = new Color[]{new Color(0, 153, 0), new Color(0, 229, 132), new Color(1, 141, 244), new Color(255, 51, 51), new Color(204, 0, 0), Color.decode("#b5babb")};
        //
        //            private final Font font = new Font("Verdana", Font.PLAIN, 12);
        //            private final String[] labels = new String[]{"Decreased 100%", "Decreased <100% ", "Equal", " Increased <100%", "Increased 100%", "No Quant. Info."};
        //
        //            @Override
        //            public LegendItemCollection getLegendItems() {
        //                LegendItemCollection legendItemCollection = new LegendItemCollection();
        //                for (int i = 0; i < labelsColor.length; i++) {
        //                    LegendItem item = new LegendItem(labels[i], labelsColor[i]);
        //                    item.setLabelFont(font);
        //                    legendItemCollection.add(item);
        //
        //                }
        //
        //                return legendItemCollection;//To change body of generated methods, choose Tools | Templates.
        //            }
    };

    JFreeChart generatedChart = new JFreeChart(xyplot) {

    };
    xyplot.setOutlineVisible(false);
    LegendTitle legend = generatedChart.getLegend();
    legend.setVisible(false);
    xyplot.setBackgroundPaint(Color.WHITE);
    generatedChart.setBackgroundPaint(Color.WHITE);
    generatedChart.setPadding(new RectangleInsets(0, 0, 0, 0));
    Quant_Central_Manager.setProteinsOverviewBubbleChart(generatedChart);
    return generatedChart;

}

From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java

private List getAllTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new java.util.ArrayList();

    //get lower bound value:
    double lowerBoundVal = getRange().getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }/* w ww  .  j av a  2s .c om*/
    //get upper bound value
    double upperBoundVal = getRange().getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    int numberOfGrids = 0;
    int numberOfTicks = 0;
    NumberTick lastTick = null;
    double tickVal;
    String tickLabel;
    //        tickVal = lowerBoundVal;
    //        
    //        tickLabel = Long.toString((long) Math.rint(tickVal));
    //        ticks.add(new NumberTick(new Double(tickVal), tickLabel,
    //              TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0));
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each tick with a label to be displayed
        int jEndCount = 10;
        if (i == iEndCount) {
            //                jEndCount = 1;
        }

        for (int j = 0; j < jEndCount; j++) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use
                tickVal = Math.pow(10, i) + (Math.pow(10, i) * j);
                //first tick of group; create label text
                if (this.log10TickLabelsFlag) {
                    //if flag then
                    tickLabel = "10^" + i; //create "log10"-type label
                } else { //not "log10"-type label
                    if (this.expTickLabelsFlag) {
                        //if flag then
                        tickLabel = "1e" + i; //create "1e#"-type label
                    } else { //not "1e#"-type label
                        if (i >= 0) { // if positive exponent then
                                      // make integer
                            NumberFormat format = getNumberFormatOverride();
                            if (format != null) {
                                tickLabel = format.format(tickVal);
                            } else {
                                tickLabel = Long.toString((long) Math.rint(tickVal));
                            }
                        } else {
                            //negative exponent; create fractional value
                            //set exact number of fractional digits to
                            // be shown:
                            this.numberFormatterObj.setMaximumFractionDigits(-i);
                            //create tick label:
                            tickLabel = this.numberFormatterObj.format(tickVal);
                        }
                    }
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j;
                } //decrement to do 1.0 tick now
                tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (!zeroTickFlag) { // did not do zero tick last
                                     // iteration
                    if (i > iBegCount && i < iEndCount && Math.abs(tickVal - 1.0) < 0.0001) {
                        // not first or last tick on graph and value
                        // is 1.0
                        tickVal = 0.0; //change value to 0.0
                        zeroTickFlag = true; //indicate zero tick
                        tickLabel = "0"; //create label for tick
                    } else {
                        //first or last tick on graph or value is 1.0
                        //create label for tick:
                        tickLabel = createTickLabel(tickVal, i);
                    }
                } else { // not first tick of group
                    tickLabel = createTickLabel(tickVal, i);
                }
            }

            if (tickVal > upperBoundVal) {
                if (lastTick != null) {
                    String lastTickText = lastTick.getText();
                    if (lastTickText == null || lastTickText.trim().length() == 0) {
                        ticks.remove(lastTick);
                        ticks.add(new NumberTick(lastTick.getValue(),
                                createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(),
                                lastTick.getRotationAnchor(), lastTick.getAngle()));
                    }
                }
                if (ticks.size() < 2) {
                    double definition = Math.abs(lowerBoundVal - upperBoundVal);
                    int numberOfDigits = 0;
                    if (definition >= 1)
                        numberOfDigits = 0;
                    else {
                        numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
                    }
                    tickVal = lowerBoundVal;
                    if (definition > 1)
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    else
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.CENTER_RIGHT,
                            TextAnchor.CENTER_RIGHT, 0.0));
                    tickVal = upperBoundVal;
                    if (definition > 1)
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    else
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.CENTER_RIGHT,
                            TextAnchor.CENTER_RIGHT, 0.0));
                }
                return ticks; //if past highest data value then exit method
            }

            if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = -Math.PI / 2.0;
                    } else {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                    } else {
                        anchor = TextAnchor.CENTER_LEFT;
                        rotationAnchor = TextAnchor.CENTER_LEFT;
                    }
                }
                //create tick object and add to list:
                lastTick = new NumberTick(new Double(tickVal), tickLabel, anchor, rotationAnchor, angle);
                ticks.add(lastTick);
                if (tickLabel != null && tickLabel.trim().length() > 0)
                    numberOfTicks++;
                numberOfGrids++;
            }
        }
    }
    if (ticks.size() < 2) {
        double definition = Math.abs(lowerBoundVal - upperBoundVal);
        int numberOfDigits = 0;
        if (definition >= 1)
            numberOfDigits = 0;
        else {
            numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
        }
        tickVal = lowerBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.CENTER_RIGHT,
                TextAnchor.CENTER_RIGHT, 0.0));
        tickVal = upperBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.CENTER_RIGHT,
                TextAnchor.CENTER_RIGHT, 0.0));
    }
    return ticks;
}

From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java

/**
 * Calculates the positions of the tick labels for the axis, storing the
 * results in the tick label list (ready for drawing).
 *
 * @param g2  the graphics device.//from  w ww .  j a  v  a2s.  co m
 * @param dataArea  the area in which the plot should be drawn.
 * @param edge  the location of the axis.
 *
 * @return A list of ticks.
 */
protected List logRefreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new java.util.ArrayList();

    //get lower bound value:
    double lowerBoundVal = getRange().getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }
    //get upper bound value
    double upperBoundVal = getRange().getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    double tickVal;
    String tickLabel;
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each tick with a label to be displayed
        int jEndCount = 10;
        if (i == iEndCount) {
            jEndCount = 1;
        }

        for (int j = 0; j < jEndCount; j++) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use
                tickVal = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (j == 0) {
                    //first tick of group; create label text
                    if (this.log10TickLabelsFlag) {
                        //if flag then
                        tickLabel = "10^" + i; //create "log10"-type label
                    } else { //not "log10"-type label
                        if (this.expTickLabelsFlag) {
                            //if flag then
                            tickLabel = "1e" + i; //create "1e#"-type label
                        } else { //not "1e#"-type label
                            if (i >= 0) { // if positive exponent then
                                          // make integer
                                NumberFormat format = getNumberFormatOverride();
                                if (format != null) {
                                    tickLabel = format.format(tickVal);
                                } else {
                                    tickLabel = Long.toString((long) Math.rint(tickVal));
                                }
                            } else {
                                //negative exponent; create fractional value
                                //set exact number of fractional digits to
                                // be shown:
                                this.numberFormatterObj.setMaximumFractionDigits(-i);
                                //create tick label:
                                tickLabel = this.numberFormatterObj.format(tickVal);
                            }
                        }
                    }
                } else { //not first tick to be displayed
                    tickLabel = ""; //no tick label
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j;
                } //decrement to do 1.0 tick now
                tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (j == 0) { //first tick of group
                    if (!zeroTickFlag) { // did not do zero tick last
                                         // iteration
                        if (i > iBegCount && i < iEndCount && Math.abs(tickVal - 1.0) < 0.0001) {
                            // not first or last tick on graph and value
                            // is 1.0
                            tickVal = 0.0; //change value to 0.0
                            zeroTickFlag = true; //indicate zero tick
                            tickLabel = "0"; //create label for tick
                        } else {
                            //first or last tick on graph or value is 1.0
                            //create label for tick:
                            if (this.log10TickLabelsFlag) {
                                //create "log10"-type label
                                tickLabel = (((i < 0) ? "-" : "") + "10^" + Math.abs(i));
                            } else {
                                if (this.expTickLabelsFlag) {
                                    //create "1e#"-type label
                                    tickLabel = (((i < 0) ? "-" : "") + "1e" + Math.abs(i));
                                } else {
                                    NumberFormat format = getNumberFormatOverride();
                                    if (format != null) {
                                        tickLabel = format.format(tickVal);
                                    } else {
                                        tickLabel = Long.toString((long) Math.rint(tickVal));
                                    }
                                }
                            }
                        }
                    } else { // did zero tick last iteration
                        tickLabel = ""; //no label
                        zeroTickFlag = false; //clear flag
                    }
                } else { // not first tick of group
                    tickLabel = ""; //no label
                    zeroTickFlag = false; //make sure flag cleared
                }
            }

            if (tickVal > upperBoundVal) {
                return ticks; //if past highest data value then exit method
            }

            if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = -Math.PI / 2.0;
                    } else {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        angle = Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                    } else {
                        anchor = TextAnchor.CENTER_LEFT;
                        rotationAnchor = TextAnchor.CENTER_LEFT;
                    }
                }
                //create tick object and add to list:
                ticks.add(new NumberTick(new Double(tickVal), tickLabel, anchor, rotationAnchor, angle));
            }
        }
    }
    return ticks;
}

From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java

private List getAllTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    // TODO Auto-generated method stub
    List ticks = new java.util.ArrayList();
    Range range = getRange();//from   w  ww  .  jav a 2 s  .  c o m

    //get lower bound value:
    double lowerBoundVal = range.getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }

    //get upper bound value
    double upperBoundVal = range.getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    //        if (iBegCount == iEndCount && iBegCount >= 0
    if (iBegCount == iEndCount && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    int numberOfGrids = 0;
    int numberOfTicks = 0;
    NumberTick lastTick = null;

    double currentTickValue;
    String tickLabel;
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each power of 10 value; create ten ticks
        for (int j = 0; j < 10; ++j) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use; create numeric value for tick
                currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) {
                    //showing "1e#"-style ticks or negative exponent
                    // generating tick value between 0 & 1; show fewer
                    //first tick of series, or not too small a value and
                    // one of first 3 ticks, or last tick to be displayed
                    // set exact number of fractional digits to be shown
                    // (no effect if showing "1e#"-style ticks):
                    this.numberFormatterObj.setMaximumFractionDigits(-i);
                    //create tick label (force use of fmt obj):
                    tickLabel = makeTickLabel(currentTickValue, true);
                } else { //tick value not between 0 & 1
                         //show tick label if it's the first or last in
                         // the set, or if it's 1-5; beyond that show
                         // fewer as the values get larger:
                    tickLabel = makeTickLabel(currentTickValue);
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j; //decrement to do 1.0 tick now
                } //calculate power-of-ten value for tick:
                currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (!zeroTickFlag) { // did not do zero tick last iteration
                    if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0
                            && upperBoundVal >= 0.0) {
                        //tick value is 1.0 and 0.0 is within data range
                        currentTickValue = 0.0; //set tick value to zero
                        zeroTickFlag = true; //indicate zero tick
                    }
                } else { //did zero tick last iteration
                    zeroTickFlag = false; //clear flag
                } //create tick label string:
                //show tick label if "1e#"-style and it's one
                // of the first two, if it's the first or last
                // in the set, or if it's 1-5; beyond that
                // show fewer as the values get larger:
                tickLabel = makeTickLabel(currentTickValue);
            }

            if (currentTickValue > upperBoundVal) {
                if (lastTick != null) {
                    String lastTickText = lastTick.getText();
                    if (lastTickText == null || lastTickText.trim().length() == 0) {
                        ticks.remove(lastTick);
                        ticks.add(new NumberTick(lastTick.getValue(),
                                createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(),
                                lastTick.getRotationAnchor(), lastTick.getAngle()));
                    }
                }
                if (ticks.size() < 2) {
                    double definition = Math.abs(lowerBoundVal - upperBoundVal);
                    int numberOfDigits = 0;
                    if (definition >= 1)
                        numberOfDigits = 0;
                    else {
                        numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
                    }
                    if (definition < 2 * Math.pow(10, -numberOfDigits)) {
                        numberOfDigits++;
                    }
                    double tickVal;
                    tickVal = lowerBoundVal;
                    if (definition > 1)
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    else
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_CENTER, 0.0));
                    tickVal = upperBoundVal;
                    if (definition > 1) {
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    } else {
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    }
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_CENTER, 0.0));
                }
                return ticks; // if past highest data value then exit
                              // method
            }

            if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                    if (edge == RectangleEdge.TOP) {
                        angle = Math.PI / 2.0;
                    } else {
                        angle = -Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.TOP) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    } else {
                        anchor = TextAnchor.TOP_CENTER;
                        rotationAnchor = TextAnchor.TOP_CENTER;
                    }
                }

                lastTick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor,
                        angle);
                ticks.add(lastTick);
                if (tickLabel != null && tickLabel.trim().length() > 0)
                    numberOfTicks++;
                numberOfGrids++;
            }
        }
    }
    if (ticks.size() < 2) {
        double definition = Math.abs(lowerBoundVal - upperBoundVal);
        int numberOfDigits = 0;
        if (definition >= 1)
            numberOfDigits = 0;
        else {
            numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
        }
        double tickVal;
        tickVal = lowerBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER,
                0.0));
        tickVal = upperBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER,
                0.0));
    }
    return ticks;
}