KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > VerticalBarChart3D


1 package com.calipso.reportgenerator.userinterface;
2
3 import org.jfree.chart.JFreeChart;
4 import org.jfree.chart.ChartFactory;
5 import org.jfree.chart.ChartPanel;
6 import org.jfree.chart.plot.CategoryPlot;
7 import org.jfree.chart.axis.CategoryLabelPosition;
8 import org.jfree.chart.axis.CategoryAxis;
9 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 JavaDoc tittle, Color color, boolean legend, boolean toolTips, Dimension size, boolean multipleAxis) {
35       super(dataset, tittle, color, legend, toolTips, size, multipleAxis);
36       previewVerticalBarChart3D();
37       this.setVisible(true);
38     }
39
40
41     /**
42      * Crea el chart correspondiente a partir de un <code>CategoryDataset</code>,
43      * titulo, leyenda y toolTips
44      */

45     void previewVerticalBarChart3D(){
46         JFreeChart chart = ChartFactory.createBarChart3D(
47                                                   tittle, // chart title
48
LanguageTraslator.traslate("336"), // domain axis label
49
LanguageTraslator.traslate("337"), // range axis label
50
dataset, // data
51
org.jfree.chart.plot.PlotOrientation.VERTICAL,
52                                                   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, TextAnchor.TOP_RIGHT,-70, CategoryLabelWidthType.RANGE, 70);
62         domainAxis.setCategoryLabelPositions(new CategoryLabelPositions(position,position,position,position));
63
64         // add the chart to a panel...
65
ChartPanel chartPanel = new ChartPanel(chart);
66         chartPanel.setPreferredSize(getSize());
67         add(chartPanel);
68     }
69 }
70
71
72
Popular Tags