Java Code Examples for org.jfree.chart.renderer.xy.XYBarRenderer#setBarPainter()
The following examples show how to use
org.jfree.chart.renderer.xy.XYBarRenderer#setBarPainter() .
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: HistogramChartFactory.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example 2
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min, double max) { if (data != null && data.length > 0) { HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("histo", data, bin, min, max); JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); XYPlot xyplot = chart.getXYPlot(); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); // xybarrenderer.setDrawBarOutline(false); return chart; } else return null; }
Example 3
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example 4
Source File: HistogramChartFactory.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min, double max) { if (data != null && data.length > 0) { HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("histo", data, bin, min, max); JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); XYPlot xyplot = chart.getXYPlot(); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); // xybarrenderer.setDrawBarOutline(false); return chart; } else return null; }
Example 5
Source File: HistogramChartFactory.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example 6
Source File: NumericalAttributeStatisticsModel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the histogram chart. * * @param exampleSet * @return */ private JFreeChart createHistogramChart(ExampleSet exampleSet) { JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet), PlotOrientation.VERTICAL, false, false, false); AbstractAttributeStatisticsModel.setDefaultChartFonts(chart); chart.setBackgroundPaint(null); chart.setBackgroundImageAlpha(0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setOutlineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setDomainZeroBaselineVisible(false); plot.setBackgroundPaint(COLOR_INVISIBLE); plot.setBackgroundImageAlpha(0.0f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL)); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); return chart; }
Example 7
Source File: DateTimeAttributeStatisticsModel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the histogram chart. * * @param exampleSet * @return */ private JFreeChart createHistogramChart(final ExampleSet exampleSet) { JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet), PlotOrientation.VERTICAL, false, false, false); AbstractAttributeStatisticsModel.setDefaultChartFonts(chart); chart.setBackgroundPaint(null); chart.setBackgroundImageAlpha(0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setOutlineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setDomainZeroBaselineVisible(false); plot.getDomainAxis().setTickLabelsVisible(false); plot.setBackgroundPaint(COLOR_INVISIBLE); plot.setBackgroundImageAlpha(0.0f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME)); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); return chart; }
Example 8
Source File: BeltTimeColumnStatisticsModel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the histogram chart. */ private JFreeChart createHistogramChart(final Table table) { JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table), PlotOrientation.VERTICAL, false, false, false); setDefaultChartFonts(chart); chart.setBackgroundPaint(null); chart.setBackgroundImageAlpha(0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setOutlineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setDomainZeroBaselineVisible(false); plot.getDomainAxis().setTickLabelsVisible(false); plot.setBackgroundPaint(COLOR_INVISIBLE); plot.setBackgroundImageAlpha(0.0f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME)); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); return chart; }
Example 9
Source File: BeltNumericalColumnStatisticsModel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the histogram chart. */ private JFreeChart createHistogramChart(Table table) { JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table), PlotOrientation.VERTICAL, false, false, false); AbstractAttributeStatisticsModel.setDefaultChartFonts(chart); chart.setBackgroundPaint(null); chart.setBackgroundImageAlpha(0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setOutlineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setDomainZeroBaselineVisible(false); plot.setBackgroundPaint(COLOR_INVISIBLE); plot.setBackgroundImageAlpha(0.0f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL)); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); return chart; }
Example 10
Source File: BeltDateTimeColumnStatisticsModel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the histogram chart. */ private JFreeChart createHistogramChart(final Table table) { JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table), PlotOrientation.VERTICAL, false, false, false); setDefaultChartFonts(chart); chart.setBackgroundPaint(null); chart.setBackgroundImageAlpha(0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setOutlineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setDomainZeroBaselineVisible(false); plot.getDomainAxis().setTickLabelsVisible(false); plot.setBackgroundPaint(COLOR_INVISIBLE); plot.setBackgroundImageAlpha(0.0f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME)); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); return chart; }
Example 11
Source File: HistogramChartFactory.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min, double max) { if (data != null && data.length > 0) { HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("histo", data, bin, min, max); JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); XYPlot xyplot = chart.getXYPlot(); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); // xybarrenderer.setDrawBarOutline(false); return chart; } else return null; }
Example 12
Source File: StatisticsPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) { JFreeChart chart = ChartFactory.createHistogram( null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); //xyPlot.setForegroundAlpha(0.85f); xyPlot.setNoDataMessage("No data"); xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, color); StandardXYBarPainter painter = new StandardXYBarPainter(); renderer.setBarPainter(painter); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(300, 200)); // chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
Example 13
Source File: StandardChartTheme.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (<code>null</code> not permitted). */ protected void applyToXYItemRenderer(XYItemRenderer renderer) { ParamChecks.nullNotPermitted(renderer, "renderer"); if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); if (renderer instanceof XYBarRenderer) { XYBarRenderer br = (XYBarRenderer) renderer; br.setBarPainter(this.xyBarPainter); br.setShadowVisible(this.shadowVisible); } }
Example 14
Source File: StandardChartTheme.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (<code>null</code> not permitted). */ protected void applyToXYItemRenderer(XYItemRenderer renderer) { ParamChecks.nullNotPermitted(renderer, "renderer"); if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); if (renderer instanceof XYBarRenderer) { XYBarRenderer br = (XYBarRenderer) renderer; br.setBarPainter(this.xyBarPainter); br.setShadowVisible(this.shadowVisible); } }
Example 15
Source File: StandardChartTheme.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (<code>null</code> not permitted). */ protected void applyToXYItemRenderer(XYItemRenderer renderer) { ParamChecks.nullNotPermitted(renderer, "renderer"); if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); if (renderer instanceof XYBarRenderer) { XYBarRenderer br = (XYBarRenderer) renderer; br.setBarPainter(this.xyBarPainter); br.setShadowVisible(this.shadowVisible); } }
Example 16
Source File: HistogramPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void createUI() { dataset = new XIntervalSeriesCollection(); chart = ChartFactory.createHistogram( CHART_TITLE, "Values", "Frequency in #pixels", dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); xyPlot.setDomainZeroBaselineStroke(new BasicStroke(0.2f)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setShadowYOffset(-4.0); renderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator()); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setSeriesPaint(0, new Color(0, 0, 200)); createUI(createChartPanel(chart), createOptionsPanel(), bindingContext); isInitialized = true; final Binding minBinding = xAxisRangeControl.getBindingContext().getBinding("min"); final double min = (Double) minBinding.getPropertyValue(); final Binding maxBinding = xAxisRangeControl.getBindingContext().getBinding("max"); final double max = (Double) maxBinding.getPropertyValue(); if (!histogramComputing && min > max) { minBinding.setPropertyValue(max); maxBinding.setPropertyValue(min); } updateXAxis(); }
Example 17
Source File: ChartFormatter.java From nmonvisualizer with Apache License 2.0 | 5 votes |
void formatRenderer(XYBarRenderer renderer) { renderer.setShadowVisible(false); renderer.setDrawBarOutline(false); renderer.setBarPainter(new GradientPainters.GradientXYBarPainter()); renderer.setMargin(0.15d); renderer.setBaseOutlineStroke(OUTLINE_STROKE); renderer.setBaseOutlinePaint(OUTLINE_COLOR); }
Example 18
Source File: MsSpectrumPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
private void configureRenderer(MsSpectrumDataSet dataset, int datasetIndex) { final MsSpectrumType renderingType = dataset.getRenderingType(); final XYPlot plot = chartNode.getChart().getXYPlot(); // Set renderer AbstractXYItemRenderer newRenderer; switch (renderingType) { case PROFILE: case THRESHOLDED: XYLineAndShapeRenderer newLineRenderer = new XYLineAndShapeRenderer(); final int lineThickness = dataset.getLineThickness(); newLineRenderer.setBaseShape(new Ellipse2D.Double(-2 * lineThickness, -2 * lineThickness, 4 * lineThickness + 1, 4 * lineThickness + 1)); newLineRenderer.setBaseShapesFilled(true); newLineRenderer.setBaseShapesVisible(dataset.getShowDataPoints()); newLineRenderer.setDrawOutlines(false); Stroke baseStroke = new BasicStroke(lineThickness); newLineRenderer.setBaseStroke(baseStroke); newRenderer = newLineRenderer; break; case CENTROIDED: default: XYBarRenderer newBarRenderer = new XYBarRenderer(); // Avoid gradients newBarRenderer.setBarPainter(new StandardXYBarPainter()); newBarRenderer.setShadowVisible(false); newRenderer = newBarRenderer; break; } // Set tooltips for legend newRenderer.setLegendItemToolTipGenerator((ds, series) -> { if (ds instanceof MsSpectrumDataSet) { return ((MsSpectrumDataSet) ds).getDescription(); } else return null; }); // Set color Color baseColor = dataset.getColor(); newRenderer.setBasePaint(JavaFXUtil.convertColorToAWT(baseColor)); // Set label generator XYItemLabelGenerator intelligentLabelGenerator = new IntelligentItemLabelGenerator(chartNode, 100, dataset); newRenderer.setBaseItemLabelGenerator(intelligentLabelGenerator); newRenderer.setBaseItemLabelPaint(JavaFXUtil.convertColorToAWT(labelsColor)); newRenderer.setBaseItemLabelsVisible(itemLabelsVisible.get()); // Set tooltip generator newRenderer.setBaseToolTipGenerator(dataset); plot.setRenderer(datasetIndex, newRenderer); }
Example 19
Source File: Chart.java From freeacs with MIT License | 4 votes |
/** * All params can be null. * * @param min - the minimum number on the left range axis (must be set if max is set) * @param max - the maximum number on the left range axis (must be set if min is set) * @param method2 - the method to run out of Record, and populates a bar series (right range axis) * @param highLightIndex - the index to highlight * @return * @throws Exception */ public JFreeChart makeTimeChart(Double min, Double max, String method2, Integer highLightIndex) throws Exception { startTms = System.currentTimeMillis(); endTms = 0; XYBarRenderer.setDefaultShadowsVisible(false); TimeSeriesCollection data = new TimeSeriesCollection(); Map<String, TimeSeries> timeSeriesMap = makeTimeSeriesMap(method, recordMap, keyNames); for (TimeSeries timeSeries : timeSeriesMap.values()) { data.addSeries(timeSeries); } String yAxisLabel = method; String denominator = Record.getDenominator(report.getRecordClass(), method.toLowerCase()); if (denominator != null) { yAxisLabel += " (" + denominator + ")"; } chart = ChartFactory.createTimeSeriesChart(title, "Time", yAxisLabel, data, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); if (method2 != null) { Map<Key, R> recordMap2 = recordMap; TimeSeriesCollection data2 = new TimeSeriesCollection(); if (keyNames.length > 0) { recordMap2 = report.getMapAggregatedOn(); } Map<String, TimeSeries> timeSeriesMap2 = makeTimeSeriesMap(method2, recordMap2); if (timeSeriesMap2.get("Total (" + method2 + ")") != null) { data2.addSeries(timeSeriesMap2.get("Total (" + method2 + ")")); } String y2AxisLabel = method2; String demoninator2 = Record.getDenominator(report.getRecordClass(), method2.toLowerCase()); if (demoninator2 != null) { y2AxisLabel += " (" + demoninator2 + ")"; } NumberAxis axis2 = new NumberAxis(y2AxisLabel); XYBarRenderer renderer2 = new XYBarRenderer(0.20); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); renderer2.setBarPainter(new StandardXYBarPainter()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); } if (min != null && max != null) { plot.getRangeAxis(0).setRange(min, max); } if (highLightIndex != null) { chart.getXYPlot().getRenderer().setSeriesStroke(highLightIndex, new BasicStroke(5f)); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setUseFillPaint(true); renderer.setDefaultFillPaint(Color.white); long diff = endTms - startTms; String format; if (diff > NINTY_DAYS) { format = "MMM-yyyy"; } else if (diff > TWO_DAYS) { format = "dd-MMM"; } else if (diff > TWO_MINUTES) { format = "HH:mm"; } else { format = "HH:mm:ss"; } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(format)); LegendTitle lt = chart.getLegend(0); lt.setPosition(RectangleEdge.RIGHT); if (displayFrame) { ChartFrame frame = new ChartFrame(title, chart); frame.pack(); frame.setVisible(true); } return chart; }
Example 20
Source File: XYBarRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances XYBarRenderer r1 = new XYBarRenderer(); XYBarRenderer r2 = new XYBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // setBase() r1.setBase(1.0); assertFalse(r1.equals(r2)); r2.setBase(1.0); assertTrue(r1.equals(r2)); // setUseYInterval r1.setUseYInterval(!r1.getUseYInterval()); assertFalse(r1.equals(r2)); r2.setUseYInterval(!r2.getUseYInterval()); assertTrue(r1.equals(r2)); // setMargin() r1.setMargin(0.10); assertFalse(r1.equals(r2)); r2.setMargin(0.10); assertTrue(r1.equals(r2)); // setDrawBarOutline() r1.setDrawBarOutline(!r1.isDrawBarOutline()); assertFalse(r1.equals(r2)); r2.setDrawBarOutline(!r2.isDrawBarOutline()); assertTrue(r1.equals(r2)); // setGradientPaintTransformer() r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertFalse(r1.equals(r2)); r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertTrue(r1.equals(r2)); // legendBar r1.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); // positiveItemLabelFallbackPosition r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); assertTrue(r1.equals(r2)); // negativeItemLabelFallbackPosition r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); assertTrue(r1.equals(r2)); // barPainter r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); assertFalse(r1.equals(r2)); r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); assertTrue(r1.equals(r2)); // shadowsVisible r1.setShadowVisible(false); assertFalse(r1.equals(r2)); r2.setShadowVisible(false); assertTrue(r1.equals(r2)); // shadowXOffset r1.setShadowXOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowXOffset(3.3); assertTrue(r1.equals(r2)); // shadowYOffset r1.setShadowYOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowYOffset(3.3); assertTrue(r1.equals(r2)); }