List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero
public void setAutoRangeIncludesZero(boolean flag)
From source file:edu.cuny.cat.ui.TraderDistributionPanel.java
public TraderDistributionPanel() { registry = GameController.getInstance().getRegistry(); clock = GameController.getInstance().getClock(); dataset = new DefaultCategoryDataset(); setTitledBorder("Trader Distribution"); chart = ChartFactory.createLineChart("", "", "", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(getBackground()); final CategoryPlot categoryplot = chart.getCategoryPlot(); categoryplot.setOrientation(PlotOrientation.HORIZONTAL); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); final LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); UIUtils.setDefaultLineAndShapeRendererStyle(lineandshaperenderer); lineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); final NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setUpperMargin(0.12D);/* w w w . j a v a2s . c o m*/ final ChartPanel chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo1.java
/** * Creates a sample chart./*from w w w .ja v a 2 s. c o m*/ * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setUpperMargin(0.0); domainAxis.setLowerMargin(0.0); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.ietr.preesm.mapper.ui.stats.PerformancePlotter.java
/** * Creates a chart in order to plot the speed-ups. * /*from ww w .j a va 2s . c om*/ * @return A chart. */ private JFreeChart createChart(String title) { // Creating display domain NumberAxis horizontalAxis = new NumberAxis("Number of operators"); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(horizontalAxis); // Creating the best speedups subplot this.speedups = new DefaultXYDataset(); final NumberAxis xAxis = new NumberAxis("speedups"); xAxis.setAutoRangeIncludesZero(false); XYSplineRenderer renderer = new XYSplineRenderer(); final XYPlot subplot = new XYPlot(this.speedups, null, xAxis, renderer); subplot.setBackgroundPaint(Color.white); subplot.setDomainGridlinePaint(Color.lightGray); subplot.setRangeGridlinePaint(Color.lightGray); plot.add(subplot); plot.setForegroundAlpha(0.5f); final JFreeChart chart = new JFreeChart(title, plot); chart.setBorderPaint(Color.white); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); return chart; }
From source file:web.diva.server.unused.ProfilePlotGenerator.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings./* w w w .j a va2 s. c o m*/ * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return The chart. */ private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } Font f = new Font("ARIAL", 1, 7); // NumberAxis xAxis = new NumberAxis(xAxisLabel); // xAxis.setAutoRangeIncludesZero(false); SymbolAxis xAxis = new SymbolAxis("", columnIds); xAxis.setAxisLineVisible(false); xAxis.setGridBandsVisible(false); xAxis.setVerticalTickLabels(true); xAxis.setVisible(true); xAxis.setTickLabelPaint(shadowColor); xAxis.setTickLabelFont(f); xAxis.setFixedDimension(51.0); boolean auto = xAxis.getAutoRangeIncludesZero(); xAxis.setAutoRangeIncludesZero(true ^ auto); xAxis.setTickUnit(new NumberTickUnit(1)); xAxis.setRange(0, columnIds.length); // NumberAxis yAxis = new NumberAxis(yAxisLabel); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(true ^ auto); yAxis.setAxisLineVisible(false); yAxis.setTickLabelFont(f); yAxis.setTickLabelPaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseShapesVisible(false); renderer.setPaint(shadowColor); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(shadowColor); plot.setRangeGridlinePaint(shadowColor); plot.setOutlinePaint(Color.BLUE); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // plot.setRenderer(renderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); plot.setDomainAxis(xAxis); if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:ec.nbdemetra.ui.chart3d.functions.Functions2DChart.java
private void configureAxis(XYPlot plot) { NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRange(true);// w ww . j a v a 2 s .c o m xAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(xAxis); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(yAxis); }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo2.java
/** * Creates a sample chart./*from w w w . j a v a 2 s. c o m*/ * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setUpperMargin(0.0); domainAxis.setLowerMargin(0.0); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:ascensionxyplot.AscensionXYPlot.java
/** * Creates a combined chart./* www . j ava 2 s. c o m*/ * * @return The combined chart. */ private JFreeChart createCombinedChart(File dataFile) { // create subplot 1... final XYDataset data1 = createDataset1(dataFile); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // add secondary axis // subplot1.setDataset(1, createDataset2()); // final NumberAxis axis2 = new NumberAxis("Range Axis 2"); // axis2.setAutoRangeIncludesZero(false); // subplot1.setRangeAxis(1, axis2); // subplot1.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // subplot1.setRenderer(1, new StandardXYItemRenderer()); // subplot1.mapDatasetToRangeAxis(1, 1); final XYTextAnnotation annotation1 = new XYTextAnnotation("x value", 20.0, 120000.0); final XYTextAnnotation annotation2 = new XYTextAnnotation("y value", 20.0, 110000.0); final XYTextAnnotation annotation3 = new XYTextAnnotation("z value", 20.0, 100000.0); final XYTextAnnotation annotation4 = new XYTextAnnotation("timepoint", 20.0, 10000.0); annotation1.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation2.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation3.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation4.setFont(new Font("SansSerif", Font.PLAIN, 9)); // annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation1); subplot1.addAnnotation(annotation2); subplot1.addAnnotation(annotation3); subplot1.addAnnotation(annotation4); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Is this the title?", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupRtBoxPlot.java
public List<JFreeChart> createChart() { List<JFreeChart> charts = new ArrayList<>(); LinkedHashSet<ITreatmentGroupDescriptor> treatmentGroups = new LinkedHashSet<>( project.getTreatmentGroups()); List<CategoryPlot> plots = new LinkedList<>(); for (IPeakGroupDescriptor pgd : pgdl) { LinkedHashMap<ITreatmentGroupDescriptor, HashSet<IPeakAnnotationDescriptor>> map = new LinkedHashMap<>(); for (ITreatmentGroupDescriptor itgd : treatmentGroups) { map.put(itgd, new LinkedHashSet<IPeakAnnotationDescriptor>()); }/* w ww . ja va 2s . co m*/ List<IPeakAnnotationDescriptor> descriptors = pgd.getPeakAnnotationDescriptors(); DefaultBoxAndWhiskerCategoryDataset baw = new DefaultBoxAndWhiskerCategoryDataset(); for (IPeakAnnotationDescriptor ipad : descriptors) { ITreatmentGroupDescriptor treatmentGroup = ipad.getChromatogramDescriptor().getTreatmentGroup(); HashSet<IPeakAnnotationDescriptor> descr = map.get(treatmentGroup); if (descr == null) { descr = new HashSet<>(); map.put(treatmentGroup, descr); } descr.add(ipad); } List<Color> colors = new LinkedList<>(); for (ITreatmentGroupDescriptor tgd : map.keySet()) { String name = getPeakName(pgd); baw.add(createBoxAndWhiskerItem(map.get(tgd)), tgd.getName() + " (" + map.get(tgd).size() + ")", name); colors.add(tgd.getColor()); } BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setMeanVisible(false); renderer.setMedianVisible(true); renderer.setArtifactPaint(new Color(0, 0, 0, 128)); renderer.setMaximumBarWidth(0.1); renderer.setUseOutlinePaintForWhiskers(false); // renderer.setAutoPopulateSeriesFillPaint(true); // renderer.setAutoPopulateSeriesPaint(true); // renderer.setAutoPopulateSeriesOutlinePaint(true); NumberAxis yAxis = new NumberAxis("Peak Apex Retention Time"); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); CategoryPlot cp = new CategoryPlot(baw, new CategoryAxis("Treatment Groups"), yAxis, renderer); Logger.getLogger(getClass().getName()).log(Level.INFO, "Setting {0} colors!", colors.size()); ChartCustomizer.setSeriesColors(cp, 0.6f, colors); // ChartCustomizer.setSeriesColors(cp, 0.9f,colors); plots.add(cp); JFreeChart chart = new JFreeChart(cp); chart.setTitle( "Peak group " + pgd.getDisplayName() + " size: " + pgd.getPeakAnnotationDescriptors().size()); charts.add(chart); } // CategoryAxis ca = new CategoryAxis("Treatment Groups"); // NumberAxis va = new NumberAxis("Normalized Peak Area"); // CombinedDomainCategoryPlot cdcp = new CombinedDomainCategoryPlot(ca); // for (CategoryPlot cp : plots) { // cp.setRangeAxis(va); // cdcp.add(cp); // break; // } // return new JFreeChart(cdcp); return charts; }
From source file:org.signserver.client.cli.performance.PerformanceTestPDFServlet.java
License:asdf
/** * Create and write diagrams to disk.//w ww . ja va 2 s . co m */ private void createDiagram(String statisticsDirectory, ArrayList<String> explanationRow, ArrayList<ArrayList<Double>> processedData, int xRow, int y1Row, int y2Row) { final XYSeries s1 = new XYSeries(explanationRow.get(y1Row)); final XYSeries s2 = new XYSeries(explanationRow.get(y2Row)); for (ArrayList<Double> currentRow : processedData) { s1.add(currentRow.get(xRow), currentRow.get(y1Row)); s2.add(currentRow.get(xRow), currentRow.get(y2Row)); } final XYSeriesCollection dataset1 = new XYSeriesCollection(); dataset1.addSeries(s1); final XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(s2); final JFreeChart chart = ChartFactory.createXYLineChart("Test result " + xRow + "" + y1Row + "" + y2Row, explanationRow.get(xRow), explanationRow.get(y1Row), dataset1, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); if (y1Row == COLUMN_INVOCATIONS_PER_SECOND) { final NumberAxis axis1 = new LogarithmicAxis(explanationRow.get(y1Row)); plot.setRangeAxis(0, axis1); } final NumberAxis axis2 = new NumberAxis(explanationRow.get(y2Row)); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.BLUE); plot.setRenderer(1, renderer2); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file = new File( statisticsDirectory + "PDF Signatures" + "-" + xRow + "" + y1Row + "" + y2Row + ".png"); int imageWidth = 800; int imageHeight = 600; try { System.out.println("Writing diagram to " + file.getName()); System.out.flush(); ChartUtilities.saveChartAsPNG(file, chart, imageWidth, imageHeight, info); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
private NumberAxis createRangeAxis(String[] flagNames) { final NumberAxis axis = new SymbolAxis(null, flagNames); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setAutoRangeIncludesZero(false); axis.setLowerMargin(0.0);//from w ww .ja v a 2s.co m axis.setUpperMargin(0.0); axis.setInverted(true); return axis; }