Source Code Cross Referenced for ChartUI.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.common.HeaderTableModel;
004:        import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
005:        import javax.swing.*;
006:        import java.awt.*;
007:        import java.awt.event.*;
008:
009:        import org.jfree.data.category.DefaultCategoryDataset;
010:        import org.jfree.data.category.CategoryDataset;
011:
012:        /** Representa la interfaz grafica generada cuando se presiona sobre
013:         *  el boton Grafico de la interfaz principal.
014:         */
015:        public class ChartUI extends JFrame implements  ItemListener,
016:                ActionListener, KeyListener {
017:
018:            private ChartCustomizer chartCustomizer;
019:            private ReportGeneratorConfiguration conf;
020:            private PivotTable pivotTable;
021:            private JPanel northPanel;
022:            private JPanel mainPanel;
023:            private JRadioButton btRow;
024:            private JRadioButton btCol;
025:            private JComboBox cbChart;
026:            private JButton btAceptar;
027:            private JButton btCancelar;
028:            private ChartData chartData;
029:            private ButtonGroup btGroup;
030:            private JButton btChartCustomizer;
031:            private JPanel btsPanel;
032:
033:            /**
034:             * Inicializa una instancia de ChartUI
035:             * @param pivotTable contiene los componentes necesarios que utiliza esta clase
036:             */
037:            public ChartUI(PivotTable pivotTable,
038:                    ReportGeneratorConfiguration conf) {
039:                Image icon = conf.getImage("icon");
040:                if (icon != null) {
041:                    setIconImage(icon);
042:                }
043:                this .conf = conf;
044:                this .pivotTable = pivotTable;
045:                initialize();
046:                HeaderTableModel rowHeaderTableModel = (HeaderTableModel) pivotTable
047:                        .getRowHeaderjTable().getModel();
048:                HeaderTableModel columnHeaderTableModel = (HeaderTableModel) pivotTable
049:                        .getColumnHeaderjTable().getModel();
050:                chartData = new ChartData(pivotTable.getDatajTable(),
051:                        rowHeaderTableModel, columnHeaderTableModel);
052:                this .pack();
053:                this .setResizable(false);
054:                this 
055:                        .setTitle(com.calipso.reportgenerator.common.LanguageTraslator
056:                                .traslate("238"));
057:                java.awt.Dimension screenSize = java.awt.Toolkit
058:                        .getDefaultToolkit().getScreenSize();
059:                setLocation((screenSize.width - 250) / 2,
060:                        (screenSize.height - 200) / 2);
061:                this .setVisible(true);
062:            }
063:
064:            /**
065:             * Crea los componentes graficos
066:             */
067:            private void initialize() {
068:                Container container = this .getContentPane();
069:
070:                createCboBox();
071:
072:                btRow = new JRadioButton(
073:                        com.calipso.reportgenerator.common.LanguageTraslator
074:                                .traslate("110"));
075:                btRow.addActionListener(this );
076:                btRow.setSelected(true);
077:                btCol = new JRadioButton(
078:                        com.calipso.reportgenerator.common.LanguageTraslator
079:                                .traslate("111"));
080:                btCol.addActionListener(this );
081:                northPanel = new JPanel(new FlowLayout());
082:                btGroup = new ButtonGroup();
083:                btGroup.add(btRow);
084:                btGroup.add(btCol);
085:                northPanel.add(btRow);
086:                northPanel.add(btCol);
087:                northPanel.setBorder(BorderFactory.createTitledBorder(
088:                        BorderFactory.createEtchedBorder(),
089:                        com.calipso.reportgenerator.common.LanguageTraslator
090:                                .traslate("240")));
091:
092:                mainPanel = new JPanel(new BorderLayout());
093:                btChartCustomizer = new JButton(
094:                        com.calipso.reportgenerator.common.LanguageTraslator
095:                                .traslate("239"));
096:                btChartCustomizer.addActionListener(this );
097:                btChartCustomizer.addKeyListener(this );
098:                mainPanel.add(cbChart, BorderLayout.CENTER);
099:                mainPanel.add(btChartCustomizer, BorderLayout.EAST);
100:                mainPanel.setBorder(BorderFactory.createTitledBorder(
101:                        BorderFactory.createEtchedBorder(),
102:                        com.calipso.reportgenerator.common.LanguageTraslator
103:                                .traslate("241")));
104:
105:                btAceptar = new JButton(
106:                        com.calipso.reportgenerator.common.LanguageTraslator
107:                                .traslate("112"));
108:                btAceptar.addActionListener(this );
109:                btAceptar.setFocusable(true);
110:                btAceptar.setFocusTraversalKeysEnabled(true);
111:                btAceptar.addKeyListener(this );
112:                btCancelar = new JButton(
113:                        com.calipso.reportgenerator.common.LanguageTraslator
114:                                .traslate("113"));
115:                btCancelar.addActionListener(this );
116:                btCancelar.addKeyListener(this );
117:                btsPanel = new JPanel(new FlowLayout());
118:                btsPanel.add(btAceptar);
119:                btsPanel.add(btCancelar);
120:
121:                container.add(northPanel, BorderLayout.NORTH);
122:                container.add(mainPanel, BorderLayout.CENTER);
123:                container.add(btsPanel, BorderLayout.SOUTH);
124:            }
125:
126:            /**
127:             * Crea un JComboBox dependiendo del rango seleccionado
128:             * en la tabla de datos
129:             */
130:            private void createCboBox() {
131:                cbChart = new JComboBox();
132:                JTable table = pivotTable.getDatajTable();
133:                int selectedColumnCount = table.getSelectedColumnCount();
134:                int selectedRowCount = table.getSelectedRowCount();
135:                if (selectedColumnCount > 1 && selectedRowCount > 1) {
136:                    cbChart
137:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
138:                                    .traslate("114"));
139:                    cbChart
140:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
141:                                    .traslate("115"));
142:                    cbChart
143:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
144:                                    .traslate("245"));
145:                    cbChart
146:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
147:                                    .traslate("242"));
148:                    cbChart
149:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
150:                                    .traslate("243"));
151:                    cbChart
152:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
153:                                    .traslate("244"));
154:                } else {
155:                    cbChart
156:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
157:                                    .traslate("114"));
158:                    cbChart
159:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
160:                                    .traslate("116"));
161:                    cbChart
162:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
163:                                    .traslate("115"));
164:                    cbChart
165:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
166:                                    .traslate("245"));
167:                    cbChart
168:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
169:                                    .traslate("242"));
170:                    cbChart
171:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
172:                                    .traslate("243"));
173:                    cbChart
174:                            .addItem(com.calipso.reportgenerator.common.LanguageTraslator
175:                                    .traslate("244"));
176:                }
177:                cbChart.addItemListener(this );
178:            }
179:
180:            /***
181:             * Evento que se ejecuta al realizar una accion sobre el JComboBox
182:             */
183:            public void itemStateChanged(ItemEvent e) {
184:            }
185:
186:            /**
187:             * Ejecuta el chart seleccionado
188:             * @param isRow determina si la ejecucion se realiza en base a filas o columnas
189:             */
190:            private void executeChart(boolean isRow) {
191:
192:                String tittle = pivotTable.getReportResult().getReportSpec()
193:                        .getDescription();
194:                JFrame frame = new JFrame();
195:                Image icon = conf.getImage("icon");
196:                if (icon != null) {
197:                    frame.setIconImage(icon);
198:                }
199:                frame.setSize(600, 500);
200:                JScrollPane pane;
201:                if (cbChart.getSelectedItem().toString().equals(
202:                        com.calipso.reportgenerator.common.LanguageTraslator
203:                                .traslate("114"))) {
204:                    DefaultCategoryDataset dataset = chartData
205:                            .getDatasetForChart(isRow);
206:                    if (chartCustomizer == null) {
207:                        AreaChart areaChart = new AreaChart(dataset, tittle,
208:                                Color.white, true, true, frame.getSize(), false);
209:                        pane = new JScrollPane(areaChart);
210:                        frame.getContentPane().add(pane);
211:                        frame.pack();
212:                        frame.setVisible(true);
213:                        return;
214:                    }
215:                    AreaChart areaChart = new AreaChart(dataset, tittle,
216:                            chartCustomizer.getColor(), chartCustomizer
217:                                    .isLegend(), chartCustomizer.isTooltips(),
218:                            frame.getSize(), chartCustomizer.isMultipleAxis());
219:                    pane = new JScrollPane(areaChart);
220:                    frame.getContentPane().add(pane);
221:                    frame.pack();
222:                    frame.setVisible(true);
223:                    return;
224:                }
225:                if (cbChart.getSelectedItem().toString().equals(
226:                        com.calipso.reportgenerator.common.LanguageTraslator
227:                                .traslate("116"))) {
228:                    double chartDataArray[] = chartData.getChartDataArray();
229:                    String descripcion[] = chartData
230:                            .getDescriptionForChart(null);
231:                    if (chartCustomizer == null) {
232:                        PieChart pieChart = new PieChart(chartDataArray,
233:                                descripcion, tittle, true, true);
234:                        pane = new JScrollPane(pieChart);
235:                        frame.getContentPane().add(pane);
236:                        frame.pack();
237:                        frame.setVisible(true);
238:                        return;
239:                    }
240:                    PieChart pieChart = new PieChart(chartDataArray,
241:                            descripcion, tittle, chartCustomizer.isLegend(),
242:                            chartCustomizer.isTooltips());
243:                    pane = new JScrollPane(pieChart);
244:                    frame.getContentPane().add(pane);
245:                    frame.pack();
246:                    frame.setVisible(true);
247:                    return;
248:                }
249:                if (cbChart.getSelectedItem().toString().equals(
250:                        com.calipso.reportgenerator.common.LanguageTraslator
251:                                .traslate("115"))) {
252:                    CategoryDataset dataset = chartData
253:                            .getDatasetForChart(isRow);
254:                    if (chartCustomizer == null) {
255:                        HorizontalBarChart horBarChart = new HorizontalBarChart(
256:                                dataset, tittle, Color.white, true, true, frame
257:                                        .getSize(), false);
258:                        pane = new JScrollPane(horBarChart);
259:                        frame.getContentPane().add(pane);
260:                        frame.pack();
261:                        frame.setVisible(true);
262:                        return;
263:                    }
264:                    HorizontalBarChart horBarChart = new HorizontalBarChart(
265:                            dataset, tittle, chartCustomizer.getColor(),
266:                            chartCustomizer.isLegend(), chartCustomizer
267:                                    .isTooltips(), frame.getSize(),
268:                            chartCustomizer.isMultipleAxis());
269:                    pane = new JScrollPane(horBarChart);
270:                    frame.getContentPane().add(pane);
271:                    frame.pack();
272:                    frame.setVisible(true);
273:                    return;
274:                }
275:                if (cbChart.getSelectedItem().toString().equals(
276:                        com.calipso.reportgenerator.common.LanguageTraslator
277:                                .traslate("242"))) {
278:                    CategoryDataset dataset = chartData
279:                            .getDatasetForChart(isRow);
280:
281:                    if (chartCustomizer == null) {
282:                        LineChart lineChart = new LineChart(dataset, tittle,
283:                                Color.white, true, true, frame.getSize(), false);
284:                        pane = new JScrollPane(lineChart);
285:                        frame.getContentPane().add(pane);
286:                        frame.pack();
287:                        frame.setVisible(true);
288:                        return;
289:                    }
290:                    LineChart lineChart = new LineChart(dataset, tittle,
291:                            chartCustomizer.getColor(), chartCustomizer
292:                                    .isLegend(), chartCustomizer.isTooltips(),
293:                            frame.getSize(), chartCustomizer.isMultipleAxis());
294:                    pane = new JScrollPane(lineChart);
295:                    frame.getContentPane().add(pane);
296:                    frame.pack();
297:                    frame.setVisible(true);
298:                    return;
299:                }
300:                if (cbChart.getSelectedItem().toString().equals(
301:                        com.calipso.reportgenerator.common.LanguageTraslator
302:                                .traslate("243"))) {
303:                    CategoryDataset dataset = chartData
304:                            .getDatasetForChart(isRow);
305:                    if (chartCustomizer == null) {
306:                        VerticalBarChart verticalBarChart = new VerticalBarChart(
307:                                dataset, tittle, Color.white, true, true, frame
308:                                        .getSize(), false);
309:                        pane = new JScrollPane(verticalBarChart);
310:                        frame.getContentPane().add(pane);
311:                        frame.pack();
312:                        frame.setVisible(true);
313:                        return;
314:                    }
315:                    VerticalBarChart verticalBarChart = new VerticalBarChart(
316:                            dataset, tittle, chartCustomizer.getColor(),
317:                            chartCustomizer.isLegend(), chartCustomizer
318:                                    .isTooltips(), frame.getSize(),
319:                            chartCustomizer.isMultipleAxis());
320:                    pane = new JScrollPane(verticalBarChart);
321:                    frame.getContentPane().add(pane);
322:                    frame.pack();
323:                    frame.setVisible(true);
324:                    return;
325:                }
326:                if (cbChart.getSelectedItem().toString().equals(
327:                        com.calipso.reportgenerator.common.LanguageTraslator
328:                                .traslate("244"))) {
329:                    CategoryDataset dataset = chartData
330:                            .getDatasetForChart(isRow);
331:                    if (chartCustomizer == null) {
332:                        VerticalBarChart3D verticalBarChart3D = new VerticalBarChart3D(
333:                                dataset, tittle, Color.white, true, true, frame
334:                                        .getSize(), false);
335:                        pane = new JScrollPane(verticalBarChart3D);
336:                        frame.getContentPane().add(pane);
337:                        frame.pack();
338:                        frame.setVisible(true);
339:                        return;
340:                    }
341:                    VerticalBarChart3D verticalBarChart3D = new VerticalBarChart3D(
342:                            dataset, tittle, chartCustomizer.getColor(),
343:                            chartCustomizer.isLegend(), chartCustomizer
344:                                    .isTooltips(), frame.getSize(),
345:                            chartCustomizer.isMultipleAxis());
346:                    pane = new JScrollPane(verticalBarChart3D);
347:                    frame.getContentPane().add(pane);
348:                    frame.pack();
349:                    frame.setVisible(true);
350:                    return;
351:                }
352:                if (cbChart.getSelectedItem().toString().equals(
353:                        com.calipso.reportgenerator.common.LanguageTraslator
354:                                .traslate("245"))) {
355:                    CategoryDataset dataset = chartData
356:                            .getDatasetForChart(isRow);
357:                    if (chartCustomizer == null) {
358:                        HorizontalBarChart3D horizontalBarChart3D = new HorizontalBarChart3D(
359:                                dataset, tittle, Color.white, true, true, frame
360:                                        .getSize(), false);
361:                        pane = new JScrollPane(horizontalBarChart3D);
362:                        frame.getContentPane().add(pane);
363:                        frame.pack();
364:                        frame.setVisible(true);
365:                        return;
366:                    }
367:                    HorizontalBarChart3D horizontalBarChart3D = new HorizontalBarChart3D(
368:                            dataset, tittle, chartCustomizer.getColor(),
369:                            chartCustomizer.isLegend(), chartCustomizer
370:                                    .isTooltips(), frame.getSize(),
371:                            chartCustomizer.isMultipleAxis());
372:                    pane = new JScrollPane(horizontalBarChart3D);
373:                    frame.getContentPane().add(pane);
374:                    frame.pack();
375:                    frame.setVisible(true);
376:                    return;
377:                }
378:            }
379:
380:            /**
381:             * Se ejecuta al presionar un boton
382:             * @param e representa el evento que se ejecuta
383:             */
384:            public void actionPerformed(ActionEvent e) {
385:                if (e.getActionCommand().equals(
386:                        com.calipso.reportgenerator.common.LanguageTraslator
387:                                .traslate("113"))) {
388:                    this .dispose();
389:                    return;
390:                }
391:                if (e.getActionCommand().equals(
392:                        com.calipso.reportgenerator.common.LanguageTraslator
393:                                .traslate("112"))) {
394:                    this .setVisible(false);
395:                    executeChart(getExecutionType());
396:                    //            this.dispose();
397:                    return;
398:                }
399:                if (e.getSource() == btChartCustomizer) {
400:                    chartCustomizer = new ChartCustomizer(this , true);
401:                    chartCustomizer.show();
402:                }
403:            }
404:
405:            /**
406:             * Determina el tipo de ejecucion de chart, es decir, por filas o columnas
407:             * @return boolean true si es por filas, false si es por columnas
408:             */
409:            private boolean getExecutionType() {
410:                if (btRow.isSelected()) {
411:                    return true;
412:                }
413:                return false;
414:            }
415:
416:            /**
417:             * Intercepta los eventos del teclado
418:             * @param e
419:             */
420:            public void keyTyped(KeyEvent e) {
421:            }
422:
423:            /**
424:             * Intercepta los eventos del teclado y realiza
425:             * la accion correspondiente.
426:             * @param e
427:             */
428:            public void keyPressed(KeyEvent e) {
429:                if (e.getSource() == btAceptar) {
430:                    this .setVisible(false);
431:                    executeChart(getExecutionType());
432:                    return;
433:                } else if (e.getSource() == btCancelar) {
434:                    this .dispose();
435:                    return;
436:                } else if (e.getSource() == btChartCustomizer) {
437:                    chartCustomizer = new ChartCustomizer(this , true);
438:                    chartCustomizer.show();
439:                }
440:            }
441:
442:            /**
443:             * Intercepta los eventos del teclado
444:             * @param e
445:             */
446:            public void keyReleased(KeyEvent e) {
447:            }
448:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.