Source Code Cross Referenced for ChartPivotTable.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » dinamicchart » 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.dinamicchart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface.dinamicchart;
002:
003:        import com.calipso.reportgenerator.userinterface.*;
004:        import com.calipso.reportgenerator.reportdefinitions.types.DimensionDefinitionLocationType;
005:        import com.calipso.reportgenerator.common.*;
006:
007:        import javax.swing.*;
008:        import java.awt.*;
009:        import java.awt.event.*;
010:        import java.util.*;
011:        import java.util.List;
012:
013:        import com.calipso.reportgenerator.common.InfoException;
014:
015:        /**
016:         *
017:         * User: soliveri
018:         * Date: Jul 23, 2003
019:         * Time: 4:42:52 PM
020:         *
021:         */
022:
023:        public class ChartPivotTable extends JPanel implements 
024:                ComponentListener, AdjustmentListener {
025:
026:            private DropPanel pageDimensionsPanel;
027:            private DropPanel columnDimensionsPanel;
028:            private DropPanel rowDimensionsPanel;
029:            private JPanel chartPanel;
030:            private JSplitPane splitPane;
031:            private ChartPivotTableManager manager;
032:            private ReportResult reportResult;
033:            private ChartPivotTableSelection selection;
034:            private ChartMetricsSelection metricsSelection;
035:            int reportHandle;
036:            private JScrollPane pageDimensionsScrollPane,
037:                    columnDimensionsScrollPane, rowDimensionsScrollPane;
038:            private JScrollBar pageDimensionsScrollBar,
039:                    columnDimensionsScrollBar, rowDimensionsScrollBar;
040:            private IReportManager reportManager;
041:            private JButton btChartCustomizer;
042:            private IReportFrame owner;
043:
044:            public ChartPivotTable(ReportSpec reportSpec,
045:                    IReportManager reportManager, Map params, String userId,
046:                    String reportDefId, IReportFrame owFrame)
047:                    throws HeadlessException, InfoException {
048:                this .reportManager = reportManager;
049:                owner = owFrame;
050:                initialize(reportSpec, reportManager, params, userId,
051:                        reportDefId);
052:                initComponents(reportResult.getReportSpec().getMetrics());
053:                manager = ChartPivotTableManager.getManager();
054:                manager.setManagerComponents(this , reportResult,
055:                        getPanelsMap(), reportManager, params, userId,
056:                        reportHandle);
057:            }
058:
059:            private void initialize(ReportSpec reportSpec,
060:                    IReportManager reportManager, Map params, String userId,
061:                    String reportDefId) throws InfoException {
062:                this .reportManager = reportManager;
063:                reportSpec = reportManager.getReportSpec(reportDefId);
064:                if (reportSpec.getCached()) {
065:                    reportHandle = reportManager.PrepareReport(reportDefId);
066:                } else {
067:                    reportHandle = reportManager.PrepareReport(reportDefId,
068:                            params);
069:                }
070:                ReportQuery query = reportManager.getDefaultReportQuery(
071:                        reportHandle, userId);
072:                query.setParamValues(params);
073:                query.setVisibleTotals(false);
074:                reportResult = reportManager.ExecReportQuery(reportHandle,
075:                        query);
076:            }
077:
078:            private HashMap getPanelsMap() {
079:                HashMap targetPanels = new HashMap();
080:                targetPanels.put(
081:                        DimensionDefinitionLocationType.ROW.toString(),
082:                        rowDimensionsPanel);
083:                targetPanels.put(DimensionDefinitionLocationType.PAGE
084:                        .toString(), pageDimensionsPanel);
085:                targetPanels.put(DimensionDefinitionLocationType.COLUMN
086:                        .toString(), columnDimensionsPanel);
087:                return targetPanels;
088:            }
089:
090:            private void initComponents(Object[] metrics) {
091:                setLayout(new BorderLayout());
092:                JPanel firstNorthPanel = new JPanel(new BorderLayout());
093:                pageDimensionsPanel = new DropPanel(
094:                        DimensionDefinitionLocationType.PAGE.toString(),
095:                        BoxLayout.X_AXIS);
096:                pageDimensionsScrollPane = new JScrollPane(pageDimensionsPanel);
097:                pageDimensionsScrollPane.setSize(new Dimension(0, 21));
098:                pageDimensionsScrollPane.setPreferredSize(new Dimension(0, 21));
099:                pageDimensionsScrollPane.setMinimumSize(new Dimension(0, 21));
100:                pageDimensionsScrollPane.setMaximumSize(new Dimension(0, 21));
101:                pageDimensionsScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
102:                pageDimensionsScrollBar.addAdjustmentListener(this );
103:                pageDimensionsScrollBar.setSize(new Dimension(30, 0));
104:                pageDimensionsScrollBar.setPreferredSize(new Dimension(30, 0));
105:                pageDimensionsScrollBar.setMinimumSize(new Dimension(30, 0));
106:                pageDimensionsScrollBar.setMaximumSize(new Dimension(30, 0));
107:                pageDimensionsScrollBar.setUnitIncrement(5);
108:                pageDimensionsScrollPane
109:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
110:                pageDimensionsScrollPane
111:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
112:                firstNorthPanel.add(pageDimensionsScrollPane,
113:                        BorderLayout.CENTER);
114:                firstNorthPanel.add(pageDimensionsScrollBar, BorderLayout.EAST);
115:                add(firstNorthPanel, BorderLayout.NORTH);
116:                JPanel firstCenterPanel = new JPanel(new BorderLayout());
117:                JPanel secondNorthCenterPanel = new JPanel(new BorderLayout());
118:                columnDimensionsPanel = new DropPanel(
119:                        DimensionDefinitionLocationType.COLUMN.toString(),
120:                        BoxLayout.X_AXIS);
121:                columnDimensionsScrollPane = new JScrollPane(
122:                        columnDimensionsPanel);
123:                columnDimensionsScrollPane
124:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
125:                columnDimensionsScrollPane
126:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
127:                columnDimensionsScrollPane.setSize(new Dimension(0, 21));
128:                columnDimensionsScrollPane
129:                        .setPreferredSize(new Dimension(0, 21));
130:                columnDimensionsScrollPane.setMinimumSize(new Dimension(0, 21));
131:                columnDimensionsScrollPane.setMaximumSize(new Dimension(0, 21));
132:                columnDimensionsScrollBar = new JScrollBar(
133:                        JScrollBar.HORIZONTAL);
134:                columnDimensionsScrollBar.addAdjustmentListener(this );
135:                columnDimensionsScrollBar.setSize(new Dimension(30, 0));
136:                columnDimensionsScrollBar
137:                        .setPreferredSize(new Dimension(30, 0));
138:                columnDimensionsScrollBar.setMinimumSize(new Dimension(30, 0));
139:                columnDimensionsScrollBar.setMaximumSize(new Dimension(30, 0));
140:                columnDimensionsScrollBar.setUnitIncrement(5);
141:                secondNorthCenterPanel.add(columnDimensionsScrollPane,
142:                        BorderLayout.CENTER);
143:                secondNorthCenterPanel.add(columnDimensionsScrollBar,
144:                        BorderLayout.EAST);
145:                chartPanel = new JPanel(new FlowLayout());
146:                java.awt.Dimension screenSize = java.awt.Toolkit
147:                        .getDefaultToolkit().getScreenSize();
148:                screenSize.width = (new Double(screenSize.width * 0.80))
149:                        .intValue();
150:                screenSize.height = (new Double(screenSize.height * 0.65))
151:                        .intValue();
152:                chartPanel.setSize(screenSize);
153:
154:                JScrollPane chartScrollPane = new JScrollPane(chartPanel);
155:                firstCenterPanel
156:                        .add(secondNorthCenterPanel, BorderLayout.NORTH);
157:                firstCenterPanel.add(chartScrollPane, BorderLayout.CENTER);
158:                JPanel firstWestPanel = new JPanel(new BorderLayout());
159:                rowDimensionsPanel = new DropPanel(
160:                        DimensionDefinitionLocationType.ROW.toString(),
161:                        BoxLayout.Y_AXIS);
162:                rowDimensionsScrollPane = new JScrollPane(rowDimensionsPanel);
163:                rowDimensionsScrollPane
164:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
165:                rowDimensionsScrollPane
166:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
167:                rowDimensionsScrollBar = new JScrollBar(JScrollBar.VERTICAL);
168:                rowDimensionsScrollBar.addAdjustmentListener(this );
169:                rowDimensionsScrollBar.setSize(new Dimension(0, 30));
170:                rowDimensionsScrollBar.setPreferredSize(new Dimension(0, 30));
171:                rowDimensionsScrollBar.setMinimumSize(new Dimension(0, 30));
172:                rowDimensionsScrollBar.setMaximumSize(new Dimension(0, 30));
173:                rowDimensionsScrollBar.setUnitIncrement(5);
174:                rowDimensionsScrollBar.addComponentListener(this );
175:                firstWestPanel
176:                        .add(rowDimensionsScrollPane, BorderLayout.CENTER);
177:                firstWestPanel.add(rowDimensionsScrollBar, BorderLayout.SOUTH);
178:                splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
179:                        firstWestPanel, firstCenterPanel);
180:                splitPane.setOneTouchExpandable(false);
181:                splitPane.setDividerSize(5);
182:                splitPane.setDividerLocation(75);
183:                add(firstNorthPanel, BorderLayout.NORTH);
184:                add(splitPane, BorderLayout.CENTER);
185:                JPanel southPanel = new JPanel(new BorderLayout());
186:                selection = new ChartPivotTableSelection(owner);
187:                southPanel.add(selection, BorderLayout.EAST);
188:                metricsSelection = new ChartMetricsSelection(metrics);
189:                JScrollPane metricsPane = new JScrollPane(metricsSelection);
190:                metricsPane
191:                        .setSize(new Dimension(getPreferredSize().width, 50));
192:                metricsPane.setPreferredSize(new Dimension(
193:                        getPreferredSize().width, 50));
194:                metricsPane.setMaximumSize(new Dimension(
195:                        getPreferredSize().width, 50));
196:                metricsPane.setMinimumSize(new Dimension(
197:                        getPreferredSize().width, 50));
198:                southPanel.add(metricsPane, BorderLayout.CENTER);
199:                JLabel lbUseless = new JLabel("");
200:                lbUseless.setSize(new Dimension(splitPane.getDividerLocation(),
201:                        10));
202:                lbUseless.setPreferredSize(new Dimension(splitPane
203:                        .getDividerLocation(), 10));
204:                lbUseless.setMinimumSize(new Dimension(splitPane
205:                        .getDividerLocation(), 10));
206:                lbUseless.setMaximumSize(new Dimension(splitPane
207:                        .getDividerLocation(), 10));
208:                add(southPanel, BorderLayout.SOUTH);
209:            }
210:
211:            public void paintComponents(boolean init) throws InfoException {
212:                pageDimensionsPanel.removeAll();
213:                rowDimensionsPanel.removeAll();
214:                columnDimensionsPanel.removeAll();
215:                chartPanel.removeAll();
216:
217:                List rowDimensions = reportResult.getReportQuery()
218:                        .getRowDimensions();
219:                List pageDimensions = reportResult.getReportQuery()
220:                        .getPageDimensions();
221:                List columnDimensions = reportResult.getReportQuery()
222:                        .getColumnDimensions();
223:
224:                System.out.println();
225:                for (Iterator iterator = rowDimensions.iterator(); iterator
226:                        .hasNext();) {
227:                    QueryDimension dimension = (QueryDimension) iterator.next();
228:                    String caption = reportResult.getDimensionFromName(
229:                            dimension.getName()).getCaption();
230:                    System.out.print(caption + " ");
231:                    if (init) {
232:                        rowDimensionsPanel.addDimension(dimension.getName(),
233:                                caption, (HashSet) reportResult
234:                                        .getDimensionUnCheckedValues(dimension
235:                                                .getName()), getReportManager()
236:                                        .getDimensionValues(reportHandle,
237:                                                dimension.getName()));
238:                    } else {
239:                        rowDimensionsPanel.addDimensionToPanel(dimension
240:                                .getName());
241:                    }
242:                }
243:
244:                System.out.println();
245:                for (Iterator iterator = pageDimensions.iterator(); iterator
246:                        .hasNext();) {
247:                    QueryDimension dimension = (QueryDimension) iterator.next();
248:                    String caption = reportResult.getDimensionFromName(
249:                            dimension.getName()).getCaption();
250:                    System.out.print(caption + " ");
251:                    if (init) {
252:                        pageDimensionsPanel.addDimension(dimension.getName(),
253:                                caption, (HashSet) reportResult
254:                                        .getDimensionUnCheckedValues(dimension
255:                                                .getName()), getReportManager()
256:                                        .getDimensionValues(reportHandle,
257:                                                dimension.getName()));
258:                    } else {
259:                        pageDimensionsPanel.addDimensionToPanel(dimension
260:                                .getName());
261:                    }
262:                }
263:
264:                System.out.println();
265:                for (Iterator iterator = columnDimensions.iterator(); iterator
266:                        .hasNext();) {
267:                    QueryDimension dimension = (QueryDimension) iterator.next();
268:                    String caption = reportResult.getDimensionFromName(
269:                            dimension.getName()).getCaption();
270:                    System.out.print(caption + " ");
271:                    if (init) {
272:                        columnDimensionsPanel.addDimension(dimension.getName(),
273:                                caption, (HashSet) reportResult
274:                                        .getDimensionUnCheckedValues(dimension
275:                                                .getName()), getReportManager()
276:                                        .getDimensionValues(reportHandle,
277:                                                dimension.getName()));
278:                    } else {
279:                        columnDimensionsPanel.addDimensionToPanel(dimension
280:                                .getName());
281:                    }
282:                }
283:                generateChart(0, false);
284:            }
285:
286:            public void repaintComponents() {
287:                flushComponents();
288:                Vector rowDimensionsVector = rowDimensionsPanel.getDimensions();
289:                fillComponent(rowDimensionsVector, rowDimensionsPanel);
290:                Vector colDimensionsVector = columnDimensionsPanel
291:                        .getDimensions();
292:                fillComponent(colDimensionsVector, columnDimensionsPanel);
293:                Vector pageDimensionsVector = pageDimensionsPanel
294:                        .getDimensions();
295:                fillComponent(pageDimensionsVector, pageDimensionsPanel);
296:                generateChart(selection.getCurrentChartType(), selection
297:                        .getCurrentValue());
298:                validate();
299:            }
300:
301:            private void flushComponents() {
302:                pageDimensionsPanel.removeAll();
303:                rowDimensionsPanel.removeAll();
304:                columnDimensionsPanel.removeAll();
305:                chartPanel.removeAll();
306:                validate();
307:            }
308:
309:            private void fillComponent(Vector vector, DropPanel panel) {
310:                for (int i = 0; i < vector.size(); i++) {
311:                    panel.addDimensionToPanel(((SourceDimension) vector
312:                            .elementAt(i)).getName());
313:                }
314:                pageDimensionsPanel.validate();
315:                rowDimensionsPanel.validate();
316:                columnDimensionsPanel.validate();
317:            }
318:
319:            public void generateChart(int type, boolean byRow) {
320:                chartPanel.removeAll();
321:                DinamicChartData chartData = new DinamicChartData();
322:                chartData.updateDinamicChartData(reportResult);
323:                Dimension size = new Dimension(chartPanel.getSize());
324:                size.height = (new Double(size.height * 0.80)).intValue();
325:                boolean legend = getLegendValue();
326:                boolean toolTips = getToolTipsValue();
327:                boolean multipleAxis = getMultipleAxis();
328:                switch (type) {
329:                case 0:
330:                    Component component = new VerticalBarChart3D(chartData
331:                            .getCategoryDataset(byRow), reportResult
332:                            .getReportSpec().getTitle(), Color.white, legend,
333:                            toolTips, size, multipleAxis);
334:                    chartPanel.add(component);
335:                    break;
336:                case 1:
337:                    chartPanel.add(new HorizontalBarChart(chartData
338:                            .getCategoryDataset(byRow), reportResult
339:                            .getReportSpec().getTitle(), Color.white, legend,
340:                            toolTips, size, multipleAxis));
341:                    break;
342:                case 2:
343:                    chartPanel.add(new HorizontalBarChart3D(chartData
344:                            .getCategoryDataset(byRow), reportResult
345:                            .getReportSpec().getTitle(), Color.white, legend,
346:                            toolTips, size, multipleAxis));
347:                    break;
348:                case 3:
349:                    chartPanel.add(new LineChart(chartData
350:                            .getCategoryDataset(byRow), reportResult
351:                            .getReportSpec().getTitle(), Color.white, legend,
352:                            toolTips, size, multipleAxis));
353:                    break;
354:                case 4:
355:                    chartPanel.add(new VerticalBarChart(chartData
356:                            .getCategoryDataset(byRow), reportResult
357:                            .getReportSpec().getTitle(), Color.white, legend,
358:                            toolTips, size, multipleAxis));
359:                    break;
360:                case 5:
361:                    chartPanel.add(new AreaChart(chartData
362:                            .getCategoryDataset(byRow), reportResult
363:                            .getReportSpec().getTitle(), Color.white, legend,
364:                            toolTips, size, multipleAxis));
365:                    break;
366:                }
367:                validate();
368:            }
369:
370:            private boolean getMultipleAxis() {
371:                if (selection.getChartCustomizer() != null) {
372:                    return selection.getChartCustomizer().isMultipleAxis();
373:                } else {
374:                    return false;
375:                }
376:            }
377:
378:            private boolean getToolTipsValue() {
379:                if (selection.getChartCustomizer() != null) {
380:                    return selection.getChartCustomizer().isTooltips();
381:                } else {
382:                    return true;
383:                }
384:            }
385:
386:            private boolean getLegendValue() {
387:                if (selection.getChartCustomizer() != null) {
388:                    return selection.getChartCustomizer().isLegend();
389:                } else {
390:                    return true;
391:                }
392:            }
393:
394:            public void setReportResult(ReportResult reportResult) {
395:                this .reportResult = reportResult;
396:            }
397:
398:            public void componentResized(ComponentEvent e) {
399:                if (e.getSource() == rowDimensionsScrollBar) {
400:                    Vector rowDimensions = rowDimensionsPanel.getDimensions();
401:                    for (int i = 0; i < rowDimensions.size(); i++) {
402:                        SourceDimension current = (SourceDimension) rowDimensions
403:                                .elementAt(i);
404:                        current.setSize(new Dimension(rowDimensionsScrollBar
405:                                .getSize().width - 4, 15));
406:                        current
407:                                .setPreferredSize(new Dimension(
408:                                        rowDimensionsScrollBar.getSize().width - 4,
409:                                        15));
410:                        current
411:                                .setMinimumSize(new Dimension(
412:                                        rowDimensionsScrollBar.getSize().width - 4,
413:                                        15));
414:                        current
415:                                .setMaximumSize(new Dimension(
416:                                        rowDimensionsScrollBar.getSize().width - 4,
417:                                        15));
418:                    }
419:                    validate();
420:                }
421:            }
422:
423:            public void componentMoved(ComponentEvent e) {
424:
425:            }
426:
427:            public void componentShown(ComponentEvent e) {
428:
429:            }
430:
431:            public void componentHidden(ComponentEvent e) {
432:
433:            }
434:
435:            public void adjustmentValueChanged(AdjustmentEvent e) {
436:                if (e.getSource() == columnDimensionsScrollBar) {
437:                    columnDimensionsScrollPane.getHorizontalScrollBar()
438:                            .setValue(e.getValue());
439:                    return;
440:                }
441:                if (e.getSource() == rowDimensionsScrollBar) {
442:                    rowDimensionsScrollPane.getVerticalScrollBar().setValue(
443:                            e.getValue());
444:                    return;
445:                }
446:                if (e.getSource() == pageDimensionsScrollBar) {
447:                    pageDimensionsScrollPane.getHorizontalScrollBar().setValue(
448:                            e.getValue());
449:                    return;
450:                }
451:            }
452:
453:            public IReportManager getReportManager() {
454:                return reportManager;
455:            }
456:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.