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

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

Introduction

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

Prototype

public double getX() 

Source Link

Document

Returns the x coordinate for the text anchor point (measured against the domain axis).

Usage

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

private void removeAnnotation() {
    for (Object annotation : chartPanel.getChart().getXYPlot().getAnnotations()) {
        if (annotation instanceof XYPointerAnnotation) {
            XYPointerAnnotation pointer = (XYPointerAnnotation) annotation;
            if (pointer.getX() == item.getDataset().getXValue(item.getSeriesIndex(), item.getItem())
                    && pointer.getY() == item.getDataset().getYValue(item.getSeriesIndex(), item.getItem())) {
                chartPanel.getChart().getXYPlot().removeAnnotation(pointer);
                break;
            }//from  w ww .  jav  a2  s . c o  m
        }
    }
}

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

private boolean hasAnnoationAlready() {
    boolean hasAnnotationAlready = false;
    for (Object annotation : chartPanel.getChart().getXYPlot().getAnnotations()) {
        if (annotation instanceof XYPointerAnnotation) {
            XYPointerAnnotation pointer = (XYPointerAnnotation) annotation;
            if (pointer.getX() == item.getDataset().getXValue(item.getSeriesIndex(), item.getItem())
                    && pointer.getY() == item.getDataset().getYValue(item.getSeriesIndex(), item.getItem())) {
                hasAnnotationAlready = true;
                break;
            }//ww  w  . j ava 2  s . c  om
        }
    }
    return hasAnnotationAlready;
}

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

/**
 *
 * @param f/*from   w w  w . ja  v a  2  s  . c o m*/
 * @param ordinateValues
 * @param useScanAcquisitionTime
 * @return
 */
public List<XYPointerAnnotation> getCSVPeakAnnotations(IFileFragment f, Array ordinateValues,
        boolean useScanAcquisitionTime) {
    List<XYPointerAnnotation> l = new ArrayList<>();
    try {
        String basename = StringTools.removeFileExt(f.getName());

        File peakAnnotations = new File(new File(f.getAbsolutePath()).getParentFile(), basename + ".csv");
        Logger.getLogger(Chromatogram1DChartProvider.class.getName()).log(Level.INFO, "Looking for file {0}",
                peakAnnotations);
        if (!peakAnnotations.exists()) {
            Logger.getLogger(Chromatogram1DChartProvider.class.getName()).info("File does not exist!");
            return l;
        }
        Logger.getLogger(Chromatogram1DChartProvider.class.getName()).info("File exists!");
        CSVReader csvr = new CSVReader();
        try {
            Tuple2D<Vector<Vector<String>>, Vector<String>> t = csvr
                    .read(new BufferedInputStream(new FileInputStream(peakAnnotations)));
            HashMap<String, Vector<String>> hm = csvr.getColumns(t);
            Vector<String> rt = hm.get("RT");
            Vector<String> scan = hm.get("SCAN");
            int i = 0;
            Vector<String> id = hm.get("NO");
            for (String s : rt) {
                XYPointerAnnotation xypa = null;
                //correct chemstation scan index by -1 (1 based)
                int scanIdx = Integer.parseInt(scan.get(i)) - 1;
                double apex = ordinateValues.getDouble(scanIdx);
                if (useScanAcquisitionTime) {
                    double srt = (Double.parseDouble(s));
                    xypa = new XYPointerAnnotation(id.get(i), srt * 60.0, apex, -0.8);
                } else {
                    xypa = new XYPointerAnnotation(id.get(i), scanIdx, apex, -0.8);
                }
                xypa.setTipRadius(0.01);
                xypa.setLabelOffset(1);
                xypa.setBaseRadius(10);
                xypa.setTextAnchor(TextAnchor.BOTTOM_LEFT);
                l.add(xypa);
                Logger.getLogger(Chromatogram1DChartProvider.class.getName()).log(Level.INFO,
                        "Adding annotation at: {0}", xypa.getX());
                i++;
            }
        } catch (FileNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
    } catch (ResourceNotAvailableException rnae) {
    }
    return l;
}