List of usage examples for org.jfree.eastwood GCategoryAxis GCategoryAxis
public GCategoryAxis()
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a bar chart with the specified orientation and using the * specified renderer.//www . ja v a 2 s. c o m * * @param orientation the plot orientation. * @param renderer the renderer. * * @return A bar chart. */ private static JFreeChart createBarChart(PlotOrientation orientation, BarRenderer renderer) { GCategoryPlot plot = new GCategoryPlot(); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(null); plot.setRenderer(renderer); StandardBarPainter bp = new StandardBarPainter(); renderer.setBarPainter(bp); renderer.setShadowVisible(false); renderer.setBasePaint(new Color(0xFFCC33)); renderer.setAutoPopulateSeriesPaint(false); renderer.setItemLabelsVisible(true); renderer.setItemLabelGenerator(new GCategoryPlot.LabelGenerator()); renderer.setItemLabelPaint(new Color(0x333435)); renderer.setDrawBarOutline(false); renderer.setItemMargin(0.07); if (orientation == PlotOrientation.HORIZONTAL) { renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT)); renderer.setPositiveItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_RIGHT)); } else { renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setPositiveItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER)); } GCategoryAxis xAxis = new GCategoryAxis(); xAxis.setAxisLineVisible(true); xAxis.setTickLabelsVisible(false); xAxis.setMaximumCategoryLabelLines(5); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setAxisLineVisible(true); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Processes a string that indicates the axes that should be visible on * the plot.// w ww. j av a 2 s .co 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); } } }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Processes a string that indicates the axes that should be visible on * the plot./* w ww . j av a 2 s .co 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); } } }