Example usage for org.jfree.chart.annotations XYPointerAnnotation setBaseRadius

List of usage examples for org.jfree.chart.annotations XYPointerAnnotation setBaseRadius

Introduction

In this page you can find the example usage for org.jfree.chart.annotations XYPointerAnnotation setBaseRadius.

Prototype

public void setBaseRadius(double radius) 

Source Link

Document

Sets the base radius and sends an AnnotationChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.XYAreaChartDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)",
            xydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setForegroundAlpha(0.65F);//w ww  .j  a  va2s.  c  o m
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D);
    xypointerannotation.setTipRadius(0.0D);
    xypointerannotation.setBaseRadius(35D);
    xypointerannotation.setFont(new Font("SansSerif", 0, 9));
    xypointerannotation.setPaint(Color.blue);
    xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    xyplot.addAnnotation(xypointerannotation);
    return jfreechart;
}

From source file:com.bwc.ora.views.LabelPopupMenu.java

private void initMenu() {
    //determine if the point clicked already has an annotation
    boolean hasAnnotationAlready = hasAnnoationAlready();

    if (hasAnnotationAlready) {
        //add label to allow users to deselect the label for a given peak
        JMenuItem nonItem = new JMenuItem("Remove Label");
        nonItem.addActionListener(e -> {
            removeAnnotation();//from  ww  w.j  a v a  2  s. com
            lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations());
        });
        add(nonItem);
    }

    //add list of possible labels for a point to the popup menu
    Arrays.stream(RetinalBand.values()).map(RetinalBand::toString).map(label -> {
        XYPointerAnnotation pointer = new XYPointerAnnotation(label,
                item.getDataset().getXValue(item.getSeriesIndex(), item.getItem()),
                item.getDataset().getYValue(item.getSeriesIndex(), item.getItem()), 0);
        pointer.setBaseRadius(35.0);
        pointer.setTipRadius(10.0);
        pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
        pointer.setPaint(Color.blue);
        pointer.setTextAnchor(TextAnchor.CENTER_LEFT);
        JMenuItem l = new JMenuItem(label);
        l.addActionListener(e -> {
            if (hasAnnotationAlready) {
                removeAnnotation();
            }
            chartPanel.getChart().getXYPlot().addAnnotation(pointer);
            lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations());
        });
        return l;
    }).forEach(this::add);
}

From source file:org.jfree.chart.demo.MarkerDemo1.java

/**
 * Creates a sample chart.//from  w w  w.j  a  v a  2  s  .c om
 *
 * @param data  the sample data.
 *
 * @return A configured chart.
 */
private JFreeChart createChart(final XYDataset data) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Marker Demo 1", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);
    //    chart.getLegend().setAnchor(Legend.EAST);

    // customise...
    final XYPlot plot = chart.getXYPlot();
    plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

    // set axis margins to allow space for marker labels...
    final DateAxis domainAxis = new DateAxis("Time");
    domainAxis.setUpperMargin(0.50);
    plot.setDomainAxis(domainAxis);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.30);
    rangeAxis.setLowerMargin(0.50);

    // add a labelled marker for the bid start price...
    final Marker start = new ValueMarker(200.0);
    start.setPaint(Color.green);
    start.setLabel("Bid Start Price");
    start.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    start.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addRangeMarker(start);

    // add a labelled marker for the target price...
    final Marker target = new ValueMarker(175.0);
    target.setPaint(Color.red);
    target.setLabel("Target Price");
    target.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(target);

    // add a labelled marker for the original closing time...
    final Hour hour = new Hour(2, new Day(22, 5, 2003));
    double millis = hour.getFirstMillisecond();
    final Marker originalEnd = new ValueMarker(millis);
    originalEnd.setPaint(Color.orange);
    originalEnd.setLabel("Original Close (02:00)");
    originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addDomainMarker(originalEnd);

    // add a labelled marker for the current closing time...
    final Minute min = new Minute(15, hour);
    millis = min.getFirstMillisecond();
    final Marker currentEnd = new ValueMarker(millis);
    currentEnd.setPaint(Color.red);
    currentEnd.setLabel("Close Date (02:15)");
    currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plot.addDomainMarker(currentEnd);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // label the best bid with an arrow and label...
    final Hour h = new Hour(2, new Day(22, 5, 2003));
    final Minute m = new Minute(10, h);
    millis = m.getFirstMillisecond();
    final CircleDrawer cd = new CircleDrawer(Color.red, new BasicStroke(1.0f), null);
    final XYAnnotation bestBid = new XYDrawableAnnotation(millis, 163.0, 11, 11, cd);
    plot.addAnnotation(bestBid);
    final XYPointerAnnotation pointer = new XYPointerAnnotation("Best Bid", millis, 163.0, 3.0 * Math.PI / 4.0);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(10.0);
    pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
    pointer.setPaint(Color.blue);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    plot.addAnnotation(pointer);

    return chart;

}

From source file:com.att.aro.ui.view.diagnostictab.plot.AlarmPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis == null) {
        logger.info("analysis data is null");
    } else {/*from   ww w  .j a va 2  s  . c o m*/
        alarmDataCollection.removeAllSeries();
        pointerAnnotation.clear();

        TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
        if (resultType.equals(TraceResultType.TRACE_FILE)) {
            logger.info("didn't get analysis trace data!");

        } else {
            // Remove old annotation from previous plots
            Iterator<XYPointerAnnotation> pointers = pointerAnnotation.iterator();
            while (pointers.hasNext()) {
                plot.removeAnnotation(pointers.next());
            }

            for (AlarmType eventType : AlarmType.values()) {
                XYIntervalSeries series = new XYIntervalSeries(eventType);
                seriesMap.put(eventType, series);
                alarmDataCollection.addSeries(series);
            }
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult()
                    .getTraceresult();
            List<AlarmInfo> alarmInfos = traceresult.getAlarmInfos();
            List<ScheduledAlarmInfo> pendingAlarms = getHasFiredAlarms(traceresult.getScheduledAlarms());
            Iterator<ScheduledAlarmInfo> iterPendingAlarms = pendingAlarms.iterator();
            double firedTime = 0;
            while (iterPendingAlarms.hasNext()) {
                ScheduledAlarmInfo scheduledEvent = iterPendingAlarms.next();
                AlarmType pendingAlarmType = scheduledEvent.getAlarmType();
                if (pendingAlarmType != null) {
                    firedTime = (scheduledEvent.getTimeStamp() - scheduledEvent.getRepeatInterval()) / 1000;
                    seriesMap.get(pendingAlarmType).add(firedTime, firedTime, firedTime, 1, 0.8, 1);
                    eventMapPending.put(firedTime, scheduledEvent);
                    // logger.fine("populateAlarmScheduledPlot type:\n" +
                    // pendingAlarmType
                    // + "\ntime " + scheduledEvent.getTimeStamp()
                    // + "\nrepeating " + firedTime);
                }
            }

            Iterator<AlarmInfo> iter = alarmInfos.iterator();
            while (iter.hasNext()) {
                AlarmInfo currEvent = iter.next();
                if (currEvent != null) {
                    AlarmType alarmType = currEvent.getAlarmType();
                    if (alarmType != null) {
                        firedTime = currEvent.getTimeStamp() / 1000;

                        /*
                         * Catching any alarms align to quanta as being
                         * inexactRepeating alarms
                         */
                        if ((currEvent.getTimestampElapsed() / 1000) % 900 < 1) {
                            seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.7);

                            // Adding an arrow to mark these
                            // inexactRepeating alarms
                            XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(alarmType.name(),
                                    firedTime, 0.6, 3.92699082D);
                            xypointerannotation.setBaseRadius(20D);
                            xypointerannotation.setTipRadius(1D);
                            pointerAnnotation.add(xypointerannotation);
                            plot.addAnnotation(xypointerannotation);

                            // logger.info("SetInexactRepeating alarm type: "
                            // + alarmType
                            // + " time " + firedTime
                            // + " epoch " + currEvent.getTimestampEpoch()
                            // + " elapsed:\n" +
                            // currEvent.getTimestampElapsed()/1000);
                        } else {
                            seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.5);
                        }
                        eventMap.put(firedTime, currEvent);
                    }
                }
            }
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC_WAKEUP), Color.red);

            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC), Color.pink);

            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME_WAKEUP), Color.blue);

            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME), Color.cyan);

            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.UNKNOWN), Color.black);

            // Assign ToolTip to renderer
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    AlarmInfo info = eventMap.get(dataset.getX(series, item));
                    Date epochTime = new Date();
                    if (info != null) {

                        epochTime.setTime((long) info.getTimestampEpoch());

                        StringBuffer displayInfo = new StringBuffer(
                                ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
                        displayInfo.append(MessageFormat.format(
                                ResourceBundleHelper.getMessageString("alarm.tooltip.content"),
                                info.getAlarmType(), info.getTimeStamp() / 1000, epochTime.toString()));
                        if ((info.getTimestampElapsed() / 1000) % 900 < 1) {
                            displayInfo.append(
                                    ResourceBundleHelper.getMessageString("alarm.tooltip.setInexactRepeating"));
                        }
                        displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
                        return displayInfo.toString();
                    }
                    ScheduledAlarmInfo infoPending = eventMapPending.get(dataset.getX(series, item));
                    if (infoPending != null) {

                        epochTime.setTime(
                                (long) (infoPending.getTimestampEpoch() - infoPending.getRepeatInterval()));

                        StringBuffer displayInfo = new StringBuffer(
                                ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
                        displayInfo.append(MessageFormat.format(
                                ResourceBundleHelper.getMessageString("alarm.tooltip.contentWithName"),
                                infoPending.getAlarmType(),
                                (infoPending.getTimeStamp() - infoPending.getRepeatInterval()) / 1000,
                                epochTime.toString(), infoPending.getApplication(),
                                infoPending.getRepeatInterval() / 1000));
                        displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
                        return displayInfo.toString();
                    }
                    return null;
                }
            });

        }
    }
    plot.setDataset(alarmDataCollection);
    //      return plot;
}

From source file:com.sdk.connector.chart.TimeDomainRenderer.java

public void createAnnotation(String lap, double x, double y) {

    final CircleDrawer cd = new CircleDrawer(Color.GREEN, new BasicStroke(1.0f), null);
    final XYAnnotation lapLabel = new XYDrawableAnnotation(x, y, 15, 15, cd);
    lapAnnotations.add(lapLabel);/*  ww  w .java 2s.  c  o  m*/
    plot.addAnnotation(lapAnnotations.lastElement(), false);
    final XYPointerAnnotation pointer = new XYPointerAnnotation(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("label.lap") + lap,
            x, y, 345);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(10.0);
    pointer.setFont(new Font("DejaVu Sans", Font.BOLD, 11));
    pointer.setPaint(Color.black);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    lapAnnotations.add(pointer);
    plot.addAnnotation(lapAnnotations.lastElement(), false);
}

From source file:com.sdk.connector.chart.FrequencyDomainRenderer.java

public void createAnnotation(Color color, double lap, double x, double y) {

    final XYPointerAnnotation pointer = new XYPointerAnnotation("", x, y, 345);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(5.0);//from   ww w  . j a  v  a2s  . co m
    pointer.setFont(new Font("DejaVu Sans", Font.PLAIN, 9));
    pointer.setPaint(Color.blue);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    lapAnnotations.add(pointer);
    renderer.addAnnotation(lapAnnotations.lastElement());

    chartPanel.repaint();
    chartPanel.revalidate();
}

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

@SuppressWarnings("unchecked")
public void updateData(ChartDataVO chartData) {

    resetAxis();//  w  w w  .  j a  v  a 2 s .  co  m

    // add/update indicators
    for (IndicatorVO indicator : chartData.getIndicators()) {

        RegularTimePeriod timePeriod = getRegularTimePeriod(indicator.getDateTime());
        TimeSeries series = this.indicators.get(indicator.getName());

        if (series != null) {
            series.addOrUpdate(timePeriod, indicator.getValue());
        }
    }

    // add/update bars
    for (BarVO bar : chartData.getBars()) {

        OHLCSeries series = this.bars.get(bar.getSecurityId());

        if (series != null) {

            // remove a value if it already exists
            RegularTimePeriod timePeriod = getRegularTimePeriod(bar.getDateTime());
            if (series.indexOf(timePeriod) >= 0) {
                series.remove(timePeriod);
            }
            series.add(timePeriod, bar.getOpen().doubleValue(), bar.getHigh().doubleValue(),
                    bar.getLow().doubleValue(), bar.getClose().doubleValue());
        }
    }

    // make all invisible since they might not currently have a value
    for (Marker marker : this.markers.values()) {
        marker.setAlpha(0);
    }

    // update markers
    for (MarkerVO markerVO : chartData.getMarkers()) {

        Marker marker = this.markers.get(markerVO.getName());
        Boolean selected = this.markersSelectionStatus.get(markerVO.getName());
        String name = marker.getLabel().split(":")[0];
        if (marker instanceof ValueMarker && markerVO instanceof ValueMarkerVO) {

            ValueMarker valueMarker = (ValueMarker) marker;
            ValueMarkerVO valueMarkerVO = (ValueMarkerVO) markerVO;
            valueMarker.setValue(valueMarkerVO.getValue());
            marker.setLabel(name + ": " + valueMarkerVO.getValue());
            marker.setAlpha(selected ? 1.0f : 0.0f);

        } else if (marker instanceof IntervalMarker && markerVO instanceof IntervalMarkerVO) {

            IntervalMarker intervalMarker = (IntervalMarker) marker;
            IntervalMarkerVO intervalMarkerVO = (IntervalMarkerVO) markerVO;
            intervalMarker.setStartValue(intervalMarkerVO.getStartValue());
            intervalMarker.setEndValue(intervalMarkerVO.getEndValue());
            marker.setLabel(
                    name + ": " + intervalMarkerVO.getStartValue() + " - " + intervalMarkerVO.getEndValue());
            marker.setAlpha(selected ? 0.5f : 0.0f);

        } else {
            throw new RuntimeException(marker.getClass() + " does not match " + markerVO.getClass());
        }
    }

    // update annotations
    for (AnnotationVO annotationVO : chartData.getAnnotations()) {

        AbstractXYAnnotation annotation;
        if (annotationVO instanceof PointerAnnotationVO) {

            PointerAnnotationVO pointerAnnotationVO = (PointerAnnotationVO) annotationVO;
            XYPointerAnnotation pointerAnnotation = new XYPointerAnnotation(pointerAnnotationVO.getText(),
                    pointerAnnotationVO.getDateTime().getTime(), pointerAnnotationVO.getValue(),
                    3.926990816987241D);
            pointerAnnotation.setTipRadius(0);
            pointerAnnotation.setBaseRadius(20);
            pointerAnnotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
            pointerAnnotation.setFont(new Font("SansSerif", 0, 9));
            pointerAnnotation.setToolTipText("<html>" + formatter.format(pointerAnnotationVO.getDateTime())
                    + "<br>" + pointerAnnotationVO.getValue() + "</html>");

            annotation = pointerAnnotation;

        } else if (annotationVO instanceof BoxAnnotationVO) {

            BoxAnnotationVO boxAnnotationVO = (BoxAnnotationVO) annotationVO;
            XYBoxAnnotation boxAnnotation = new XYBoxAnnotation(boxAnnotationVO.getStartDateTime().getTime(),
                    boxAnnotationVO.getStartValue(), boxAnnotationVO.getEndDateTime().getTime(),
                    boxAnnotationVO.getEndValue(), null, null, new java.awt.Color(0, 0, 0, 60));
            boxAnnotation.setToolTipText("<html>" + formatter.format(boxAnnotationVO.getStartDateTime()) + " - "
                    + formatter.format(boxAnnotationVO.getEndDateTime()) + "<br>"
                    + boxAnnotationVO.getStartValue() + " - " + boxAnnotationVO.getEndValue() + "</html>");

            annotation = boxAnnotation;
        } else {
            throw new RuntimeException("unkown annotation type" + annotationVO.getClass());
        }

        if (!getPlot().getAnnotations().contains(annotation)) {
            getPlot().addAnnotation(annotation);
        }
    }

    // update description
    for (Title title : (List<Title>) this.getChart().getSubtitles()) {
        if (title instanceof TextTitle) {
            TextTitle textTitle = ((TextTitle) title);
            if (chartData.getDescription() != null && !("".equals(chartData.getDescription()))) {
                textTitle.setText(chartData.getDescription());
                textTitle.setVisible(true);
            } else {
                textTitle.setVisible(false);
            }
        }
    }

    initAxis();
}

From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java

private void prepareWaypontOnChart(XYPlot xyplot, Waypoint waypoint) {
    Vector positions = waypoint.getPositionsOnTrack();
    for (int i = 0; i < positions.size(); i++) {
        double position = ((Double) positions.get(i)).doubleValue();
        double elevation = waypoint.getElevation();

        if (position > 0 && waypoint.isVisible()) {

            String waypointLabel;
            if (TrackProfilerAppContext.getInstance().isWaypointLabelFromTitle()) {
                waypointLabel = waypoint.getTitle();
            } else {
                waypointLabel = waypoint.getDescription();
            }/*w  w  w  .j av  a2s.  c o m*/

            double arrowAngle = Math.PI * 1.5;
            if (waypoint.getArrowLength() < 0) {
                arrowAngle += Math.PI;
            }

            XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(waypointLabel, position,
                    elevation, arrowAngle);
            xypointerannotation.setTipRadius(3.0D);
            xypointerannotation.setBaseRadius(Math.abs(waypoint.getArrowLength()));
            xypointerannotation.setFont(GUIConstants.SANS_SERIF_11);
            xypointerannotation.setPaint(Color.blue);
            xypointerannotation.setTextAnchor(TextAnchor.BASELINE_CENTER);
            xyplot.addAnnotation(xypointerannotation);

            ValueMarker valuemarker = new ValueMarker(position);
            valuemarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
            valuemarker.setStroke(new BasicStroke(1.0F));

            // TODO: u postavke da li ispisivati ovdje
            if (false) {
                valuemarker.setLabel(waypoint.getTitle());
            }

            valuemarker.setLabelFont(GUIConstants.SANS_SERIF_11);

            if (waypoint instanceof TrackExtreeme) {
                valuemarker.setPaint(Color.blue);
            } else {
                valuemarker.setPaint(new Color(220, 220, 220));
            }
            valuemarker.setLabelPaint(Color.red);
            valuemarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
            // xyplot.addRangeMarker(valuemarker);

            xyplot.addDomainMarker(valuemarker);
        }
    }
}

From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java

private void _drawSelectedPoint(XYPlot xyplot, int position) {
    TrackPoint point = this.getTrack().getPointAt(position);

    // Strelicu crtamo samo ako je samo jedna tocka oznacena:
    if (this.startSelectedPoints < 0 || this.endSelectedPoints < 0
            || this.startSelectedPoints == this.endSelectedPoints) {
        double angle = point.getAngle();
        XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("", point.getPosition(), //$NON-NLS-1$
                point.getElevation(), Math.PI - angle);
        xypointerannotation.setTipRadius(3.0D);
        xypointerannotation.setBaseRadius(30);
        xypointerannotation.setTextAnchor(TextAnchor.BASELINE_RIGHT);
        xypointerannotation.setFont(GUIConstants.SANS_SERIF_11);
        if (angle > 0) {
            xypointerannotation.setPaint(Color.red);
        } else if (angle < 0) {
            xypointerannotation.setPaint(Color.green);
        } else {/*from   www  .  j a  va2s .  co m*/
            xypointerannotation.setPaint(Color.gray);
        }
        xypointerannotation.setText((TrackProfilerMath.round(100 * angle, 1)) + " %"); //$NON-NLS-1$
        xyplot.addAnnotation(xypointerannotation);
    }

    ValueMarker valuemarker = new ValueMarker(point.getPosition());
    valuemarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
    valuemarker.setStroke(new BasicStroke(1.0F));

    if (this.startSelectedPoints != this.endSelectedPoints && position == this.startSelectedPoints) {
        valuemarker.setLabelPaint(Color.blue);
        valuemarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
        valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);

        // Ispisuje udaljenost i kut:
        TrackPoint t1 = this.getTrack().getPointAt(this.startSelectedPoints);
        TrackPoint t2 = this.getTrack().getPointAt(this.endSelectedPoints);
        double distance3D = TrackProfilerMath.round(t1.getPosition() - t2.getPosition(), 1);
        String angle = Math.abs(TrackProfilerMath.round(t1.getAngle(t2) * 100, 1)) + "%"; //$NON-NLS-1$
        String label = Message.get(Messages.SELECTED_DISTANCE_LABEL) + distance3D + ", " //$NON-NLS-1$
                + Message.get(Messages.SELECTED_ANGLE_LABEL) + angle;

        valuemarker.setLabel("  " + label); //$NON-NLS-1$
        valuemarker.setLabelFont(GUIConstants.SANS_SERIF_11);
    }

    xyplot.addDomainMarker(valuemarker);

}

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

/**
 *
 * @param f/*from  ww  w  .jav  a2s . co m*/
 * @param useScanAcquisitionTime
 * @param valueVariable
 * @return
 */
public List<XYPointerAnnotation> getANDIChromPeakAnnotations(IFileFragment f, boolean useScanAcquisitionTime,
        String valueVariable) {
    List<XYPointerAnnotation> l = new ArrayList<>();
    try {
        IVariableFragment peakNames = f.getChild("peak_name");
        IVariableFragment peakRT = f.getChild("peak_retention_time");
        Array ordinateValues = f.getChild(valueVariable).getArray();
        double delay = f.getChild("actual_delay_time").getArray().getDouble(0);
        double samplingRate = f.getChild("actual_sampling_interval").getArray().getDouble(0);
        Index idx = ordinateValues.getIndex();
        Collection<String> peaknames = ArrayTools.getStringsFromArray(peakNames.getArray());
        IndexIterator ii = peakRT.getArray().getIndexIterator();
        Iterator<String> peaknamesIter = peaknames.iterator();
        while (ii.hasNext() && peaknamesIter.hasNext()) {
            double sat = ii.getDoubleNext();
            int scan = (int) (Math.floor(((sat - delay) / samplingRate)));
            String name = peaknamesIter.next();
            if (name.trim().isEmpty()) {
                name = "NN";
            }
            if (useScanAcquisitionTime) {
                XYPointerAnnotation xypa = new XYPointerAnnotation(name, sat,
                        ordinateValues.getDouble(idx.set(scan)), -0.8);
                xypa.setTipRadius(0.01);
                xypa.setLabelOffset(1);
                xypa.setBaseRadius(10);
                xypa.setTextAnchor(TextAnchor.BOTTOM_LEFT);
                l.add(xypa);
                //                    XYLineAnnotation baseline = new XYLineAnnotation();
            } else {
                XYPointerAnnotation xypa = new XYPointerAnnotation(name, scan,
                        ordinateValues.getDouble(idx.set(scan)), -0.8);
                xypa.setTipRadius(0.01);
                xypa.setLabelOffset(1);
                xypa.setBaseRadius(10);
                xypa.setTextAnchor(TextAnchor.BOTTOM_LEFT);
                l.add(xypa);
            }
        }
    } catch (ResourceNotAvailableException rnae) {
    }
    return l;
}