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

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

Introduction

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

Prototype

public void setLabelAnchor(RectangleAnchor anchor) 

Source Link

Document

Sets the label anchor and sends a MarkerChangeEvent to all registered listeners.

Usage

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);/*from w  ww.jav a 2 s  .c o  m*/
    start.setLabel(Labelstr);
    start.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    start.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    start.setLabelPaint(color);
    plot.addDomainMarker(start);
}

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 w w . j  ava  2  s. c  o  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: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  a  2  s  .c  om

    }
}

From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java

protected void redoStraightLegs() {
    // ok, clear any leg markers
    if (legPlot != null) {
        if (!graphTabs.isDisposed())
            graphTabs.setSelection(legTab);

        // hmm, actually we have to remove any target leg markers
        @SuppressWarnings("unchecked")
        Collection<IntervalMarker> markers = legPlot.getDomainMarkers(Layer.FOREGROUND);
        if (markers != null) {
            ArrayList<IntervalMarker> markersToDelete = new ArrayList<IntervalMarker>(markers);
            Iterator<IntervalMarker> mIter = markersToDelete.iterator();
            while (mIter.hasNext()) {
                IntervalMarker im = mIter.next();
                legPlot.removeDomainMarker(im);
            }/*  w  ww  . j a va2 s . com*/
        }

        Iterator<BaseContribution> conts = activeSolver.getContributions().iterator();
        while (conts.hasNext()) {
            BaseContribution baseC = conts.next();
            if (baseC.isActive())
                if (baseC instanceof StraightLegForecastContribution) {
                    StraightLegForecastContribution slf = (StraightLegForecastContribution) baseC;
                    java.awt.Color thisCol = slf.getColor();

                    // hmm, has it been given a color (initialised) yet?
                    if (thisCol == null)
                        continue;

                    long thisStart = baseC.getStartDate().getTime();
                    long thisFinish = baseC.getFinishDate().getTime();

                    java.awt.Color transCol = new java.awt.Color(255, 0, 0, 22);

                    final Marker bst = new IntervalMarker(thisStart, thisFinish, transCol,
                            new BasicStroke(2.0f), null, null, 1.0f);
                    bst.setLabel(baseC.getName());
                    bst.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
                    bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, 10));
                    bst.setLabelTextAnchor(TextAnchor.BASELINE_LEFT);
                    legPlot.addDomainMarker(bst, Layer.FOREGROUND);
                } else {
                    if (baseC instanceof BearingMeasurementContribution) {

                    }
                }
        }

    }

}

From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java

protected void redoOwnshipStates() {
    if (legPlot == null)
        return;/*w ww  .ja  v a 2s  .co m*/

    boolean showCourses = true;
    if (showOSCourse != null)
        showCourses = showOSCourse.getSelection();

    java.awt.Color courseCol = java.awt.Color.blue.darker().darker();
    java.awt.Color speedCol = java.awt.Color.blue.brighter().brighter();

    // ok, now loop through and set them
    long startTime = Long.MAX_VALUE;
    long endTime = Long.MIN_VALUE;

    // clear any datasets
    legPlot.setDataset(0, null);
    legPlot.setDataset(1, null);

    // hmm, actually we have to remove any target leg markers
    @SuppressWarnings("unchecked")
    Collection<IntervalMarker> markers = legPlot.getDomainMarkers(Layer.BACKGROUND);
    if (markers != null) {
        ArrayList<IntervalMarker> markersToDelete = new ArrayList<IntervalMarker>(markers);
        Iterator<IntervalMarker> mIter = markersToDelete.iterator();
        while (mIter.hasNext()) {
            IntervalMarker im = mIter.next();
            legPlot.removeDomainMarker(im);
        }
    }

    // hey, does it have any ownship legs?
    TimeSeriesCollection tscC = new TimeSeriesCollection();
    TimeSeriesCollection tscS = new TimeSeriesCollection();
    TimeSeriesCollection tscCLegs = new TimeSeriesCollection();
    TimeSeriesCollection tscSLegs = new TimeSeriesCollection();
    TimeSeries courses = new TimeSeries("Course");
    TimeSeries bearings = new TimeSeries("Bearings");
    TimeSeries speeds = new TimeSeries("Speed");
    TimeSeries courseLegs = new TimeSeries("Course (leg)");
    TimeSeries speedLegs = new TimeSeries("Speed (leg)");

    Iterator<BaseContribution> conts = activeSolver.getContributions().iterator();
    while (conts.hasNext()) {
        BaseContribution baseC = conts.next();
        if (baseC.isActive())
            if (baseC instanceof BearingMeasurementContribution) {
                BearingMeasurementContribution bmc = (BearingMeasurementContribution) baseC;

                Iterator<LegOfData> lIter = null;
                LegOfData thisLeg = null;

                if (bmc.getOwnshipLegs() != null) {
                    lIter = bmc.getOwnshipLegs().iterator();
                    thisLeg = lIter.next();
                }

                List<HostState> hostStates = bmc.getHostState();
                if (hostStates != null) {
                    Iterator<HostState> stateIter = hostStates.iterator();
                    while (stateIter.hasNext()) {
                        BearingMeasurementContribution.HostState hostState = stateIter.next();
                        long thisTime = hostState.time;
                        double thisCourse = hostState.courseDegs;
                        if (showCourses)
                            courses.add(new FixedMillisecond(thisTime), thisCourse);
                        double thisSpeed = hostState.speedKts;
                        speeds.add(new FixedMillisecond(thisTime), thisSpeed);
                        startTime = Math.min(thisTime, startTime);
                        endTime = Math.max(thisTime, endTime);

                        // sort out if this is in a leg or not
                        if (thisLeg != null) {
                            if (thisTime > thisLeg.getEnd() && lIter.hasNext()) {
                                thisLeg = lIter.next();
                            } else {
                                if (thisTime >= thisLeg.getStart()) {
                                    speedLegs.add(new FixedMillisecond(thisTime), thisSpeed);
                                    if (showCourses)
                                        courseLegs.add(new FixedMillisecond(thisTime), thisCourse);
                                }
                            }
                        }
                    }
                }

                // also, we wish to show the bearings from the BMC
                Iterator<BMeasurement> cuts = bmc.getMeasurements().iterator();
                while (cuts.hasNext()) {
                    BearingMeasurementContribution.BMeasurement measurement = cuts.next();
                    if (measurement.isActive()) {
                        long thisT = measurement.getDate().getTime();
                        bearings.add(new FixedMillisecond(thisT),
                                Math.toDegrees(Math.abs(measurement.getBearingRads())));
                    }
                }

            }
    }

    // HEY, also shade the ownship legs
    conts = activeSolver.getContributions().iterator();
    while (conts.hasNext()) {
        BaseContribution baseC = conts.next();
        if (baseC.isActive()) {
            if (baseC instanceof BearingMeasurementContribution) {
                BearingMeasurementContribution bmc = (BearingMeasurementContribution) baseC;

                Iterator<LegOfData> lIter = null;
                if (bmc.getOwnshipLegs() != null) {
                    int ctr = 1;
                    lIter = bmc.getOwnshipLegs().iterator();
                    while (lIter.hasNext()) {
                        LegOfData thisL = lIter.next();
                        long thisStart = thisL.getStart();
                        long thisFinish = thisL.getEnd();

                        java.awt.Color transCol = new java.awt.Color(0, 0, 255, 12);

                        final Marker bst = new IntervalMarker(thisStart, thisFinish, transCol,
                                new BasicStroke(2.0f), null, null, 1.0f);
                        bst.setLabel("O/S-" + ctr++);
                        bst.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                        bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, 10));
                        bst.setLabelTextAnchor(TextAnchor.TOP_LEFT);
                        legPlot.addDomainMarker(bst, Layer.BACKGROUND);
                    }
                }
            }
        }
    }

    tscS.addSeries(speeds);
    tscSLegs.addSeries(speedLegs);
    tscC.addSeries(bearings);

    if (showCourses) {
        tscC.addSeries(courses);
        tscCLegs.addSeries(courseLegs);
    }

    legPlot.setDataset(0, null);
    legPlot.setDataset(1, null);
    legPlot.setDataset(2, null);
    legPlot.setDataset(3, null);
    legPlot.setDataset(0, tscC);
    legPlot.setDataset(1, tscS);
    legPlot.setDataset(2, tscCLegs);
    legPlot.setDataset(3, tscSLegs);

    final NumberAxis axis2 = new NumberAxis("Speed (Kts)");
    legPlot.setRangeAxis(1, axis2);
    legPlot.mapDatasetToRangeAxis(1, 1);
    legPlot.mapDatasetToRangeAxis(3, 1);

    legPlot.getRangeAxis(0).setLabel("Crse/Brg (Degs)");
    legPlot.mapDatasetToRangeAxis(0, 0);
    legPlot.mapDatasetToRangeAxis(2, 0);

    final XYLineAndShapeRenderer lineRenderer1 = new XYLineAndShapeRenderer(true, true);
    lineRenderer1.setSeriesPaint(1, courseCol);
    lineRenderer1.setSeriesShape(1, ShapeUtilities.createDiamond(0.1f));
    lineRenderer1.setSeriesPaint(0, java.awt.Color.RED);
    lineRenderer1.setSeriesShape(0, ShapeUtilities.createDiamond(2f));

    final XYLineAndShapeRenderer lineRenderer2 = new XYLineAndShapeRenderer(true, false);
    lineRenderer2.setSeriesPaint(0, speedCol);

    final XYLineAndShapeRenderer lineRenderer3 = new XYLineAndShapeRenderer(false, true);
    lineRenderer3.setSeriesPaint(0, courseCol);
    lineRenderer3.setSeriesShape(0, ShapeUtilities.createUpTriangle(2f));

    final XYLineAndShapeRenderer lineRenderer4 = new XYLineAndShapeRenderer(false, true);
    lineRenderer4.setSeriesPaint(0, speedCol);
    lineRenderer4.setSeriesShape(0, ShapeUtilities.createDownTriangle(2f));

    // ok, and store them
    legPlot.setRenderer(0, lineRenderer1);
    legPlot.setRenderer(1, lineRenderer2);
    legPlot.setRenderer(2, lineRenderer3);
    legPlot.setRenderer(3, lineRenderer4);

    if (startTime != Long.MAX_VALUE)
        legPlot.getDomainAxis().setRange(startTime, endTime);

    // ok - get the straight legs to sort themselves out
    // redoStraightLegs();
}

From source file:com.jtstand.swing.StatsPanel.java

public void placeLimitMarkers(XYPlot plot, boolean range) {
    if (testStepInstances.getReferenceStep() != null
            && testStepInstances.getReferenceStep().getTestLimit() != null) {
        if (testStepInstances.getReferenceStep().getTestLimit().getLowerSpecifiedLimit() != null) {
            final Marker lsl = new ValueMarker(
                    testStepInstances.getReferenceStep().getTestLimit().getLowerSpecifiedLimit());
            lsl.setPaint(limitcolor);/*  w w  w . j a  va2 s  .c o  m*/
            lsl.setLabel("LSL");
            if (range) {
                lsl.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
                lsl.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
                plot.addRangeMarker(lsl);
            } else {
                lsl.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                lsl.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
                plot.addDomainMarker(lsl);
            }

        }
        if (testStepInstances.getReferenceStep().getTestLimit().getUpperSpeficiedLimit() != null) {
            final Marker usl = new ValueMarker(
                    testStepInstances.getReferenceStep().getTestLimit().getUpperSpeficiedLimit());
            usl.setPaint(limitcolor);
            usl.setLabel("USL");
            if (range) {
                usl.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
                usl.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
                plot.addRangeMarker(usl);
            } else {
                usl.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
                usl.setLabelTextAnchor(TextAnchor.TOP_LEFT);
                plot.addDomainMarker(usl);
            }
        }
    }
}