List of usage examples for org.jfree.chart.axis CategoryAxis getLowerMargin
public double getLowerMargin()
From source file:soap.ui.stats.LineAndShapeRendererMapToBar.java
protected double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series) { double factor = 1.0 - 0.20 - axis.getLowerMargin() - axis.getUpperMargin(); if (categories > 1) { factor = factor - axis.getCategoryMargin(); }// w ww . j a v a 2 s . co m return (space * factor) / (categories * series); }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.renderer.HierarchicalBarRenderer.java
/** * Calculates the bar width and stores it in the renderer state. * * @param plot/* ww w. j av a 2 s .co m*/ * the plot. * @param dataArea * the data area. * @param rendererIndex * the renderer index. * @param state * the renderer state. */ @Override protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width - this calculation differs from the // BarRenderer calculation because the bars are layered on top of one // another, so there is effectively only one bar per category for // the purpose of the bar width calculation CategoryAxis domainAxis = this.getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = dataArea.getWidth(); double maxWidth = space * this.getMaximumBarWidth(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (dataset.getColumnCount()), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } }
From source file:KIDLYRenderer.java
/** * Calculates the available space for each series. * * @param space the space along the entire axis (in Java2D units). * @param axis the category axis./*from ww w . j av a 2 s. c om*/ * @param categories the number of categories. * @param series the number of series. * * @return The width of one series. */ protected double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series) { double factor = 1.0 - getItemMargin() - axis.getLowerMargin() - axis.getUpperMargin(); if (categories > 1) { factor = factor - axis.getCategoryMargin(); } return (space * factor) / (categories * series); }
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java
/** * Creates a sample chart./*from ww w . j ava 2 s .c o m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(BoxAndWhiskerCategoryDataset dataset) { CategoryAxis domainAxis = new CategoryAxis(null); NumberAxis rangeAxis = new NumberAxis(rangeLabel); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(chartTitle, plot); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); //RowCount -- serie count if (dataset.getColumnCount() * dataset.getRowCount() < 5) { domainAxis.setLowerMargin(0.2); domainAxis.setUpperMargin(0.2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(0.5); // domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2); /* System.out.println("1lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ } else if (dataset.getColumnCount() * dataset.getRowCount() < 10) { domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2); domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(renderer.getItemMargin() * 2); else domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2); /*System.out.println("2lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ } if (legendPanelOn) chart.removeLegend(); return chart; }
From source file:extern.NpairsBoxAndWhiskerRenderer.java
/** * Initialises the renderer. This method gets called once at the start of * the process of drawing a chart./*from www.j a v a 2 s .c o m*/ * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { prevX = -1.0; prevY = -1.0; CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info); // calculate the box width CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (dataset.getColumnCount() * dataset.getRowCount()), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } return state; }
From source file:gov.nih.nci.caintegrator.application.graphing.BoxAndWhiskerDotsRenderer.java
/** * Initialises the renderer. This method gets called once at the start of * the process of drawing a chart./* w w w .jav a 2 s.c o m*/ * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info); // calculate the box width CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(used / (dataset.getColumnCount() * dataset.getRowCount())); } else { state.setBarWidth(used); } } if (state.getBarWidth() > maxBarWidth) state.setBarWidth(maxBarWidth); return state; }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java
private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel, BoxAndWhiskerCategoryDataset dataset) { CategoryAxis domainAxis = new CategoryAxis(xLabel); NumberAxis rangeAxis = new NumberAxis(yLabel); // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(title, plot); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //columnCount -- category count //RowCount -- serie count if (dataset.getColumnCount() * dataset.getRowCount() < 5) { domainAxis.setLowerMargin(0.2);//from ww w .ja v a2s . c om domainAxis.setUpperMargin(0.2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(0.5); // domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2); /* System.out.println("lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ } else if (dataset.getColumnCount() * dataset.getRowCount() < 10) { domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2); domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(renderer.getItemMargin() * 2); else domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2); /*System.out.println("lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin()); */ } return chart; }
From source file:edu.dlnu.liuwenpeng.render.BarRenderer.java
/** * Calculates the bar width and stores it in the renderer state. * //from w w w . j a va2 s . c o m * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel, BoxAndWhiskerCategoryDataset dataset) { CategoryAxis domainAxis = new CategoryAxis(xLabel); NumberAxis rangeAxis = new NumberAxis(yLabel); // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(title, plot); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //columnCount -- category count //RowCount -- serie count if (dataset.getColumnCount() * dataset.getRowCount() < 5) { domainAxis.setLowerMargin(0.2);//ww w. j av a 2s .c o m domainAxis.setUpperMargin(0.2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(0.5); // domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2); //System.out.println("lowerMargin="+domainAxis.getLowerMargin()); //System.out.println("ItemMargin="+renderer.getItemMargin()); //System.out.println("CategoryMargin="+domainAxis.getCategoryMargin()); } else if (dataset.getColumnCount() * dataset.getRowCount() < 10) { domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2); domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(renderer.getItemMargin() * 2); else domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2); //System.out.println("lowerMargin="+domainAxis.getLowerMargin()); //System.out.println("ItemMargin="+renderer.getItemMargin()); //System.out.println("CategoryMargin="+domainAxis.getCategoryMargin()); } return chart; }
From source file:KIDLYRenderer.java
/** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot.//from w w w. jav a 2 s.c o m * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } }