List of usage examples for org.jfree.chart.axis NumberAxis setRange
public void setRange(double lower, double upper)
From source file:unalcol.termites.boxplots.SucessfulRatesHybrid.java
private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) { JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18)); jfreechart.setBackgroundPaint(new Color(221, 223, 238)); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.gray); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer renderer = (BarRenderer) categoryplot.getRenderer(); //categoryplot.setBackgroundPaint(new Color(221, 223, 238)); renderer.setSeriesPaint(0, new Color(130, 165, 70)); renderer.setSeriesPaint(1, new Color(220, 165, 70)); renderer.setSeriesPaint(4, new Color(255, 165, 70)); renderer.setDrawBarOutline(false);//w w w.j a v a 2s . co m renderer.setShadowVisible(false); // renderer.setMaximumBarWidth(1); renderer.setGradientPaintTransformer(null); renderer.setDefaultBarPainter(new StandardBarPainter()); categoryplot.setRenderer(renderer); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.25D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null)); numberaxis.setRange(0, 100); //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12); numberaxis.setTickLabelFont(font); CategoryAxis axisd = categoryplot.getDomainAxis(); ValueAxis axisr = categoryplot.getRangeAxis(); axisd.setTickLabelFont(font); axisr.setTickLabelFont(font); axisd.setMaximumCategoryLabelLines(5); final ChartPanel chartPanel = new ChartPanel(jfreechart); chartPanel.setPreferredSize(new java.awt.Dimension(1300, 370)); FileOutputStream output; try { output = new FileOutputStream("sucessrates1" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 1300, 370, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } return jfreechart; }
From source file:unalcol.termites.boxplots.SucessfulRates.java
private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) { JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18)); jfreechart.setBackgroundPaint(new Color(221, 223, 238)); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.gray); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer renderer = (BarRenderer) categoryplot.getRenderer(); //categoryplot.setBackgroundPaint(new Color(221, 223, 238)); renderer.setSeriesPaint(0, new Color(130, 165, 70)); renderer.setSeriesPaint(1, new Color(220, 165, 70)); renderer.setSeriesPaint(4, new Color(255, 165, 70)); renderer.setDrawBarOutline(false);/*from w ww .j ava 2 s. c o m*/ renderer.setShadowVisible(false); // renderer.setMaximumBarWidth(1); renderer.setGradientPaintTransformer(null); renderer.setDefaultBarPainter(new StandardBarPainter()); categoryplot.setRenderer(renderer); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.25D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null)); numberaxis.setRange(0, 100); //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12); numberaxis.setTickLabelFont(font); CategoryAxis axisd = categoryplot.getDomainAxis(); ValueAxis axisr = categoryplot.getRangeAxis(); axisd.setTickLabelFont(font); axisr.setTickLabelFont(font); final ChartPanel chartPanel = new ChartPanel(jfreechart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); FileOutputStream output; try { output = new FileOutputStream("sucessrates1" + pf + mazeMode + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 650, 370, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } return jfreechart; }
From source file:tools.descartes.bungee.chart.ChartGenerator.java
private static XYPlot createAllocationPlot(final TimeSeriesCollection dataset) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(false); final NumberAxis rangeAxis = new NumberAxis("Resource Amount"); rangeAxis.setAutoRangeIncludesZero(true); //rangeAxis.setTickUnit(new NumberTickUnit(1)); double lower = Math.min(1, dataset.getRangeBounds(false).getLowerBound()) - 0.2; double upper = Math.max(2, dataset.getRangeBounds(false).getUpperBound()) + 0.2; rangeAxis.setRange(lower, upper); final XYPlot allocationPlot = new XYPlot(dataset, null, rangeAxis, renderer); allocationPlot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); for (int i = 0; i < dataset.getSeriesCount(); i++) { TimeSeries series = dataset.getSeries(i); //addEndSeriesItem(lastDate, series); String description = series.getKey().toString(); renderer.setSeriesStroke(i, new BasicStroke(STROKE_WIDTH)); if (description.equals(AllocationSeries.CATEGORY.DEMAND.toString())) { renderer.setSeriesShapesVisible(i, false); renderer.setSeriesPaint(i, Color.RED); } else if (description.equals(SupplySeries.TYPE.VM_SCHEDULED.toString())) { renderer.setSeriesPaint(i, VARIANT_C_COLOR); } else if (description.equals(SupplySeries.TYPE.VM_COMPLETED.toString())) { renderer.setSeriesPaint(i, VARIANT_B_COLOR); } else if (description.equals(SupplySeries.TYPE.LB_RULE_ADAPTION.toString())) { if (dataset.getSeriesCount() != 2) { renderer.setSeriesPaint(i, VARIANT_A_COLOR); } else { renderer.setSeriesPaint(i, Color.BLUE); }/*w w w .j a v a2 s. co m*/ } else if (description.equals(SupplySeries.TYPE.MONITORED.toString())) { if (dataset.getSeriesCount() != 2) { renderer.setSeriesPaint(i, VARIANT_D_COLOR); } else { renderer.setSeriesPaint(i, Color.BLUE); } } else { renderer.setSeriesPaint(i, colorForConfig(description)); } } return allocationPlot; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * DOC Zqin Comment method "createBoxAndWhiskerChart". * /*from w ww . j a v a 2 s. c o m*/ * @param title * @param dataset * @return */ public static JFreeChart createBoxAndWhiskerChart(String title, BoxAndWhiskerCategoryDataset dataset) { // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // TDQ-5112~ JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, title, Messages.getString("TopChartFactory.Value"), dataset, false); //$NON-NLS-1$ CategoryPlot plot = chart.getCategoryPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(false); double min = dataset.getMinRegularValue("0", "").doubleValue(); //$NON-NLS-1$ //$NON-NLS-2$ double max = dataset.getMaxRegularValue("0", "").doubleValue(); //$NON-NLS-1$ //$NON-NLS-2$ double unit = (max - min) / 10; rangeAxis.setRange(min - unit, max + unit); rangeAxis.setTickUnit(new NumberTickUnit(unit)); BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer(); renderer.setArtifactPaint(ChartDecorator.COLOR_LIST.get(1)); return chart; }
From source file:MWC.GUI.JFreeChart.BearingRateFormatter.java
public void format(final XYPlot thePlot) { final NumberAxis theAxis = (NumberAxis) thePlot.getRangeAxis(); theAxis.setRange(-180, +180); theAxis.setLabel("(Left) " + theAxis.getLabel() + " (Right)"); }
From source file:MWC.GUI.JFreeChart.RelBearingFormatter.java
public void format(final XYPlot thePlot) { final NumberAxis theAxis = (NumberAxis) thePlot.getRangeAxis(); theAxis.setRange(-180, +180); theAxis.setLabel("(Red) " + theAxis.getLabel() + " (Green)"); // create some tick units suitable for degrees theAxis.setStandardTickUnits(CourseFormatter.getDegreeTickUnits()); theAxis.setAutoTickUnitSelection(true); }
From source file:MWC.GUI.JFreeChart.CourseFormatter.java
public final void format(final XYPlot thePlot) { final NumberAxis theAxis = (NumberAxis) thePlot.getRangeAxis(); theAxis.setRange(0, 360); // create some tick units suitable for degrees theAxis.setStandardTickUnits(getDegreeTickUnits()); theAxis.setAutoTickUnitSelection(true); }
From source file:org.geotools.renderer.chart.GeometryDataset.java
public ValueAxis getRange() { NumberAxis range = new NumberAxis(); range.setRange(bounds.getMinY() - buf, bounds.getMaxY() + buf); return range; }
From source file:org.geotools.renderer.chart.GeometryDataset.java
public ValueAxis getDomain() { NumberAxis domain = new NumberAxis(); domain.setRange(bounds.getMinX() - buf, bounds.getMaxX() + buf); return domain; }
From source file:org.jfree.chart.demo.WaterTemperatureDemo.java
/** * A demonstration application showing an XY series containing a null value. * * @param title the frame title.//w ww . jav a2 s . c o m */ public WaterTemperatureDemo(final String title) { super(title); final XYDataset dataset = createDataset(); final NumberAxis rangeAxis = new NumberAxis("Temperature"); rangeAxis.setRange(-0.55, -0.15); final NumberAxis domainAxis = new NumberAxis("Depth"); domainAxis.setInverted(true); domainAxis.setRange(0.0, 35.0); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new StandardXYItemRenderer(); final XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Water Temperature By Depth", plot); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }