List of usage examples for org.jfree.chart.axis Axis setTickLabelPaint
public void setTickLabelPaint(Paint paint)
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeAxis(Axis axis, ChartParams params, String prefix) { if (params.get(prefix + ChartParams.AXIS_VISIBLE_SUFIX) != null && params.getBoolean(prefix + ChartParams.AXIS_VISIBLE_SUFIX).booleanValue() == false) { axis.setVisible(false);/* ww w . java 2 s .co m*/ } else { if (params.get(prefix + ChartParams.AXIS_LINE_VISIBLE_SUFFIX) != null) { if (params.getBoolean(prefix + ChartParams.AXIS_LINE_VISIBLE_SUFFIX).booleanValue()) { axis.setAxisLineVisible(true); if (params.get(prefix + ChartParams.AXIS_LINE_COLOR_SUFFIX) != null) { axis.setAxisLinePaint(params.getColor(prefix + ChartParams.AXIS_LINE_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_LINE_STROKE_SUFFIX) != null) { axis.setAxisLineStroke(params.getStroke(prefix + ChartParams.AXIS_LINE_STROKE_SUFFIX)); } } else { axis.setAxisLineVisible(false); } } if (params.get(prefix + ChartParams.AXIS_LABEL_SUFFIX) != null) { axis.setLabel(params.getString(prefix + ChartParams.AXIS_LABEL_SUFFIX)); if (params.get(prefix + ChartParams.AXIS_LABEL_FONT_SUFFIX) != null) { axis.setLabelFont(params.getFont(prefix + ChartParams.AXIS_LABEL_FONT_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_LABEL_COLOR_SUFFIX) != null) { axis.setLabelPaint(params.getColor(prefix + ChartParams.AXIS_LABEL_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_LABEL_INSERTS_SUFFIX) != null) { axis.setLabelInsets(params.getRectangleInsets(prefix + ChartParams.AXIS_LABEL_INSERTS_SUFFIX)); } } if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_VISIBLE_SUFFIX) != null) { if (params.getBoolean(prefix + ChartParams.AXIS_TICK_LABEL_VISIBLE_SUFFIX).booleanValue()) { axis.setTickLabelsVisible(true); if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_FONT_SUFFIX) != null) { axis.setTickLabelFont(params.getFont(prefix + ChartParams.AXIS_TICK_LABEL_FONT_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_COLOR_SUFFIX) != null) { axis.setTickLabelPaint(params.getColor(prefix + ChartParams.AXIS_TICK_LABEL_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_INSERTS_SUFFIX) != null) { axis.setTickLabelInsets( params.getRectangleInsets(prefix + ChartParams.AXIS_TICK_LABEL_INSERTS_SUFFIX)); } } else { axis.setTickLabelsVisible(false); } } if (params.get(prefix + ChartParams.AXIS_TICK_MARK_VISIBLE_SUFFIX) != null) { if (params.getBoolean(prefix + ChartParams.AXIS_TICK_MARK_VISIBLE_SUFFIX).booleanValue()) { axis.setTickMarksVisible(true); if (params.get(prefix + ChartParams.AXIS_TICK_MARK_INSIDE_LENGTH_SUFFIX) != null) { axis.setTickMarkInsideLength(params .getFloat(prefix + ChartParams.AXIS_TICK_MARK_INSIDE_LENGTH_SUFFIX).floatValue()); } if (params.get(prefix + ChartParams.AXIS_TICK_MARK_OUTSIDE_LENGTH_SUFFIX) != null) { axis.setTickMarkOutsideLength(params .getFloat(prefix + ChartParams.AXIS_TICK_MARK_OUTSIDE_LENGTH_SUFFIX).floatValue()); } if (params.get(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX) != null) { axis.setTickMarkPaint(params.getColor(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX) != null) { axis.setTickMarkStroke(params.getStroke(prefix + ChartParams.AXIS_TICK_MARK_STROKE_SUFFIX)); } } else { axis.setTickMarksVisible(false); } } } }
From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java
private void customizeAxisEx(ChartDefinition cd, ChartAxis ai, Axis axis) { axis.setLabelPaint(getAxisTitleColor(ai)); axis.setTickLabelPaint(getAxisLabelColor(ai)); axis.setLabelFont(getAxisTitleFont(ai)); axis.setTickLabelFont(getAxisLabelFont(ai)); axis.setVisible(ai.isVisible());//from w w w . j a v a 2 s .com axis.setTickLabelsVisible(ai.isLabelsVisible()); }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
protected void setAxisStyles(Axis axis, UIAxis comp) { axis.setVisible(comp.isVisible());//from ww w . j a v a 2 s . c om axis.setAxisLineVisible(comp.isDrawLine()); axis.setTickLabelsVisible(comp.isDrawTickLabels()); axis.setTickMarksVisible(comp.isDrawTickMarks()); String label = comp.getLabel(); Font labelFont = comp.getLabelFont(); Paint labelColor = comp.getLabelColor(); Paint lineColor = comp.getLineColor(); Font tickLabelFont = comp.getTickLabelFont(); Paint tickLabelColor = comp.getTickLabelColor(); Paint tickMarkColor = comp.getTickMarkColor(); if (label != null) axis.setLabel(label); if (labelFont != null) axis.setLabelFont(labelFont); if (labelColor != null) axis.setLabelPaint(labelColor); if (lineColor != null) axis.setAxisLinePaint(lineColor); if (tickLabelFont != null) axis.setTickLabelFont(tickLabelFont); if (tickLabelColor != null) axis.setTickLabelPaint(tickLabelColor); if (tickMarkColor != null) axis.setTickMarkPaint(tickMarkColor); axis.setTickMarkInsideLength(comp.getTickMarkInsideLength()); axis.setTickMarkOutsideLength(comp.getTickMarkOutsideLength()); if (axis instanceof CategoryAxis) { setCategoryAxisStyles((CategoryAxis) axis, comp); } else if (axis instanceof DateAxis) { setDateAxisStyles((DateAxis) axis, comp); } else if (axis instanceof NumberAxis) { setNumberAxisStyles((NumberAxis) axis, comp); } }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * Sets all the axis formatting options. This includes the colors and fonts to use on * the axis as well as the color to use when drawing the axis line. * * @param axis the axis to format/*from ww w . j a v a2 s . c om*/ * @param labelFont the font to use for the axis label * @param labelColor the color of the axis label * @param tickLabelFont the font to use for each tick mark value label * @param tickLabelColor the color of each tick mark value label * @param tickLabelMask formatting mask for the label. If the axis is a NumberAxis then * the mask should be <code>java.text.DecimalFormat</code> mask, and * if it is a DateAxis then the mask should be a * <code>java.text.SimpleDateFormat</code> mask. * @param verticalTickLabels flag to draw tick labels at 90 degrees * @param lineColor color to use when drawing the axis line and any tick marks */ protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont, Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Color lineColor, boolean isRangeAxis, Comparable<?> axisMinValue, Comparable<?> axisMaxValue) { axis.setLabelFont(fontUtil.getAwtFont(getFont(labelFont), getLocale())); axis.setTickLabelFont(fontUtil.getAwtFont(getFont(tickLabelFont), getLocale())); if (labelColor != null) { axis.setLabelPaint(labelColor); } if (tickLabelColor != null) { axis.setTickLabelPaint(tickLabelColor); } if (lineColor != null) { axis.setAxisLinePaint(lineColor); axis.setTickMarkPaint(lineColor); } TimeZone timeZone = chartContext.getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } // FIXME use locale for formats if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) { ((DecimalFormat) fmt).applyPattern(tickLabelMask); } ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) { fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); } else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) { fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); } else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) { fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); } else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) { fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); } else { fmt = new SimpleDateFormat(tickLabelMask, getLocale()); } if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } // ignore mask for other axis types. } if (verticalTickLabels != null && axis instanceof ValueAxis) { ((ValueAxis) axis).setVerticalTickLabels(verticalTickLabels); } setAxisBounds(axis, isRangeAxis, axisMinValue, axisMaxValue); }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {//from w w w .ja v a 2s .c om Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible.booleanValue()) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {/*w ww .j av a2s.c o m*/ boolean axisTickLabelsVisible = axisSettings.getTickLabelsVisible() == null || axisSettings.getTickLabelsVisible().booleanValue();//FIXMETHEME axis visibility should be dealt with above; axis.setTickLabelsVisible(axisTickLabelsVisible); if (axisTickLabelsVisible) { JRBaseFont font = new JRBaseFont(); JRFontUtil.copyNonNullOwnProperties(axisSettings.getTickLabelFont(), font); JRFontUtil.copyNonNullOwnProperties(tickLabelFont, font); font = new JRBaseFont(getChart(), font); axis.setTickLabelFont(JRFontUtil.getAwtFont(font, getLocale())); RectangleInsets tickLabelInsets = axisSettings.getTickLabelInsets(); if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : axisSettings.getTickLabelPaint() != null ? axisSettings.getTickLabelPaint().getPaint() : null; if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {/*w w w . j ava 2s .c o m*/ Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); else fmt = new SimpleDateFormat(tickLabelMask, getLocale()); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale())); } // ignore mask for other axis types. } } }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {/*from ww w . j a v a 2s . co m*/ boolean axisTickLabelsVisible = axisSettings.getTickLabelsVisible() == null || axisSettings.getTickLabelsVisible();//FIXMETHEME axis visibility should be dealt with above; axis.setTickLabelsVisible(axisTickLabelsVisible); if (axisTickLabelsVisible) { JRBaseFont font = new JRBaseFont(); FontUtil.copyNonNullOwnProperties(axisSettings.getTickLabelFont(), font); FontUtil.copyNonNullOwnProperties(tickLabelFont, font); font = new JRBaseFont(getChart(), font); axis.setTickLabelFont(getFontUtil().getAwtFont(font, getLocale())); RectangleInsets tickLabelInsets = axisSettings.getTickLabelInsets(); if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : axisSettings.getTickLabelPaint() != null ? axisSettings.getTickLabelPaint().getPaint() : null; if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); else fmt = new SimpleDateFormat(tickLabelMask, getLocale()); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale())); } // ignore mask for other axis types. } } }
From source file:org.orbeon.oxf.processor.serializer.legacy.JFreeChartSerializer.java
protected JFreeChart drawChart(ChartConfig chartConfig, final Dataset ds) { JFreeChart chart = null;/*from w w w . j a v a2 s .c om*/ Axis categoryAxis = null; if (ds instanceof XYSeriesCollection) { categoryAxis = new RestrictedNumberAxis(chartConfig.getCategoryTitle()); } else if (ds instanceof TimeSeriesCollection) { categoryAxis = new DateAxis(chartConfig.getCategoryTitle()); ((DateAxis) categoryAxis).setDateFormatOverride(new SimpleDateFormat(chartConfig.getDateFormat())); if (chartConfig.getCategoryLabelAngle() == 90) { ((DateAxis) categoryAxis).setVerticalTickLabels(true); } else { if (chartConfig.getCategoryLabelAngle() != 0) throw new OXFException( "The only supported values of category-label-angle for time-series charts are 0 or 90"); } } else { categoryAxis = new CategoryAxis(chartConfig.getCategoryTitle()); ((CategoryAxis) categoryAxis).setCategoryLabelPositions(chartConfig.getCategoryLabelPosition()); } NumberAxis valueAxis = new RestrictedNumberAxis(chartConfig.getSerieTitle()); valueAxis.setAutoRangeIncludesZero(chartConfig.getSerieAutoRangeIncludeZero()); AbstractRenderer renderer = null; Plot plot = null; switch (chartConfig.getType()) { case ChartConfig.VERTICAL_BAR_TYPE: case ChartConfig.HORIZONTAL_BAR_TYPE: renderer = (ds instanceof ItemPaintCategoryDataset) ? new BarRenderer() { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : new BarRenderer(); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); if (chartConfig.getType() == ChartConfig.VERTICAL_BAR_TYPE) ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); else ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL); break; case ChartConfig.STACKED_VERTICAL_BAR_TYPE: case ChartConfig.STACKED_HORIZONTAL_BAR_TYPE: renderer = (ds instanceof ItemPaintCategoryDataset) ? new StackedBarRenderer() { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : new StackedBarRenderer(); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); if (chartConfig.getType() == ChartConfig.STACKED_VERTICAL_BAR_TYPE) ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); else ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL); break; case ChartConfig.LINE_TYPE: renderer = (ds instanceof ItemPaintCategoryDataset) ? new LineAndShapeRenderer(true, false) { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : (new LineAndShapeRenderer(true, false)); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); break; case ChartConfig.AREA_TYPE: renderer = (ds instanceof ItemPaintCategoryDataset) ? new AreaRenderer() { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : new AreaRenderer(); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); break; case ChartConfig.VERTICAL_BAR3D_TYPE: case ChartConfig.HORIZONTAL_BAR3D_TYPE: categoryAxis = new CategoryAxis3D(chartConfig.getCategoryTitle()); valueAxis = new NumberAxis3D(chartConfig.getSerieTitle()); renderer = (ds instanceof ItemPaintCategoryDataset) ? new BarRenderer3D() { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : new BarRenderer3D(); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); if (chartConfig.getType() == ChartConfig.VERTICAL_BAR3D_TYPE) ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); else ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL); break; case ChartConfig.STACKED_VERTICAL_BAR3D_TYPE: case ChartConfig.STACKED_HORIZONTAL_BAR3D_TYPE: categoryAxis = new CategoryAxis3D(chartConfig.getCategoryTitle()); valueAxis = new NumberAxis3D(chartConfig.getSerieTitle()); renderer = (ds instanceof ItemPaintCategoryDataset) ? new StackedBarRenderer3D() { public Paint getItemPaint(int row, int column) { Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column); if (p != null) return p; else return getSeriesPaint(row); } } : new StackedBarRenderer3D(); plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis, (CategoryItemRenderer) renderer); if (chartConfig.getType() == ChartConfig.STACKED_VERTICAL_BAR3D_TYPE) ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); else ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL); break; case ChartConfig.PIE_TYPE: case ChartConfig.PIE3D_TYPE: categoryAxis = null; valueAxis = null; renderer = null; ExtendedPieDataset pds = (ExtendedPieDataset) ds; plot = chartConfig.getType() == ChartConfig.PIE_TYPE ? new PiePlot(pds) : new PiePlot3D(pds); PiePlot pp = (PiePlot) plot; pp.setLabelGenerator(new StandardPieSectionLabelGenerator()); for (int i = 0; i < pds.getItemCount(); i++) { Paint p = pds.getPaint(i); if (p != null) pp.setSectionPaint(i, p); pp.setExplodePercent(i, pds.getExplodePercent(i)); Paint paint = pds.getPaint(i); if (paint != null) pp.setSectionPaint(i, paint); } break; case ChartConfig.XY_LINE_TYPE: renderer = new XYLineAndShapeRenderer(true, false); plot = new XYPlot((XYDataset) ds, (ValueAxis) categoryAxis, (ValueAxis) valueAxis, (XYLineAndShapeRenderer) renderer); break; case ChartConfig.TIME_SERIES_TYPE: renderer = new XYLineAndShapeRenderer(true, false); plot = new XYPlot((XYDataset) ds, (DateAxis) categoryAxis, (ValueAxis) valueAxis, (XYLineAndShapeRenderer) renderer); break; default: throw new OXFException("Chart Type not supported"); } if (categoryAxis != null) { categoryAxis.setLabelPaint(chartConfig.getTitleColor()); categoryAxis.setTickLabelPaint(chartConfig.getTitleColor()); categoryAxis.setTickMarkPaint(chartConfig.getTitleColor()); if (categoryAxis instanceof RestrictedNumberAxis) { ((RestrictedNumberAxis) categoryAxis).setMaxTicks(chartConfig.getMaxNumOfLabels()); } if (categoryAxis instanceof CategoryAxis && chartConfig.getCategoryMargin() != 0) ((CategoryAxis) categoryAxis).setCategoryMargin(chartConfig.getCategoryMargin()); } if (valueAxis != null) { valueAxis.setLabelPaint(chartConfig.getTitleColor()); valueAxis.setTickLabelPaint(chartConfig.getTitleColor()); valueAxis.setTickMarkPaint(chartConfig.getTitleColor()); ((RestrictedNumberAxis) valueAxis).setMaxTicks(chartConfig.getMaxNumOfLabels()); } if (renderer != null) { if (renderer instanceof XYLineAndShapeRenderer) { ((XYLineAndShapeRenderer) renderer).setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); } else { ((CategoryItemRenderer) renderer) .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } if (renderer instanceof BarRenderer) ((BarRenderer) renderer).setItemMargin(chartConfig.getBarMargin()); int j = 0; for (Iterator i = chartConfig.getValueIterator(); i.hasNext();) { Value v = (Value) i.next(); renderer.setSeriesPaint(j, v.getColor()); j++; } } plot.setOutlinePaint(chartConfig.getTitleColor()); CustomLegend legend = chartConfig.getLegendConfig(); chart = new JFreeChart(chartConfig.getTitle(), TextTitle.DEFAULT_FONT, plot, false); if (legend.isVisible()) { legend.setSources(new LegendItemSource[] { plot }); chart.addLegend(legend); } chart.setBackgroundPaint(chartConfig.getBackgroundColor()); TextTitle textTitle = new TextTitle(chartConfig.getTitle(), TextTitle.DEFAULT_FONT, chartConfig.getTitleColor(), TextTitle.DEFAULT_POSITION, TextTitle.DEFAULT_HORIZONTAL_ALIGNMENT, TextTitle.DEFAULT_VERTICAL_ALIGNMENT, TextTitle.DEFAULT_PADDING); chart.setTitle(textTitle); return chart; }