Source Code Cross Referenced for XYDatasetPanel.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » chart » 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 » iReport 2.0.5 » it.businesslogic.ireport.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * XYDatasetPanel.java
028:         * 
029:         * Created on 15 agosto 2005, 17.55
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.chart;
034:
035:        import it.businesslogic.ireport.SubDataset;
036:        import java.awt.event.ActionEvent;
037:        import java.util.*;
038:        import it.businesslogic.ireport.util.I18n;
039:
040:        /**
041:         *
042:         * @author  Administrator
043:         */
044:        public class XYDatasetPanel extends javax.swing.JPanel implements 
045:                ChartDatasetPanel {
046:
047:            private XYDataset xyDataset = null;
048:            private SubDataset subDataset = null;
049:
050:            /** Creates new form PieDatasetPanel */
051:            public XYDatasetPanel() {
052:                initComponents();
053:                applyI18n();
054:                jList1.setModel(new javax.swing.DefaultListModel());
055:            }
056:
057:            public void setXYDataset(XYDataset xyDataset) {
058:                this .xyDataset = xyDataset;
059:
060:                jButtonModify.setEnabled(false);
061:                jButtonModify.setEnabled(false);
062:                javax.swing.DefaultListModel lm = (javax.swing.DefaultListModel) jList1
063:                        .getModel();
064:
065:                lm.removeAllElements();
066:
067:                Vector v = xyDataset.getXYSeries();
068:
069:                for (int i = 0; i < v.size(); ++i) {
070:                    lm.addElement(v.elementAt(i));
071:                }
072:            }
073:
074:            public XYDataset getXYDataset() {
075:                return xyDataset;
076:            }
077:
078:            private void updateSeriesType() {
079:                for (int i = 0; i < xyDataset.getXYSeries().size(); ++i) {
080:                    Object series = xyDataset.getXYSeries().elementAt(i);
081:                    ((javax.swing.DefaultListModel) jList1.getModel())
082:                            .removeElement(series);
083:                    xyDataset.getXYSeries().removeElementAt(i);
084:                    i--;
085:                }
086:                jList1.updateUI();
087:            }
088:
089:            /** This method is called from within the constructor to
090:             * initialize the form.
091:             * WARNING: Do NOT modify this code. The content of this method is
092:             * always regenerated by the Form Editor.
093:             */
094:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
095:            private void initComponents() {
096:                java.awt.GridBagConstraints gridBagConstraints;
097:
098:                buttonGroup1 = new javax.swing.ButtonGroup();
099:                jPopupMenuSeries = new javax.swing.JPopupMenu();
100:                jMenuItemCopy = new javax.swing.JMenuItem();
101:                jMenuItemPaste = new javax.swing.JMenuItem();
102:                jScrollPane1 = new javax.swing.JScrollPane();
103:                jList1 = new javax.swing.JList();
104:                jPanel1 = new javax.swing.JPanel();
105:                jButtonAdd = new javax.swing.JButton();
106:                jButtonModify = new javax.swing.JButton();
107:                jButtonRemove = new javax.swing.JButton();
108:                jPanel2 = new javax.swing.JPanel();
109:                jLabel1 = new javax.swing.JLabel();
110:
111:                jMenuItemCopy.setText("Copy series");
112:                jMenuItemCopy
113:                        .addActionListener(new java.awt.event.ActionListener() {
114:                            public void actionPerformed(
115:                                    java.awt.event.ActionEvent evt) {
116:                                jMenuItemCopyActionPerformed(evt);
117:                            }
118:                        });
119:
120:                jPopupMenuSeries.add(jMenuItemCopy);
121:
122:                jMenuItemPaste.setText("Paste series");
123:                jMenuItemPaste
124:                        .addActionListener(new java.awt.event.ActionListener() {
125:                            public void actionPerformed(
126:                                    java.awt.event.ActionEvent evt) {
127:                                jMenuItemPasteActionPerformed(evt);
128:                            }
129:                        });
130:
131:                jPopupMenuSeries.add(jMenuItemPaste);
132:
133:                setLayout(new java.awt.GridBagLayout());
134:
135:                addComponentListener(new java.awt.event.ComponentAdapter() {
136:                    public void componentShown(java.awt.event.ComponentEvent evt) {
137:                        formComponentShown(evt);
138:                    }
139:                });
140:
141:                jList1
142:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
143:                            public void valueChanged(
144:                                    javax.swing.event.ListSelectionEvent evt) {
145:                                jList1ValueChanged(evt);
146:                            }
147:                        });
148:                jList1.addMouseListener(new java.awt.event.MouseAdapter() {
149:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
150:                        jList1MouseClicked(evt);
151:                    }
152:                });
153:
154:                jScrollPane1.setViewportView(jList1);
155:
156:                gridBagConstraints = new java.awt.GridBagConstraints();
157:                gridBagConstraints.gridy = 2;
158:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
159:                gridBagConstraints.weightx = 1.0;
160:                gridBagConstraints.weighty = 1.0;
161:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
162:                add(jScrollPane1, gridBagConstraints);
163:
164:                jPanel1.setLayout(new java.awt.GridBagLayout());
165:
166:                jPanel1.setMinimumSize(new java.awt.Dimension(100, 0));
167:                jPanel1.setPreferredSize(new java.awt.Dimension(100, 0));
168:                jButtonAdd.setText("Add");
169:                jButtonAdd
170:                        .addActionListener(new java.awt.event.ActionListener() {
171:                            public void actionPerformed(
172:                                    java.awt.event.ActionEvent evt) {
173:                                jButtonAddActionPerformed(evt);
174:                            }
175:                        });
176:
177:                gridBagConstraints = new java.awt.GridBagConstraints();
178:                gridBagConstraints.gridy = 0;
179:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180:                gridBagConstraints.weightx = 1.0;
181:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 4);
182:                jPanel1.add(jButtonAdd, gridBagConstraints);
183:
184:                jButtonModify.setText("Modify");
185:                jButtonModify
186:                        .addActionListener(new java.awt.event.ActionListener() {
187:                            public void actionPerformed(
188:                                    java.awt.event.ActionEvent evt) {
189:                                jButtonModifyActionPerformed(evt);
190:                            }
191:                        });
192:
193:                gridBagConstraints = new java.awt.GridBagConstraints();
194:                gridBagConstraints.gridy = 1;
195:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196:                gridBagConstraints.weightx = 1.0;
197:                gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 4);
198:                jPanel1.add(jButtonModify, gridBagConstraints);
199:
200:                jButtonRemove.setText("Remove");
201:                jButtonRemove
202:                        .addActionListener(new java.awt.event.ActionListener() {
203:                            public void actionPerformed(
204:                                    java.awt.event.ActionEvent evt) {
205:                                jButtonRemoveActionPerformed(evt);
206:                            }
207:                        });
208:
209:                gridBagConstraints = new java.awt.GridBagConstraints();
210:                gridBagConstraints.gridy = 2;
211:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
212:                gridBagConstraints.weightx = 1.0;
213:                gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 4);
214:                jPanel1.add(jButtonRemove, gridBagConstraints);
215:
216:                gridBagConstraints = new java.awt.GridBagConstraints();
217:                gridBagConstraints.gridy = 99;
218:                gridBagConstraints.weighty = 1.0;
219:                jPanel1.add(jPanel2, gridBagConstraints);
220:
221:                gridBagConstraints = new java.awt.GridBagConstraints();
222:                gridBagConstraints.gridy = 2;
223:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
224:                add(jPanel1, gridBagConstraints);
225:
226:                jLabel1.setText("XY series");
227:                gridBagConstraints = new java.awt.GridBagConstraints();
228:                gridBagConstraints.gridy = 1;
229:                gridBagConstraints.gridwidth = 2;
230:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
231:                gridBagConstraints.weightx = 1.0;
232:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
233:                add(jLabel1, gridBagConstraints);
234:
235:            }// </editor-fold>//GEN-END:initComponents
236:
237:            private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
238:                openExtraWindows();
239:            }//GEN-LAST:event_formComponentShown
240:
241:            private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
242:                if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3) {
243:                    jMenuItemCopy.setEnabled(jList1.getSelectedIndex() >= 0);
244:                    jMenuItemPaste
245:                            .setEnabled(it.businesslogic.ireport.gui.MainFrame
246:                                    .getMainInstance()
247:                                    .getChartSeriesClipBoard() != null
248:                                    && it.businesslogic.ireport.gui.MainFrame
249:                                            .getMainInstance()
250:                                            .getChartSeriesClipBoard().size() > 0);
251:
252:                    jPopupMenuSeries.show(jList1, evt.getPoint().x, evt
253:                            .getPoint().y);
254:                } else if (evt.getClickCount() == 2
255:                        && evt.getButton() == evt.BUTTON1) {
256:                    jButtonModifyActionPerformed(null);
257:                }
258:            }//GEN-LAST:event_jList1MouseClicked
259:
260:            private void jMenuItemPasteActionPerformed(
261:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
262:                Vector v = it.businesslogic.ireport.gui.MainFrame
263:                        .getMainInstance().getChartSeriesClipBoard();
264:
265:                if (v != null && v.size() > 0) {
266:                    for (int i = 0; i < v.size(); ++i) {
267:                        XYSeries cs = (XYSeries) v.elementAt(i);
268:                        cs = cs.cloneMe();
269:                        getXYDataset().getXYSeries().addElement(cs);
270:                        ((javax.swing.DefaultListModel) jList1.getModel())
271:                                .addElement(cs);
272:                    }
273:                    jList1.updateUI();
274:                }
275:            }//GEN-LAST:event_jMenuItemPasteActionPerformed
276:
277:            private void jMenuItemCopyActionPerformed(
278:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
279:
280:                Object[] values = jList1.getSelectedValues();
281:                Vector copy_c = new Vector();
282:                for (int i = 0; i < values.length; ++i) {
283:                    copy_c.add(((XYSeries) values[i]).cloneMe());
284:                }
285:                it.businesslogic.ireport.gui.MainFrame.getMainInstance()
286:                        .setChartSeriesClipBoard(copy_c);
287:            }//GEN-LAST:event_jMenuItemCopyActionPerformed
288:
289:            private void jButtonModifyActionPerformed(
290:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyActionPerformed
291:
292:                if (jList1.getSelectedIndex() >= 0) {
293:
294:                    XYSeries cs = (XYSeries) jList1.getSelectedValue();
295:                    XYSeriesDialog csd = new XYSeriesDialog(
296:                            it.businesslogic.ireport.gui.MainFrame
297:                                    .getMainInstance(), true);
298:
299:                    csd.setSeriesExpression(cs.getSeriesExpression());
300:                    csd.setXValueExpression(cs.getXValueExpression());
301:                    csd.setYValueExpression(cs.getYValueExpression());
302:                    csd.setLabelExpression(cs.getLabelExpression());
303:                    csd.setSectionItemHyperlink(cs.getSectionItemHyperlink());
304:
305:                    csd.setSubDataset(this .getSubDataset());
306:
307:                    if (newInfo != null) {
308:                        csd.setFocusedExpression(newInfo);
309:                    }
310:                    csd.setVisible(true);
311:
312:                    if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
313:                        cs.setSeriesExpression(csd.getSeriesExpression());
314:                        cs.setXValueExpression(csd.getXValueExpression());
315:                        cs.setYValueExpression(csd.getYValueExpression());
316:                        cs.setLabelExpression(csd.getLabelExpression());
317:                        cs.setSectionItemHyperlink(csd
318:                                .getSectionItemHyperlink());
319:
320:                        jList1.updateUI();
321:                    }
322:                }
323:            }//GEN-LAST:event_jButtonModifyActionPerformed
324:
325:            private void jButtonAddActionPerformed(
326:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed
327:
328:                XYSeriesDialog csd = new XYSeriesDialog(
329:                        it.businesslogic.ireport.gui.MainFrame
330:                                .getMainInstance(), true);
331:                csd.setSubDataset(this .getSubDataset());
332:                csd.setVisible(true);
333:
334:                if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
335:                    XYSeries cs = new XYSeries();
336:                    cs.setSeriesExpression(csd.getSeriesExpression());
337:                    cs.setXValueExpression(csd.getXValueExpression());
338:                    cs.setYValueExpression(csd.getYValueExpression());
339:                    cs.setLabelExpression(csd.getLabelExpression());
340:                    cs.setSectionItemHyperlink(csd.getSectionItemHyperlink());
341:
342:                    xyDataset.getXYSeries().addElement(cs);
343:                    ((javax.swing.DefaultListModel) jList1.getModel())
344:                            .addElement(cs);
345:                    jList1.updateUI();
346:                }
347:
348:            }//GEN-LAST:event_jButtonAddActionPerformed
349:
350:            private void jButtonRemoveActionPerformed(
351:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveActionPerformed
352:
353:                while (jList1.getSelectedIndex() >= 0) {
354:                    xyDataset.getXYSeries().remove(jList1.getSelectedValue());
355:                    ((javax.swing.DefaultListModel) jList1.getModel())
356:                            .removeElementAt(jList1.getSelectedIndex());
357:                }
358:
359:            }//GEN-LAST:event_jButtonRemoveActionPerformed
360:
361:            private void jList1ValueChanged(
362:                    javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
363:
364:                if (jList1.getSelectedIndex() >= 0) {
365:                    jButtonModify.setEnabled(true);
366:                    jButtonModify.setEnabled(true);
367:                } else {
368:                    jButtonModify.setEnabled(false);
369:                    jButtonModify.setEnabled(false);
370:                }
371:            }//GEN-LAST:event_jList1ValueChanged
372:
373:            // Variables declaration - do not modify//GEN-BEGIN:variables
374:            private javax.swing.ButtonGroup buttonGroup1;
375:            private javax.swing.JButton jButtonAdd;
376:            private javax.swing.JButton jButtonModify;
377:            private javax.swing.JButton jButtonRemove;
378:            private javax.swing.JLabel jLabel1;
379:            private javax.swing.JList jList1;
380:            private javax.swing.JMenuItem jMenuItemCopy;
381:            private javax.swing.JMenuItem jMenuItemPaste;
382:            private javax.swing.JPanel jPanel1;
383:            private javax.swing.JPanel jPanel2;
384:            private javax.swing.JPopupMenu jPopupMenuSeries;
385:            private javax.swing.JScrollPane jScrollPane1;
386:
387:            // End of variables declaration//GEN-END:variables
388:
389:            public void applyI18n() {
390:                // Start autogenerated code ----------------------
391:                jMenuItemCopy.setText(I18n.getString(
392:                        "xYDatasetPanel.menuItemCopy", "Copy series"));
393:                jMenuItemPaste.setText(I18n.getString(
394:                        "xYDatasetPanel.menuItemPaste", "Paste series"));
395:                // End autogenerated code ----------------------
396:                // Start autogenerated code ----------------------
397:                jLabel1.setText(I18n.getString("xYDatasetPanel.label1",
398:                        "XY series"));
399:                // End autogenerated code ----------------------
400:                jButtonAdd.setText(it.businesslogic.ireport.util.I18n
401:                        .getString("charts.newseries", "Add series"));
402:                jButtonModify.setText(it.businesslogic.ireport.util.I18n
403:                        .getString("charts.modifyseries", "Modify series"));
404:                jButtonRemove.setText(it.businesslogic.ireport.util.I18n
405:                        .getString("charts.removeseries", "Remove series"));
406:                this .updateUI();
407:
408:            }
409:
410:            public SubDataset getSubDataset() {
411:                return subDataset;
412:            }
413:
414:            public void setSubDataset(SubDataset subDataset) {
415:                this .subDataset = subDataset;
416:            }
417:
418:            public static final int COMPONENT_NONE = 0;
419:            public static final int COMPONENT_XY_LIST = 1;
420:
421:            /**
422:             * This variable is checked by openExtraWindows() called when the component is shown.
423:             * If the value is != 0, the modify button will be action-performed.
424:             */
425:            public Object[] newInfo = null;
426:
427:            /**
428:             * This method set the focus on a specific component.
429:             * 
430:             * For this kind of datasource otherInfo must be:
431:             * [0] = Fixed to COMPONENT_PERIOD_SERIES_LIST (used for future extensions)
432:             * [1] = Integer, the category series to edit
433:             * [2] = The expression id in the category window to focus on 
434:             * [3] = The expression in the hyperlink...
435:             * [4] = The hyperlink parameter
436:             * [5] = The expression of the hyperlink parameter
437:             */
438:            public void setFocusedExpression(Object[] expressionInfo) {
439:                if (expressionInfo == null)
440:                    return;
441:                int expID = ((Integer) expressionInfo[0]).intValue();
442:                switch (expID) {
443:                case COMPONENT_XY_LIST:
444:                    int index = ((Integer) expressionInfo[1]).intValue();
445:
446:                    if (index >= 0 && jList1.getModel().getSize() > index) {
447:                        jList1.setSelectedIndex(index);
448:                        newInfo = new Object[expressionInfo.length - 2];
449:                        for (int i = 2; i < expressionInfo.length; ++i)
450:                            newInfo[i - 2] = expressionInfo[i];
451:                        break;
452:                    }
453:                }
454:            }
455:
456:            /**
457:             * This method checks for the variable subExpID. It is called when the component is shown.
458:             * If the value is >= 0, the modify button will be action-performed
459:             */
460:            private void openExtraWindows() {
461:                if (newInfo != null) {
462:                    jButtonModifyActionPerformed(new ActionEvent(jButtonModify,
463:                            0, ""));
464:                }
465:                newInfo = null;
466:            }
467:
468:            public void containerWindowOpened() {
469:                openExtraWindows();
470:            }
471:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.