Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

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

Prototype

double POSITIVE_INFINITY

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

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:com.aliyun.odps.ship.common.RecordConverterTest.java

/**
 * double? ???"Infinity",?"-Infinity"<br/>
 * <br/>//from  w  w w  .  jav a2 s . com
 * 1) double??<br/>
 * 2?????<br/>
 * 3) <br/>
 * */
@Test
public void testDouble() throws Exception {
    TableSchema rs = new TableSchema();
    rs.addColumn(new Column("d1", OdpsType.DOUBLE));
    rs.addColumn(new Column("d2", OdpsType.DOUBLE));
    rs.addColumn(new Column("d3", OdpsType.DOUBLE));
    rs.addColumn(new Column("d4", OdpsType.DOUBLE));
    rs.addColumn(new Column("d5", OdpsType.DOUBLE));
    rs.addColumn(new Column("d6", OdpsType.DOUBLE));
    rs.addColumn(new Column("d7", OdpsType.DOUBLE));

    String[] l = new String[] { "211.234567", "Infinity", "-Infinity", "12345678.1234567", "1.23456781234567E7",
            "1.2345E2", "1.2345E10" };
    RecordConverter cv = new RecordConverter(rs, "NULL", "yyyyMMddHHmmss", null);

    Record r = cv.parse(toByteArray(l));
    assertEquals("d1 not equal.", "211.234567", r.getDouble(0).toString());
    assertEquals("d2 not equal.", new Double(Double.POSITIVE_INFINITY).toString(), r.getDouble(1).toString());
    assertEquals("d3 not equal.", new Double(Double.NEGATIVE_INFINITY).toString(), r.getDouble(2).toString());
    assertEquals("d3 not equal d4.", r.getDouble(3), r.getDouble(4));

    l = new String[] { "211.234567", "Infinity", "-Infinity", "12345678.1234567", "12345678.1234567", "123.45",
            "12345000000" };
    byte[][] l1 = cv.format(r);
    for (int i = 0; i < l1.length; i++) {
        assertEquals("converter at index:" + i, l[i], new String(l1[i]));
    }

    try {
        String[] l2 = new String[] { "12345678.1234567", "1.23456781234567E7", "1", "a", "b", "1", "1" };
        Record r2 = cv.parse(toByteArray(l2));
        fail("need fail");
    } catch (Exception e) {
        assertTrue(e.getMessage(), e.getMessage().indexOf("ERROR: format error - :4, DOUBLE:'a'") >= 0);
    }

}

From source file:com.rapidminer.operator.preprocessing.NoiseOperator.java

@Override
protected ExampleSetMetaData modifyMetaData(ExampleSetMetaData exampleSetMetaData)
        throws UndefinedParameterError {
    AttributeMetaData label = exampleSetMetaData.getLabelMetaData();
    if (label != null) {
        if (label.isNumerical() && getParameterAsDouble(PARAMETER_LABEL_NOISE) > 0) {
            label.setValueSetRelation(SetRelation.SUPERSET);
        }//from  ww w  .j a v  a 2  s.co  m
    }
    double defaultNoise = getParameterAsDouble(PARAMETER_DEFAULT_ATTRIBUTE_NOISE);
    if (defaultNoise > 0) {
        for (AttributeMetaData amd : exampleSetMetaData.getAllAttributes()) {
            if (!amd.isSpecial()) {
                if (amd.isNumerical()) {
                    amd.setValueSetRelation(SetRelation.SUPERSET);
                }
            }
        }
    }
    int numberOfRandomAttributes = getParameterAsInt(PARAMETER_RANDOM_ATTRIBUTES);
    for (int i = 0; i < numberOfRandomAttributes; i++) {
        AttributeMetaData amd = new AttributeMetaData("random" + ((i == 0) ? "" : i + ""), Ontology.REAL);
        amd.setValueRange(new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), SetRelation.SUBSET);
        exampleSetMetaData.addAttribute(amd);
    }
    return exampleSetMetaData;
}

From source file:de.cebitec.readXplorer.differentialExpression.plot.ExpressTestGraphicsTopComponent.java

public Map<PersistentFeature, Pair<Double, Double>> createSamplePoints(int n) {
    Random r = new Random(System.nanoTime());
    Map<PersistentFeature, Pair<Double, Double>> points = new HashMap<>();
    for (int i = 0; i < n; i++) {
        PersistentFeature dummyFeature = new PersistentFeature(0, 0, "", "", "", "", 0, 0, true,
                FeatureType.ANY, "");
        double random = Math.random();
        if (random > 0.95) {
            points.put(dummyFeature, new Pair<>(r.nextDouble() * 256.0d, Double.POSITIVE_INFINITY));
            points.put(dummyFeature, new Pair<>(r.nextDouble() * 256.0d, Double.NEGATIVE_INFINITY));
        } else {/*from  www .j  a  va2s  .c  o  m*/
            points.put(dummyFeature, new Pair<>(2 * i + (r.nextGaussian() - 0.5d), r.nextDouble() * 256.0d));
        }
    }
    PersistentFeature dummyFeature = new PersistentFeature(0, 0, "", "", "", "", 0, 0, true, FeatureType.ANY,
            "");
    points.put(dummyFeature, new Pair<>(200d, 300d));
    dummyFeature = new PersistentFeature(0, 0, "", "", "", "", 0, 0, true, FeatureType.ANY, "");
    points.put(dummyFeature, new Pair<>(100d, Double.POSITIVE_INFINITY));
    return points;
}

From source file:com.microsoft.azure.storage.table.TableEntitySerializer.java

/**
 * Reserved for internal use. Writes an entity to the specified <code>JsonGenerator</code> as a JSON resource
 * //  ww  w .ja  va2  s .c om
 * @param generator
 *            The <code>JsonGenerator</code> to write the entity to.
 * @param options
 *            The {@link TableRequestOptions} to use for serializing.
 * @param entity
 *            The instance implementing {@link TableEntity} to write to the output stream.
 * @param isTableEntry
 *            A flag indicating the entity is a reference to a table at the top level of the storage service when
 *            <code>true<code> and a reference to an entity within a table when <code>false</code>.
 * @param opContext
 *            An {@link OperationContext} object used to track the execution of the operation.
 * 
 * @throws StorageException
 *             if a Storage service error occurs.
 * @throws IOException
 *             if an error occurs while accessing the stream.
 */
private static void writeJsonEntity(final JsonGenerator generator, final TableRequestOptions options,
        final TableEntity entity, final boolean isTableEntry, final OperationContext opContext)
        throws StorageException, IOException {

    Map<String, EntityProperty> properties = getPropertiesFromDictionary(entity, options, opContext);

    // start object
    generator.writeStartObject();

    if (!isTableEntry) {
        Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey());
        Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey());
        Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp());

        // PartitionKey
        generator.writeStringField(TableConstants.PARTITION_KEY, entity.getPartitionKey());

        // RowKey
        generator.writeStringField(TableConstants.ROW_KEY, entity.getRowKey());

        // Timestamp
        generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
    }

    for (final Entry<String, EntityProperty> ent : properties.entrySet()) {
        if (ent.getKey().equals(TableConstants.PARTITION_KEY) || ent.getKey().equals(TableConstants.ROW_KEY)
                || ent.getKey().equals(TableConstants.TIMESTAMP) || ent.getKey().equals("Etag")) {
            continue;
        }

        EntityProperty currProp = ent.getValue();
        if (currProp.getEdmType().mustAnnotateType()) {
            final String edmTypeString = currProp.getEdmType().toString();

            // property type
            generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

            // property key and value
            generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
        } else if (currProp.getEdmType() == EdmType.DOUBLE && currProp.getIsNull() == false) {
            final String edmTypeString = currProp.getEdmType().toString();
            final Double value = currProp.getValueAsDouble();

            // property type, if needed
            if (value.equals(Double.POSITIVE_INFINITY) || value.equals(Double.NEGATIVE_INFINITY)
                    || value.equals(Double.NaN)) {
                generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

                // property key and value
                generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
            } else {
                writeJsonProperty(generator, ent);
            }

        } else {
            writeJsonProperty(generator, ent);
        }
    }

    // end object
    generator.writeEndObject();
}

From source file:ffx.xray.CNSFilter.java

/**
 * {@inheritDoc}//from   w w  w. j  a v  a 2s  .  c  om
 */
@Override
public double getResolution(File cnsFile, Crystal crystal) {
    double res = Double.POSITIVE_INFINITY;

    try {
        BufferedReader br = new BufferedReader(new FileReader(cnsFile));

        String str;
        boolean hashkl, hasfo, hassigfo, hasfree;
        int ih, ik, il;
        HKL hkl = new HKL();

        ih = ik = il = -1;

        while ((str = br.readLine()) != null) {
            String strarray[] = str.split("\\s+");

            for (int i = 0; i < strarray.length; i++) {
                if (strarray[i].toLowerCase().startsWith("inde")) {
                    if (i < strarray.length - 3) {
                        ih = Integer.parseInt(strarray[i + 1]);
                        ik = Integer.parseInt(strarray[i + 2]);
                        il = Integer.parseInt(strarray[i + 3]);
                        hkl.h(ih);
                        hkl.k(ik);
                        hkl.l(il);
                        res = Math.min(res, Crystal.res(crystal, hkl));
                    }
                }
            }
        }
    } catch (IOException ioe) {
        System.out.println("IO Exception: " + ioe.getMessage());
        return -1.0;
    }

    return res;
}

From source file:ffx.realspace.CCP4MapFilter.java

/**
 * {@inheritDoc}//from w  ww . jav  a2  s . c o m
 */
@Override
public boolean readFile(String filename, RealSpaceRefinementData refinementdata,
        CompositeConfiguration properties) {

    int imapData;
    double cellA, cellB, cellC, cellAlpha, cellBeta, cellGamma;
    String stampString;

    ByteOrder byteOrder = ByteOrder.nativeOrder();
    FileInputStream fileInputStream;
    DataInputStream dataInputStream;

    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    double mean = 0.0;
    double sd = 0.0;
    double rmsd = 0.0;

    // First determine byte order of file versus system
    try {
        fileInputStream = new FileInputStream(filename);
        dataInputStream = new DataInputStream(fileInputStream);

        dataInputStream.skipBytes(212);
        byte bytes[] = new byte[4];
        dataInputStream.read(bytes, 0, 4);
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);

        imapData = byteBuffer.order(ByteOrder.BIG_ENDIAN).getInt();
        stampString = Integer.toHexString(imapData);
        switch (stampString.charAt(0)) {
        case '1':
        case '3':
            if (byteOrder.equals(ByteOrder.LITTLE_ENDIAN)) {
                byteOrder = ByteOrder.BIG_ENDIAN;
            }
            break;
        case '4':
            if (byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
                byteOrder = ByteOrder.LITTLE_ENDIAN;
            }
            break;
        }
        if (logger.isLoggable(Level.INFO)) {
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("\n Opening CCP4 map: %s\n", filename));
            //sb.append(String.format("file type (machine stamp): %s\n", stampString));
            logger.info(sb.toString());
        }

        fileInputStream.close();
    } catch (Exception e) {
        String message = " Fatal exception reading CCP4 map.\n";
        logger.log(Level.SEVERE, message, e);
    }

    try {
        fileInputStream = new FileInputStream(filename);
        dataInputStream = new DataInputStream(fileInputStream);

        byte bytes[] = new byte[2048];

        dataInputStream.read(bytes, 0, 1024);
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);

        int ext[] = new int[3];
        ext[0] = byteBuffer.order(byteOrder).getInt();
        ext[1] = byteBuffer.order(byteOrder).getInt();
        ext[2] = byteBuffer.order(byteOrder).getInt();

        // mode (2 = reals, only one we accept)
        int mode = byteBuffer.order(byteOrder).getInt();

        int ori[] = new int[3];
        ori[0] = byteBuffer.order(byteOrder).getInt();
        ori[1] = byteBuffer.order(byteOrder).getInt();
        ori[2] = byteBuffer.order(byteOrder).getInt();

        int ni[] = new int[3];
        ni[0] = byteBuffer.order(byteOrder).getInt();
        ni[1] = byteBuffer.order(byteOrder).getInt();
        ni[2] = byteBuffer.order(byteOrder).getInt();

        cellA = byteBuffer.order(byteOrder).getFloat();
        cellB = byteBuffer.order(byteOrder).getFloat();
        cellC = byteBuffer.order(byteOrder).getFloat();
        cellAlpha = byteBuffer.order(byteOrder).getFloat();
        cellBeta = byteBuffer.order(byteOrder).getFloat();
        cellGamma = byteBuffer.order(byteOrder).getFloat();

        int axisi[] = new int[3];
        for (int i = 0; i < 3; i++) {
            int axis = byteBuffer.order(byteOrder).getInt();
            switch (axis) {
            case 1:
                axisi[0] = i;
                break;
            case 2:
                axisi[1] = i;
                break;
            case 3:
                axisi[2] = i;
                break;
            }
        }

        min = byteBuffer.order(byteOrder).getFloat();
        max = byteBuffer.order(byteOrder).getFloat();
        mean = byteBuffer.order(byteOrder).getFloat();
        int sg = byteBuffer.order(byteOrder).getInt();
        int nsymb = byteBuffer.order(byteOrder).getInt();
        int skew = byteBuffer.order(byteOrder).getInt();

        for (int i = 0; i < 12; i++) {
            byteBuffer.order(byteOrder).getFloat();
        }

        for (int i = 0; i < 15; i++) {
            byteBuffer.order(byteOrder).getInt();
        }

        byte word[] = new byte[2048];
        byteBuffer.order(byteOrder).get(word, 0, 4);
        String mapString = new String(word);
        sd = byteBuffer.order(byteOrder).getFloat();
        rmsd = byteBuffer.order(byteOrder).getFloat();

        if (logger.isLoggable(Level.INFO)) {
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("  Column origin:  %d\t Extent: %d\n", ori[0], ext[0]));
            sb.append(String.format("  Row origin:     %d\t Extent: %d\n", ori[1], ext[1]));
            sb.append(String.format("  Section origin: %d\t Extent: %d\n", ori[2], ext[2]));
            sb.append(String.format("  Axis order:     %d %d %d\n", axisi[0], axisi[1], axisi[2]));
            sb.append(String.format("  Number of X, Y, Z columns: %d %d %d\n", ni[0], ni[1], ni[2]));
            sb.append(String.format("  Spacegroup:     %d (%s)\n", sg, SpaceGroup.spaceGroupNames[sg - 1]));
            sb.append(String.format("  Cell: %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", cellA, cellB, cellC,
                    cellAlpha, cellBeta, cellGamma));
            logger.info(sb.toString());
        }

        int nlabel = byteBuffer.order(byteOrder).getInt();
        for (int i = 0; i < 10; i++) {
            byteBuffer.order(byteOrder).get(word, 0, 80);
            mapString = new String(word);
        }

        if (nsymb > 0) {
            byteBuffer.rewind();
            dataInputStream.read(bytes, 0, nsymb);
            for (int i = 0; i < nsymb / 80; i += 80) {
                byteBuffer.order(byteOrder).get(word, 0, 80);
                mapString = new String(word);
            }
        }

        byteBuffer.rewind();
        dataInputStream.read(bytes, 0, 2048);
        refinementdata.setData(new double[ext[0] * ext[1] * ext[2]]);
        int ijk[] = new int[3];
        int index, x, y, z;
        refinementdata.setOrigin(ori[axisi[0]], ori[axisi[1]], ori[axisi[2]]);
        int nx = ext[axisi[0]];
        int ny = ext[axisi[1]];
        int nz = ext[axisi[2]];
        refinementdata.setExtent(nx, ny, nz);
        refinementdata.setNI(ni[0], ni[1], ni[2]);
        for (ijk[2] = 0; ijk[2] < ext[2]; ijk[2]++) {
            for (ijk[1] = 0; ijk[1] < ext[1]; ijk[1]++) {
                for (ijk[0] = 0; ijk[0] < ext[0]; ijk[0]++) {
                    x = ijk[axisi[0]];
                    y = ijk[axisi[1]];
                    z = ijk[axisi[2]];
                    index = x + nx * (y + ny * z);
                    refinementdata.getData()[index] = byteBuffer.order(byteOrder).getFloat();
                    if (!byteBuffer.hasRemaining()) {
                        byteBuffer.rewind();
                        dataInputStream.read(bytes, 0, 2048);
                    }
                }
            }
        }
        fileInputStream.close();
    } catch (Exception e) {
        String message = " Fatal exception reading CCP4 map.\n";
        logger.log(Level.SEVERE, message, e);
    }

    return true;
}

From source file:com.clust4j.algo.AbstractClusterer.java

final private Array2DRowRealMatrix initData(final RealMatrix data) {
    final int m = data.getRowDimension(), n = data.getColumnDimension();
    final double[][] ref = new double[m][n];
    final HashSet<Double> unique = new HashSet<>();

    // Used to compute variance on the fly for summaries later...
    double[] sum = new double[n];
    double[] sumSq = new double[n];
    double[] maxes = VecUtils.rep(Double.NEGATIVE_INFINITY, n);
    double[] mins = VecUtils.rep(Double.POSITIVE_INFINITY, n);

    // This will store summaries for each column + a header
    ModelSummary summaries = new ModelSummary(
            new Object[] { "Feature #", "Variance", "Std. Dev", "Mean", "Max", "Min" });

    /*/*from w  w  w . j  a v  a 2  s  . c  om*/
     * Internally performs the copy
     */
    double entry;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            entry = data.getEntry(i, j);

            if (Double.isNaN(entry)) {
                error(new NaNException("NaN in input data. " + "Select a matrix imputation method for "
                        + "incomplete records"));
            } else {
                // copy the entry
                ref[i][j] = entry;
                unique.add(entry);

                // capture stats...
                sumSq[j] += entry * entry;
                sum[j] += entry;
                maxes[j] = FastMath.max(entry, maxes[j]);
                mins[j] = FastMath.min(entry, mins[j]);

                // if it's the last row, we can compute these:
                if (i == m - 1) {
                    double var = (sumSq[j] - (sum[j] * sum[j]) / (double) m) / ((double) m - 1.0);
                    if (var == 0) {
                        warn("zero variance in feature " + j);
                    }

                    summaries.add(new Object[] { j, // feature num
                            var, // var
                            m < 2 ? Double.NaN : FastMath.sqrt(var), // std dev
                            sum[j] / (double) m, // mean
                            maxes[j], // max
                            mins[j] // min
                    });
                }
            }
        }
    }

    // Log the summaries
    summaryLogger(formatter.format(summaries));

    if (unique.size() == 1)
        this.singular_value = true;

    /*
     * Don't need to copy again, because already internally copied...
     */
    return new Array2DRowRealMatrix(ref, false);
}

From source file:com.cinnober.msgcodec.json.JsonValueHandlerTest.java

@Test
public void testFloat64EncodePosInfinity() throws IOException {
    StringWriter out = new StringWriter();
    JsonGenerator g = f.createGenerator(out);

    JsonValueHandler.FLOAT64.writeValue(Double.POSITIVE_INFINITY, g);
    g.flush();//from   w  ww .j a  v  a 2 s  . c o  m
    assertEquals("\"Infinity\"", out.toString());
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java

@Override
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    XYDataset dataset = (XYDataset) datasets.getDatasets().get("1");

    final JFreeChart sparkLineGraph = ChartFactory.createTimeSeriesChart(null, null, null, dataset, legend,
            false, false);//from w w  w .  j  a  va  2s.  c  o m
    sparkLineGraph.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    sparkLineGraph.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        sparkLineGraph.addSubtitle(subTitle);
    }

    sparkLineGraph.setBorderVisible(false);
    sparkLineGraph.setBorderPaint(Color.BLACK);
    XYPlot plot = sparkLineGraph.getXYPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setBackgroundPaint(color);

    // calculate the last marker color
    Paint colorLast = getLastPointColor();

    // Calculate average, minimum and maximum to draw plot borders.
    boolean isFirst = true;
    double avg = 0, min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY;
    int count = 0;
    for (int i = 0; i < timeSeries.getItemCount(); i++) {
        if (timeSeries.getValue(i) != null) {
            count++;
            if (isFirst) {
                min = timeSeries.getValue(i).doubleValue();
                max = timeSeries.getValue(i).doubleValue();
                isFirst = false;
            }
            double n = timeSeries.getValue(i).doubleValue();
            //calculate avg, min, max
            avg += n;
            if (n < min)
                min = n;
            if (n > max)
                max = n;
        }
    }
    // average
    avg = avg / (double) count;

    // calculate min and max between thresholds!
    boolean isFirst2 = true;
    double lb = 0, ub = 0;
    for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) {
        Double thres = (Double) iterator.next();
        if (isFirst2 == true) {
            ub = thres.doubleValue();
            lb = thres.doubleValue();
            isFirst2 = false;
        }
        if (thres.doubleValue() > ub)
            ub = thres.doubleValue();
        if (thres.doubleValue() < lb)
            lb = thres.doubleValue();
    }

    plot.getRangeAxis().setRange(new Range(Math.min(lb, min - 2), Math.max(ub, max + 2) + 2));

    addMarker(1, avg, Color.GRAY, 0.8f, plot);
    //addAvaregeSeries(series, plot);
    addPointSeries(timeSeries, plot);

    int num = 3;
    for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) {
        Double thres = (Double) iterator.next();
        TargetThreshold targThres = thresholds.get(thres);
        Color color = Color.WHITE;
        if (targThres != null && targThres.getColor() != null) {
            color = targThres.getColor();
        }
        if (targThres.isVisible()) {
            addMarker(num++, thres.doubleValue(), color, 0.5f, plot);
        }
    }

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setUpperMargin(0.2);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(false);

    plot.getRenderer().setSeriesPaint(0, Color.BLACK);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
        public boolean getItemShapeVisible(int _series, int item) {
            TimeSeriesDataItem tsdi = timeSeries.getDataItem(item);
            if (tsdi == null)
                return false;
            Month period = (Month) tsdi.getPeriod();
            int currMonth = period.getMonth();
            int currYear = period.getYearValue();
            int lastMonthFilled = lastMonth.getMonth();
            int lastYearFilled = lastMonth.getYearValue();
            boolean isLast = false;
            if (currYear == lastYearFilled && currMonth == lastMonthFilled) {
                isLast = true;
            }
            return isLast;
        }
    };
    renderer.setSeriesPaint(0, Color.decode("0x000000"));

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(colorLast);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setUseOutlinePaint(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    if (wlt_mode.doubleValue() == 0) {
        renderer.setBaseItemLabelsVisible(Boolean.FALSE, true);
    } else {
        renderer.setBaseItemLabelsVisible(Boolean.TRUE, true);
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
        renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("{2}", new DecimalFormat("0.###"),
                new DecimalFormat("0.###")) {
            public String generateLabel(CategoryDataset dataset, int row, int column) {
                if (dataset.getValue(row, column) == null || dataset.getValue(row, column).doubleValue() == 0)
                    return "";
                String columnKey = (String) dataset.getColumnKey(column);
                int separator = columnKey.indexOf('-');
                String month = columnKey.substring(0, separator);
                String year = columnKey.substring(separator + 1);
                int monthNum = Integer.parseInt(month);
                if (wlt_mode.doubleValue() >= 1 && wlt_mode.doubleValue() <= 4) {
                    if (wlt_mode.doubleValue() == 2 && column % 2 == 0)
                        return "";

                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.MONTH, monthNum - 1);
                    SimpleDateFormat dataFormat = new SimpleDateFormat("MMM");
                    return dataFormat.format(calendar.getTime());
                } else
                    return "" + monthNum;
            }
        });
    }

    if (wlt_mode.doubleValue() == 3) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 2));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 2));

    } else if (wlt_mode.doubleValue() == 4) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 4));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 4));
    }

    if (legend == true) {
        LegendItemCollection collection = createThresholdLegend(plot);
        LegendItem item = new LegendItem("Avg", "Avg", "Avg", "Avg", new Rectangle(10, 10), colorAverage);
        collection.add(item);
        plot.setFixedLegendItems(collection);

    }

    plot.setRenderer(0, renderer);
    logger.debug("OUT");
    return sparkLineGraph;
}

From source file:gedi.util.math.stat.distributions.GeneralizedExtremeValueDistribution.java

@Override
public double getSupportUpperBound() {
    if (shape < 0)
        return location - scale / shape;
    return Double.POSITIVE_INFINITY;
}