Java Code Examples for org.jfree.chart.ChartFactory#createXYAreaChart()
The following examples show how to use
org.jfree.chart.ChartFactory#createXYAreaChart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XYAreaChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected JFreeChart computeXYChart( final XYDataset xyDataset ) { final JFreeChart chart; if ( xyDataset instanceof TimeSeriesCollection ) { if ( isStacked() ) { final ExtTimeTableXYDataset tableXYDataset = convertToTable( xyDataset ); chart = createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), tableXYDataset, isShowLegend(), false, false, isStacked() ); } else { chart = createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, isShowLegend(), false, false, isStacked() ); } } else { final PlotOrientation orientation = computePlotOrientation(); if ( isStacked() ) { chart = createStackedXYAreaChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false ); } else { chart = ChartFactory.createXYAreaChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false ); } } configureLogarithmicAxis( chart.getXYPlot() ); return chart; }
Example 2
Source File: JPanelProfil.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
private JFreeChart CreateChartProfil(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart("", "Distance", // x axis label "Elevation", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(renderer); // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
Example 3
Source File: XYAreaChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYAreaChart( "Area Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); }
Example 4
Source File: DefaultChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
Example 5
Source File: GenericChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
Example 6
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
Example 7
Source File: frmEditCurve.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
/** * Creates the chart * * @param dataset Dataset to display * @return Return a JFreeChart object */ private JFreeChart CreateChartProfile(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart("", bundle.getString("frmEditCurve.chart.slope"), // "Slope" x // axis // label bundle.getString("frmEditCurve.chart.speed") + " (" + Utils.uSpeed2String(settings.Unit, settings.isPace) + ")", // "speed" y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYAreaRenderer renderer = new XYAreaRenderer(); // Green (safe color) renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); // Width of the outline renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(renderer); // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
Example 8
Source File: XYAreaLineChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected JFreeChart computeXYChart( final XYDataset xyDataset ) { final JFreeChart chart; if ( xyDataset instanceof TimeSeriesCollection ) { if ( isStacked() ) { final ExtTimeTableXYDataset tableXYDataset = convertToTable( xyDataset ); chart = createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), tableXYDataset, isShowLegend(), false, false, isStacked() ); } else { chart = createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, isShowLegend(), false, false, isStacked() ); } } else { final PlotOrientation orientation = computePlotOrientation(); if ( isStacked() ) { chart = createStackedXYAreaChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false ); } else { chart = ChartFactory.createXYAreaChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false ); } } configureLogarithmicAxis( chart.getXYPlot() ); configureLineChart( chart.getXYPlot() ); return chart; }
Example 9
Source File: JFuzzyChartImpl.java From jFuzzyLogic with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create a defuzzifier's chart * @param title : Title to show (if null => show membership function name) * @param showIt : If true, plot is displayed */ private JFreeChart chartDefuzzifierContinuous(DefuzzifierContinuous def, String title, boolean showIt) { // Default title if (title == null) title = def.getName(); // Sanity check double min = def.getMin(); double max = def.getMax(); if (Double.isNaN(min) || Double.isInfinite(max)) { Gpr.debug("Limits not calculated yet: [" + min + ", " + max + "]"); return null; } // Create a series and add values[] points XYSeries series = new XYSeries(title); double values[] = def.getValues(); int numberOfPoints = values.length; double xx = min; double step = (max - min) / (numberOfPoints); for (int i = 0; i < numberOfPoints; i++, xx += step) series.add(xx, values[i]); XYDataset xyDataset = new XYSeriesCollection(series); // Create plot and show it JFreeChart chart = ChartFactory.createXYAreaChart(title, "x", "Membership", xyDataset, PlotOrientation.VERTICAL, false, true, false); if (showIt) PlotWindow.showIt(title, chart); return chart; }
Example 10
Source File: XYAreaChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); return ChartFactory.createXYAreaChart("Area Chart", "Domain", "Range", dataset, true); }
Example 11
Source File: JPanelAnalysisSpeed.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisSpeed.labelX"), // "Distance", // y axis label bundle.getString("JPanelAnalysisSpeed.labelY"), // "Speed" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 12
Source File: ProjectionPlotPanel.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset, ParameterSet parameters) { super(null); boolean createLegend = false; if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20)) createLegend = true; chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset, PlotOrientation.VERTICAL, createLegend, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setForegroundAlpha(dataPointAlpha); NumberFormat numberFormat = NumberFormat.getNumberInstance(); // set the X axis (component 1) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(numberFormat); // set the Y axis (component 2) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(numberFormat); plot.setDataset(dataset); spotRenderer = new ProjectionPlotRenderer(plot, dataset); itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters); spotRenderer.setDefaultItemLabelGenerator(itemLabelGenerator); spotRenderer.setDefaultItemLabelsVisible(true); spotRenderer.setDefaultToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters)); plot.setRenderer(spotRenderer); // Setup legend if (createLegend) { LegendItemCollection legendItemsCollection = new LegendItemCollection(); for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) { Object paramValue = dataset.getGroupParameterValue(groupNumber); if (paramValue == null) { // No parameter value available: search for raw data files // within this group, and use their names as group's name String fileNames = new String(); for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) { String rawDataFile = dataset.getRawDataFile(itemNumber); if (dataset.getGroupNumber(itemNumber) == groupNumber) fileNames = fileNames.concat(rawDataFile); } if (fileNames.length() == 0) fileNames = "Empty group"; paramValue = fileNames; } Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber); Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(), (int) Math.round(255 * dataPointAlpha)); legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null, spotRenderer.getDataPointsShape(), groupColor)); } plot.setFixedLegendItems(legendItemsCollection); } // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 13
Source File: RTMZPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public RTMZPlot(RTMZAnalyzerWindow masterFrame, AbstractXYZDataset dataset, InterpolatingLookupPaintScale paintScale) { super(null); this.paintScale = paintScale; chart = ChartFactory.createXYAreaChart("", "Retention time", "m/z", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); plot.setDataset(dataset); spotRenderer = new RTMZRenderer(dataset, paintScale); plot.setRenderer(spotRenderer); spotRenderer.setDefaultToolTipGenerator(new RTMZToolTipGenerator()); // Add a paintScaleLegend to chart paintScaleAxis = new NumberAxis("Logratio"); paintScaleAxis.setRange(paintScale.getLowerBound(), paintScale.getUpperBound()); paintScaleLegend = new PaintScaleLegend(paintScale, paintScaleAxis); paintScaleLegend.setPosition(plot.getDomainAxisEdge()); paintScaleLegend.setMargin(5, 25, 5, 25); chart.addSubtitle(paintScaleLegend); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 14
Source File: JPanelAnalysisTimeDist.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Distance" // y axis label bundle.getString("JPanelAnalysisTimeDist.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 15
Source File: RTMZPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public RTMZPlot(RTMZAnalyzerWindow masterFrame, AbstractXYZDataset dataset, InterpolatingLookupPaintScale paintScale) { super(null); this.paintScale = paintScale; chart = ChartFactory.createXYAreaChart("", "Retention time", "m/z", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); plot.setDataset(dataset); spotRenderer = new RTMZRenderer(dataset, paintScale); plot.setRenderer(spotRenderer); spotRenderer.setDefaultToolTipGenerator(new RTMZToolTipGenerator()); // Add a paintScaleLegend to chart paintScaleAxis = new NumberAxis("Logratio"); paintScaleAxis.setRange(paintScale.getLowerBound(), paintScale.getUpperBound()); paintScaleLegend = new PaintScaleLegend(paintScale, paintScaleAxis); paintScaleLegend.setPosition(plot.getDomainAxisEdge()); paintScaleLegend.setMargin(5, 25, 5, 25); chart.addSubtitle(paintScaleLegend); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 16
Source File: FrmElevationFilter.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Update the chart * * @param dataset1 * @param dataset2 * @return */ private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("frmElevationFilter.labelX"), // "Distance" // y axis label bundle.getString("frmElevationFilter.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis("");// bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" // plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); // plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); renderer2.setSeriesStroke(0, new BasicStroke(1.0f)); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 17
Source File: ProjectionPlotPanel.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset, ParameterSet parameters) { super(null); boolean createLegend = false; if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20)) createLegend = true; chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset, PlotOrientation.VERTICAL, createLegend, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setForegroundAlpha(dataPointAlpha); NumberFormat numberFormat = NumberFormat.getNumberInstance(); // set the X axis (component 1) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(numberFormat); // set the Y axis (component 2) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(numberFormat); plot.setDataset(dataset); spotRenderer = new ProjectionPlotRenderer(plot, dataset); itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters); spotRenderer.setDefaultItemLabelGenerator(itemLabelGenerator); spotRenderer.setDefaultItemLabelsVisible(true); spotRenderer.setDefaultToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters)); plot.setRenderer(spotRenderer); // Setup legend if (createLegend) { LegendItemCollection legendItemsCollection = new LegendItemCollection(); for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) { Object paramValue = dataset.getGroupParameterValue(groupNumber); if (paramValue == null) { // No parameter value available: search for raw data files // within this group, and use their names as group's name String fileNames = new String(); for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) { String rawDataFile = dataset.getRawDataFile(itemNumber); if (dataset.getGroupNumber(itemNumber) == groupNumber) fileNames = fileNames.concat(rawDataFile); } if (fileNames.length() == 0) fileNames = "Empty group"; paramValue = fileNames; } Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber); Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(), Math.round(255 * dataPointAlpha)); legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null, spotRenderer.getDataPointsShape(), groupColor)); } plot.setFixedLegendItems(legendItemsCollection); } // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }