Example usage for org.jfree.chart.plot XYPlot setNoDataMessage

List of usage examples for org.jfree.chart.plot XYPlot setNoDataMessage

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setNoDataMessage.

Prototype

public void setNoDataMessage(String message) 

Source Link

Document

Sets the message that is displayed when the dataset is empty or null, and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private ChartPanel createChartPanel(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();

    plot.setForegroundAlpha(0.85f);/*w  w  w.  j  a  v a 2s . c om*/
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    ChartPanel chartPanel = new ChartPanel(chart);

    MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, chartPanel,
            "histogram_plot_area", "Mask generated from selected histogram plot area", Color.RED,
            PlotAreaSelectionTool.AreaType.X_RANGE) {

        @Override
        protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) {
            Rectangle2D bounds = shape.getBounds2D();
            return createMaskExpression(bounds.getMinX(), bounds.getMaxX());
        }

        protected String createMaskExpression(double x1, double x2) {
            String bandName = BandArithmetic.createExternalName(getRaster().getName());
            HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig();
            return String.format("%s >= %s && %s <= %s", bandName,
                    model.hasStx(currentConfig)
                            ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x1)
                            : x1,
                    bandName,
                    model.hasStx(currentConfig)
                            ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x2)
                            : x2);
        }
    };

    chartPanel.getPopupMenu().addSeparator();
    chartPanel.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem());
    chartPanel.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem());
    chartPanel.getPopupMenu().addSeparator();
    chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem());
    return chartPanel;
}

From source file:org.openmrs.web.servlet.ShowGraphServlet.java

/**
 * The main method for this class. It will create a JFreeChart object to be written to the
 * response.//from   w ww  . jav a 2 s . c om
 *
 * @param request the current request will all the parameters needed
 * @return JFreeChart object to be rendered
 * @should set value axis label to given units
 * @should set value axis label to concept numeric units if given units is null
 */
protected JFreeChart getChart(HttpServletRequest request) {
    // All available GET parameters
    String patientId = request.getParameter("patientId"); // required
    String conceptId1 = request.getParameter("conceptId"); // required
    String conceptId2 = request.getParameter("conceptId2");
    String chartTitle = request.getParameter("chartTitle");
    String units = request.getParameter("units");

    String minRangeString = request.getParameter("minRange");
    String maxRangeString = request.getParameter("maxRange");

    String hideDate = request.getParameter("hideDate");

    Patient patient = Context.getPatientService().getPatient(Integer.parseInt(patientId));

    // Set date range to passed values, otherwise set a default date range to the last 12 months
    Calendar cal = Calendar.getInstance();
    Date fromDate = getFromDate(request.getParameter("fromDate"));
    Date toDate = getToDate(request.getParameter("toDate"));

    // Swap if fromDate is after toDate
    if (fromDate.getTime() > toDate.getTime()) {
        Long temp = fromDate.getTime();
        fromDate.setTime(toDate.getTime());
        toDate.setTime(temp);
    }

    // Graph parameters
    Double minRange = null;
    Double maxRange = null;
    Double normalLow = null;
    Double normalHigh = null;
    Double criticalLow = null;
    Double criticalHigh = null;
    String timeAxisTitle = null;
    String rangeAxisTitle = null;
    boolean userSpecifiedMaxRange = false;
    boolean userSpecifiedMinRange = false;

    // Fetching obs
    List<Obs> observations1 = new ArrayList<Obs>();
    List<Obs> observations2 = new ArrayList<Obs>();
    Concept concept1 = null, concept2 = null;
    if (conceptId1 != null) {
        concept1 = Context.getConceptService().getConcept(Integer.parseInt(conceptId1));
    }
    if (conceptId2 != null) {
        concept2 = Context.getConceptService().getConcept(Integer.parseInt(conceptId2));
    }
    if (concept1 != null) {
        observations1 = Context.getObsService().getObservationsByPersonAndConcept(patient, concept1);
        chartTitle = concept1.getName().getName();
        rangeAxisTitle = ((ConceptNumeric) concept1).getUnits();
        minRange = ((ConceptNumeric) concept1).getLowAbsolute();
        maxRange = ((ConceptNumeric) concept1).getHiAbsolute();
        normalLow = ((ConceptNumeric) concept1).getLowNormal();
        normalHigh = ((ConceptNumeric) concept1).getHiNormal();
        criticalLow = ((ConceptNumeric) concept1).getLowCritical();
        criticalHigh = ((ConceptNumeric) concept1).getHiCritical();

        // Only get observations2 if both concepts share the same units; update chart title and ranges
        if (concept2 != null) {
            String concept2Units = ((ConceptNumeric) concept2).getUnits();
            if (concept2Units != null && concept2Units.equals(rangeAxisTitle)) {
                observations2 = Context.getObsService().getObservationsByPersonAndConcept(patient, concept2);
                chartTitle += " + " + concept2.getName().getName();
                if (((ConceptNumeric) concept2).getHiAbsolute() != null
                        && ((ConceptNumeric) concept2).getHiAbsolute() > maxRange) {
                    maxRange = ((ConceptNumeric) concept2).getHiAbsolute();
                }
                if (((ConceptNumeric) concept2).getLowAbsolute() != null
                        && ((ConceptNumeric) concept2).getLowAbsolute() < minRange) {
                    minRange = ((ConceptNumeric) concept2).getLowAbsolute();
                }
            } else {
                log.warn("Units for concept id: " + conceptId2 + " don't match units for concept id: "
                        + conceptId1 + ". Only displaying " + conceptId1);
                concept2 = null; // nullify concept2 so that the legend isn't shown later
            }
        }
    } else {
        chartTitle = "Concept " + conceptId1 + " not found";
        rangeAxisTitle = "Value";
    }

    // Overwrite with user-specified values, otherwise use default values
    if (units != null && units.length() > 0) {
        rangeAxisTitle = units;
    }
    if (minRangeString != null) {
        minRange = Double.parseDouble(minRangeString);
        userSpecifiedMinRange = true;
    }
    if (maxRangeString != null) {
        maxRange = Double.parseDouble(maxRangeString);
        userSpecifiedMaxRange = true;
    }
    if (chartTitle == null) {
        chartTitle = "";
    }
    if (rangeAxisTitle == null) {
        rangeAxisTitle = "";
    }
    if (minRange == null) {
        minRange = 0.0;
    }
    if (maxRange == null) {
        maxRange = 200.0;
    }

    // Create data set
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeries series1, series2;

    // Interval-dependent units
    Class<? extends RegularTimePeriod> timeScale = null;
    if (toDate.getTime() - fromDate.getTime() <= 86400000) {
        // Interval <= 1 day: minutely
        timeScale = Minute.class;
        timeAxisTitle = "Time";
    } else if (toDate.getTime() - fromDate.getTime() <= 259200000) {
        // Interval <= 3 days: hourly
        timeScale = Hour.class;
        timeAxisTitle = "Time";
    } else {
        timeScale = Day.class;
        timeAxisTitle = "Date";
    }
    if (concept1 == null) {
        series1 = new TimeSeries("NULL", Hour.class);
    } else {
        series1 = new TimeSeries(concept1.getName().getName(), timeScale);
    }
    if (concept2 == null) {
        series2 = new TimeSeries("NULL", Hour.class);
    } else {
        series2 = new TimeSeries(concept2.getName().getName(), timeScale);
    }

    // Add data points for concept1
    for (Obs obs : observations1) {
        if (obs.getValueNumeric() != null && obs.getObsDatetime().getTime() >= fromDate.getTime()
                && obs.getObsDatetime().getTime() < toDate.getTime()) {
            cal.setTime(obs.getObsDatetime());
            if (timeScale == Minute.class) {
                Minute min = new Minute(cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY),
                        cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                series1.addOrUpdate(min, obs.getValueNumeric());
            } else if (timeScale == Hour.class) {
                Hour hour = new Hour(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.DAY_OF_MONTH),
                        cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                series1.addOrUpdate(hour, obs.getValueNumeric());
            } else {
                Day day = new Day(cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1,
                        cal.get(Calendar.YEAR));
                series1.addOrUpdate(day, obs.getValueNumeric());
            }
        }
    }

    // Add data points for concept2
    for (Obs obs : observations2) {
        if (obs.getValueNumeric() != null && obs.getObsDatetime().getTime() >= fromDate.getTime()
                && obs.getObsDatetime().getTime() < toDate.getTime()) {
            cal.setTime(obs.getObsDatetime());
            if (timeScale == Minute.class) {
                Minute min = new Minute(cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY),
                        cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                series2.addOrUpdate(min, obs.getValueNumeric());
            } else if (timeScale == Hour.class) {
                Hour hour = new Hour(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.DAY_OF_MONTH),
                        cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                series2.addOrUpdate(hour, obs.getValueNumeric());
            } else {
                Day day = new Day(cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1,
                        cal.get(Calendar.YEAR));
                series2.addOrUpdate(day, obs.getValueNumeric());
            }
        }
    }

    // Add series to dataset
    dataset.addSeries(series1);
    if (!series2.isEmpty()) {
        dataset.addSeries(series2);
    }

    // As of JFreeChart 1.0.11 the default background color is dark grey instead of white.
    // This line restores the original white background.
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());

    JFreeChart chart = null;

    // Show legend only if more than one series
    if (concept2 == null) {
        chart = ChartFactory.createTimeSeriesChart(chartTitle, timeAxisTitle, rangeAxisTitle, dataset, false,
                false, false);
    } else {
        chart = ChartFactory.createTimeSeriesChart(chartTitle, timeAxisTitle, rangeAxisTitle, dataset, true,
                false, false);
    }

    // Customize title font
    Font font = new Font("Arial", Font.BOLD, 12);
    TextTitle title = chart.getTitle();
    title.setFont(font);
    chart.setTitle(title);

    // Add subtitle, unless 'hideDate' has been passed
    if (hideDate == null) {
        TextTitle subtitle = new TextTitle(fromDate.toString() + " - " + toDate.toString());
        subtitle.setFont(font);
        chart.addSubtitle(subtitle);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data Available");

    // Add abnormal/critical range background color (only for single-concept graphs)
    if (concept2 == null) {
        IntervalMarker abnormalLow, abnormalHigh, critical;
        if (normalHigh != null) {
            abnormalHigh = new IntervalMarker(normalHigh, maxRange, COLOR_ABNORMAL);
            plot.addRangeMarker(abnormalHigh);
        }
        if (normalLow != null) {
            abnormalLow = new IntervalMarker(minRange, normalLow, COLOR_ABNORMAL);
            plot.addRangeMarker(abnormalLow);
        }
        if (criticalHigh != null) {
            critical = new IntervalMarker(criticalHigh, maxRange, COLOR_CRITICAL);
            plot.addRangeMarker(critical);
        }
        if (criticalLow != null) {
            critical = new IntervalMarker(minRange, criticalLow, COLOR_CRITICAL);
            plot.addRangeMarker(critical);
        }

        // there is data outside of the absolute lower limits for this concept (or of what the user specified as minrange)
        if (plot.getRangeAxis().getLowerBound() < minRange) {
            IntervalMarker error = new IntervalMarker(plot.getRangeAxis().getLowerBound(), minRange,
                    COLOR_ERROR);
            plot.addRangeMarker(error);
        }

        if (plot.getRangeAxis().getUpperBound() > maxRange) {
            IntervalMarker error = new IntervalMarker(maxRange, plot.getRangeAxis().getUpperBound(),
                    COLOR_ERROR);
            plot.addRangeMarker(error);
        }

    }

    // Visuals
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesFilled(true);
        renderer.setBaseShapesVisible(true);
    }

    // Customize the plot (range and domain axes)

    // Modify x-axis (datetime)
    DateAxis timeAxis = (DateAxis) plot.getDomainAxis();
    if (timeScale == Day.class) {
        timeAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy"));
    }

    timeAxis.setRange(fromDate, toDate);

    // Set y-axis range (values)
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    if (userSpecifiedMinRange) {
        minRange = (rangeAxis.getLowerBound() < minRange) ? rangeAxis.getLowerBound() : minRange;
    }

    if (userSpecifiedMaxRange) {
        // otherwise we just use default range
        maxRange = (rangeAxis.getUpperBound() > maxRange) ? rangeAxis.getUpperBound() : maxRange;
    }

    rangeAxis.setRange(minRange, maxRange);

    return chart;
}

From source file:org.gwaspi.gui.reports.ManhattanPlotZoom.java

private JFreeChart createChart(XYDataset dataset, ChromosomeKey chr) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, "", "P value", dataset, PlotOrientation.VERTICAL,
            true, false, false);/*from   w ww  .j a  va 2s .  co m*/

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    // CHART BACKGROUD COLOR
    chart.setBackgroundPaint(Color.getHSBColor(0.1f, 0.1f, 1.0f)); // Hue, saturation, brightness
    plot.setBackgroundPaint(manhattan_back); // Hue, saturation, brightness 9

    // GRIDLINES
    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setDomainMinorGridlinePaint(manhattan_back); // Hue, saturation, brightness 9
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setRangeMinorGridlinePaint(manhattan_back.darker()); // Hue, saturation, brightness 8

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    // DOTS RENDERER
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, manhattan_dot);
    //      renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);
    //      renderer.setUseOutlinePaint(true);
    // Set dot shape of the currently appended Series
    renderer.setSeriesShape(0, new Rectangle2D.Double(0.0, 0.0, 2, 2));

    renderer.setSeriesVisibleInLegend(0, false);

    NumberAxis positionAxis = (NumberAxis) plot.getDomainAxis();
    //      domainAxis.setAutoRangeIncludesZero(false);
    //      domainAxis.setTickMarkInsideLength(2.0f);
    //      domainAxis.setTickMarkOutsideLength(2.0f);
    //      domainAxis.setMinorTickCount(2);
    //      domainAxis.setMinorTickMarksVisible(true);
    positionAxis.setLabelAngle(1.0);
    positionAxis.setAutoRangeIncludesZero(false);
    positionAxis.setAxisLineVisible(true);
    positionAxis.setTickLabelsVisible(true);
    positionAxis.setTickMarksVisible(true);

    // ADD INVERSE LOG(10) Y AXIS
    LogAxis logPAxis = new LogAxis("P value");
    logPAxis.setBase(10);
    logPAxis.setInverted(true);
    logPAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

    logPAxis.setTickMarkOutsideLength(2.0f);
    logPAxis.setMinorTickCount(2);
    logPAxis.setMinorTickMarksVisible(true);
    logPAxis.setAxisLineVisible(true);
    logPAxis.setUpperMargin(0);

    TickUnitSource units = NumberAxis.createIntegerTickUnits();
    logPAxis.setStandardTickUnits(units);
    plot.setRangeAxis(0, logPAxis);

    // Add significance Threshold to subplot
    //threshold = 0.5/rdMatrixMetadata.getMarkerSetSize();  // (0.05/10? SNPs => 5*10-?)
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to threshold
    thresholdLine.setLabel("P = " + GenericReportGenerator.FORMAT_P_VALUE.format(threshold));
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(thresholdLine);

    // Marker label if below threshold
    XYItemRenderer lblRenderer = plot.getRenderer();

    // THRESHOLD AND SELECTED LABEL GENERATOR
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(threshold, chr);
    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("SansSerif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_LEFT, Math.PI / 4.0));

    // TOOLTIP GENERATOR
    MyXYToolTipGenerator tooltipGenerator = new MyXYToolTipGenerator(chr);

    lblRenderer.setBaseToolTipGenerator(tooltipGenerator);

    lblRenderer.setSeriesItemLabelsVisible(0, true);

    return chart;
}

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCorrelationScatterPlot.java

private void createChart() {

    String title = "Correlation Scatter Plot  correlationCoefficient=" + nf.format(corrValue) + " N="
            + dataPoints.size();//  w w  w  . j a va2 s.  c o  m

    corrChart = ChartFactory.createScatterPlot(title, xLabel, yLabel, null, PlotOrientation.VERTICAL, true,
            true, false);

    XYPlot plot = (XYPlot) corrChart.getPlot();

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //           
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    List<PlotPoint> plotPoints = new ArrayList<PlotPoint>(dataPoints);
    DataRange Xrange = PlotPoint.getDataRange(plotPoints, AxisType.X_AXIS);
    DataRange Yrange = PlotPoint.getDataRange(plotPoints, AxisType.Y_AXIS);

    //        Double xAbsMax = Math.max(Math.abs(Xrange.getMaxRange()), Math.abs(Xrange.getMinRange()));
    //        Double yAbsMax = Math.max(Math.abs(Yrange.getMaxRange()), Math.abs(Yrange.getMinRange()));
    //        
    //        Double maxAbsVal = Math.max(xAbsMax, yAbsMax);

    domainAxis.setAutoRangeIncludesZero(false);

    double xTick = 10.0;
    double yTick = 10.0;

    double xdist = Math.abs(Xrange.getMaxRange() - Xrange.getMinRange());
    double ydist = Math.abs(Yrange.getMaxRange() - Yrange.getMinRange());
    if (xdist < 10.0) {
        xTick = 1.0;
    }

    if (ydist < 10.0) {
        yTick = 1.0;
    }

    //        if (maxAbsVal <= 25.0) {
    //          tickUnit =5.0;
    //        }
    //        else if (maxAbsVal <= 50.0) {
    //          tickUnit = 10.0;
    //        }

    domainAxis.setTickUnit(new NumberTickUnit(xTick));
    rangeAxis.setTickUnit(new NumberTickUnit(yTick));

    //double glyphScaleFactor = (maxAbsVal*2.0)/600.0;   //assuming 600 pixels for the graph
    double xScale = xdist / 600.0;
    //double glyphScaleFactor = 1.0;
    double yScale = ydist / 600.0;

    //double adjAbsVal = Math.ceil(maxAbsVal + (glyphScaleFactor*8.0));

    //domainAxis.setRange(-maxAbsVal, maxAbsVal);
    double xMin = Xrange.getMinRange() - xScale * glyphSize;
    double xMax = Xrange.getMaxRange() + xScale * glyphSize;
    double yMin = Yrange.getMinRange() - yScale * glyphSize;
    double yMax = Yrange.getMaxRange() + yScale * glyphSize;

    domainAxis.setRange(xMin, xMax);

    //rangeAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(yMin, yMax);
    Set<SampleInfo> infoSet = new HashSet<SampleInfo>();

    if ((colorBy == ColorByType.IHC_EXPRESSION_X) || (colorBy == ColorByType.IHC_EXPRESSION_Y)) {
        String geneName = null;
        if ((colorBy == ColorByType.IHC_EXPRESSION_X) && (ct1 != ContinuousType.GENE)) {
            logger.info("User attempted to color by ihc x on non gene continuous type.");
            //need to show validation error
            return;
        } else if ((colorBy == ColorByType.IHC_EXPRESSION_Y) && (ct2 != ContinuousType.GENE)) {
            logger.info("User attempted to color by ihc y on non gene continuous type.");
            //need to show validation error
            return;
        } else {
            if (colorBy == ColorByType.IHC_EXPRESSION_X) {
                //parse the gene name from the xLabel
                geneName = xLabel.substring(0, xLabel.indexOf('_'));
            } else if (colorBy == ColorByType.IHC_EXPRESSION_Y) {
                //parse the gene name from the yLabel
                geneName = yLabel.substring(0, yLabel.indexOf('_'));
            }
        }

        //Get the IHC data for the samples to be graphed   
        LevelOfExpressionIHCService loeService = LevelOfExpressionIHCService.getInstance();
        LossOfExpressionIHCService lossService = LossOfExpressionIHCService.getInstance();
        Set<String> sampleIds = new HashSet<String>();
        String labtrackId;
        SampleInfo info;
        for (ISPYPlotPoint corrPoint : dataPoints) {
            info = corrPoint.getSampleInfo();
            if (info != null) {
                labtrackId = corrPoint.getSampleInfo().getLabtrackId();
                sampleIds.add(labtrackId);
                infoSet.add(info);
            } else {
                logger.warn("Point id=" + corrPoint.getId() + " has no sample info. Skipping point");
            }
        }

        Collection<? extends Finding> loeFindings = loeService.getFindingsFromSampleInfo(infoSet);
        Collection<? extends Finding> lossFindings = lossService.getFindingsFromSampleInfo(infoSet);

        List<IHCFinding> findings = new ArrayList<IHCFinding>();

        for (Finding f : loeFindings) {
            findings.add((IHCFinding) f);
        }

        for (Finding f : lossFindings) {
            findings.add((IHCFinding) f);
        }

        //        Need to handle mapping names to IHC biomarker names.
        //EGFR (ok), FAK (PTK2), HER2 (ERBB2), Ki-67, P53, bcl2 (ok), p27, CYCLIN_D1 (CCND1)
        //Translate the gene names into the biomarker names 
        //used by ihc. This code should be removed once protein biomarker
        //alias is implmented.
        String ihcBiomarker = geneName;
        if (geneName.equalsIgnoreCase("PTK2")) {
            ihcBiomarker = "FAK";
            ihcBiomarkerType = IHCBiomarkerType.FAK;
        } else if (geneName.equalsIgnoreCase("ERBB2")) {
            ihcBiomarker = "HER2";
            ihcBiomarkerType = IHCBiomarkerType.HER2;
        } else if (geneName.equalsIgnoreCase("MKI67")) {
            //need to check this one
            ihcBiomarker = "Ki-67";
            ihcBiomarkerType = IHCBiomarkerType.KI67;
        } else if (geneName.equalsIgnoreCase("TP53")) {
            ihcBiomarker = "P53";
            ihcBiomarkerType = IHCBiomarkerType.P53;
        } else if (geneName.equalsIgnoreCase("Cdkn1b")) {
            ihcBiomarker = "P27";
            ihcBiomarkerType = IHCBiomarkerType.P27;
        } else if (geneName.equalsIgnoreCase("BCL2")) {
            ihcBiomarker = "BCL2";
            ihcBiomarkerType = IHCBiomarkerType.BCL2;
        } else if (geneName.equalsIgnoreCase("EGFR")) {
            ihcBiomarker = "EGFR";
            ihcBiomarkerType = IHCBiomarkerType.EGFR;
        } else if (geneName.equalsIgnoreCase("CCND1")) {
            ihcBiomarker = "CYCLIN_D1";
            ihcBiomarkerType = IHCBiomarkerType.CYCLIN_D1;
        }

        List<IHCFinding> filteredList = getIHCFindingsForBiomarker(findings, ihcBiomarker);

        //TEST Case
        //          Set<String> testIds = new HashSet<String>();
        //          testIds.add("212833");
        //          testIds.add("213152");

        //Collection<? extends Finding> loeFindings = loeService.getFindingsFromSampleIds(testIds);

        //Collection<? extends Finding> lossFindings = lossService.getFindingsFromSampleIds(sampleIds);

        ihcData = new HashMap<String, List<IHCFinding>>();
        IHCFinding loeFinding;
        List<IHCFinding> findingList;
        Specimen specimen = null;
        String patientDID = null;
        for (Finding finding : filteredList) {
            loeFinding = (IHCFinding) finding;
            specimen = loeFinding.getSpecimen();
            if ((specimen != null) && (specimen.getPatientDID() != null)) {
                patientDID = specimen.getPatientDID();
                findingList = ihcData.get(patientDID);

                if (findingList == null) {
                    findingList = new ArrayList<IHCFinding>();
                    ihcData.put(patientDID, findingList);
                }

                findingList.add(loeFinding);
            } else {
                logger.warn(
                        "loeFinding id=" + loeFinding.getId() + " has null specimen or patientDID. Skipping..");
            }

        }
        //          IHCFinding lossFinding;
        //          for (Finding finding : lossFindings) {
        //           lossFinding = (IHCFinding) finding;
        //            ihcData.put(lossFinding.getId(), lossFinding);
        //          }

    }

    createGlyphsAndAddToPlot(plot, xScale, yScale);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    corrChart.setBackgroundPaint(p);

    buildLegend();

}

From source file:ec.util.chart.swing.JTimeSeriesChart.java

private void onNoDataMessageChange(XYPlot plot) {
    plot.setNoDataMessage(noDataMessage);
}

From source file:org.eumetsat.metop.visat.SounderInfoView.java

protected void configureSpectrumPlot(XYPlot plot) {
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setNoDataMessage(NO_IFOV_SELECTED);
}

From source file:org.eumetsat.metop.visat.IasiInfoView.java

private void configureSpectrumPlot(XYPlot plot) {
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setNoDataMessage(NO_IFOV_SELECTED);
}

From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java

private void addChartToPanel(JPanel panel, int gridY) {
    // create a dataset for displaying schedule data
    chartData = new ChartData();
    updateChart();//  w  w  w.  j  av  a2 s  . c o  m

    // customize a renderer for displaying schedules
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(true);
    renderer.setBaseToolTipGenerator(chartData);
    renderer.setDrawBarOutline(true);

    // use an inverted, unadorned numeric Y-axis
    NumberAxis yAxis = new NumberAxis();
    yAxis.setInverted(true);
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    yAxis.setUpperMargin(0);

    // use a Date-based X-axis
    DateAxis xAxis = new DateAxis();

    // create an XY plot to display the data
    XYPlot plot = new XYPlot(chartData, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(false);
    plot.setNoDataMessage(TaskScheduleDialog.resources.getString("Chart.No_Data_Message"));

    // create a chart and a chart panel
    JFreeChart chart = new JFreeChart(plot);
    chart.removeLegend();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setInitialDelay(50);
    chartPanel.setDismissDelay(60000);
    chartPanel.setMinimumDrawHeight(40);
    chartPanel.setMinimumDrawWidth(40);
    chartPanel.setMaximumDrawHeight(3000);
    chartPanel.setMaximumDrawWidth(3000);
    chartPanel.setPreferredSize(new Dimension(300, gridY * 25));

    // add the chart to the dialog content pane
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = gridY;
    c.gridwidth = 4;
    c.weightx = 2;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 0, 0, 0);
    panel.add(chartPanel, c);

    // retrieve the colors used for each chart bar, and register those
    // colors with the schedule rows so they can act as a legend
    for (int i = scheduleRows.size(); i-- > 0;) {
        ScheduleTableRow oneRow = scheduleRows.get(i);
        oneRow.addColoredIcon(renderer.lookupSeriesPaint(i));
    }
}

From source file:org.esa.snap.rcp.statistics.ScatterPlotPanel.java

private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    int confidenceDSIndex = 0;
    int regressionDSIndex = 1;
    int scatterpointsDSIndex = 2;
    plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
    plot.setDataset(regressionDSIndex, regressionDataset);
    plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(confidenceDSIndex, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(regressionDSIndex, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> {
        final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
        final Comparable key = collection.getSeriesKey(series);
        final double xValue = collection.getXValue(series, item);
        final double endYValue = collection.getEndYValue(series, item);
        final double yValue = collection.getYValue(series, item);
        return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue,
                endYValue - yValue, key, xValue);
    });//from  w  w  w  .  jav a2s  .c o m
    plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
            StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
            StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
}

From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java

private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setDataset(CONFIDENCE_DSINDEX, acceptableDeviationDataset);
    plot.setDataset(REGRESSION_DSINDEX, regressionDataset);
    plot.setDataset(SCATTERPOINTS_DSINDEX, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(CONFIDENCE_DSINDEX, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(REGRESSION_DSINDEX, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
        @Override/*  w w w  .ja v  a 2s .  co m*/
        public String generateToolTip(XYDataset dataset, int series, int item) {
            final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
            final Comparable key = collection.getSeriesKey(series);
            final double xValue = collection.getXValue(series, item);
            final double endYValue = collection.getEndYValue(series, item);
            final double yValue = collection.getYValue(series, item);
            return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue,
                    endYValue - yValue, key, xValue);
        }
    });
    plot.setRenderer(SCATTERPOINTS_DSINDEX, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
            StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
            StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
}