List of usage examples for org.jfree.chart.axis Axis setAxisLinePaint
public void setAxisLinePaint(Paint paint)
From source file:org.openfaces.component.chart.impl.helpers.AxisUtil.java
public static void setupAxisPresentation(String label, Axis axis, FakeAxisStyle axisStyle) { StyleObjectModel model = axisStyle.getStyleObjectModel(); StyleBorderModel border = model.getBorder(); if (border != null) { if (border.getColor() != null) { axis.setAxisLinePaint(border.getColor()); }/* ww w.j ava 2s . c om*/ if (!border.isNone()) { axis.setAxisLineVisible(true); axis.setAxisLineStroke(PropertiesConverter.toStroke(border)); axis.setTickMarkPaint(border.getColor()); axis.setTickMarksVisible(true); if (!axis.isTickMarksVisible()) axis.setTickMarksVisible(false); } if (border.getStyle().equalsIgnoreCase("none")) { axis.setAxisLineVisible(false); axis.setTickMarksVisible(false); if (axis.isTickMarksVisible()) axis.setTickMarksVisible(true); } } axis.setTickLabelsVisible(axisStyle.isTickLabelsVisible()); if (axisStyle.isLabelVisible() && label != null) { axis.setLabel(label); axis.setLabelPaint(model.getColor()); axis.setLabelFont(CSSUtil.getFont(model)); } if (axisStyle.isTickLabelsVisible()) { axis.setTickLabelsVisible(true); axis.setTickLabelPaint(model.getColor()); axis.setTickLabelFont(CSSUtil.getFont(model)); } else { axis.setTickLabelsVisible(false); } Double tickInterval = axisStyle.getTickInterval(); if (tickInterval != null && tickInterval != 0 && axis instanceof NumberAxis) { NumberAxis numberAxis = (NumberAxis) axis; if (tickInterval > 0) { NumberTickUnit tickUnit = new NumberTickUnit(tickInterval); numberAxis.setTickUnit(tickUnit); } else if (tickInterval == -1) { TickUnitSource tickUnits = NumberAxis.createIntegerTickUnits(); numberAxis.setStandardTickUnits(tickUnits); } else { throw new FacesException("tickInterval must be a positive number for a fixed tick interval, " + "or -1 for automatic integer tick selection: " + tickInterval); } numberAxis.setMinorTickMarksVisible(true); numberAxis.setMinorTickCount(2); numberAxis.setMinorTickMarkOutsideLength(3); numberAxis.setMinorTickMarkInsideLength(3); numberAxis.setTickMarkInsideLength(5); numberAxis.setTickMarkOutsideLength(5); } axis.setTickMarkInsideLength(axisStyle.getTickInsideLength()); axis.setTickMarkOutsideLength(axisStyle.getTickOutsideLength()); if (axisStyle.getMinorTicksVisible()) { axis.setMinorTickMarksVisible(true); if (axis instanceof ValueAxis) ((ValueAxis) axis).setMinorTickCount(axisStyle.getMinorTickCount() + 1); axis.setMinorTickMarkInsideLength(axisStyle.getMinorTickInsideLength()); axis.setMinorTickMarkOutsideLength(axisStyle.getMinorTickOutsideLength()); } else { axis.setMinorTickMarksVisible(false); } }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.ChartAxisFactory.java
public static void formatAxis(PlotConfiguration plotConfiguration, Axis axis) { Color axisColor = plotConfiguration.getAxisLineColor(); if (axis != null) { axis.setAxisLinePaint(axisColor); axis.setAxisLineStroke(new BasicStroke(plotConfiguration.getAxisLineWidth())); axis.setLabelPaint(axisColor);/* www . ja v a 2s .c om*/ axis.setTickLabelPaint(axisColor); } }
From source file:org.jreserve.dummy.plot.charts.AbstractChart.java
protected void formatAxisColors(Axis axis) { Color color = format.getForeColor(); axis.setAxisLinePaint(color); axis.setTickMarkPaint(color);//from ww w .ja v a2 s . c o m axis.setTickLabelPaint(color); axis.setLabelPaint(color); }
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);/* www.j ava 2 s. com*/ } 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.manydesigns.portofino.chart.Chart2DGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);/* w ww. ja va2 s . c om*/ Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // ? plot.setForegroundAlpha(1.0f); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:com.redhat.thermostat.byteman.chart.swing.SwingBarChart.java
private void colorAxis(Axis ax) { ax.setAxisLinePaint(toColor(cf.axisLinePaint)); ax.setTickMarkPaint(toColor(cf.tickMarkPaint)); ax.setTickLabelPaint(toColor(cf.tickLabelPaint)); }
From source file:com.manydesigns.portofino.chart.ChartBarGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);// w w w . j av a 2 s .co m Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer || renderer instanceof BarRenderer3D) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); // ? setSeriesItemLabelGenerator barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.05); // ????? // ??90,??/3.14 ItemLabelPosition itemLabelPositionFallback = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT, TextAnchor.HALF_ASCENT_LEFT, -1.57D); // ??labelposition // barRenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback); // barRenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setItemLabelsVisible(true); // ? barRenderer.setBaseOutlinePaint(Color.BLACK); // ??? barRenderer.setDrawBarOutline(true); // ??? barRenderer.setItemMargin(0.0); // ? barRenderer.setIncludeBaseInRange(true); barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); // ? plot.setForegroundAlpha(1.0f); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:com.manydesigns.portofino.chart.ChartStackedBarGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);/* w w w .j av a 2 s .c om*/ Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add // ? barRenderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.06); } if (renderer instanceof StackedBarRenderer3D || renderer instanceof StackedBarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); // hongliangpan add // ? setSeriesItemLabelGenerator barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); // bar??? barRenderer.setMinimumBarLength(0.02); // barRenderer.setMaximumBarWidth(0.06); // ????? ItemLabelPosition itemLabelPositionFallback = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT, TextAnchor.HALF_ASCENT_LEFT, -1.57D); // ??labelposition barRenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback); barRenderer.setItemLabelsVisible(true); barRenderer.setItemMargin(10); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:ec.util.chart.swing.JTimeSeriesChart.java
private void onColorSchemeSupportChange(Axis axis) { axis.setAxisLinePaint(colorSchemeSupport.getAxisColor()); axis.setTickLabelPaint(colorSchemeSupport.getAxisColor()); axis.setTickMarkPaint(colorSchemeSupport.getAxisColor()); }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
protected void setAxisStyles(Axis axis, UIAxis comp) { axis.setVisible(comp.isVisible());//from www. ja v a 2 s. c o m 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); } }