/** * Sets the font for the sublabels and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param font the font (<code>null</code> not permitted). * * @see #getSubLabelFont() */ public void setSubLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.sublabelFont = font; notifyListeners(new AxisChangeEvent(this)); }
/** * {@inheritDoc} * * Adds a sublabel for a category. */ @Override public void addSubLabel(@SuppressWarnings("rawtypes") Comparable category, String label) { super.addSubLabel(category, convertLabel(label)); }
public JFreeChart createLayeredBarChart(String title, String domainLabel, String rangeLabel, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(title, domainLabel, rangeLabel, dataset, PlotOrientation.HORIZONTAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ExtendedCategoryAxis domainAxis = new ExtendedCategoryAxis(null); domainAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12)); domainAxis.setCategoryMargin(0.20); //domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(domainAxis); LayeredBarRenderer renderer = new LayeredBarRenderer(); renderer.setDrawBarOutline(false); plot.setRenderer(renderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(1, gp1); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(2, gp2); return chart; }
/** * Sets the paint for the sublabels and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param paint the paint (<code>null</code> not permitted). * * @see #getSubLabelPaint() */ public void setSubLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.sublabelPaint = paint; notifyListeners(new AxisChangeEvent(this)); }
/** * {@inheritDoc} * * Adds a sublabel for a category. */ @Override public void addSubLabel(@SuppressWarnings("rawtypes") Comparable category, String label) { super.addSubLabel(category, convertLabel(label)); }
/** * Sets the font for the sublabels and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param font the font ({@code null} not permitted). * * @see #getSubLabelFont() */ public void setSubLabelFont(Font font) { Args.nullNotPermitted(font, "font"); this.sublabelFont = font; notifyListeners(new AxisChangeEvent(this)); }
/** * @param barChart TODO * @param subLabelClass */ private static void addSubLabels(JFreeChart barChart, String subLabelClass) { ExtendedCategoryAxis subLabels; CategoryPlot plot = barChart.getCategoryPlot(); try { subLabels = (ExtendedCategoryAxis) Class.forName(subLabelClass).newInstance(); List<?> cats = plot.getCategories(); for(int i=0; i<cats.size(); i++) { subLabels.addSubLabel((Comparable<?>)cats.get(i), cats.get(i).toString()); } plot.setDomainAxis(subLabels); } catch (InstantiationException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (IllegalAccessException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (ClassNotFoundException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } }
/** * Sets the paint for the sublabels and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param paint the paint ({@code null} not permitted). * * @see #getSubLabelPaint() */ public void setSubLabelPaint(Paint paint) { Args.nullNotPermitted(paint, "paint"); this.sublabelPaint = paint; notifyListeners(new AxisChangeEvent(this)); }
/** * @param barChart TODO * @param subLabelClass */ private static void addSubLabels(JFreeChart barChart, String subLabelClass) { ExtendedCategoryAxis subLabels; CategoryPlot plot = barChart.getCategoryPlot(); try { subLabels = (ExtendedCategoryAxis) Class.forName(subLabelClass).newInstance(); List<?> cats = plot.getCategories(); for(int i=0; i<cats.size(); i++) { subLabels.addSubLabel((Comparable<?>)cats.get(i), cats.get(i).toString()); } plot.setDomainAxis(subLabels); } catch (InstantiationException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (IllegalAccessException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (ClassNotFoundException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } }