List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setToolTipGenerator
@Override public void setToolTipGenerator(XYToolTipGenerator generator)
From source file:edu.unc.LCCC.caBIG.DWD.javaCode.visualization.SetUpPlotWindow.java
public static JPanel createXYLineAndShapeRendererChart(XYDataset data, String x, String y, int w, int h) { //XYDataset data = new SampleXYDataset2(); JFreeChart chart = ChartFactory.createScatterPlot(null, // the title of the chart x, // the label for the X axis y, // the label for the Y axis data, // the dataset for the chart PlotOrientation.VERTICAL, // the orientation of the chart true, // a flag specifying whether or not a legend is required true, // a flag specifying whether or not tooltips should be generated false); // a flag specifying whether or not the chart should generate URLs XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6);/* w w w . ja va 2 s .c o m*/ plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(w, h)); return chartPanel; }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java
private void createChart() { //String xLabel = factor1.toString(); String xLabel = factor1AxisLabel; //String yLabel = factor2.toString(); String yLabel = factor2AxisLabel; clinicalChart = ChartFactory.createScatterPlot("Clinical Plot", xLabel, yLabel, null, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) clinicalChart.getPlot(); buildLegend();/* w w w.j a va2s . co m*/ plot.setNoDataMessage(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setUseOutlinePaint(true); plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(false); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //should determine axis range using datapoints. domainAxis.setAutoRangeIncludesZero(false); //get domain and range of the axis. DataRange domainAxisLimits = getDataRange(dataPoints, factor1, true); DataRange rangeAxisLimits = getDataRange(dataPoints, factor2, true); //domainAxis.setRange(domainAxisLimits.getMinRange(), domainAxisLimits.getMaxRange()); //rangeAxis.setRange(rangeAxisLimits.getMinRange(), rangeAxisLimits.getMaxRange()); double domainMax = Math.max(100.0, domainAxisLimits.getMaxRange()) + 5.0; double rangeMax = Math.max(100.0, rangeAxisLimits.getMaxRange()) + 5.0; domainAxis.setRange(0.0, domainMax); rangeAxis.setRange(0.0, rangeMax); System.out.println("domainAxis=" + domainAxis.getLabel()); System.out.println("rangeAxis=" + rangeAxis.getLabel()); createGlyphsAndAddToPlot(plot); }
From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.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();// w ww. ja v a 2s .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 <= 50.0 && maxAbsVal >= 25.0) { tickUnit = 10.0; //5.0; } else if (maxAbsVal <= 25.0) { tickUnit = 5.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: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();/*from www . j a va 2 s . c om*/ } 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: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();/* ww w . jav a 2s . c om*/ 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:grafix.graficos.indices.Indice.java
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) { XYLineAndShapeRenderer indicesRenderer = new XYLineAndShapeRenderer(); indicesRenderer.setSeriesLinesVisible(0, isTracoContinuo()); indicesRenderer.setSeriesShapesVisible(0, !isTracoContinuo()); indicesRenderer.setSeriesShape(0, ShapeUtilities.createDiamond(1.5f)); indicesRenderer.setStroke(new BasicStroke(getEspessura() * 0.5f)); indicesRenderer.setToolTipGenerator(new IndiceToolTipGenerator(this)); indicesRenderer.setPaint(getCor());/* w w w . ja va2s . c om*/ plot.setRenderer(contador, indicesRenderer); plot.setDataset(contador, getDataSet(janela)); }
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 av a2 s. co 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:grafix.graficos.indices.IndiceADX.java
@Override public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) { XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); r.setSeriesLinesVisible(0, true);//from w w w.j av a 2 s .com r.setSeriesShapesVisible(0, false); r.setSeriesPaint(0, Color.BLUE); r.setSeriesStroke(0, new BasicStroke(.75f)); r.setSeriesPaint(1, Color.RED); r.setSeriesStroke(1, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 3.0f, 4.0f }, 0.0f)); r.setSeriesLinesVisible(1, true); r.setSeriesShapesVisible(1, false); r.setSeriesPaint(2, new Color(0f, .6f, 0f)); r.setSeriesStroke(2, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f, new float[] { 3.0f, 4.0f }, 0.0f)); r.setSeriesLinesVisible(2, true); r.setSeriesShapesVisible(2, false); r.setToolTipGenerator(new IndiceToolTipGenerator(this)); plot.setRenderer(contador, r); plot.setDataset(contador, getDataSet(janela)); }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java
private void createChart(XYDataset dataset) { //Create the chart, dropping in the data set JFreeChart chart = ChartFactory.createXYLineChart("", "Days in Study", "Probability of Survival", dataset, PlotOrientation.VERTICAL, false, //legend true, //tooltips false//urls );/*w ww . j a va2 s . c om*/ LegendTitle legend = chart.getLegend(); XYPlot plot = (XYPlot) chart.getPlot(); /******************************************************** * IMPORTANT: * Ideally I would create the actual Renderer settings for * the at the time I start to march through the * KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. * But you have no idea how they are going to be sitting in * the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact * it didn't work when I wrote this. * */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KaplanMeierPlotPointSeries kmSeries = (KaplanMeierPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); } else if (kmSeries.getType() == SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); kmChart = chart; }
From source file:net.nosleep.superanalyzer.analysis.views.YearView.java
private void createChart() { NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR")); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT")); yAxis.setAutoRangeIncludesZero(true); xAxis.setNumberFormatOverride(new DecimalFormat("0")); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer); // create and return the chart panel... _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); LegendTitle legend = _chart.getLegend(); legend.setFrame(BlockBorder.NONE);//from w w w .j av a 2s. c om _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP"))); XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(generator); ChartUtilities.applyCurrentTheme(_chart); // format the lines after applying the theme renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f)); renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); _chart.setPadding(new RectangleInsets(10, 10, 10, 10)); Misc.formatChart(plot); }