List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis()
From source file:org.tsho.dmc2.managers.AbstractManager.java
protected AbstractManager(ManagerListener2 frame) { this.frame = frame; xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); xAxis.setAutoRangeStickyZero(false); xAxis.setLowerMargin(0);// w ww . jav a 2 s . c o m xAxis.setUpperMargin(0); yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeStickyZero(false); yAxis.setLowerMargin(0); yAxis.setUpperMargin(0); plot = new DmcRenderablePlot(xAxis, yAxis); plot.setNoDataMessage("No data."); chart = new JFreeChart(plot); chart.setNotify(false); chartPanel = new DmcChartPanel(chart); //chartPanel.setDataset(frame.getDataset()); chartPanel.setMouseZoomable(true, false); chartPanel.setPopupMenu(null); chartPanel.setStatusBarFrame((AbstractPlotComponent) frame); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void configureRangeAxis_PositiveValues() { final double lower = 10; final double upper = 20; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);/*from w w w . j a v a 2s . c om*/ expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getLowerBound() > 0); Assert.assertTrue(axis.getUpperBound() > upper); }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Creates a plot which contains multiple chromosome histograms * @param chromosomeHistograms//from ww w . ja v a 2 s.c o m * the chromosome histograms * @param xAxisLabel * the X axis label * @param yAxisLabel * the Y axis label * @return * the object for the multiple chromosome plots */ public JFreeChart createMultiChromosomeHistogram( final List<? extends ChromosomeHistogramValues> chromosomeHistograms, final String xAxisLabel, final String yAxisLabel) { // create the y-axis that is shared by all of the chromosomes NumberAxis yAxis = new NumberAxis(); if (yAxisLabel != null) { yAxis.setLabel(yAxisLabel); } // the combined plot makes all of the chromosomes to share the same // y-axis but to have thier own x-axis CombinedRangeXYPlot combinedChromosomePlot = new CombinedRangeXYPlot(yAxis); combinedChromosomePlot.setGap(4.0); // iterate through the chromosomes adding a new plot for each one for (ChromosomeHistogramValues currChromHist : chromosomeHistograms) { // use a weight to ensure that the amount of space that the // subgraph gets on the x-axis is proportional to the chromosome's // extent final int currWeight = (int) (currChromHist.getExtentInBasePairs() / 1000 + 1); final NumberAxis currXAxis = new NumberAxis(); currXAxis.setAutoRangeIncludesZero(false); currXAxis.setTickLabelsVisible(false); currXAxis.setTickMarksVisible(false); currXAxis.setLabel(Integer.toString(currChromHist.getChromosomeNumber())); final XYPlot currPlot = this.createSnpIntervalHistogramPlot(currChromHist.getIntervals(), currChromHist.getVisualInterval(), currXAxis, null); combinedChromosomePlot.add(currPlot, currWeight); } JFreeChart multiChromosomeChart = new JFreeChart(combinedChromosomePlot); multiChromosomeChart.removeLegend(); return multiChromosomeChart; }
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.ujmp.jfreechart.MatrixChartPanel.java
public synchronized void redraw() { Dataset dataset = null;/*from w w w . ja v a 2 s.co m*/ dataset = new XYSeriesCollectionWrapper(getMatrix()); // dataset = new CategoryDatasetWrapper(getMatrix()); String title = getMatrix().getLabel(); String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null; // setChart(ChartFactory.createLineChart(title, xLabel, yLabel, // (CategoryDataset) dataset, PlotOrientation.VERTICAL, true, // true, false)); setChart(ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset, PlotOrientation.VERTICAL, true, true, false)); XYPlot plot = getChart().getXYPlot(); if (getConfig().isLogScaleDomain()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setDomainAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } if (getConfig().isLogScaleRange()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setRangeAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } getChart().setTitle((String) null); getChart().setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); for (int i = 0; i < getMatrix().getColumnCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(3)); plot.setRenderer(i, renderer); } plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRangeAxis().setAutoRange(true); plot.getDomainAxis().setAutoRange(true); plot.getDomainAxis().setUpperMargin(0); setMouseZoomable(false); }
From source file:org.perfmon4j.visualvm.chart.DynamicTimeSeriesChart.java
public DynamicTimeSeriesChart(int maxAgeInSeconds) { super(new BorderLayout()); this.maxAgeInSeconds = maxAgeInSeconds; dataset = new TimeSeriesCollection(); renderer = new MyXYRenderer(); renderer.setBaseStroke(NORMAL_STROKE); NumberAxis numberAxis = new NumberAxis(); numberAxis.setAutoRange(false);/*from www . j ava 2 s. co m*/ numberAxis.setRange(new Range(0d, 100d)); DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); dateAxis.setAutoRange(true); dateAxis.setFixedAutoRange(maxAgeInSeconds * 1000); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.SECOND, 30)); XYPlot plot = new XYPlot(dataset, dateAxis, numberAxis, renderer); JFreeChart chart = new JFreeChart(null, null, plot, false); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); chartPanel.setPopupMenu(null); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1), BorderFactory.createLineBorder(Color.black))); add(chartPanel); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CloverTimeChartStrategy.java
/** * // www. ja v a 2s . com */ public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.05D); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setLabel(this.getYAxisLabel()); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); return valueaxis; }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.BarChart.java
@Override protected JFreeChart createGraph() { CategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createBarChart(graphTitle, "", "Number of failures", dataset, PlotOrientation.HORIZONTAL, false, false, false); NumberAxis domainAxis = new NumberAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxis(domainAxis);//from www. j av a 2 s . c o m BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setMaximumBarWidth(MAX_BAR_WIDTH); return chart; }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a xy area chart.//from w w w . j a v a 2 s .c o m * * @param title * the diagram title * @param dataset * the dataset. * @param width * the width of the chart as image * @param height * the height of the chart as image * @return the xy area chart as image */ public static ImageIcon createXYAreaChart(String title, XYDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createXYAreaChart(title, "", "", dataset, PlotOrientation.VERTICAL, false, false, false); Font titleFont = UIManager.getFont("TitledBorder.font"); chart.setBackgroundPaint(null); chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14)); chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor")); chart.setBorderPaint(null); XYPlot plot = chart.getXYPlot(); plot.setInsets(new RectangleInsets(10, 1, 5, 1)); plot.setBackgroundPaint(null); plot.setOutlineVisible(false); plot.setNoDataMessage(_("No data to display.")); ValueAxis domainAxis = new DateAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setTickLabelFont(UIManager.getFont("RootPane.font")); ValueAxis rangeAxis = new NumberAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); plot.setForegroundAlpha(0.5f); return new ImageIcon(chart.createBufferedImage(width, height)); }
From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java
private static JFreeChart createChart(String title) { JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(), PlotOrientation.VERTICAL, false, false, false); result.setPadding(TsCharts.CHART_PADDING); result.setTitle(new TextTitle(title, new Font("SansSerif", Font.PLAIN, 12))); XYPlot plot = result.getXYPlot();/*from w ww. j a va 2 s . c o m*/ plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); LinesThickness linesThickness = LinesThickness.Thin; XYLineAndShapeRenderer daily = new XYLineAndShapeRenderer(true, false); daily.setAutoPopulateSeriesPaint(false); daily.setAutoPopulateSeriesStroke(false); daily.setBaseStroke(TsCharts.getStrongStroke(linesThickness)); plot.setRenderer(DAILY_INDEX, daily); XYDifferenceRenderer difference = new XYDifferenceRenderer(); difference.setAutoPopulateSeriesPaint(false); difference.setAutoPopulateSeriesStroke(false); difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness)); plot.setRenderer(DIFF_INDEX, difference); XYLineAndShapeRenderer smooth = new XYLineAndShapeRenderer(true, false); smooth.setAutoPopulateSeriesPaint(false); smooth.setAutoPopulateSeriesStroke(false); smooth.setBaseStroke(TsCharts.getStrongStroke(linesThickness)); plot.setRenderer(SMOOTH_INDEX, smooth); DateAxis domainAxis = new DateAxis(); domainAxis.setTickMarkPosition(DateTickMarkPosition.START); domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setDomainAxis(domainAxis); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setRangeAxis(rangeAxis); return result; }