01: package com.calipso.reportgenerator.userinterface;
02:
03: import org.jfree.chart.JFreeChart;
04: import org.jfree.chart.ChartFactory;
05: import org.jfree.chart.ChartPanel;
06: import org.jfree.chart.plot.CategoryPlot;
07: import org.jfree.chart.axis.CategoryLabelPosition;
08: import org.jfree.chart.axis.CategoryAxis;
09: import org.jfree.chart.axis.CategoryLabelPositions;
10: import org.jfree.chart.axis.CategoryLabelWidthType;
11: import org.jfree.ui.RectangleAnchor;
12: import org.jfree.ui.TextAnchor;
13: import org.jfree.text.TextBlockAnchor;
14: import org.jfree.data.category.CategoryDataset;
15:
16: import java.awt.*;
17:
18: import com.calipso.reportgenerator.common.LanguageTraslator;
19:
20: /**
21: * Representa un grafico de tipo Barras Verticales en 3D.
22: */
23:
24: public class VerticalBarChart3D extends Charts {
25:
26: /**
27: * Crea una instancia de VerticalBarChart3D.
28: * @param dataset
29: * @param tittle
30: * @param color
31: * @param legend
32: * @param toolTips
33: */
34: public VerticalBarChart3D(CategoryDataset dataset, String tittle,
35: Color color, boolean legend, boolean toolTips,
36: Dimension size, boolean multipleAxis) {
37: super (dataset, tittle, color, legend, toolTips, size,
38: multipleAxis);
39: previewVerticalBarChart3D();
40: this .setVisible(true);
41: }
42:
43: /**
44: * Crea el chart correspondiente a partir de un <code>CategoryDataset</code>,
45: * titulo, leyenda y toolTips
46: */
47: void previewVerticalBarChart3D() {
48: JFreeChart chart = ChartFactory.createBarChart3D(tittle, // chart title
49: LanguageTraslator.traslate("336"), // domain axis label
50: LanguageTraslator.traslate("337"), // range axis label
51: dataset, // data
52: org.jfree.chart.plot.PlotOrientation.VERTICAL, legend, // include legend
53: toolTips, // tooltips
54: false // urls
55: );
56:
57: chart.setBackgroundPaint(color);
58: CategoryPlot plot = chart.getCategoryPlot();
59: CategoryAxis domainAxis = plot.getDomainAxis();
60: CategoryLabelPosition position = new CategoryLabelPosition(
61: RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT,
62: TextAnchor.TOP_RIGHT, -70,
63: CategoryLabelWidthType.RANGE, 70);
64: domainAxis
65: .setCategoryLabelPositions(new CategoryLabelPositions(
66: position, position, position, position));
67:
68: // add the chart to a panel...
69: ChartPanel chartPanel = new ChartPanel(chart);
70: chartPanel.setPreferredSize(getSize());
71: add(chartPanel);
72: }
73: }
|