Example usage for java.lang Float POSITIVE_INFINITY

List of usage examples for java.lang Float POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Float POSITIVE_INFINITY.

Prototype

float POSITIVE_INFINITY

To view the source code for java.lang Float POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type float .

Usage

From source file:org.jboss.bqt.client.xml.XMLQueryVisitationStrategy.java

/**
 * Consume an XML message and update the specified Float instance.
 * <br>/*from w  ww. java  2  s  .c o m*/
 * @param object the instance that is to be updated with the XML message data.
 * @param cellElement the XML element that contains the data
 * @return the updated instance.
 * @exception JDOMException if there is an error consuming the message.
 */
private Object consumeMsg(Float object, Element cellElement) throws JDOMException {

    // -----------------------
    // Process the element ...
    // -----------------------
    String strElement = cellElement.getTextTrim();
    Float result;

    if (strElement.equals("NaN")) { //$NON-NLS-1$
        result = new Float(Float.NaN);
    } else if (strElement.equals("-Infinity")) { //$NON-NLS-1$
        result = new Float(Float.NEGATIVE_INFINITY);
    } else if (strElement.equals("Infinity")) { //$NON-NLS-1$
        result = new Float(Float.POSITIVE_INFINITY);
    } else {
        try {
            result = Float.valueOf(strElement);
        } catch (NumberFormatException e) {
            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
                    " element: " + strElement, e); //$NON-NLS-1$
        }
    }
    return result;
}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 * Calculates the X data range./*from  ww w.j ava2s  .  c  om*/
 *
 * @param data the data (<code>null</code> permitted).
 *
 * @return The range.
 */
private Range calculateXDataRange(float[][] data) {

    Range result = null;

    if (data != null) {
        float lowest = Float.POSITIVE_INFINITY;
        float highest = Float.NEGATIVE_INFINITY;
        for (int i = 0; i < data[0].length; i++) {
            float v = data[0][i];
            if (v < lowest) {
                lowest = v;
            }
            if (v > highest) {
                highest = v;
            }
        }
        if (lowest <= highest) {
            result = new Range(lowest, highest);
        }
    }

    return result;

}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 * Calculates the Y data range.//from  w  w w . j  a  v  a 2s . c  o m
 *
 * @param data the data (<code>null</code> permitted).
 *
 * @return The range.
 */
private Range calculateYDataRange(float[][] data) {

    Range result = null;
    if (data != null) {
        float lowest = Float.POSITIVE_INFINITY;
        float highest = Float.NEGATIVE_INFINITY;
        for (int i = 0; i < data[0].length; i++) {
            float v = data[1][i];
            if (v < lowest) {
                lowest = v;
            }
            if (v > highest) {
                highest = v;
            }
        }
        if (lowest <= highest) {
            result = new Range(lowest, highest);
        }
    }
    return result;

}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfinite(java.lang.Object)}.
 */// w  w  w  .  j  a v a  2s.c  o m
@Test
public void testIsInfiniteObject() {
    assertEquals("null", false, isInfinite(null));
    assertEquals("empty", false, isInfinite(""));
    assertEquals("invalidString", false, isInfinite("not a number"));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }));
    assertEquals("NaN", false, isInfinite(Double.NaN));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY));
    assertEquals("Infinity: String", true, isInfinite("Infinity"));
    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity"));
    assertEquals("Infinity: BIgDecimal", false, isInfinite(INFINITY_DOUBLE));

    assertEquals(true, isInfinite(INFINITY_DOUBLE.doubleValue()));
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfinite(java.lang.Object, int)}.
 *///w  w w.  j a va 2 s  .c  om
@Test
public void testIsInfiniteObjectInt() {
    assertEquals("null", false, isInfinite(null, -1));
    assertEquals("null", false, isInfinite(null, 0));
    assertEquals("null", false, isInfinite(null, 1));
    assertEquals("empty", false, isInfinite("", -1));
    assertEquals("empty", false, isInfinite("", 0));
    assertEquals("empty", false, isInfinite("", 1));
    assertEquals("invalidString", false, isInfinite("not a number", -1));
    assertEquals("invalidString", false, isInfinite("not a number", 0));
    assertEquals("invalidString", false, isInfinite("not a number", 1));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, -1));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, 0));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, 1));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, -1));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, 0));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, 1));
    assertEquals("NaN", false, isInfinite(Double.NaN, -1));
    assertEquals("NaN", false, isInfinite(Double.NaN, 0));
    assertEquals("NaN", false, isInfinite(Double.NaN, 1));

    assertEquals("Infinity: Float", false, isInfinite(Float.POSITIVE_INFINITY, -1));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY, 0));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY, 1));
    assertEquals("Infinity: Double", false, isInfinite(Double.POSITIVE_INFINITY, -1));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY, 0));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY, 1));
    assertEquals("Infinity: String", false, isInfinite("Infinity", -1));
    assertEquals("Infinity: String", true, isInfinite("Infinity", 0));
    assertEquals("Infinity: String", true, isInfinite("Infinity", 1));

    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY, -1));
    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY, 0));
    assertEquals("-Infinity: Float", false, isInfinite(Float.NEGATIVE_INFINITY, 1));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY, -1));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY, 0));
    assertEquals("-Infinity: Double", false, isInfinite(Double.NEGATIVE_INFINITY, 1));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity", -1));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity", 0));
    assertEquals("-Infinity: String", false, isInfinite("-Infinity", 1));
}

From source file:edu.harvard.iq.dataverse.dataaccess.TabularSubsetGenerator.java

public Object[] subsetObjectVector(File tabfile, int column, int varcount, int casecount, int columntype,
        boolean compatmode) throws IOException {

    Object[] retVector = null;//  ww w  .j  a  v a2  s. c  om

    boolean isString = false;
    boolean isDouble = false;
    boolean isLong = false;
    boolean isFloat = false;

    //Locale loc = new Locale("en", "US");

    if (columntype == COLUMN_TYPE_STRING) {
        isString = true;
        retVector = new String[casecount];
    } else if (columntype == COLUMN_TYPE_DOUBLE) {
        isDouble = true;
        retVector = new Double[casecount];
    } else if (columntype == COLUMN_TYPE_LONG) {
        isLong = true;
        retVector = new Long[casecount];
    } else if (columntype == COLUMN_TYPE_FLOAT) {
        isFloat = true;
        retVector = new Float[casecount];
    } else {
        throw new IOException("Unsupported column type: " + columntype);
    }

    File rotatedImageFile = getRotatedImage(tabfile, varcount, casecount);
    long[] columnEndOffsets = extractColumnOffsets(rotatedImageFile, varcount, casecount);
    long columnOffset = 0;
    long columnLength = 0;

    if (column > 0) {
        columnOffset = columnEndOffsets[column - 1];
        columnLength = columnEndOffsets[column] - columnEndOffsets[column - 1];
    } else {
        columnOffset = varcount * 8;
        columnLength = columnEndOffsets[0] - varcount * 8;
    }

    FileChannel fc = (FileChannel.open(Paths.get(rotatedImageFile.getAbsolutePath()), StandardOpenOption.READ));
    fc.position(columnOffset);
    int MAX_COLUMN_BUFFER = 8192;

    ByteBuffer in = ByteBuffer.allocate(MAX_COLUMN_BUFFER);

    if (columnLength < MAX_COLUMN_BUFFER) {
        in.limit((int) (columnLength));
    }

    long bytesRead = 0;
    long bytesReadTotal = 0;
    int caseindex = 0;
    int byteoffset = 0;
    byte[] leftover = null;

    while (bytesReadTotal < columnLength) {
        bytesRead = fc.read(in);
        byte[] columnBytes = in.array();
        int bytecount = 0;

        while (bytecount < bytesRead) {
            if (columnBytes[bytecount] == '\n') {
                /*
                String token = new String(columnBytes, byteoffset, bytecount-byteoffset, "UTF8");
                        
                if (leftover != null) {
                String leftoverString = new String (leftover, "UTF8");
                token = leftoverString + token;
                leftover = null;
                }
                */
                /* 
                 * Note that the way I was doing it at first - above - 
                 * was not quite the correct way - because I was creating UTF8
                 * strings from the leftover bytes, and the bytes in the 
                 * current buffer *separately*; which means, if a multi-byte
                 * UTF8 character got split in the middle between one buffer
                 * and the next, both chunks of it would become junk 
                 * characters, on each side!
                 * The correct way of doing it, of course, is to create a
                 * merged byte buffer, and then turn it into a UTF8 string. 
                 *      -- L.A. 4.0
                 */
                String token = null;

                if (leftover == null) {
                    token = new String(columnBytes, byteoffset, bytecount - byteoffset, "UTF8");
                } else {
                    byte[] merged = new byte[leftover.length + bytecount - byteoffset];

                    System.arraycopy(leftover, 0, merged, 0, leftover.length);
                    System.arraycopy(columnBytes, byteoffset, merged, leftover.length, bytecount - byteoffset);
                    token = new String(merged, "UTF8");
                    leftover = null;
                    merged = null;
                }

                if (isString) {
                    if ("".equals(token)) {
                        // An empty string is a string missing value!
                        // An empty string in quotes is an empty string!
                        retVector[caseindex] = null;
                    } else {
                        // Strip the outer quotes:
                        token = token.replaceFirst("^\\\"", "");
                        token = token.replaceFirst("\\\"$", "");

                        // We need to restore the special characters that 
                        // are stored in tab files escaped - quotes, new lines 
                        // and tabs. Before we do that however, we need to 
                        // take care of any escaped backslashes stored in 
                        // the tab file. I.e., "foo\t" should be transformed 
                        // to "foo<TAB>"; but "foo\\t" should be transformed 
                        // to "foo\t". This way new lines and tabs that were
                        // already escaped in the original data are not 
                        // going to be transformed to unescaped tab and 
                        // new line characters!

                        String[] splitTokens = token.split(Matcher.quoteReplacement("\\\\"), -2);

                        // (note that it's important to use the 2-argument version 
                        // of String.split(), and set the limit argument to a
                        // negative value; otherwise any trailing backslashes 
                        // are lost.)

                        for (int i = 0; i < splitTokens.length; i++) {
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\\""), "\"");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\t"), "\t");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\n"), "\n");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\r"), "\r");
                        }
                        // TODO: 
                        // Make (some of?) the above optional; for ex., we 
                        // do need to restore the newlines when calculating UNFs;
                        // But if we are subsetting these vectors in order to 
                        // create a new tab-delimited file, they will 
                        // actually break things! -- L.A. Jul. 28 2014

                        token = StringUtils.join(splitTokens, '\\');

                        // "compatibility mode" - a hack, to be able to produce
                        // unfs identical to those produced by the "early" 
                        // unf5 jar; will be removed in production 4.0. 
                        // -- L.A. (TODO: ...)
                        if (compatmode && !"".equals(token)) {
                            if (token.length() > 128) {
                                if ("".equals(token.trim())) {
                                    // don't ask... 
                                    token = token.substring(0, 129);
                                } else {
                                    token = token.substring(0, 128);
                                    //token = String.format(loc, "%.128s", token);
                                    token = token.trim();
                                    //dbgLog.info("formatted and trimmed: "+token);
                                }
                            } else {
                                if ("".equals(token.trim())) {
                                    // again, don't ask; 
                                    // - this replicates some bugginness 
                                    // that happens inside unf5;
                                    token = "null";
                                } else {
                                    token = token.trim();
                                }
                            }
                        }

                        retVector[caseindex] = token;
                    }
                } else if (isDouble) {
                    try {
                        // TODO: verify that NaN and +-Inf are 
                        // handled correctly here! -- L.A.
                        // Verified: new Double("nan") works correctly, 
                        // resulting in Double.NaN;
                        // Double("[+-]Inf") doesn't work however; 
                        // (the constructor appears to be expecting it
                        // to be spelled as "Infinity", "-Infinity", etc. 
                        if ("inf".equalsIgnoreCase(token) || "+inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Double.POSITIVE_INFINITY;
                        } else if ("-inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Double.NEGATIVE_INFINITY;
                        } else if (token == null || token.equals("")) {
                            // missing value:
                            retVector[caseindex] = null;
                        } else {
                            retVector[caseindex] = new Double(token);
                        }
                    } catch (NumberFormatException ex) {
                        dbgLog.warning("NumberFormatException thrown for " + token + " as Double");

                        retVector[caseindex] = null; // missing value
                        // TODO: ?
                    }
                } else if (isLong) {
                    try {
                        retVector[caseindex] = new Long(token);
                    } catch (NumberFormatException ex) {
                        retVector[caseindex] = null; // assume missing value
                    }
                } else if (isFloat) {
                    try {
                        if ("inf".equalsIgnoreCase(token) || "+inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Float.POSITIVE_INFINITY;
                        } else if ("-inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Float.NEGATIVE_INFINITY;
                        } else if (token == null || token.equals("")) {
                            // missing value:
                            retVector[caseindex] = null;
                        } else {
                            retVector[caseindex] = new Float(token);
                        }
                    } catch (NumberFormatException ex) {
                        dbgLog.warning("NumberFormatException thrown for " + token + " as Float");
                        retVector[caseindex] = null; // assume missing value (TODO: ?)
                    }
                }
                caseindex++;

                if (bytecount == bytesRead - 1) {
                    byteoffset = 0;
                } else {
                    byteoffset = bytecount + 1;
                }
            } else {
                if (bytecount == bytesRead - 1) {
                    // We've reached the end of the buffer; 
                    // This means we'll save whatever unused bytes left in 
                    // it - i.e., the bytes between the last new line 
                    // encountered and the end - in the leftover buffer. 

                    // *EXCEPT*, there may be a case of a very long String
                    // that is actually longer than MAX_COLUMN_BUFFER, in 
                    // which case it is possible that we've read through
                    // an entire buffer of bytes without finding any 
                    // new lines... in this case we may need to add this
                    // entire byte buffer to an already existing leftover 
                    // buffer!
                    if (leftover == null) {
                        leftover = new byte[(int) bytesRead - byteoffset];
                        System.arraycopy(columnBytes, byteoffset, leftover, 0, (int) bytesRead - byteoffset);
                    } else {
                        if (byteoffset != 0) {
                            throw new IOException(
                                    "Reached the end of the byte buffer, with some leftover left from the last read; yet the offset is not zero!");
                        }
                        byte[] merged = new byte[leftover.length + (int) bytesRead];

                        System.arraycopy(leftover, 0, merged, 0, leftover.length);
                        System.arraycopy(columnBytes, byteoffset, merged, leftover.length, (int) bytesRead);
                        //leftover = null;
                        leftover = merged;
                        merged = null;
                    }
                    byteoffset = 0;

                }
            }
            bytecount++;
        }

        bytesReadTotal += bytesRead;
        in.clear();
        if (columnLength - bytesReadTotal < MAX_COLUMN_BUFFER) {
            in.limit((int) (columnLength - bytesReadTotal));
        }
    }

    fc.close();

    if (caseindex != casecount) {
        throw new IOException("Faile to read " + casecount + " tokens for column " + column);
        //System.out.println("read "+caseindex+" tokens instead of expected "+casecount+".");
    }

    return retVector;
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfiniteOrNaN(java.lang.Object)}.
 *///  w ww  .j  a  va 2 s.  c om
// @Test
public void testIsInfiniteOrNaN() {
    assertEquals("null", false, isInfiniteOrNaN(null));
    assertEquals("empty", false, isInfiniteOrNaN(""));
    assertEquals("invalidString", false, isInfiniteOrNaN("not a number"));
    assertEquals("notParsable", false, isInfiniteOrNaN(new int[] { 1, 2, 3 }));
    assertEquals("notParsable", false,
            isInfiniteOrNaN(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }));
    assertEquals("Infinity: Float", true, isInfiniteOrNaN(Float.POSITIVE_INFINITY));
    assertEquals("Infinity: Double", true, isInfiniteOrNaN(Double.POSITIVE_INFINITY));
    assertEquals("Infinity: String", true, isInfiniteOrNaN("Infinity"));
    assertEquals("-Infinity: Float", true, isInfiniteOrNaN(Float.NEGATIVE_INFINITY));
    assertEquals("-Infinity: Double", true, isInfiniteOrNaN(Double.NEGATIVE_INFINITY));
    assertEquals("-Infinity: String", true, isInfiniteOrNaN("-Infinity"));
    assertEquals("NaN: Double", true, isInfiniteOrNaN(Double.NaN));
    assertEquals("NaN: Float", true, isInfiniteOrNaN(Double.NaN));
    assertEquals("NaN: String", true, isInfiniteOrNaN("NaN"));

    assertEquals("NaN: Double", true, isInfiniteOrNaN(Double.POSITIVE_INFINITY / Double.POSITIVE_INFINITY));
    assertEquals("NaN: Float", true,
            isInfiniteOrNaN(divide(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, float.class)));
}

From source file:ml.shifu.shifu.core.dtrain.dt.DTWorker.java

/**
 * 'binBoundary' is ArrayList in fact, so we can use get method. ["-Infinity", 1d, 4d, ....]
 * /*  w  w w  .  j a v a2 s. c o  m*/
 * @param value
 *            the value to be checked
 * @param binBoundary
 *            the bin boundary list
 * @return the index in which bin
 */
public static int getBinIndex(float value, List<Double> binBoundary) {
    if (binBoundary.size() <= 1) {
        // feature with binBoundary.size() <= 1 will not be send to worker, while such feature is still loading into
        // memory, just return the first bin index to avoid exception, while actually such feature isn't used in
        // GBT/RF.
        return 0;
    }

    // the last bin if positive infinity
    if (value == Float.POSITIVE_INFINITY) {
        return binBoundary.size() - 1;
    }

    // the first bin if negative infinity
    if (value == Float.NEGATIVE_INFINITY) {
        return 0;
    }

    int low = 0, high = binBoundary.size() - 1;
    while (low <= high) {
        int mid = (low + high) >>> 1;
        double lowThreshold = binBoundary.get(mid);
        double highThreshold = mid == binBoundary.size() - 1 ? Double.MAX_VALUE : binBoundary.get(mid + 1);
        if (value >= lowThreshold && value < highThreshold) {
            return mid;
        }
        if (value >= highThreshold) {
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }
    return -1;
}

From source file:net.pms.util.Rational.java

/**
 * Converts this {@link Rational} to a {@code float}. This conversion is
 * similar to the <i>narrowing primitive conversion</i> from {@code double}
 * to {@code float} as defined in section 5.1.3 of <cite>The Java&trade;
 * Language Specification</cite>: if this {@link Rational} has too great a
 * magnitude to represent as a {@code float}, it will be converted to
 * {@link Float#NEGATIVE_INFINITY} or {@link Float#POSITIVE_INFINITY} as
 * appropriate./*w ww.j a v  a2 s .  com*/
 * <p>
 * Note that even when the return value is finite, this conversion can lose
 * information about the precision of the {@link Rational} value.
 *
 * @return This {@link Rational} converted to a {@code float}.
 */
@Override
public float floatValue() {
    if (isNaN()) {
        return Float.NaN;
    }
    if (isInfinitePositive()) {
        return Float.POSITIVE_INFINITY;
    }
    if (isInfiniteNegative()) {
        return Float.NEGATIVE_INFINITY;
    }
    return new BigDecimal(reducedNumerator).divide(new BigDecimal(reducedDenominator), MathContext.DECIMAL32)
            .floatValue();
}

From source file:com.actelion.research.table.view.JVisualization.java

/**
 * Based on axis column assignments and on hvIndices of VisualizationPoints
 * this method assigns all visible VisualizationPoints to bars/pies and to color categories
 * within these bars/pies. It also calculates relative bar/pie sizes.
 * @param hvCount//from   ww w .  ja v a2s  .  co  m
 */
protected void calculateBarsOrPies() {
    calculateCategoryCounts(-1);

    Color[] colorList = mMarkerColor.getColorList();
    int focusFlagNo = getFocusFlag();
    int basicColorCount = colorList.length + 1;
    int colorCount = basicColorCount * ((focusFlagNo == -1) ? 1 : 2);

    int catCount = mCaseSeparationCategoryCount;
    for (int count : mCategoryVisibleCount)
        catCount *= count;

    mChartInfo = new CategoryViewInfo(mHVCount, catCount, colorCount);

    mChartInfo.barAxis = 0;
    for (int axis = 1; axis < mDimensions; axis++)
        if (mAxisIndex[axis] == cColumnUnassigned)
            mChartInfo.barAxis = axis;
        else if (mAxisIndex[mChartInfo.barAxis] != cColumnUnassigned
                && mCategoryVisibleCount[axis] <= mCategoryVisibleCount[mChartInfo.barAxis])
            mChartInfo.barAxis = axis;

    for (int i = 0; i < colorList.length; i++)
        mChartInfo.color[i] = colorList[i];
    mChartInfo.color[colorList.length] = VisualizationColor.cSelectedColor;
    if (focusFlagNo != -1) {
        for (int i = 0; i < colorList.length; i++)
            mChartInfo.color[i + basicColorCount] = VisualizationColor.grayOutColor(colorList[i]);
        mChartInfo.color[colorList.length + basicColorCount] = VisualizationColor
                .grayOutColor(VisualizationColor.cSelectedColor);
    }

    int visibleCount = 0;
    for (int i = 0; i < mDataPoints; i++) {
        if (isVisibleExcludeNaN(mPoint[i])) {
            int colorIndex = ((mPoint[i].record.getFlags() & CompoundRecord.cFlagMaskSelected) != 0
                    && mFocusHitlist != cFocusOnSelection) ? colorList.length : mPoint[i].colorIndex;
            if (focusFlagNo != -1 && !mPoint[i].record.isFlagSet(focusFlagNo))
                colorIndex += basicColorCount;

            int cat = getChartCategoryIndex(mPoint[i]);
            mChartInfo.pointsInCategory[mPoint[i].hvIndex][cat]++;
            mChartInfo.pointsInColorCategory[mPoint[i].hvIndex][cat][colorIndex]++;
            visibleCount++;
            switch (mChartMode) {
            case cChartModeCount:
            case cChartModePercent:
                mChartInfo.barValue[mPoint[i].hvIndex][cat]++;
                break;
            case cChartModeMean:
            case cChartModeSum:
                mChartInfo.barValue[mPoint[i].hvIndex][cat] += mPoint[i].record.getDouble(mChartColumn);
                break;
            case cChartModeMin:
            case cChartModeMax:
                float value = mPoint[i].record.getDouble(mChartColumn);
                if (mChartInfo.pointsInCategory[mPoint[i].hvIndex][cat] == 1)
                    mChartInfo.barValue[mPoint[i].hvIndex][cat] = value;
                else if (mChartMode == cChartModeMin)
                    mChartInfo.barValue[mPoint[i].hvIndex][cat] = Math
                            .min(mChartInfo.barValue[mPoint[i].hvIndex][cat], value);
                else
                    mChartInfo.barValue[mPoint[i].hvIndex][cat] = Math
                            .max(mChartInfo.barValue[mPoint[i].hvIndex][cat], value);
                break;
            }
        }
    }
    if (mChartMode == cChartModePercent)
        for (int i = 0; i < mHVCount; i++)
            for (int j = 0; j < catCount; j++)
                mChartInfo.barValue[i][j] *= 100f / visibleCount;
    if (mChartMode == cChartModeMean)
        for (int i = 0; i < mHVCount; i++)
            for (int j = 0; j < catCount; j++)
                if (mChartInfo.pointsInCategory[i][j] != 0)
                    mChartInfo.barValue[i][j] /= mChartInfo.pointsInCategory[i][j];

    int[][][] count = new int[mHVCount][catCount][colorCount];
    for (int hv = 0; hv < mHVCount; hv++)
        for (int cat = 0; cat < catCount; cat++)
            for (int color = 1; color < colorCount; color++)
                count[hv][cat][color] = count[hv][cat][color - 1]
                        + mChartInfo.pointsInColorCategory[hv][cat][color - 1];
    for (int i = 0; i < mDataPoints; i++) {
        if (isVisibleExcludeNaN(mPoint[i])) {
            int colorIndex = (mPoint[i].record.isSelected() && mFocusHitlist != cFocusOnSelection)
                    ? colorList.length
                    : mPoint[i].colorIndex;
            if (focusFlagNo != -1 && !mPoint[i].record.isFlagSet(focusFlagNo))
                colorIndex += basicColorCount;

            int hv = mPoint[i].hvIndex;
            int cat = getChartCategoryIndex(mPoint[i]);
            mPoint[i].chartGroupIndex = count[hv][cat][colorIndex];
            count[hv][cat][colorIndex]++;
        }
    }

    float dataMin = Float.POSITIVE_INFINITY;
    float dataMax = Float.NEGATIVE_INFINITY;
    for (int i = 0; i < mHVCount; i++) {
        for (int j = 0; j < catCount; j++) {
            if (mChartInfo.pointsInCategory[i][j] != 0) {
                if (dataMin > mChartInfo.barValue[i][j])
                    dataMin = mChartInfo.barValue[i][j];
                if (dataMax < mChartInfo.barValue[i][j])
                    dataMax = mChartInfo.barValue[i][j];
            }
        }
    }
    mChartInfo.barOrPieDataAvailable = (dataMin != Float.POSITIVE_INFINITY);

    if (mChartInfo.barOrPieDataAvailable) {
        switch (mChartMode) {
        case cChartModeCount:
        case cChartModePercent:
            mChartInfo.axisMin = 0.0f;
            mChartInfo.axisMax = dataMax * cBarSpacingFactor;
            mChartInfo.barBase = 0.0f;
            break;
        default:
            if (mTableModel.isLogarithmicViewMode(mChartColumn)) {
                float dataRange = dataMax - dataMin;
                mChartInfo.axisMin = dataMin - dataRange * (cBarSpacingFactor - 1.0f);
                mChartInfo.axisMax = dataMax + dataRange * (cBarSpacingFactor - 1.0f);
                mChartInfo.barBase = mChartInfo.axisMin;
            } else {
                if (dataMin >= 0.0) {
                    mChartInfo.axisMin = 0.0f;
                    mChartInfo.axisMax = dataMax * cBarSpacingFactor;
                } else if (dataMax <= 0.0) {
                    mChartInfo.axisMin = dataMin * cBarSpacingFactor;
                    mChartInfo.axisMax = 0.0f;
                } else {
                    float dataRange = dataMax - dataMin;
                    float spacing = (cBarSpacingFactor - 1.0f) * dataRange / 2.0f;
                    mChartInfo.axisMax = dataMax + spacing;
                    mChartInfo.axisMin = dataMin - spacing;
                }
                mChartInfo.barBase = 0.0f;
            }
            break;
        }
    } else {
        mChartInfo.axisMin = 0.0f;
        mChartInfo.axisMax = cBarSpacingFactor;
        mChartInfo.barBase = 0.0f;
    }
    //System.out.println("calculateBarsOrPies() dataMin:"+mChartInfo.dataMin+" dataMax:"+mChartInfo.dataMax+" axisMin:"+mChartInfo.axisMin+" axisMax:"+mChartInfo.axisMax+" barBase:"+mChartInfo.barBase);
}