List of usage examples for org.jfree.chart.axis Axis setTickLabelInsets
public void setTickLabelInsets(RectangleInsets insets)
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultAxisEditor.java
/** * Sets the properties of the specified axis to match the properties defined * on this panel.//from w w w . ja va2 s. c om * * @param axis * the axis. */ public void setAxisProperties(Axis axis) { axis.setLabel(getLabel()); axis.setLabelFont(getLabelFont()); axis.setLabelPaint(getLabelPaint()); axis.setTickMarksVisible(isTickMarksVisible()); axis.setTickLabelsVisible(isTickLabelsVisible()); axis.setTickLabelFont(getTickLabelFont()); axis.setTickLabelPaint(getTickLabelPaint()); axis.setTickLabelInsets(getTickLabelInsets()); axis.setLabelInsets(getLabelInsets()); }
From source file:daylightchart.options.chart.AxisOptions.java
/** * Sets the properties of the specified axis to match the properties * defined on this panel./*from w ww . ja v a 2s . c o m*/ * * @param axis * the axis. */ void setAxisProperties(final Axis axis) { axis.setLabel(label); if (labelFont != null) { axis.setLabelFont(labelFont); } if (labelPaint != null) { axis.setLabelPaint(labelPaint); } if (labelInsets != null) { axis.setLabelInsets(labelInsets); } // axis.setTickMarksVisible(tickMarksVisible); axis.setTickLabelsVisible(tickLabelsVisible); if (tickLabelFont != null) { axis.setTickLabelFont(tickLabelFont); } if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } }
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);/*from www . ja va2 s . c om*/ } 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:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {// ww w .j a 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 w w . ja v a 2 s . c om 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 ww .j a v a 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 w w w . j av a 2 s . c om 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. } } }