List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setUseOutlinePaint
public void setUseOutlinePaint(boolean flag)
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
/** * Creates a residue plot.// w ww. j a v a 2 s. c o m * * @param yValues * @param header * @param xAxis * @param yAxis * @param seriesNames * @return */ public JFreeChart createResiduePlot(List<Double[]> yValues, String header, String xAxis, String yAxis, List<String> seriesNames) { LinkedList<XYLineAnnotation> lines = new LinkedList<XYLineAnnotation>(); DefaultXYDataset xyDataSet = new DefaultXYDataset(); for (int j = 0; j < yValues.size(); j++) { XYSeries series = new XYSeries(seriesNames.get(j)); for (int i = 0; i < yValues.get(j).length; i++) { series.add(i + 1, yValues.get(j)[i]); float dash[] = { 10.0f }; BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); XYLineAnnotation annotation = new XYLineAnnotation(i + 1, 0, i + 1, yValues.get(j)[i], stroke, Color.BLUE); lines.add(annotation); } xyDataSet.addSeries(seriesNames.get(j), series.toArray()); } JFreeChart chart = ChartFactory.createScatterPlot(header, xAxis, yAxis, xyDataSet, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); for (int i = 0; i < lines.size(); i++) { plot.addAnnotation(lines.get(i)); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setUseOutlinePaint(true); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setTickMarkInsideLength(2.0f); domainAxis.setTickMarkOutsideLength(0.0f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setTickMarkInsideLength(2.0f); rangeAxis.setTickMarkOutsideLength(0.0f); return chart; }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java
protected void createChart() { String xLabel = component1.toString(); String yLabel = component2.toString(); pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) pcaChart.getPlot(); if (!this.colorBy.equals(PCAcolorByType.NONE)) { buildLegend();/* w w w.j a va2 s .c o m*/ } 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. DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1); DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2); DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3); Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()), Math.abs(component1Range.getMinRange())); Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()), Math.abs(component2Range.getMinRange())); Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()), Math.abs(component3Range.getMinRange())); Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax); maxAbsVal = Math.max(maxAbsVal, pc3AbsMax); maxAbsVal = Math.max(150.0, maxAbsVal); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setRange(-maxAbsVal, maxAbsVal); rangeAxis.setRange(-maxAbsVal, maxAbsVal); domainAxis.setTickUnit(new NumberTickUnit(25.0)); rangeAxis.setTickUnit(new NumberTickUnit(25.0)); createGlyphsAndAddToPlot(plot); // 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); pcaChart.setBackgroundPaint(p); }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * Build a JPanel with plotType of a DesmoJ time-series dataset. * When allowMultipleValues is set, multiple range values of a time value are allowed. * In the opposite Case only the last range value of a time value is accepted. * In the case ts.getShowTimeSpansInReport() the data values are interpreted as * a timespan in a appropriate time unit. * @param ts DesmoJ time-series dataset * @param plotType possible Values: * Plotter.TimeSeries_ScatterPlot, * Plotter.TimeSeries_StepChart * Plotter.TimeSeries_LinePlot * @param allowMultipleValues/*from w w w . j av a 2 s. c om*/ * @return */ private JPanel getTimeSeriesPanel(TimeSeries ts, int plotType, boolean allowMultipleValues) { JFreeChart chart; TimeSeriesDataSetAdapter dataset = new TimeSeriesDataSetAdapter(ts, allowMultipleValues); switch (plotType) { case Plotter.TimeSeries_LineChart: chart = ChartFactory.createXYLineChart(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; case Plotter.TimeSeries_ScatterPlot: chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; case Plotter.TimeSeries_StepChart: chart = ChartFactory.createXYStepChart(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; default: chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; } if (ts.getDescription() != null) chart.setTitle(ts.getDescription()); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setNoDataMessage("NO DATA"); if (ts.getShowTimeSpansInReport() && !dataset.isValid()) xyplot.setNoDataMessage("NO VALID TIMESPANS"); xyplot.setDomainZeroBaselineVisible(false); xyplot.setRangeZeroBaselineVisible(false); DateAxis dateAxis = new DateAxis(); xyplot.setDomainAxis(dateAxis); this.configureDomainAxis(dateAxis); String numberLabel; if (!dataset.isValid()) numberLabel = "Unit: invalid"; else if (ts.getShowTimeSpansInReport()) numberLabel = "Unit: timespan [" + dataset.getRangeTimeUnit().name() + "]"; else if (ts.getUnit() != null) numberLabel = "Unit: [" + ts.getUnit() + "]"; else numberLabel = "Unit: unknown"; NumberAxis numberAxis = new NumberAxis(); xyplot.setRangeAxis(numberAxis); this.configureRangeAxis(numberAxis, numberLabel); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black); xylineandshaperenderer.setUseOutlinePaint(true); ChartPanel panel = new ChartPanel(chart); panel.setVerticalAxisTrace(false); panel.setHorizontalAxisTrace(false); panel.setPopupMenu(null); panel.setDomainZoomable(false); panel.setRangeZoomable(false); return panel; }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.java
private void createChart() { String xLabel = component1.toString(); String yLabel = component2.toString(); pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) pcaChart.getPlot(); buildLegend();/*from www . jav a2 s . c o m*/ 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. DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1); DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2); DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3); Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()), Math.abs(component1Range.getMinRange())); Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()), Math.abs(component2Range.getMinRange())); Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()), Math.abs(component3Range.getMinRange())); Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax); maxAbsVal = Math.max(maxAbsVal, pc3AbsMax); //maxAbsVal = Math.max(100.0, maxAbsVal); domainAxis.setAutoRangeIncludesZero(false); double tickUnit = 25.0; if (maxAbsVal <= 25.0) { tickUnit = 5.0; } else if (maxAbsVal <= 50.0) { tickUnit = 10.0; } domainAxis.setTickUnit(new NumberTickUnit(tickUnit)); rangeAxis.setTickUnit(new NumberTickUnit(tickUnit)); double glyphScaleFactor = (maxAbsVal * 2.0) / 600.0; //assuming 600 pixels for the graph double adjAbsVal = Math.ceil(maxAbsVal + (glyphScaleFactor * 8.0)); //domainAxis.setRange(-maxAbsVal, maxAbsVal); domainAxis.setRange(-adjAbsVal, adjAbsVal); //rangeAxis.setRange(-maxAbsVal, maxAbsVal); rangeAxis.setRange(-adjAbsVal, adjAbsVal); createGlyphsAndAddToPlot(plot, glyphScaleFactor); // 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); pcaChart.setBackgroundPaint(p); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
/** * Creates a chart.//from ww w. j a v a 2 s .c om * * @param dataset the data for the chart. * * @return a chart. */ public JFreeChart createChart() { //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm String xlabel = "Delay (ps)"; String ylabel = "Signal (DN)"; // create the chart with findmaxpoint results final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title xlabel, // x axis label ylabel, // y axis label findMaxpointData_, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); // deal with axes and add second dataset final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis(); yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); final NumberAxis yaxis2 = new NumberAxis(null); final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis(); xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); plot.setRangeAxis(1, yaxis2); plot.setDataset(1, gatePositionData_); plot.mapDatasetToRangeAxis(1, 1); yaxis1.setRange(0, 5000); yaxis2.setRange(-1, 1); yaxis2.setTickLabelsVisible(false); xaxis.setRange(0, 16666); // deal with visuals final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true); renderer1.setSeriesPaint(0, Color.RED); renderer1.setSeriesStroke(0, new BasicStroke(3)); // renderer1.setBaseShapesVisible(true); // renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1)); plot.setRenderer(0, renderer1); // final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true); renderer2.setSeriesPaint(0, Color.CYAN); renderer2.setSeriesShapesFilled(0, Boolean.TRUE); renderer2.setBaseShapesVisible(true); renderer2.setShape(new Rectangle(-2, -100, 4, 200)); renderer2.setOutlineStroke(new BasicStroke(1)); renderer2.setOutlinePaint(Color.GRAY); renderer2.setUseOutlinePaint(true); plot.setRenderer(1, renderer2); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // return chart; }
From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java
private void showChart(String service) { final TimeSeriesCollection chartData = generateTimeSeriesData(service); JFreeChart chart = ChartFactory.createTimeSeriesChart(service, "Time", "Calls", chartData, false, true, false);/*from w w w. j a v a 2 s.c o m*/ // draw outter line XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(); lineAndShapeRenderer.setPaint(new Color(64, 168, 228, 75)); lineAndShapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6)); lineAndShapeRenderer.setSeriesShapesFilled(0, true); lineAndShapeRenderer.setSeriesShapesVisible(0, true); lineAndShapeRenderer.setUseOutlinePaint(true); lineAndShapeRenderer.setUseFillPaint(true); // draw filled area XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setPaint(new Color(64, 168, 228, 50)); // configure Plot final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setDataset(0, chartData); plot.setDataset(1, chartData); plot.setRenderer(0, lineAndShapeRenderer); plot.setRenderer(1, renderer); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); // format chart title TextTitle t = chart.getTitle(); t.setFont(new Font("Arial", Font.BOLD, 14)); // Cross Hairs xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); xCrosshair.setLabelVisible(true); xCrosshair.setLabelGenerator(new DateTimeCrosshairLabelGenerator()); CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); crosshairOverlay.addDomainCrosshair(xCrosshair); // Create the panel chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMouseZoomable(true, false); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(false); chartPanel.addChartMouseListener(this); chartPanel.addOverlay(crosshairOverlay); // update the display chartCards.removeAll(); chartCards.add(chartPanel, ""); chartCards.revalidate(); }
From source file:org.operamasks.faces.render.graph.LineChartRenderer.java
private void setLineStyles(XYLineAndShapeRenderer renderer, UIChart comp) { Boolean drawLines = comp.getDrawLines(); if (drawLines != null) { renderer.setBaseLinesVisible(drawLines); }/* w ww.j av a2 s . c om*/ Boolean drawMarkers = comp.getDrawMarkers(); if (drawMarkers != null) { renderer.setBaseShapesVisible(drawMarkers); } Boolean fillMarkers = comp.getFillMarkers(); if (fillMarkers != null) { renderer.setBaseShapesFilled(fillMarkers); } renderer.setUseFillPaint(true); Boolean drawOutline = comp.getDrawOutline(); if (drawOutline != null) { renderer.setDrawOutlines(drawOutline); } renderer.setUseOutlinePaint(true); }
From source file:com.rapidminer.gui.plotter.charts.MultipleScatterPlotter.java
@Override public void updatePlotter() { prepareData();//from w ww .j a v a2s . co m JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); if (xAxis >= 0) { int size = dataSet.getSeriesCount(); chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // URLs ); // renderer settings XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setDrawOutlines(true); for (int i = 0; i < size; i++) { renderer.setSeriesShapesVisible(i, this.showPoints[plotIndexToColumnIndexMap.get(i)]); renderer.setSeriesLinesVisible(i, this.showLines[plotIndexToColumnIndexMap.get(i)]); } renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7)); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } // GENERAL CHART SETTINGS int size = dataSet.getSeriesCount(); if (size <= 1) { chart.getXYPlot().getRenderer().setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); } else { for (int i = 0; i < dataSet.getSeriesCount(); i++) { chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); chart.getXYPlot().getRenderer().setSeriesPaint(i, getColorProvider().getPointColor(i / (double) (dataSet.getSeriesCount() - 1))); } } // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(false); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (xAxis >= 0) { if (dataTable.isNominal(xAxis)) { String[] values = new String[dataTable.getNumberOfValues(xAxis)]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(xAxis, i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(xAxis), values)); } else if ((dataTable.isDate(xAxis)) || (dataTable.isDateTime(xAxis))) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(xAxis)); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (xLogScale) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(xAxis)); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(xAxis)); domainAxis.setAutoRangeStickyZero(false); domainAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(domainAxis); } } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); // Chart Panel Settings if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); // react to mouse clicks // ATTENTION: ACTIVATING THIS WILL LEAD TO SEVERE MEMORY LEAKS!!! (see below) panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (e.getTrigger().getClickCount() > 1) { XYItemEntity entity = (XYItemEntity) e.getEntity(); if (entity != null) { String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem())); if (id != null) { ObjectVisualizer visualizer = ObjectVisualizerService .getVisualizerForObject(dataTable); visualizer.startVisualization(id); } } } } @Override public void chartMouseMoved(ChartMouseEvent e) { } }); } // tooltips class CustomXYToolTipGenerator implements XYToolTipGenerator { public CustomXYToolTipGenerator() { } @Override public String generateToolTip(XYDataset dataset, int row, int column) { String id = idMap.get(new SeriesAndItem(row, column)); if (id != null) { return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } else { return "<html>(" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } } } for (int i = 0; i < dataSet.getSeriesCount(); i++) { plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator()); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java
private void addPointSeries(TimeSeries series, XYPlot plot) { logger.debug("IN"); TimeSeries pointSerie = new TimeSeries("Point", Month.class); for (int i = 0; i < series.getItemCount(); i++) { pointSerie.add(series.getTimePeriod(i), series.getValue(i)); }//from w w w . j a va 2s .c om final TimeSeriesCollection avgDs = new TimeSeriesCollection(pointSerie); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { public boolean getItemShapeVisible(int _series, int item) { return (true); } }; renderer.setSeriesPaint(2, Color.LIGHT_GRAY); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.BLACK); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, -2.0, 4.0, 4.0)); plot.setDataset(2, avgDs); plot.setRenderer(2, renderer); logger.debug("OUT"); }
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();/*from ww w. j a v a 2 s .c om*/ 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(); }