List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:org.jfree.chart.demo.LineChartDemo5.java
/** * Creates a sample chart.//from w w w. j a v a 2s. c o m * * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 5", // chart title "Type", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final Shape[] shapes = new Shape[3]; int[] xpoints; int[] ypoints; // right-pointing triangle xpoints = new int[] { -3, 3, -3 }; ypoints = new int[] { -3, 0, 3 }; shapes[0] = new Polygon(xpoints, ypoints, 3); // vertical rectangle shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6); // left-pointing triangle xpoints = new int[] { -3, 3, 3 }; ypoints = new int[] { 0, -3, 3 }; shapes[2] = new Polygon(xpoints, ypoints, 3); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, shapes); final CategoryPlot plot = chart.getCategoryPlot(); plot.setDrawingSupplier(supplier); chart.setBackgroundPaint(Color.yellow); // set the stroke for each series... plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setItemLabelsVisible(true); // renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.12); return chart; }
From source file:CargarEntrenamiento.grafica2.java
private void configurarDomainAxis(NumberAxis domainAxis) { domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setTickUnit(new NumberTickUnit(1)); }
From source file:CargarEntrenamiento.grafica2.java
private void configurarRangeAxis(NumberAxis rangeAxis) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickUnit(new NumberTickUnit(2)); rangeAxis.setRange(0, 100);/*from www .ja va 2 s .c o m*/ }
From source file:org.esa.smos.gui.gridpoint.GridPointBtDataFlagmatrixTopComponent.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);//from w ww .ja v a2 s . com xAxis.setUpperMargin(0.0); final List<FlagDescriptor> flagDescriptorList = Dddb.getInstance() .getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER).asList(); flagDescriptors = flagDescriptorList.toArray(new FlagDescriptor[flagDescriptorList.size()]); final String[] flagNames = createFlagNames(flagDescriptors); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createChart4() { JFreeChart chart4 = ChartFactory.createHistogram("Wealth Distribution", "Wealth", "Count", model.dataset, PlotOrientation.VERTICAL, true, true, false); model.chart4 = chart4;/*w ww. j av a 2s. co m*/ NumberAxis rangeAxis1 = new NumberAxis("Wealth"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart4.getXYPlot(); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.MAGENTA); return chart4; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createCultureTagChart() { JFreeChart chart = ChartFactory.createXYLineChart("Culture Tag Time Series", "Time", "Fraction Blue", model.culture_tag_coll, PlotOrientation.VERTICAL, true, true, false); model.culture_tag_chart = chart;/*from w w w.j a v a2s . co m*/ NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createEvolution() { JFreeChart chart = ChartFactory.createXYLineChart("Evolution of Mean Agent Vision and Metabolism", "Time", "Level", model.evolution_vision_coll, PlotOrientation.VERTICAL, true, true, false); model.evolution_chart = chart;//w ww .ja v a2 s.c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, model.evolution_metabolism_coll); renderer.setSeriesPaint(1, Color.BLUE); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createAgeHistoChart() { JFreeChart chart = ChartFactory.createHistogram("Age Distribution", "Age", "Count", model.age_hist_dataset, PlotOrientation.VERTICAL, true, true, false); model.age_histo_chart = chart;//from w ww . j a v a 2 s.co m //CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Age"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setRange(0, 100); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.MAGENTA); return chart; }
From source file:hudson.model.LoadStatistics.java
/** * Creates a trend chart./* ww w . j a v a 2 s . c om*/ */ public JFreeChart createChart(CategoryDataset ds) { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused null, // range axis label ds, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(3)); configureRenderer(renderer); final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createTradeChart() { JFreeChart chart = ChartFactory.createXYLineChart("Trading and Population over Time", "Time", "Level", model.agents_series_coll, PlotOrientation.VERTICAL, true, true, false); model.trade_chart = chart;//from w ww . ja v a2 s .c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLUE); plot.setDataset(1, model.trade_coll); XYItemRenderer rend2 = new StandardXYItemRenderer(); //if (rend2 != null) rend2.setSeriesPaint(1, Color.BLACK); plot.setRenderer(1, rend2); return chart; }