List of usage examples for org.jfree.chart.plot CategoryPlot setDomainAxis
public void setDomainAxis(int index, CategoryAxis axis)
From source file:net.sf.jsfcomp.chartcreator.utils.ChartAxisUtils.java
public static void createCategorySeriesAxis(JFreeChart chart, ChartAxisData chartAxisData, int axisIndex) { CategoryPlot plot = chart.getCategoryPlot(); if (chartAxisData.isDomain()) { CategoryAxis axis = new CategoryAxis(chartAxisData.getLabel()); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); }/* ww w.java 2 s .c o m*/ if (chartAxisData.isVerticalTickLabels()) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } plot.setDomainAxis(plot.getDomainAxisCount() - 1, axis); } else { ValueAxis axis = createNumberAxis(chart, chartAxisData); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); } plot.setRangeAxis(axis); } }
From source file:org.operamasks.faces.render.graph.CompositeChartRenderer.java
private JFreeChart createCategoryCompositeChart(List<JFreeChart> subcharts, UIChart comp) { CategoryPlot compositePlot = new CategoryPlot(); compositePlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); compositePlot.setOrientation(getChartOrientation(comp)); for (int i = 0; i < subcharts.size(); i++) { CategoryPlot subplot = (CategoryPlot) subcharts.get(i).getPlot(); compositePlot.setDataset(i, subplot.getDataset()); compositePlot.setRenderer(i, subplot.getRenderer()); if (i == 0) { // Axis zero is always available. compositePlot.setDomainAxis(0, subplot.getDomainAxis()); compositePlot.setRangeAxis(0, subplot.getRangeAxis()); } else {// www. j a v a 2s. c o m int yAxisMap = getRangeAxisMap(comp, i); ValueAxis yAxis = null; if (yAxisMap == -1) { yAxisMap = 0; // map to axis zero by default } else if (yAxisMap == i) { yAxis = subplot.getRangeAxis(); // add subplot axis to composite plot } compositePlot.setRangeAxis(i, yAxis); compositePlot.mapDatasetToRangeAxis(i, yAxisMap); } } return new JFreeChart(null, null, compositePlot, false); }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Processes a string that indicates the axes that should be visible on * the plot./*from ww w. j av a 2 s . c o m*/ * * @param plot the plot. * @param axisStr the axis specification. * @param axes a list that will be populated with any axes added to the * plot. */ private static void processAxisStrH(CategoryPlot plot, String axisStr, List axes) { int xAxisCount = 0; int yAxisCount = 0; for (int i = 0; i < axisStr.length(); i++) { char c = axisStr.charAt(i); if (c == 'y') { if (yAxisCount == 0) { CategoryAxis axis = plot.getDomainAxis(); axis.setTickLabelsVisible(true); axes.add(axis); yAxisCount++; } else { GCategoryAxis axis = new GCategoryAxis(); axis.setAxisLineVisible(false); plot.setDomainAxis(yAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); yAxisCount++; } } else if (c == 'x') { if (xAxisCount == 0) { Axis axis = plot.getRangeAxis(); axis.setTickLabelsVisible(true); axis.setTickMarksVisible(true); axes.add(axis); xAxisCount++; } else { GValueAxis axis = new GValueAxis(); axis.setAxisLineVisible(false); plot.setRangeAxis(xAxisCount, axis); plot.setRangeAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); xAxisCount++; } } else if (c == 't') { GValueAxis axis = new GValueAxis(); plot.setRangeAxis(xAxisCount, axis); plot.setRangeAxisLocation(yAxisCount, AxisLocation.TOP_OR_LEFT); axes.add(axis); xAxisCount++; } else if (c == 'r') { GCategoryAxis axis = new GCategoryAxis(); plot.setDomainAxis(yAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_RIGHT); axes.add(axis); yAxisCount++; } else if (c == ',') { // nothing to do } else { throw new RuntimeException("Bad character " + c); } } }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Processes a string that indicates the axes that should be visible on * the plot.//from w w w . ja v a 2 s. c o m * * @param plot the plot. * @param axisStr the axis specification. * @param axes a list that will be populated with any axes added to the * plot. */ private static void processAxisStrV(CategoryPlot plot, String axisStr, List axes) { int xAxisCount = 0; int yAxisCount = 0; for (int i = 0; i < axisStr.length(); i++) { char c = axisStr.charAt(i); if (c == 'x') { if (xAxisCount == 0) { CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setTickLabelsVisible(true); axes.add(xAxis); xAxisCount++; } else { GCategoryAxis axis = new GCategoryAxis(); axis.setAxisLineVisible(false); plot.setDomainAxis(xAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); xAxisCount++; } } else if (c == 'y') { if (yAxisCount == 0) { Axis yAxis = plot.getRangeAxis(); yAxis.setTickLabelsVisible(true); yAxis.setTickMarksVisible(true); axes.add(yAxis); yAxisCount++; } else { GValueAxis axis = new GValueAxis(); axis.setAxisLineVisible(false); plot.setRangeAxis(yAxisCount, axis); plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); yAxisCount++; } } else if (c == 'r') { GValueAxis axis = new GValueAxis(); plot.setRangeAxis(yAxisCount, axis); plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_RIGHT); axes.add(axis); yAxisCount++; } else if (c == 't') { GCategoryAxis axis = new GCategoryAxis(); axis.setAxisLineVisible(false); plot.setDomainAxis(xAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.TOP_OR_LEFT); axes.add(axis); xAxisCount++; } else if (c == ',') { // nothing to do } else { throw new RuntimeException("Bad character " + c); } } }