Example usage for org.jfree.chart.plot Marker setPaint

List of usage examples for org.jfree.chart.plot Marker setPaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot Marker setPaint.

Prototype

public void setPaint(Paint paint) 

Source Link

Document

Sets the paint and sends a MarkerChangeEvent to all registered listeners.

Usage

From source file:KIDLYFactory.java

/**
 * Creates a waterfall chart.  The chart object returned by this method
 * uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link WaterfallBarRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).// w ww.  j  a  v  a2  s .  c  o  m
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A waterfall chart.
 */
public static JFreeChart createWaterfallChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);

    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
                TextAnchor.CENTER, Math.PI / 2.0);
        renderer.setBasePositiveItemLabelPosition(position);
        renderer.setBaseNegativeItemLabelPosition(position);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0);
        renderer.setBasePositiveItemLabelPosition(position);
        renderer.setBaseNegativeItemLabelPosition(position);
    }
    if (tooltips) {
        StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator();
        renderer.setBaseToolTipGenerator(generator);
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.clearRangeMarkers();
    Marker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.black);
    plot.addRangeMarker(baseline, Layer.FOREGROUND);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

private void paintDomainGridLine(Calendar date, XYPlot plot) {

    long millis = date.getTimeInMillis();
    final Marker originalEnd = new ValueMarker(millis);
    originalEnd.setPaint(DOMAIN_GRID_LINE_COLOR);
    originalEnd.setStroke(new BasicStroke(1));
    plot.addDomainMarker(originalEnd, Layer.BACKGROUND);
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

public void addPercipitationBars(TimeBase timeBase, String title, NumberPhenomenon phenomenon, Color color) {
    XYDataset dataSet = phenomenon.getTimeSeries(title, timeBase);
    if (dataSet.getSeriesCount() > 0) {

        double margin = 0.1;
        double maxPrecipitation = phenomenon.getMaxValue();
        addBarChart(dataSet, "value", color, margin, maxPrecipitation);
        showBarValuesOnTop(plotIndex - 1, 6D);

        plot.getRangeAxis(getRangeAxisIndex() - 1).setVisible(false);

        final Marker marker = new ValueMarker(0);
        marker.setPaint(Color.GRAY);
        marker.setStroke(new BasicStroke(1));
        plot.addRangeMarker(getRangeAxisIndex() - 1, marker, Layer.BACKGROUND);
    }/*w ww  .  jav  a2s  .c  om*/
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

/**
Add max min bar. Mainly used to show precipitation that has max and min values
* @param timeBase//from   ww  w  .ja  v a 2 s .  c  om
* @param title
* @param maxMinTimeSeriesEnabler
* @param maxColor
* @param minColor 
*/
public void addMaxMinPercipitationBars(TimeBase timeBase, String title, NumberPhenomenon max,
        NumberPhenomenon min, Color maxColor, Color minColor) {

    XYDataset maxDataset = max.getTimeSeries(title, timeBase);
    XYDataset minDataset = min.getTimeSeries(title, timeBase);
    if (maxDataset.getSeriesCount() > 0 && minDataset.getSeriesCount() > 0 && maxDataset.getItemCount(0) > 0
            && minDataset.getItemCount(0) > 0) {

        double margin = 0.2;
        double maxPrecipitation = max.getMaxValue();

        addBarChart(minDataset, "min", minColor, margin, maxPrecipitation);
        showBarValuesOnBottom(plotIndex - 1, 1D);

        rangeAxisIndex--;

        addBarChart(maxDataset, "max", maxColor, margin, maxPrecipitation);
        showBarValuesOnTop(plotIndex - 1, 6D);

        plot.getRangeAxis(getRangeAxisIndex() - 1).setVisible(false);

        final Marker marker = new ValueMarker(0);
        marker.setPaint(Color.GRAY);
        marker.setStroke(new BasicStroke(1));
        plot.addRangeMarker(getRangeAxisIndex() - 1, marker, Layer.BACKGROUND);
    }
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

public void addDomainMarkers(Date start, Date stop, TimeZone timeZone, Locale locale) {
    if (!addedDomainMarkers) {
        //make a one hour by one hour time list
        //The reason is that not all the data are hour by hour
        //domainMarkers will not mark labels when no date at clock 00:00

        List<Date> time = getTimeHourByHour(start, stop);
        // set the markers
        Map<Long, String> domainMarkers = getDomainMarkersWithLabel(time, timeZone, locale);
        for (Map.Entry<Long, String> entry : domainMarkers.entrySet()) {
            Long timeInMilli = entry.getKey();
            String label = entry.getValue();
            final Marker originalEnd = new ValueMarker(timeInMilli);
            originalEnd.setPaint(Color.DARK_GRAY);
            originalEnd.setStroke(new BasicStroke(1.0f));
            originalEnd.setLabel(label);//Arial Hebrew, SansSerif
            originalEnd.setLabelFont(new Font("Arial", Font.PLAIN, 14));
            originalEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
            originalEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
            plot.addDomainMarker(originalEnd, Layer.BACKGROUND);
            setAddedDomainMarkers(true);
        }/*from w  w w .  j  av a2  s.c o m*/

    }
}

From source file:net.liuxuan.device.w3330.JIF_DrawChart_w3330.java

private void chartDrawHerizonLine(W3330MetaData data, Color color, String Labelstr) {
    XYPlot plot = (XYPlot) chartPanel.getChart().getPlot();
    final Marker start = new ValueMarker(data.zero);
    start.setPaint(color);
    start.setLabel(Labelstr);//  w w w  .  java 2 s. c o  m
    start.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
    start.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    start.setLabelPaint(color);
    plot.addRangeMarker(start);
}

From source file:net.liuxuan.device.w3330.JIF_DrawChart_w3330.java

private void chartDrawVerticalLine(W3330MetaData data, Color color, String Labelstr) {
    XYPlot plot = (XYPlot) chartPanel.getChart().getPlot();
    final Marker start = new ValueMarker(data.time.getTime());
    start.setPaint(color);
    start.setLabel(Labelstr);/*from  w w  w .jav a  2 s  .  c om*/
    start.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    start.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    start.setLabelPaint(color);
    plot.addDomainMarker(start);
}

From source file:ch.algotrader.client.chart.ChartTab.java

private void initMarker(SeriesDefinitionVO seriesDefinition) {

    final MarkerDefinitionVO markerDefinition = (MarkerDefinitionVO) seriesDefinition;

    final Marker marker;
    if (markerDefinition.isInterval()) {
        marker = new IntervalMarker(0, 0);
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); // position of the label
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); // position of the text within the label
    } else {/*from www  .  j a  va2 s  .  c o m*/
        marker = new ValueMarker(0);
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    }

    marker.setPaint(getColor(markerDefinition.getColor()));
    marker.setLabel(markerDefinition.getLabel());
    marker.setLabelFont(new Font("SansSerif", 0, 9));

    if (seriesDefinition.isDashed()) {
        marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 5.0f }, 0.0f));
    } else {
        marker.setStroke(new BasicStroke(1.0f));
    }

    getPlot().addRangeMarker(marker, markerDefinition.isInterval() ? Layer.BACKGROUND : Layer.FOREGROUND);

    this.markers.put(markerDefinition.getName(), marker);
    this.markersSelectionStatus.put(markerDefinition.getName(), seriesDefinition.isSelected());

    // add the menu item
    JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel());
    menuItem.setSelected(seriesDefinition.isSelected());
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetAxis();
            boolean selected = ((JCheckBoxMenuItem) e.getSource()).isSelected();
            ChartTab.this.markersSelectionStatus.put(markerDefinition.getName(), selected);
            if (selected) {
                if (marker instanceof ValueMarker) {
                    marker.setAlpha(1.0f);
                } else {
                    marker.setAlpha(0.5f);
                }
            } else {
                marker.setAlpha(0);
            }
            initAxis();
        }
    });
    this.getPopupMenu().add(menuItem);
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java

private GapFillingCase refresh(final Algo algo, final int[] indexesOfUsedSeries, final boolean hideOthers,
        final boolean showError, final boolean zoom, final boolean showEnvelope, final boolean multAxis)
        throws Exception {
    if (!inBatchMode)
        this.centerPanel.removeAll();

    int[] arr = new int[] { attr.index(), dateIdx };
    for (final int iii : indexesOfUsedSeries) {
        arr = ArraysUtil.concat(arr, new int[] { dataSet.attribute(this.attrNames.get(iii)).index() });
    }/*from  w ww .  ja  v  a 2s  . co  m*/

    Instances filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet, arr);
    //System.out.println(filteredDs.toSummaryString());

    Attribute original = null;
    Instances filteredDsWithOriginal = null;
    if (this.isGapSimulated) {
        original = new Attribute("original");
        filteredDsWithOriginal = new Instances(filteredDs);
        filteredDsWithOriginal.insertAttributeAt(original, filteredDsWithOriginal.numAttributes() - 1);
        final Attribute origAttr = filteredDsWithOriginal.attribute(original.name());
        for (int ii = position - 1; ii < position + gapsize + 1; ii++) {
            filteredDsWithOriginal.instance(ii).setValue(origAttr, this.originalDataBeforeGapSimulation[ii]);
        }
    }

    filteredDs = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs, 0, filteredDs.numAttributes() - 1,
            Math.max(0, this.position - this.valuesBeforeAndAfter),
            Math.min(this.position + this.gapsize + this.valuesBeforeAndAfter, filteredDs.numInstances() - 1));

    this.gapFiller = GapFillerFactory.getGapFiller(algo);

    final Instances completedds = this.gapFiller.fillGaps(filteredDs);
    final Instances diff = WekaTimeSeriesUtil.buildDiff(filteredDs, completedds);

    final int valuesToCheckForError = this.valuesBeforeAndAfter / 4;

    double maeByEnlargingGap = Double.NaN;
    double maeByAddingAGapBefore = Double.NaN;
    double maeByAddingAGapAfter = Double.NaN;
    double maeByComparingWithOriginal = Double.NaN;

    double rmseByEnlargingGap = Double.NaN;
    double rmseByAddingAGapBefore = Double.NaN;
    double rmseByAddingAGapAfter = Double.NaN;
    double rmseByComparingWithOriginal = Double.NaN;

    double rsrByEnlargingGap = Double.NaN;
    double rsrByAddingAGapBefore = Double.NaN;
    double rsrByAddingAGapAfter = Double.NaN;
    double rsrByComparingWithOriginal = Double.NaN;

    double pbiasByEnlargingGap = Double.NaN;
    double pbiasByAddingAGapBefore = Double.NaN;
    double pbiasByAddingAGapAfter = Double.NaN;
    double pbiasByComparingWithOriginal = Double.NaN;

    double nsByEnlargingGap = Double.NaN;
    double nsByAddingAGapBefore = Double.NaN;
    double nsByAddingAGapAfter = Double.NaN;
    double nsByComparingWithOriginal = Double.NaN;

    double indexOfAgreementByEnlargingGap = Double.NaN;
    double indexOfAgreementByAddingAGapBefore = Double.NaN;
    double indexOfAgreementByAddingAGapAfter = Double.NaN;
    double indexOfAgreementByComparingWithOriginal = Double.NaN;

    if (this.isGapSimulated) {
        //System.out.println(attr.index()+" begin="+(this.position)+" end="+(this.position+this.gapsize));

        final Instances correctedDataSet = buildCorrectedDataset(diff);

        final double[] cad = correctedDataSet.attributeToDoubleArray(attr.index());
        maeByComparingWithOriginal = MathsUtil.mae(this.originalDataBeforeGapSimulation, cad, this.position,
                this.position + this.gapsize);
        rmseByComparingWithOriginal = MathsUtil.rmse(this.originalDataBeforeGapSimulation, cad, this.position,
                this.position + this.gapsize);
        rsrByComparingWithOriginal = MathsUtil.rsr(this.originalDataBeforeGapSimulation, cad, this.position,
                this.position + this.gapsize);
        pbiasByComparingWithOriginal = MathsUtil.pbias(this.originalDataBeforeGapSimulation, cad, this.position,
                this.position + this.gapsize);
        nsByComparingWithOriginal = MathsUtil.nashSutcliffe(this.originalDataBeforeGapSimulation, cad,
                this.position, this.position + this.gapsize);
        indexOfAgreementByComparingWithOriginal = MathsUtil.indexOfAgreement(
                this.originalDataBeforeGapSimulation, cad, this.position, this.position + this.gapsize);
    } else {
        maeByEnlargingGap = this.gapFiller.evaluateMAEByEnlargingGap(filteredDs, valuesToCheckForError);
        maeByAddingAGapBefore = this.gapFiller.evaluateMAEByAddingAGapBefore(filteredDs, valuesToCheckForError);
        maeByAddingAGapAfter = this.gapFiller.evaluateMAEByAddingAGapAfter(filteredDs, valuesToCheckForError);

        rmseByEnlargingGap = this.gapFiller.evaluateRMSEByEnlargingGap(filteredDs, valuesToCheckForError);
        rmseByAddingAGapBefore = this.gapFiller.evaluateRMSEByAddingAGapBefore(filteredDs,
                valuesToCheckForError);
        rmseByAddingAGapAfter = this.gapFiller.evaluateRMSEByAddingAGapAfter(filteredDs, valuesToCheckForError);

        nsByEnlargingGap = this.gapFiller.evaluateNSByEnlargingGap(filteredDs, valuesToCheckForError);
        nsByAddingAGapBefore = this.gapFiller.evaluateNSByAddingAGapBefore(filteredDs, valuesToCheckForError);
        nsByAddingAGapAfter = this.gapFiller.evaluateNSByAddingAGapAfter(filteredDs, valuesToCheckForError);
    }

    if (hideOthers) {
        if (this.isGapSimulated) {
            filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(filteredDsWithOriginal,
                    new int[] { 0, 1, filteredDsWithOriginal.attribute(original.name()).index() });
            filteredDs = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs, 0,
                    filteredDs.numAttributes() - 1, Math.max(0, this.position - this.valuesBeforeAndAfter),
                    Math.min(this.position + this.gapsize + this.valuesBeforeAndAfter,
                            filteredDs.numInstances() - 1));
        } else {
            filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(filteredDs,
                    new int[] { 0, 1 });
        }
    }

    final Instances decomposition = WekaTimeSeriesUtil.buildMergedDataSet(filteredDs, diff);

    final Attribute diffAttribute = decomposition.attribute(attr.name() + "_diff");

    final List<XYAnnotation> aaa = new ArrayList<XYAnnotation>();
    if (showError) {
        showError(this.isGapSimulated ? maeByComparingWithOriginal : maeByEnlargingGap, decomposition,
                diffAttribute, aaa);
    }

    if (showEnvelope) {
        final MainViewLoadingFrame loadingFrame = new MainViewLoadingFrame();
        loadingFrame.setVisible(true);
        loadingFrame.pack();
        loadingFrame.repaint();
        showEnvelope(arr, aaa);
        loadingFrame.setVisible(false);
    }

    if (!inBatchMode) {
        final ChartPanel cp;
        /*if (showError)
        {
           cp=TimeSeriesChartUtil.buildChartPanelForAllAttributesInterval(decomposition,WekaDataStatsUtil.getFirstDateAttributeIdx(decomposition),mae,diffAttribute.index());
        }
        else
        {*/
        cp = TimeSeriesChartUtil.buildChartPanelForAllAttributes(decomposition, multAxis,
                WekaDataStatsUtil.getFirstDateAttributeIdx(decomposition), null, aaa);
        /*}*/

        final Marker gapBeginMarker = new ValueMarker(
                dataSet.instance(Math.max(0, position - 1)).value(dateIdx));
        gapBeginMarker.setPaint(Color.RED);
        gapBeginMarker.setLabel("Gap begin");
        gapBeginMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        gapBeginMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        cp.getChart().getXYPlot().addDomainMarker(gapBeginMarker);

        final Marker gapEndMarker = new ValueMarker(
                dataSet.instance(Math.min(dataSet.numInstances() - 1, position + gapsize)).value(dateIdx));
        gapEndMarker.setPaint(Color.RED);
        gapEndMarker.setLabel("Gap end");
        gapEndMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        gapEndMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        cp.getChart().getXYPlot().addDomainMarker(gapEndMarker);

        if (!zoom) {
            final NumberAxis na = (NumberAxis) (cp.getChart().getXYPlot().getRangeAxis());
            na.setRange(0, WekaDataStatsUtil.getMaxValue(dataSet, attrNames));
        }

        String errorInfo;
        if (!this.isGapSimulated) {
            errorInfo = "By enlarging the gap:\t MAE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(maeByEnlargingGap) + "\t RMSE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(rmseByEnlargingGap) + "\t NASH-SUTCLIFFE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(nsByEnlargingGap)
                    + "\nBy adding a gap before:\t MAE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(maeByAddingAGapBefore) + "\t RMSE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(rmseByAddingAGapBefore) + "\t NASH-SUTCLIFFE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(nsByAddingAGapBefore)
                    + "\nBy adding a gap after:\t MAE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(maeByAddingAGapAfter) + "\t RMSE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(rmseByAddingAGapAfter) + "\t NASH-SUTCLIFFE="
                    + FormatterUtil.DECIMAL_FORMAT_4.format(nsByAddingAGapAfter);
        } else {
            errorInfo = "MAE: " + FormatterUtil.DECIMAL_FORMAT_4.format(maeByComparingWithOriginal);
            errorInfo += "\n";
            errorInfo += "RMSE: " + FormatterUtil.DECIMAL_FORMAT_4.format(rmseByComparingWithOriginal);
            errorInfo += "\n";
            errorInfo += "RSR: " + FormatterUtil.DECIMAL_FORMAT_4.format(rsrByComparingWithOriginal);
            errorInfo += "\n";
            errorInfo += "PBIAS: " + FormatterUtil.DECIMAL_FORMAT_4.format(pbiasByComparingWithOriginal);
            errorInfo += "\n";
            errorInfo += "NASH-SUTCLIFFE: " + FormatterUtil.DECIMAL_FORMAT_4.format(nsByComparingWithOriginal);
            errorInfo += "\n";
            errorInfo += "INDEX OF AGREEMENT: "
                    + FormatterUtil.DECIMAL_FORMAT_4.format(indexOfAgreementByComparingWithOriginal);
        }
        cp.setBorder(new TitledBorder(""));
        final JTextArea errorTextArea = new JTextArea(errorInfo);
        errorTextArea.setBorder(new TitledBorder(""));
        this.centerPanel.add(errorTextArea, BorderLayout.NORTH);
        this.centerPanel.add(cp, BorderLayout.CENTER);

        final JXPanel cmdPanel = new JXPanel();
        final JXButton okButton = new JXButton("Ok");
        okButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                final Instances correctedDataSet = buildCorrectedDataset(diff);

                final DataChange change = new DataChange(correctedDataSet, TabView.DataChangeTypeEnum.Update);
                atv.pushDataChange(change);

                setVisible(false);
            }
        });
        cmdPanel.add(okButton);
        final JXButton cancelButton = new JXButton("Cancel");
        cancelButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                setVisible(false);
            }
        });
        cmdPanel.add(cancelButton);
        this.centerPanel.add(cmdPanel, BorderLayout.SOUTH);

        this.centerPanel.updateUI();

        getContentPane().repaint();
    }

    final double globalMAE = (this.isGapSimulated) ? maeByComparingWithOriginal
            : ((maeByEnlargingGap + maeByAddingAGapBefore + maeByAddingAGapAfter) / 3);

    final double globalRMSE = (this.isGapSimulated) ? rmseByComparingWithOriginal
            : ((rmseByEnlargingGap + rmseByAddingAGapBefore + rmseByAddingAGapAfter) / 3);

    final double globalRSR = (this.isGapSimulated) ? rsrByComparingWithOriginal
            : ((rsrByEnlargingGap + rsrByAddingAGapBefore + rsrByAddingAGapAfter) / 3);

    final double globalPBIAS = (this.isGapSimulated) ? pbiasByComparingWithOriginal
            : ((pbiasByEnlargingGap + pbiasByAddingAGapBefore + pbiasByAddingAGapAfter) / 3);

    final double globalNS = (this.isGapSimulated) ? nsByComparingWithOriginal
            : ((nsByEnlargingGap + nsByAddingAGapBefore + nsByAddingAGapAfter) / 3);

    final double globalIndexOfAgreement = (this.isGapSimulated) ? indexOfAgreementByComparingWithOriginal
            : ((indexOfAgreementByEnlargingGap + indexOfAgreementByAddingAGapBefore
                    + indexOfAgreementByAddingAGapAfter) / 3);

    // usage logs for stats      
    final long firstTimestamp = (long) dataSet.instance(position).value(dateIdx);
    final boolean isDuringRising;
    if (nearest == null)
        isDuringRising = GapsUtil.isDuringRising(dataSet, position, gapsize,
                new int[] { dateIdx, attr.index() });
    else
        isDuringRising = GapsUtil.isDuringRising(dataSet, position, gapsize,
                new int[] { dateIdx, attr.index(), dataSet.attribute(nearest).index() });

    return new GapFillingCase(DateUtil.getSeason(firstTimestamp), DateUtil.getYear(firstTimestamp), algo,
            gapsize, position, attr, gcp.getCoordinates(attr.name())[0], gcp.getCoordinates(attr.name())[1],
            gcp.findDownstreamStation(attr.name()) != null, gcp.findUpstreamStation(attr.name()) != null,
            globalMAE, globalRMSE, globalRSR, globalPBIAS, globalNS, globalIndexOfAgreement,
            ArraysUtil.contains(indexesOfUsedSeries, attrNames.indexOf(mostSimilar)),
            ArraysUtil.contains(indexesOfUsedSeries, attrNames.indexOf(nearest)),
            ArraysUtil.contains(indexesOfUsedSeries, attrNames.indexOf(downstream)),
            ArraysUtil.contains(indexesOfUsedSeries, attrNames.indexOf(upstream)), isDuringRising,
            GapsUtil.measureHighMiddleLowInterval(dataSet, attr.index(), position - 1));
}

From source file:net.sf.jasperreports.customizers.marker.AbstractMarkerCustomizer.java

protected void configureMarker(Marker marker) {
    String label = getProperty(PROPERTY_LABEL);
    if (label != null && label.length() > 0) {
        marker.setLabel(label);/*  w  w  w.ja  v a  2s .c o  m*/
    }

    RectangleAnchorEnum labelAnchor = RectangleAnchorEnum.getByName(getProperty(PROPERTY_LABEL_ANCHOR));
    if (labelAnchor != null) {
        marker.setLabelAnchor(labelAnchor.getRectangleAnchor());
    }

    Double offsetTop = getDoubleProperty(PROPERTY_LABEL_OFFSET_TOP);
    Double offsetLeft = getDoubleProperty(PROPERTY_LABEL_OFFSET_LEFT);
    Double offsetBottom = getDoubleProperty(PROPERTY_LABEL_OFFSET_BOTTOM);
    Double offsetRight = getDoubleProperty(PROPERTY_LABEL_OFFSET_RIGHT);
    if (offsetTop != null || offsetLeft != null || offsetBottom != null || offsetRight != null) {
        RectangleInsets currentOffset = marker.getLabelOffset();
        marker.setLabelOffset(new RectangleInsets(offsetTop == null ? currentOffset.getTop() : offsetTop,
                offsetLeft == null ? currentOffset.getLeft() : offsetLeft,
                offsetBottom == null ? currentOffset.getBottom() : offsetBottom,
                offsetRight == null ? currentOffset.getRight() : offsetRight));
    }

    TextAnchorEnum labelTextAnchor = TextAnchorEnum.getByName(getProperty(PROPERTY_LABEL_TEXT_ANCHOR));
    if (labelTextAnchor != null) {
        marker.setLabelTextAnchor(labelTextAnchor.getTextAnchor());
    }

    Color color = JRColorUtil.getColor(getProperty(PROPERTY_COLOR), null);
    if (color != null) {
        marker.setPaint(color);
    }

    Float alpha = getFloatProperty(PROPERTY_ALPHA);
    if (alpha != null) {
        marker.setAlpha(alpha);
    }
}