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


0001:        /*
0002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
0003:         * http://www.jaspersoft.com.
0004:         *
0005:         * Unless you have purchased a commercial license agreement from JasperSoft,
0006:         * the following license terms apply:
0007:         *
0008:         * This program is free software; you can redistribute it and/or modify
0009:         * it under the terms of the GNU General Public License version 2 as published by
0010:         * the Free Software Foundation.
0011:         *
0012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
0013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0014:         * See the GNU General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU General Public License
0017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
0018:         * or write to:
0019:         *
0020:         * Free Software Foundation, Inc.,
0021:         * 59 Temple Place - Suite 330,
0022:         * Boston, MA  USA  02111-1307
0023:         *
0024:         *
0025:         *
0026:         *
0027:         * CrosstabEditorPanel.java
0028:         * 
0029:         * Created on January 12, 2006, 4:19 PM
0030:         *
0031:         */
0032:
0033:        package it.businesslogic.ireport.crosstab.gui;
0034:
0035:        import it.businesslogic.ireport.CrosstabReportElement;
0036:        import it.businesslogic.ireport.FrameReportElement;
0037:        import it.businesslogic.ireport.OperationType;
0038:        import it.businesslogic.ireport.ReportElement;
0039:        import it.businesslogic.ireport.ReportElementFactory;
0040:        import it.businesslogic.ireport.ReportElementType;
0041:        import it.businesslogic.ireport.StaticTextReportElement;
0042:        import it.businesslogic.ireport.TransformationType;
0043:        import it.businesslogic.ireport.crosstab.CrosstabCell;
0044:        import it.businesslogic.ireport.crosstab.CrosstabGroup;
0045:        import it.businesslogic.ireport.gui.MainFrame;
0046:        import it.businesslogic.ireport.gui.event.ReportElementChangedEvent;
0047:        import it.businesslogic.ireport.undo.CrosstabColumnDraggedOperation;
0048:        import it.businesslogic.ireport.undo.CrosstabRowDraggedOperation;
0049:        import it.businesslogic.ireport.undo.InsertElementOperation;
0050:        import it.businesslogic.ireport.undo.TransformElementsOperation;
0051:        import it.businesslogic.ireport.util.LanguageChangedEvent;
0052:        import it.businesslogic.ireport.util.LanguageChangedListener;
0053:        import java.awt.Color;
0054:        import java.awt.Cursor;
0055:        import java.awt.Dimension;
0056:        import java.awt.Graphics;
0057:        import java.awt.Graphics2D;
0058:        import java.awt.Point;
0059:        import java.awt.Rectangle;
0060:        import java.awt.RenderingHints;
0061:        import java.awt.Shape;
0062:        import java.awt.Stroke;
0063:        import java.awt.geom.AffineTransform;
0064:        import java.util.ArrayList;
0065:        import java.util.Enumeration;
0066:        import java.util.Iterator;
0067:        import java.util.List;
0068:        import java.util.Vector;
0069:        import it.businesslogic.ireport.Style;
0070:        import it.businesslogic.ireport.TextFieldReportElement;
0071:        import it.businesslogic.ireport.TextReportElement;
0072:        import it.businesslogic.ireport.gui.FieldPatternDialog;
0073:        import it.businesslogic.ireport.gui.JReportFrame;
0074:        import it.businesslogic.ireport.gui.command.FormatCommand;
0075:        import it.businesslogic.ireport.gui.event.ReportElementsSelectionEvent;
0076:        import it.businesslogic.ireport.undo.ChangeEmentsOrderOperation;
0077:        import it.businesslogic.ireport.undo.DeleteElementsOperation;
0078:        import it.businesslogic.ireport.undo.PasteStyleOperation;
0079:        import it.businesslogic.ireport.undo.ReplacedElementsOperation;
0080:        import java.awt.datatransfer.DataFlavor;
0081:        import java.awt.datatransfer.Transferable;
0082:        import java.awt.dnd.DnDConstants;
0083:        import java.awt.dnd.DropTarget;
0084:        import java.awt.dnd.DropTargetContext;
0085:        import it.businesslogic.ireport.util.I18n;
0086:
0087:        /**
0088:         *
0089:         * @author  gtoffoli
0090:         */
0091:        public class CrosstabEditorPanel extends javax.swing.JPanel implements 
0092:                java.awt.dnd.DropTargetListener {
0093:
0094:            // Menus...
0095:            private javax.swing.JMenu jMenuAlign;
0096:            private javax.swing.JMenuItem jMenuItemAlignLeft;
0097:            private javax.swing.JMenuItem jMenuItemAlignRight;
0098:            private javax.swing.JMenuItem jMenuItemAlignTop;
0099:            private javax.swing.JMenuItem jMenuItemAlignBottom;
0100:            private javax.swing.JSeparator jSeparator19;
0101:            private javax.swing.JMenuItem jMenuItemAlignVerticalAxis;
0102:            private javax.swing.JMenuItem jMenuItemAlignHorizontalAxis;
0103:            private javax.swing.JMenu jMenuSize;
0104:            private javax.swing.JMenuItem jMenuItemSameWidth;
0105:            private javax.swing.JMenuItem jMenuItemSameWidthMax;
0106:            private javax.swing.JMenuItem jMenuItemSameWidthMin;
0107:            private javax.swing.JSeparator jSeparator17;
0108:            private javax.swing.JMenuItem jMenuItemSameHeight;
0109:            private javax.swing.JMenuItem jMenuItemSameHeightMax;
0110:            private javax.swing.JMenuItem jMenuItemSameHeightMin;
0111:            private javax.swing.JSeparator jSeparator18;
0112:            private javax.swing.JMenuItem jMenuItemSameSize;
0113:            private javax.swing.JMenu jMenuPosition;
0114:            private javax.swing.JMenuItem jMenuItemCenterH;
0115:            private javax.swing.JMenuItem jMenuItemCenterV;
0116:            private javax.swing.JMenuItem jMenuItemCenterInCell;
0117:            private javax.swing.JMenuItem jMenuItemJoinLeft;
0118:            private javax.swing.JMenuItem jMenuItemJoinRight;
0119:            private javax.swing.JSeparator jSeparator5;
0120:            private javax.swing.JMenuItem jMenuHSpacing;
0121:            private javax.swing.JMenuItem jMenuItemHSMakeEqual;
0122:            private javax.swing.JMenuItem jMenuItemHSIncrease;
0123:            private javax.swing.JMenuItem jMenuItemHSDecrease;
0124:            private javax.swing.JMenuItem jMenuItemHSRemove;
0125:            private javax.swing.JMenuItem jMenuVSpacing;
0126:            private javax.swing.JMenuItem jMenuItemVSMakeEqual;
0127:            private javax.swing.JMenuItem jMenuItemVSIncrease;
0128:            private javax.swing.JMenuItem jMenuItemVSDecrease;
0129:            private javax.swing.JMenuItem jMenuItemVSRemove;
0130:            private javax.swing.JSeparator jSeparator8;
0131:            private javax.swing.JMenuItem jMenuItemBringToFront;
0132:            private javax.swing.JMenuItem jMenuItemSendToBack;
0133:
0134:            private javax.swing.JMenuItem jMenuItemFillCell;
0135:            private javax.swing.JMenuItem jMenuItemFillCellH;
0136:            private javax.swing.JMenuItem jMenuItemFillCellV;
0137:
0138:            private double zoomFactor = 2.0;
0139:            private boolean animation = false;
0140:
0141:            private java.util.List openedNodesDocumentStructure = null;
0142:
0143:            private boolean defaultCellMode = false;
0144:            /**
0145:             *  It contains the number of row ready to be dragged.
0146:             **/
0147:            private int readyToDragCellVertically = -1;
0148:
0149:            /**
0150:             *  It contains the number of column ready to be dragged
0151:             **/
0152:            private int readyToDragCellHorizontally = -1;
0153:
0154:            /**
0155:             * Point from wich a drag operation is started
0156:             **/
0157:            private Point dragging_origin = null;
0158:
0159:            /**
0160:             *  True if I'm dragging a cell...
0161:             **/
0162:            private boolean cell_dragging = false;
0163:
0164:            private int newObjectType = ReportElementType.NONE;
0165:            private boolean resistenceExceeded = false;
0166:
0167:            /**
0168:             * This flag is true if we are trasforming elements...
0169:             */
0170:            private boolean trasforming = false;
0171:            /**
0172:             * The type of transformation (see TransformationTypes)...
0173:             */
0174:            private int transformation_type = TransformationType.TRANSFORMATION_NONE;
0175:            /**
0176:             * Point to start the calculation of transformation delta
0177:             */
0178:            private Point transformation_origin = null;
0179:            /**
0180:             * Point to end the calculation of transformation delta
0181:             */
0182:            private Point transformation_origin_end = null;
0183:            private Point transformation_undo_delta = null;
0184:            private boolean firstXORDrawTransforming = true;
0185:            private boolean firstXORDraw = true;
0186:            private Rectangle transformationOldBound = null;
0187:
0188:            private JReportFrame parentReportFrame = null;
0189:
0190:            /**
0191:             * Point to start the calculation of the new object
0192:             */
0193:            private Point newObjectOrigin = null;
0194:
0195:            /**
0196:             * This flag is true if we are selecting elements drawing a rectangle...
0197:             */
0198:            private boolean drag_selection_mode = false;
0199:            /**
0200:             * The origin of the selection rectangle...
0201:             */
0202:            private java.awt.Point drag_selection_origin = null;
0203:            /**
0204:             * The end of the selection rectangle...
0205:             */
0206:            private java.awt.Point drag_selection_end = null;
0207:            /**
0208:             * The flag is used to handle XOR operation on rectangle selection
0209:             */
0210:            private boolean first_draw_selection_rect = true;
0211:
0212:            /**
0213:             * Stroke to use when draw selection rectangle
0214:             */
0215:            private java.awt.Stroke selectionStroke = null;
0216:
0217:            /**
0218:             * Position of the mouse of the last draw operation. Used to restore XOR draw.
0219:             **/
0220:            private Point mouse = new Point(0, 0);
0221:
0222:            private Vector rowBands = new Vector();
0223:            private Vector columnBands = new Vector();
0224:
0225:            /**
0226:             * This array stores vertical lines positions (the number of lines is:
0227:             * [# of row groups] + [# of column groups] + [# of total column groups]
0228:             */
0229:            private List columns = new ArrayList();
0230:            /**
0231:             * This array stores horizontal lines positions (the number of lines is:
0232:             * [# of column groups] + [# of row groups] + [# of total row groups]
0233:             */
0234:            private List rows = new ArrayList();
0235:
0236:            /**
0237:             * this vector contains the current selection in the editor
0238:             */
0239:            private Vector selectedElements = new Vector();
0240:
0241:            /**
0242:             * CrosstabCell selected when right mouse is pressed
0243:             */
0244:            private CrosstabCell selectedCell = null;
0245:
0246:            private static final javax.swing.ImageIcon crosstabCornerImage = new javax.swing.ImageIcon(
0247:                    CrosstabEditorPanel.class
0248:                            .getResource("/it/businesslogic/ireport/icons/crosstabcorner.png"));
0249:            private static final javax.swing.ImageIcon crosstabBorderImage = new javax.swing.ImageIcon(
0250:                    CrosstabEditorPanel.class
0251:                            .getResource("/it/businesslogic/ireport/icons/crosstabborder.png"));
0252:            private static final javax.swing.ImageIcon crosstabBorderHImage = new javax.swing.ImageIcon(
0253:                    CrosstabEditorPanel.class
0254:                            .getResource("/it/businesslogic/ireport/icons/crosstabborderh.png"));
0255:
0256:            private CrosstabEditor editor = null;
0257:
0258:            /** Creates new form CrosstabEditorPanel */
0259:            public CrosstabEditorPanel() {
0260:                initComponents();
0261:
0262:                selectionStroke = new java.awt.BasicStroke((float) (2f),
0263:                        java.awt.BasicStroke.CAP_BUTT,
0264:                        java.awt.BasicStroke.JOIN_BEVEL, 0f, new float[] { 5f,
0265:                                3f }, 0f);
0266:
0267:                addFormatItemsToMenu(jPopupMenuCrosstabReporteElement);
0268:                new DropTarget(this , // component
0269:                        DnDConstants.ACTION_COPY_OR_MOVE, // actions
0270:                        this ); // DropTargetListener
0271:
0272:                I18n
0273:                        .addOnLanguageChangedListener(new LanguageChangedListener() {
0274:                            public void languageChanged(LanguageChangedEvent evt) {
0275:                                applyI18n();
0276:                            }
0277:                        });
0278:                applyI18n();
0279:            }
0280:
0281:            public void updateSize() {
0282:                int maxWidth = 0;
0283:                int maxHeight = 0;
0284:
0285:                if (getColumns().size() > 0)
0286:                    maxWidth = ((Integer) getColumns().get(
0287:                            getColumns().size() - 1)).intValue();
0288:                if (getRows().size() > 0)
0289:                    maxHeight = ((Integer) getRows().get(getRows().size() - 1))
0290:                            .intValue();
0291:
0292:                if (getRows().size() == 0)
0293:                    maxHeight += getRowHeight("");
0294:                if (getColumns().size() == 0)
0295:                    maxWidth += getColumnWidth("");
0296:
0297:                if (getCrosstabElement().getHeight() > maxHeight)
0298:                    maxHeight = getCrosstabElement().getHeight();
0299:                if (getCrosstabElement().getWidth() > maxWidth)
0300:                    maxWidth = getCrosstabElement().getWidth();
0301:                Dimension d = new Dimension(
0302:                        (int) (maxWidth * getZoomFactor() + 20),
0303:                        (int) (maxHeight * getZoomFactor() + 20));
0304:                this .setSize(d);
0305:                this .setPreferredSize(d);
0306:                this .setMinimumSize(d);
0307:                this .setMaximumSize(d);
0308:            }
0309:
0310:            public CrosstabReportElement getCrosstabElement() {
0311:                if (getEditor() != null)
0312:                    return getEditor().getCrosstabElement();
0313:                return null;
0314:            }
0315:
0316:            /**
0317:             * This method paint the wthite surface of the crossrtab
0318:             **/
0319:            public void paintDocument(Graphics2D g2) {
0320:                CrosstabReportElement crosstabElement = getCrosstabElement();
0321:
0322:                if (crosstabElement == null)
0323:                    return;
0324:
0325:                g2.setPaint(java.awt.Color.WHITE);
0326:
0327:                int maxWidth = 0;
0328:                int maxHeight = 0;
0329:
0330:                if (getColumns().size() > 0)
0331:                    maxWidth = ((Integer) getColumns().get(
0332:                            getColumns().size() - 1)).intValue();
0333:                if (getRows().size() > 0)
0334:                    maxHeight = ((Integer) getRows().get(getRows().size() - 1))
0335:                            .intValue();
0336:
0337:                if (getRows().size() == 0)
0338:                    maxHeight += getRowHeight("");
0339:                if (getColumns().size() == 0)
0340:                    maxWidth += getColumnWidth("");
0341:
0342:                if (getCrosstabElement().getHeight() > maxHeight)
0343:                    maxHeight = getCrosstabElement().getHeight();
0344:                if (getCrosstabElement().getWidth() > maxWidth)
0345:                    maxWidth = getCrosstabElement().getWidth();
0346:
0347:                int zoomedCrosstabWidth = getZoomedDim(maxWidth);
0348:                int zoomedCrosstabHeight = getZoomedDim(maxHeight);
0349:
0350:                g2.fillRect(10, 10, zoomedCrosstabWidth, zoomedCrosstabHeight);
0351:
0352:                // BORDER TOP...
0353:                AffineTransform at = new AffineTransform();
0354:                at.translate(17, 0);
0355:                at.scale(zoomedCrosstabWidth - 14, 1);
0356:                g2.drawImage(crosstabBorderImage.getImage(), at, this );
0357:
0358:                // BORDER BOTTOM
0359:                at = new AffineTransform();
0360:                at.translate(17, zoomedCrosstabHeight + 20);
0361:                at.scale(zoomedCrosstabWidth - 14, 1);
0362:                at.scale(1, -1);
0363:                g2.drawImage(crosstabBorderImage.getImage(), at, this );
0364:
0365:                // LEFT
0366:                at = new AffineTransform();
0367:                at.translate(0, 17);
0368:                at.scale(1, zoomedCrosstabHeight - 14);
0369:                g2.drawImage(crosstabBorderHImage.getImage(), at, this );
0370:
0371:                // RIGHT
0372:                at = new AffineTransform();
0373:                at.translate(zoomedCrosstabWidth + 20, 17);
0374:                at.scale(1, zoomedCrosstabHeight - 14);
0375:                at.scale(-1, 1);
0376:                g2.drawImage(crosstabBorderHImage.getImage(), at, this );
0377:
0378:                // CORNERS
0379:                g2.drawImage(crosstabCornerImage.getImage(), 0, 0, this );
0380:                at = new AffineTransform();
0381:                at.translate(0, zoomedCrosstabHeight
0382:                        + crosstabCornerImage.getIconHeight() + 3);
0383:                at.scale(1, -1);
0384:                g2.drawImage(crosstabCornerImage.getImage(), at, this );
0385:
0386:                at = new AffineTransform();
0387:
0388:                //at.scale(-1,1); // Horizontal flip
0389:                at.translate(zoomedCrosstabWidth
0390:                        + crosstabCornerImage.getIconWidth() + 3, 0);
0391:                at.scale(-1, 1);
0392:                g2.drawImage(crosstabCornerImage.getImage(), at, this );
0393:
0394:                at.translate(0, zoomedCrosstabHeight
0395:                        + crosstabCornerImage.getIconHeight() + 3);
0396:                at.scale(1, -1);
0397:                g2.drawImage(crosstabCornerImage.getImage(), at, this );
0398:
0399:                // Now we have to paint the cells...
0400:
0401:                maxWidth = 0;
0402:                maxHeight = 0;
0403:
0404:                g2.setColor(new Color(220, 220, 255));
0405:
0406:                if (getColumns().size() > 0)
0407:                    maxWidth = ((Integer) getColumns().get(
0408:                            getColumns().size() - 1)).intValue();
0409:                if (getRows().size() > 0)
0410:                    maxHeight = ((Integer) getRows().get(getRows().size() - 1))
0411:                            .intValue();
0412:
0413:                for (int i = 0; i < getColumns().size(); ++i) {
0414:                    int x = ((Integer) getColumns().get(i)).intValue();
0415:                    if (x > 0)
0416:                        g2.drawLine(10 + getZoomedDim(x) - 1, 10,
0417:                                10 + getZoomedDim(x) - 1,
0418:                                getZoomedDim(maxHeight) - 1 + 10);
0419:                }
0420:
0421:                for (int i = 0; i < getRows().size(); ++i) {
0422:                    int y = ((Integer) getRows().get(i)).intValue();
0423:
0424:                    if (y > 0)
0425:                        g2.drawLine(10, 10 + getZoomedDim(y) - 1,
0426:                                getZoomedDim(maxWidth) - 1 + 10,
0427:                                10 + getZoomedDim(y) - 1);
0428:                }
0429:
0430:                //g2.setColor(new Color(250,250,250));
0431:                //g2.fillRect(10,10, getZoomedDim( ((Integer)getColumns().get( getCrosstabElement().getRowGroups().size() )).intValue())-1,
0432:                //        getZoomedDim( ((Integer)getRows().get( getCrosstabElement().getColumnGroups().size() )).intValue())-1);
0433:
0434:                // FIRST DROW THE BACKGROUND FOR EACH CELLS
0435:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
0436:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0437:                            .getCells().elementAt(i);
0438:
0439:                    if (cell.getType() != cell.NODATA_CELL
0440:                            && cell.getWidth() > 0 && cell.getHeight() > 0) {
0441:                        cell.drawCell(g2, getZoomFactor());
0442:                        cell
0443:                                .drawCellBox(
0444:                                        g2,
0445:                                        getZoomFactor(),
0446:                                        (cell.getType() == cell.HEADER_CELL || cell
0447:                                                .getType() == cell.CT_HEADER_CELL)
0448:                                                && cell.getTop() == ((Integer) rows
0449:                                                        .get(getCrosstabElement()
0450:                                                                .getColumnGroups()
0451:                                                                .size()))
0452:                                                        .intValue(),
0453:                                        (cell.getType() == cell.HEADER_CELL || cell
0454:                                                .getType() == cell.CT_HEADER_CELL)
0455:                                                && cell.getLeft() == ((Integer) columns
0456:                                                        .get(getCrosstabElement()
0457:                                                                .getRowGroups()
0458:                                                                .size()))
0459:                                                        .intValue());
0460:                    }
0461:                }
0462:
0463:                // DRAW ALL ELEMENTS...
0464:                for (int i = 0; i < getCrosstabElement().getElements().size(); ++i) {
0465:                    ReportElement re = (ReportElement) getCrosstabElement()
0466:                            .getElements().elementAt(i);
0467:                    if (re.getCell().getType() != CrosstabCell.NODATA_CELL) {
0468:                        re.drawObject(g2, getZoomFactor(), 0, 0);
0469:                    }
0470:                }
0471:
0472:                // THEN DRAW THE BOX FOR EACH CELL...
0473:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
0474:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0475:                            .getCells().elementAt(i);
0476:                    if (cell.getType() != cell.NODATA_CELL
0477:                            && cell.getWidth() > 0 && cell.getHeight() > 0) {
0478:
0479:                        // cell.drawCellBox(g2, getZoomFactor());
0480:                    }
0481:                }
0482:
0483:                if (isDefaultCellMode()) {
0484:                    //g2.setColor(new Color(255,255,255,200));
0485:                    //g2.fillRect(10,10, zoomedCrosstabWidth, zoomedCrosstabHeight);
0486:
0487:                    for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
0488:                        CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0489:                                .getCells().elementAt(i);
0490:                        if (cell.getType() == cell.NODATA_CELL) {
0491:                            cell.drawCell(g2, getZoomFactor());
0492:                            cell.drawCellBox(g2, getZoomFactor(), false, false);
0493:
0494:                            // DRAW ALL ELEMENTS...
0495:                            for (int j = 0; j < getCrosstabElement()
0496:                                    .getElements().size(); ++j) {
0497:                                ReportElement re = (ReportElement) getCrosstabElement()
0498:                                        .getElements().elementAt(j);
0499:                                if (re.getCell() == cell) {
0500:                                    re.drawObject(g2, getZoomFactor(), 0, 0);
0501:                                }
0502:                            }
0503:                        }
0504:                    }
0505:                }
0506:
0507:                // DRAW SELECTION...
0508:                for (int i = 0; i < getCrosstabElement().getElements().size(); ++i) {
0509:                    ReportElement re = (ReportElement) getCrosstabElement()
0510:                            .getElements().elementAt(i);
0511:                    if (getSelectedElements().contains(re)) {
0512:                        re.drawCorona(g2, getZoomFactor(), 0, 0,
0513:                                re == getSelectedElements().firstElement());
0514:                    }
0515:                }
0516:
0517:            }
0518:
0519:            public void paint(Graphics g) {
0520:                if (animation)
0521:                    return;
0522:
0523:                Graphics2D g2 = (Graphics2D) g;
0524:                Shape s = g2.getClip();
0525:                AffineTransform at = g2.getTransform();
0526:
0527:                try {
0528:                    super .paint(g);
0529:
0530:                    if (getCrosstabElement() == null)
0531:                        return;
0532:
0533:                    if (MainFrame.getMainInstance().getProperties()
0534:                            .getProperty("Antialias", "true").equals("false")) {
0535:
0536:                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
0537:                                RenderingHints.VALUE_ANTIALIAS_OFF);
0538:                        g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
0539:                                RenderingHints.VALUE_STROKE_PURE);
0540:                        g2.setRenderingHint(RenderingHints.KEY_DITHERING,
0541:                                RenderingHints.VALUE_DITHER_DISABLE);
0542:                    } else {
0543:
0544:                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
0545:                                RenderingHints.VALUE_ANTIALIAS_ON);
0546:                        g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
0547:                                RenderingHints.VALUE_STROKE_DEFAULT);
0548:                        g2.setRenderingHint(RenderingHints.KEY_DITHERING,
0549:                                RenderingHints.VALUE_DITHER_ENABLE);
0550:                    }
0551:
0552:                    paintDocument(g2);
0553:
0554:                    g2.setClip(s);
0555:
0556:                } catch (Throwable ex) {
0557:                    ex.printStackTrace();
0558:                } finally {
0559:                    if (s != null && g2 != null) {
0560:                        g2.setClip(s);
0561:                    }
0562:
0563:                    if (at != null && g2 != null) {
0564:                        g2.setTransform(at);
0565:                    }
0566:                }
0567:
0568:            }
0569:
0570:            public CrosstabEditor getEditor() {
0571:                return editor;
0572:            }
0573:
0574:            public void setEditor(CrosstabEditor editor) {
0575:                this .editor = editor;
0576:                this .updateGrid();
0577:                this .invalidate();
0578:                this .repaint();
0579:            }
0580:
0581:            public double getZoomFactor() {
0582:                return zoomFactor;
0583:            }
0584:
0585:            public void setZoomFactor(double zoomFactor) {
0586:                this .zoomFactor = zoomFactor;
0587:                updateSize();
0588:                this .repaint();
0589:            }
0590:
0591:            /**
0592:             *  Return an int.  It performs zoomFactor*dim and a round.
0593:             */
0594:            public int getZoomedDim(int dim) {
0595:                if (zoomFactor == 1.0 || dim == 0)
0596:                    return dim;
0597:                return (int) ((double) dim * zoomFactor);
0598:            }
0599:
0600:            /**
0601:             *  Return an int.  It performs zoomFactor*dim and a round.
0602:             */
0603:            public int getRealDim(int dim) {
0604:                if (zoomFactor == 1.0 || dim == 0)
0605:                    return dim;
0606:                return (int) ((double) dim / zoomFactor);
0607:            }
0608:
0609:            /**
0610:             * This method update the cell matrix according with groups and cells contained in
0611:             * the CrosstabElement...
0612:             **/
0613:            public void updateGrid() {
0614:                if (getCrosstabElement() == null)
0615:                    return;
0616:
0617:                try {
0618:                    getColumns().clear();
0619:                    getRows().clear();
0620:                    int current_x = 0;
0621:                    int current_y = 0;
0622:
0623:                    // Adjusting cells dimensions...
0624:                    CrosstabCell mainCell = findCell("", "");
0625:                    for (int k = 0; k < getCrosstabElement().getCells().size(); ++k) {
0626:                        CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0627:                                .getCells().elementAt(k);
0628:
0629:                        cell.setParent(this .getCrosstabElement());
0630:
0631:                        if (cell.getType() == cell.DETAIL_CELL) {
0632:                            if (cell.getHeight() == 0)
0633:                                cell.setHeight(getRowHeight(cell
0634:                                        .getRowTotalGroup()));
0635:                            if (cell.getWidth() == 0)
0636:                                cell.setWidth(getColumnWidth(cell
0637:                                        .getColumnTotalGroup()));
0638:                        }
0639:                    }
0640:
0641:                    addNotDefinedCells();
0642:
0643:                    getColumns().add(new Integer(current_x));
0644:
0645:                    for (int i = 0; i < getCrosstabElement().getRowGroups()
0646:                            .size(); ++i) {
0647:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0648:                                .getRowGroups().elementAt(i);
0649:                        cg.getHeaderCell().setLeft(current_x);
0650:                        cg.getTotalCell().setLeft(current_x);
0651:                        current_x = current_x + cg.getSize();
0652:                        getColumns().add(new Integer(current_x));
0653:                    }
0654:
0655:                    ArrayList columnWidths = new ArrayList();
0656:                    for (int i = getCrosstabElement().getColumnGroups().size() - 1; i >= 0; --i) {
0657:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0658:                                .getColumnGroups().elementAt(i);
0659:
0660:                        if (i == getCrosstabElement().getColumnGroups().size() - 1) {
0661:                            columnWidths.add(new Integer(getColumnWidth("")));
0662:                        }
0663:                        if (!cg.getTotalPosition().equals("Start")) {
0664:                            columnWidths.add(new Integer(getColumnWidth(cg
0665:                                    .getName())));
0666:                        } else {
0667:                            columnWidths.add(0, new Integer(getColumnWidth(cg
0668:                                    .getName())));
0669:                        }
0670:
0671:                    }
0672:
0673:                    for (int i = 0; i < columnWidths.size(); ++i) {
0674:                        current_x += ((Integer) columnWidths.get(i)).intValue();
0675:                        getColumns().add(new Integer(current_x));
0676:                    }
0677:                    if (getCrosstabElement().getColumnGroups().size() == 0)
0678:                        getColumns().add(
0679:                                new Integer(current_x += getColumnWidth("")));
0680:
0681:                    // Look for all rows...
0682:
0683:                    getRows().add(new Integer(current_y));
0684:                    for (int i = 0; i < getCrosstabElement().getColumnGroups()
0685:                            .size(); ++i) {
0686:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0687:                                .getColumnGroups().elementAt(i);
0688:                        cg.getHeaderCell().setTop(current_y);
0689:                        cg.getTotalCell().setTop(current_y);
0690:                        current_y = current_y + cg.getSize();
0691:                        getRows().add(new Integer(current_y));
0692:
0693:                    }
0694:
0695:                    ArrayList rowHeights = new ArrayList();
0696:                    for (int i = getCrosstabElement().getRowGroups().size() - 1; i >= 0; --i) {
0697:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0698:                                .getRowGroups().elementAt(i);
0699:
0700:                        if (i == getCrosstabElement().getRowGroups().size() - 1) {
0701:                            rowHeights.add(new Integer(getRowHeight("")));
0702:                        }
0703:                        if (!cg.getTotalPosition().equals("Start")) {
0704:                            rowHeights.add(new Integer(getRowHeight(cg
0705:                                    .getName())));
0706:                        } else {
0707:                            rowHeights.add(0, new Integer(getRowHeight(cg
0708:                                    .getName())));
0709:                        }
0710:                    }
0711:
0712:                    for (int i = 0; i < rowHeights.size(); ++i) {
0713:                        current_y += ((Integer) rowHeights.get(i)).intValue();
0714:                        getRows().add(new Integer(current_y));
0715:                    }
0716:                    if (getCrosstabElement().getRowGroups().size() == 0)
0717:                        getRows().add(
0718:                                new Integer(current_y += getRowHeight("")));
0719:
0720:                    int columnGroups = getCrosstabElement().getColumnGroups()
0721:                            .size();
0722:                    int rowGroups = getCrosstabElement().getRowGroups().size();
0723:
0724:                    int currentTopRowNumber = columnGroups;
0725:                    int currentBottomRowNumber = columnGroups + rowGroups + 1;
0726:
0727:                    for (int i = 0; i < getCrosstabElement().getRowGroups()
0728:                            .size(); ++i) {
0729:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0730:                                .getRowGroups().elementAt(i);
0731:
0732:                        cg.getHeaderCell().setLeftIndex(i);
0733:                        cg.getHeaderCell().setLeft(
0734:                                ((Integer) getColumns().get(i)).intValue());
0735:                        cg
0736:                                .getHeaderCell()
0737:                                .setTopIndex(
0738:                                        (cg.getTotalPosition().equals("Start")) ? currentTopRowNumber + 1
0739:                                                : currentTopRowNumber);
0740:                        cg.getHeaderCell().setTop(
0741:                                ((Integer) getRows().get(
0742:                                        cg.getHeaderCell().getTopIndex()))
0743:                                        .intValue());
0744:                        cg.getHeaderCell().setRightIndex(i + 1);
0745:                        cg.getHeaderCell().setWidth(cg.getSize());
0746:                        cg
0747:                                .getHeaderCell()
0748:                                .setBottomIndex(
0749:                                        (cg.isHasTotal() && cg
0750:                                                .getTotalPosition().equals(
0751:                                                        "Start")) ? currentBottomRowNumber
0752:                                                : currentBottomRowNumber - 1);
0753:                        cg.getHeaderCell().setHeight(
0754:                                ((Integer) getRows().get(
0755:                                        cg.getHeaderCell().getBottomIndex()))
0756:                                        .intValue()
0757:                                        - cg.getHeaderCell().getTop());
0758:
0759:                        cg.getTotalCell().setLeftIndex(i);
0760:                        cg.getTotalCell().setLeft(cg.getHeaderCell().getLeft());
0761:                        cg
0762:                                .getTotalCell()
0763:                                .setTopIndex(
0764:                                        (cg.getTotalPosition().equals("Start")) ? currentTopRowNumber
0765:                                                : currentBottomRowNumber - 1);
0766:                        cg.getTotalCell().setTop(
0767:                                ((Integer) getRows().get(
0768:                                        cg.getTotalCell().getTopIndex()))
0769:                                        .intValue());
0770:                        cg.getTotalCell().setRightIndex(rowGroups);
0771:                        cg.getTotalCell().setWidth(
0772:                                ((Integer) getColumns().get(rowGroups))
0773:                                        .intValue()
0774:                                        - cg.getTotalCell().getLeft());
0775:                        cg
0776:                                .getTotalCell()
0777:                                .setBottomIndex(
0778:                                        (cg.isHasTotal() && cg
0779:                                                .getTotalPosition().equals(
0780:                                                        "Start")) ? currentTopRowNumber + 1
0781:                                                : currentBottomRowNumber);
0782:                        cg.getTotalCell().setHeight(
0783:                                ((Integer) getRows().get(
0784:                                        cg.getTotalCell().getBottomIndex()))
0785:                                        .intValue()
0786:                                        - cg.getTotalCell().getTop());
0787:
0788:                        if (cg.getTotalPosition().equals("Start"))
0789:                            currentTopRowNumber++;
0790:                        else
0791:                            currentBottomRowNumber--;
0792:
0793:                        // Update all cells with rowTotalGroup this group
0794:                        for (int k = 0; k < getCrosstabElement().getCells()
0795:                                .size(); ++k) {
0796:                            CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0797:                                    .getCells().elementAt(k);
0798:
0799:                            if (cell.getRowTotalGroup().equals(cg.getName())) {
0800:
0801:                                cell.setTop(cg.getTotalCell().getTop());
0802:                                cell.setHeight(cg.getTotalCell().getHeight());
0803:                            }
0804:                        }
0805:                    }
0806:
0807:                    int currentLeftColumnNumber = rowGroups;
0808:                    int currentRightColumnNumber = columnGroups + rowGroups + 1;
0809:                    for (int i = 0; i < getCrosstabElement().getColumnGroups()
0810:                            .size(); ++i) {
0811:                        CrosstabGroup cg = (CrosstabGroup) getCrosstabElement()
0812:                                .getColumnGroups().elementAt(i);
0813:
0814:                        // Count preceding total rows...
0815:
0816:                        cg
0817:                                .getHeaderCell()
0818:                                .setLeftIndex(
0819:                                        (cg.getTotalPosition().equals("Start")) ? currentLeftColumnNumber + 1
0820:                                                : currentLeftColumnNumber);
0821:                        cg.getHeaderCell().setLeft(
0822:                                ((Integer) getColumns().get(
0823:                                        cg.getHeaderCell().getLeftIndex()))
0824:                                        .intValue());
0825:                        cg.getHeaderCell().setTopIndex(i);
0826:                        cg.getHeaderCell().setTop(
0827:                                ((Integer) getRows().get(i)).intValue());
0828:                        cg
0829:                                .getHeaderCell()
0830:                                .setRightIndex(
0831:                                        (cg.isHasTotal() && cg
0832:                                                .getTotalPosition().equals(
0833:                                                        "Start")) ? currentRightColumnNumber
0834:                                                : currentRightColumnNumber - 1);
0835:                        cg.getHeaderCell().setWidth(
0836:                                ((Integer) getColumns().get(
0837:                                        cg.getHeaderCell().getRightIndex()))
0838:                                        .intValue()
0839:                                        - cg.getHeaderCell().getLeft());
0840:                        cg.getHeaderCell().setBottomIndex(i + 1);
0841:                        cg.getHeaderCell().setHeight(cg.getSize());
0842:
0843:                        cg
0844:                                .getTotalCell()
0845:                                .setLeftIndex(
0846:                                        (cg.getTotalPosition().equals("Start")) ? currentLeftColumnNumber
0847:                                                : currentRightColumnNumber - 1);
0848:                        cg.getTotalCell().setLeft(
0849:                                ((Integer) getColumns().get(
0850:                                        cg.getTotalCell().getLeftIndex()))
0851:                                        .intValue());
0852:                        cg.getTotalCell().setTopIndex(i);
0853:                        cg.getTotalCell().setTop(
0854:                                ((Integer) getRows().get(i)).intValue());
0855:                        cg
0856:                                .getTotalCell()
0857:                                .setRightIndex(
0858:                                        (cg.isHasTotal() && cg
0859:                                                .getTotalPosition().equals(
0860:                                                        "Start")) ? currentLeftColumnNumber + 1
0861:                                                : currentRightColumnNumber);
0862:                        cg.getTotalCell().setWidth(
0863:                                ((Integer) getColumns().get(
0864:                                        cg.getTotalCell().getRightIndex()))
0865:                                        .intValue()
0866:                                        - cg.getTotalCell().getLeft());
0867:                        cg.getTotalCell().setBottomIndex(columnGroups);
0868:                        cg.getTotalCell().setHeight(
0869:                                ((Integer) getRows().get(columnGroups))
0870:                                        .intValue()
0871:                                        - cg.getTotalCell().getTop());
0872:
0873:                        if (cg.getTotalPosition().equals("Start"))
0874:                            currentLeftColumnNumber++;
0875:                        else
0876:                            currentRightColumnNumber--;
0877:
0878:                        for (int k = 0; k < getCrosstabElement().getCells()
0879:                                .size(); ++k) {
0880:                            CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0881:                                    .getCells().elementAt(k);
0882:
0883:                            if (cell.getColumnTotalGroup().equals(cg.getName())) {
0884:                                cell.setLeft(cg.getTotalCell().getLeft());
0885:                                cell.setWidth(cg.getTotalCell().getWidth());
0886:                            }
0887:                        }
0888:
0889:                    }
0890:
0891:                    // Update coordinates for the A0 cell
0892:
0893:                    if (getCrosstabElement().getRowGroups().size() > 0) {
0894:                        mainCell
0895:                                .setTopIndex(((CrosstabGroup) getCrosstabElement()
0896:                                        .getRowGroups().lastElement())
0897:                                        .getHeaderCell().getTopIndex());
0898:                        mainCell.setTop(((CrosstabGroup) getCrosstabElement()
0899:                                .getRowGroups().lastElement()).getHeaderCell()
0900:                                .getTop());
0901:                    } else {
0902:                        mainCell.setTop(getCrosstabElement().getColumnGroups()
0903:                                .size());
0904:                        mainCell.setTop(((Integer) getRows().get(
0905:                                getCrosstabElement().getColumnGroups().size()))
0906:                                .intValue());
0907:                    }
0908:                    mainCell.setBottomIndex(mainCell.getTopIndex() + 1);
0909:
0910:                    if (getCrosstabElement().getColumnGroups().size() > 0) {
0911:                        mainCell
0912:                                .setLeftIndex(((CrosstabGroup) getCrosstabElement()
0913:                                        .getColumnGroups().lastElement())
0914:                                        .getHeaderCell().getLeftIndex());
0915:                        mainCell.setLeft(((CrosstabGroup) getCrosstabElement()
0916:                                .getColumnGroups().lastElement())
0917:                                .getHeaderCell().getLeft());
0918:                    } else {
0919:                        mainCell.setLeftIndex(getCrosstabElement()
0920:                                .getRowGroups().size());
0921:                        mainCell.setLeft(((Integer) getColumns().get(
0922:                                getCrosstabElement().getRowGroups().size()))
0923:                                .intValue());
0924:                    }
0925:                    mainCell.setRightIndex(mainCell.getLeftIndex() + 1);
0926:
0927:                    for (int k = 0; k < getCrosstabElement().getCells().size(); ++k) {
0928:                        CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0929:                                .getCells().elementAt(k);
0930:
0931:                        if (cell.getType() == cell.DETAIL_CELL) {
0932:                            if (cell.getRowTotalGroup().equals("")) {
0933:
0934:                                cell.setTop(mainCell.getTop());
0935:                                cell.setTopIndex(mainCell.getTopIndex());
0936:                                cell.setBottomIndex(mainCell.getBottomIndex());
0937:                            }
0938:                            if (cell.getColumnTotalGroup().equals("")) {
0939:
0940:                                cell.setLeft(mainCell.getLeft());
0941:                                cell.setLeftIndex(mainCell.getLeftIndex());
0942:                                cell.setRightIndex(mainCell.getRightIndex());
0943:                            }
0944:
0945:                            cell.setTopIndex(getTotalRowTopIndex(cell
0946:                                    .getRowTotalGroup()));
0947:                            cell.setBottomIndex(cell.getTopIndex() + 1);
0948:
0949:                            cell.setLeftIndex(getTotalColumnLeftIndex(cell
0950:                                    .getColumnTotalGroup()));
0951:                            cell.setRightIndex(cell.getLeftIndex() + 1);
0952:                        }
0953:                    }
0954:
0955:                    // adding DEFAULT NO DATA CELL....
0956:                    CrosstabCell detailCell = findCell("", "");
0957:                    boolean found = false;
0958:                    for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
0959:                        CrosstabCell cell = (CrosstabCell) getCrosstabElement()
0960:                                .getCells().elementAt(i);
0961:                        if (cell.getType() == cell.NODATA_CELL) {
0962:                            cell.setTop(0);
0963:                            cell.setLeft(0);
0964:                            cell.setWidth(this .getCrosstabElement().getWidth());
0965:                            cell.setHeight(this .getCrosstabElement()
0966:                                    .getHeight());
0967:                            cell.setTopIndex(0);
0968:                            cell.setLeftIndex(0);
0969:                            cell.setBottomIndex(0);
0970:                            cell.setRightIndex(0);
0971:                            found = true;
0972:                            break;
0973:                        }
0974:                    }
0975:
0976:                    if (!found) {
0977:                        CrosstabCell defaultWhenNoDataCell = detailCell
0978:                                .cloneMe();
0979:                        defaultWhenNoDataCell
0980:                                .setType(defaultWhenNoDataCell.NODATA_CELL);
0981:                        defaultWhenNoDataCell.setParent(this 
0982:                                .getCrosstabElement());
0983:                        defaultWhenNoDataCell.setName(null);
0984:                        defaultWhenNoDataCell.setTop(0);
0985:                        defaultWhenNoDataCell.setLeft(0);
0986:                        defaultWhenNoDataCell.setWidth(this 
0987:                                .getCrosstabElement().getWidth());
0988:                        defaultWhenNoDataCell.setHeight(this 
0989:                                .getCrosstabElement().getHeight());
0990:                        defaultWhenNoDataCell.setTopIndex(0);
0991:                        defaultWhenNoDataCell.setLeftIndex(0);
0992:                        defaultWhenNoDataCell.setBottomIndex(0);
0993:                        defaultWhenNoDataCell.setRightIndex(0);
0994:                        getCrosstabElement().getCells().add(
0995:                                defaultWhenNoDataCell);
0996:                    }
0997:
0998:                    found = false;
0999:
1000:                    // adding DEFAULT HEADER CELL....
1001:                    for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
1002:                        CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1003:                                .getCells().elementAt(i);
1004:                        if (cell.getType() == cell.CT_HEADER_CELL) {
1005:                            cell.setTop(0);
1006:                            cell.setTopIndex(0);
1007:                            cell.setLeft(0);
1008:                            cell.setLeftIndex(0);
1009:                            cell.setRightIndex(getCrosstabElement()
1010:                                    .getRowGroups().size());
1011:                            cell.setWidth(((Integer) getColumns().get(
1012:                                    cell.getRightIndex())).intValue());
1013:                            cell.setBottomIndex(getCrosstabElement()
1014:                                    .getColumnGroups().size());
1015:                            cell.setHeight(((Integer) getRows().get(
1016:                                    cell.getBottomIndex())).intValue());
1017:                            found = true;
1018:                            break;
1019:                        }
1020:                    }
1021:
1022:                    if (!found) {
1023:
1024:                        CrosstabCell crossTabHeaderCell = new CrosstabCell();
1025:                        crossTabHeaderCell
1026:                                .setType(crossTabHeaderCell.CT_HEADER_CELL);
1027:                        crossTabHeaderCell.setParent(this .getCrosstabElement());
1028:                        crossTabHeaderCell.setName(null);
1029:                        crossTabHeaderCell.setTop(0);
1030:                        crossTabHeaderCell.setTopIndex(0);
1031:                        crossTabHeaderCell.setLeft(0);
1032:                        crossTabHeaderCell.setLeftIndex(0);
1033:                        crossTabHeaderCell.setRightIndex(getCrosstabElement()
1034:                                .getRowGroups().size());
1035:                        crossTabHeaderCell.setWidth(((Integer) getColumns()
1036:                                .get(crossTabHeaderCell.getRightIndex()))
1037:                                .intValue());
1038:                        crossTabHeaderCell.setBottomIndex(getCrosstabElement()
1039:                                .getColumnGroups().size());
1040:                        crossTabHeaderCell.setHeight(((Integer) getRows().get(
1041:                                crossTabHeaderCell.getBottomIndex()))
1042:                                .intValue());
1043:                        getCrosstabElement().getCells().add(crossTabHeaderCell);
1044:                    }
1045:
1046:                    getRowBands().clear();
1047:
1048:                    for (int i = 1; i < getRows().size(); ++i) {
1049:                        Vector rowBandContents = new Vector();
1050:                        for (int k = 0; k < getCrosstabElement().getCells()
1051:                                .size(); ++k) {
1052:                            CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1053:                                    .getCells().elementAt(k);
1054:                            if (cell.getBottomIndex() == i) {
1055:                                rowBandContents.add(cell);
1056:                            }
1057:                        }
1058:                        getRowBands().add(rowBandContents);
1059:                    }
1060:
1061:                    getColumnBands().clear();
1062:
1063:                    for (int i = 1; i < getColumns().size(); ++i) {
1064:                        Vector columnBandContents = new Vector();
1065:                        for (int k = 0; k < getCrosstabElement().getCells()
1066:                                .size(); ++k) {
1067:                            CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1068:                                    .getCells().elementAt(k);
1069:                            if (cell.getRightIndex() == i) {
1070:                                columnBandContents.add(cell);
1071:                            }
1072:                        }
1073:                        getColumnBands().add(columnBandContents);
1074:                    }
1075:
1076:                    // Update  all elements positions...
1077:                    for (int i = 0; i < getCrosstabElement().getElements()
1078:                            .size(); ++i) {
1079:                        ReportElement re = (ReportElement) getCrosstabElement()
1080:                                .getElements().elementAt(i);
1081:
1082:                        re.getPosition().x = re.getRelativePosition().x
1083:                                + re.getCell().getLeft() + 10;
1084:                        re.getPosition().y = re.getRelativePosition().y
1085:                                + re.getCell().getTop() + 10;
1086:
1087:                        re.setPosition(re.position);
1088:                        re.trasform(new java.awt.Point(0, 0),
1089:                                TransformationType.TRANSFORMATION_RESIZE_SE);
1090:
1091:                    }
1092:
1093:                } catch (Exception ex) {
1094:                    ex.printStackTrace();
1095:                }
1096:                updateSize();
1097:
1098:            }
1099:
1100:            public CrosstabCell findCell(String rowGroup, String columnGroup) {
1101:                if (getCrosstabElement() == null)
1102:                    return null;
1103:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
1104:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1105:                            .getCells().elementAt(i);
1106:                    if (cell.getType() == cell.DETAIL_CELL
1107:                            && cell.getRowTotalGroup().equals(rowGroup)
1108:                            && cell.getColumnTotalGroup().equals(columnGroup)) {
1109:                        return cell;
1110:                    }
1111:                }
1112:                return null;
1113:            }
1114:
1115:            /**
1116:             * Return the maximum width of a certain column. The column "" is the A0 cell width
1117:             */
1118:            public int getColumnWidth(String columnTotalGroup) {
1119:                int tmpWidth = -1;
1120:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
1121:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1122:                            .getCells().elementAt(i);
1123:                    if (cell.getType() == cell.DETAIL_CELL
1124:                            && cell.getColumnTotalGroup().equals(
1125:                                    columnTotalGroup)
1126:                            && cell.getWidth() > tmpWidth) {
1127:                        tmpWidth = cell.getWidth();
1128:                    }
1129:                }
1130:
1131:                if (tmpWidth < 0) {
1132:                    return getColumnWidth("");
1133:                }
1134:
1135:                return tmpWidth;
1136:            }
1137:
1138:            /**
1139:             * Return the maximum height of a certain row. The row "" is the A0 cell row
1140:             */
1141:            public int getRowHeight(String rowTotalGroup) {
1142:                int tmpHeight = -1;
1143:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
1144:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
1145:                            .getCells().elementAt(i);
1146:                    if (cell.getType() == cell.DETAIL_CELL
1147:                            && cell.getRowTotalGroup().equals(rowTotalGroup)
1148:                            && cell.getHeight() > tmpHeight) {
1149:                        tmpHeight = cell.getHeight();
1150:                    }
1151:                }
1152:
1153:                if (tmpHeight < 0 && !rowTotalGroup.equals("")) {
1154:                    return getRowHeight("");
1155:                } else if (tmpHeight < 0 && rowTotalGroup.equals("")) {
1156:                    return 0;
1157:                }
1158:
1159:                return tmpHeight;
1160:            }
1161:
1162:            /**
1163:             * Return the maximum height of a certain row. The row "" is the A0 cell row
1164:             */
1165:            public int getTotalRowTopIndex(String rowTotalGroup) {
1166:                for (int i = 0; i < getCrosstabElement().getRowGroups().size(); ++i) {
1167:                    CrosstabGroup group = (CrosstabGroup) getCrosstabElement()
1168:                            .getRowGroups().elementAt(i);
1169:                    if (group.getName().equals(rowTotalGroup)) {
1170:                        return group.getTotalCell().getTopIndex();
1171:                    }
1172:                }
1173:                return findCell("", "").getTopIndex();
1174:            }
1175:
1176:            /**
1177:             * Return the maximum height of a certain row. The row "" is the A0 cell row
1178:             */
1179:            public int getTotalColumnLeftIndex(String columnTotalGroup) {
1180:                for (int i = 0; i < getCrosstabElement().getColumnGroups()
1181:                        .size(); ++i) {
1182:                    CrosstabGroup group = (CrosstabGroup) getCrosstabElement()
1183:                            .getColumnGroups().elementAt(i);
1184:                    if (group.getName().equals(columnTotalGroup)) {
1185:                        return group.getTotalCell().getLeftIndex();
1186:                    }
1187:                }
1188:                return findCell("", "").getLeftIndex();
1189:            }
1190:
1191:            /** This method is called from within the constructor to
1192:             * initialize the form.
1193:             * WARNING: Do NOT modify this code. The content of this method is
1194:             * always regenerated by the Form Editor.
1195:             */
1196:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
1197:            private void initComponents() {
1198:                jPopupMenuCrosstabReporteElement = new javax.swing.JPopupMenu();
1199:                jMenuItemElementProperties = new javax.swing.JMenuItem();
1200:                jMenuItemCrosstabProperties = new javax.swing.JMenuItem();
1201:                jMenuItemCellProperties = new javax.swing.JMenuItem();
1202:                jCheckBoxMenuItemDefaultCellEdit = new javax.swing.JCheckBoxMenuItem();
1203:                jSeparator1 = new javax.swing.JSeparator();
1204:                jMenuItemCut = new javax.swing.JMenuItem();
1205:                jMenuItemCopy = new javax.swing.JMenuItem();
1206:                jMenuItemPaste = new javax.swing.JMenuItem();
1207:                jMenuItemDelete = new javax.swing.JMenuItem();
1208:                jSeparator3 = new javax.swing.JSeparator();
1209:                jMenuItemCopyStyle = new javax.swing.JMenuItem();
1210:                jMenuItemPasteStyle = new javax.swing.JMenuItem();
1211:                jMenuItemTransformStaticText = new javax.swing.JMenuItem();
1212:                jMenuItemPattern = new javax.swing.JMenuItem();
1213:                jSeparator4 = new javax.swing.JSeparator();
1214:                jPopupMenuCrosstab = new javax.swing.JPopupMenu();
1215:                jMenuItemCrosstabProperties1 = new javax.swing.JMenuItem();
1216:                jMenuItemCellProperties1 = new javax.swing.JMenuItem();
1217:                jCheckBoxMenuItemDefaultCellEdit1 = new javax.swing.JCheckBoxMenuItem();
1218:                jMenuItemPaste1 = new javax.swing.JMenuItem();
1219:
1220:                jMenuItemElementProperties
1221:                        .setText(it.businesslogic.ireport.util.I18n.getString(
1222:                                "elementProperties", "Element properties"));
1223:                jMenuItemElementProperties
1224:                        .addActionListener(new java.awt.event.ActionListener() {
1225:                            public void actionPerformed(
1226:                                    java.awt.event.ActionEvent evt) {
1227:                                jMenuItemElementPropertiesActionPerformed(evt);
1228:                            }
1229:                        });
1230:
1231:                jPopupMenuCrosstabReporteElement
1232:                        .add(jMenuItemElementProperties);
1233:
1234:                jMenuItemCrosstabProperties.setText("Crosstab properties");
1235:                jMenuItemCrosstabProperties
1236:                        .addActionListener(new java.awt.event.ActionListener() {
1237:                            public void actionPerformed(
1238:                                    java.awt.event.ActionEvent evt) {
1239:                                jMenuItemCrosstabPropertiesActionPerformed(evt);
1240:                            }
1241:                        });
1242:
1243:                jPopupMenuCrosstabReporteElement
1244:                        .add(jMenuItemCrosstabProperties);
1245:
1246:                jMenuItemCellProperties.setText("Cell properties");
1247:                jMenuItemCellProperties
1248:                        .addActionListener(new java.awt.event.ActionListener() {
1249:                            public void actionPerformed(
1250:                                    java.awt.event.ActionEvent evt) {
1251:                                jMenuItemCellPropertiesActionPerformed(evt);
1252:                            }
1253:                        });
1254:
1255:                jPopupMenuCrosstabReporteElement.add(jMenuItemCellProperties);
1256:
1257:                jCheckBoxMenuItemDefaultCellEdit
1258:                        .setText("Edit When-No-Data default cell");
1259:                jCheckBoxMenuItemDefaultCellEdit
1260:                        .addActionListener(new java.awt.event.ActionListener() {
1261:                            public void actionPerformed(
1262:                                    java.awt.event.ActionEvent evt) {
1263:                                jCheckBoxMenuItemDefaultCellEditActionPerformed(evt);
1264:                            }
1265:                        });
1266:
1267:                jPopupMenuCrosstabReporteElement
1268:                        .add(jCheckBoxMenuItemDefaultCellEdit);
1269:
1270:                jPopupMenuCrosstabReporteElement.add(jSeparator1);
1271:
1272:                jMenuItemCut
1273:                        .setIcon(new javax.swing.ImageIcon(
1274:                                getClass()
1275:                                        .getResource(
1276:                                                "/it/businesslogic/ireport/icons/menu/cut.png")));
1277:                jMenuItemCut.setText("Cut");
1278:                jMenuItemCut.setEnabled(false);
1279:                jMenuItemCut
1280:                        .addActionListener(new java.awt.event.ActionListener() {
1281:                            public void actionPerformed(
1282:                                    java.awt.event.ActionEvent evt) {
1283:                                jMenuItemCutActionPerformed(evt);
1284:                            }
1285:                        });
1286:
1287:                jPopupMenuCrosstabReporteElement.add(jMenuItemCut);
1288:
1289:                jMenuItemCopy
1290:                        .setIcon(new javax.swing.ImageIcon(
1291:                                getClass()
1292:                                        .getResource(
1293:                                                "/it/businesslogic/ireport/icons/menu/copy.png")));
1294:                jMenuItemCopy.setText("Copy");
1295:                jMenuItemCopy.setEnabled(false);
1296:                jMenuItemCopy
1297:                        .addActionListener(new java.awt.event.ActionListener() {
1298:                            public void actionPerformed(
1299:                                    java.awt.event.ActionEvent evt) {
1300:                                jMenuItemCopyActionPerformed(evt);
1301:                            }
1302:                        });
1303:
1304:                jPopupMenuCrosstabReporteElement.add(jMenuItemCopy);
1305:
1306:                jMenuItemPaste
1307:                        .setIcon(new javax.swing.ImageIcon(
1308:                                getClass()
1309:                                        .getResource(
1310:                                                "/it/businesslogic/ireport/icons/menu/paste.png")));
1311:                jMenuItemPaste.setText("Paste");
1312:                jMenuItemPaste.setEnabled(false);
1313:                jMenuItemPaste
1314:                        .addActionListener(new java.awt.event.ActionListener() {
1315:                            public void actionPerformed(
1316:                                    java.awt.event.ActionEvent evt) {
1317:                                jMenuItemPasteActionPerformed(evt);
1318:                            }
1319:                        });
1320:
1321:                jPopupMenuCrosstabReporteElement.add(jMenuItemPaste);
1322:
1323:                jMenuItemDelete
1324:                        .setIcon(new javax.swing.ImageIcon(
1325:                                getClass()
1326:                                        .getResource(
1327:                                                "/it/businesslogic/ireport/icons/menu/delete.png")));
1328:                jMenuItemDelete.setText("Delete");
1329:                jMenuItemDelete.setEnabled(false);
1330:                jMenuItemDelete
1331:                        .addActionListener(new java.awt.event.ActionListener() {
1332:                            public void actionPerformed(
1333:                                    java.awt.event.ActionEvent evt) {
1334:                                jMenuItemDeleteActionPerformed(evt);
1335:                            }
1336:                        });
1337:
1338:                jPopupMenuCrosstabReporteElement.add(jMenuItemDelete);
1339:
1340:                jPopupMenuCrosstabReporteElement.add(jSeparator3);
1341:
1342:                jMenuItemCopyStyle.setEnabled(false);
1343:                jMenuItemCopyStyle.setLabel("Copy style");
1344:                jMenuItemCopyStyle
1345:                        .addActionListener(new java.awt.event.ActionListener() {
1346:                            public void actionPerformed(
1347:                                    java.awt.event.ActionEvent evt) {
1348:                                jMenuItemCopyStyleActionPerformed(evt);
1349:                            }
1350:                        });
1351:
1352:                jPopupMenuCrosstabReporteElement.add(jMenuItemCopyStyle);
1353:
1354:                jMenuItemPasteStyle.setEnabled(false);
1355:                jMenuItemPasteStyle.setLabel("Paste style");
1356:                jMenuItemPasteStyle
1357:                        .addActionListener(new java.awt.event.ActionListener() {
1358:                            public void actionPerformed(
1359:                                    java.awt.event.ActionEvent evt) {
1360:                                jMenuItemPasteStyleActionPerformed(evt);
1361:                            }
1362:                        });
1363:
1364:                jPopupMenuCrosstabReporteElement.add(jMenuItemPasteStyle);
1365:
1366:                jMenuItemTransformStaticText
1367:                        .setAccelerator(javax.swing.KeyStroke.getKeyStroke(
1368:                                java.awt.event.KeyEvent.VK_F3, 0));
1369:                jMenuItemTransformStaticText.setLabel("Transform in Textfield");
1370:                jMenuItemTransformStaticText
1371:                        .addActionListener(new java.awt.event.ActionListener() {
1372:                            public void actionPerformed(
1373:                                    java.awt.event.ActionEvent evt) {
1374:                                jMenuItemTransformStaticTextActionPerformed(evt);
1375:                            }
1376:                        });
1377:
1378:                jPopupMenuCrosstabReporteElement
1379:                        .add(jMenuItemTransformStaticText);
1380:
1381:                jMenuItemPattern.setText("Field pattern");
1382:                jMenuItemPattern
1383:                        .addActionListener(new java.awt.event.ActionListener() {
1384:                            public void actionPerformed(
1385:                                    java.awt.event.ActionEvent evt) {
1386:                                jMenuItemPatternActionPerformed(evt);
1387:                            }
1388:                        });
1389:
1390:                jPopupMenuCrosstabReporteElement.add(jMenuItemPattern);
1391:
1392:                jPopupMenuCrosstabReporteElement.add(jSeparator4);
1393:
1394:                jMenuItemCrosstabProperties1.setText("Crosstab properties");
1395:                jMenuItemCrosstabProperties1
1396:                        .addActionListener(new java.awt.event.ActionListener() {
1397:                            public void actionPerformed(
1398:                                    java.awt.event.ActionEvent evt) {
1399:                                jMenuItemCrosstabPropertiesActionPerformed1(evt);
1400:                            }
1401:                        });
1402:
1403:                jPopupMenuCrosstab.add(jMenuItemCrosstabProperties1);
1404:
1405:                jMenuItemCellProperties1.setText("Cell properties");
1406:                jMenuItemCellProperties1
1407:                        .addActionListener(new java.awt.event.ActionListener() {
1408:                            public void actionPerformed(
1409:                                    java.awt.event.ActionEvent evt) {
1410:                                jMenuItemCellPropertiesActionPerformed1(evt);
1411:                            }
1412:                        });
1413:
1414:                jPopupMenuCrosstab.add(jMenuItemCellProperties1);
1415:
1416:                jCheckBoxMenuItemDefaultCellEdit1
1417:                        .setText("Edit When-No-Data default cell");
1418:                jCheckBoxMenuItemDefaultCellEdit1
1419:                        .addActionListener(new java.awt.event.ActionListener() {
1420:                            public void actionPerformed(
1421:                                    java.awt.event.ActionEvent evt) {
1422:                                jCheckBoxMenuItemDefaultCellEdit1ActionPerformed(evt);
1423:                            }
1424:                        });
1425:
1426:                jPopupMenuCrosstab.add(jCheckBoxMenuItemDefaultCellEdit1);
1427:
1428:                jMenuItemPaste1
1429:                        .setIcon(new javax.swing.ImageIcon(
1430:                                getClass()
1431:                                        .getResource(
1432:                                                "/it/businesslogic/ireport/icons/menu/paste.png")));
1433:                jMenuItemPaste1.setText("Paste");
1434:                jMenuItemPaste1.setEnabled(false);
1435:                jMenuItemPaste1
1436:                        .addActionListener(new java.awt.event.ActionListener() {
1437:                            public void actionPerformed(
1438:                                    java.awt.event.ActionEvent evt) {
1439:                                jMenuItemPasteActionPerformed1(evt);
1440:                            }
1441:                        });
1442:
1443:                jPopupMenuCrosstab.add(jMenuItemPaste1);
1444:
1445:                setLayout(null);
1446:
1447:                setBackground(new java.awt.Color(204, 204, 204));
1448:                setFocusCycleRoot(true);
1449:                addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
1450:                    public void mouseDragged(java.awt.event.MouseEvent evt) {
1451:                        formMouseDragged(evt);
1452:                    }
1453:
1454:                    public void mouseMoved(java.awt.event.MouseEvent evt) {
1455:                        formMouseMoved(evt);
1456:                    }
1457:                });
1458:                addFocusListener(new java.awt.event.FocusAdapter() {
1459:                    public void focusGained(java.awt.event.FocusEvent evt) {
1460:                        formFocusGained(evt);
1461:                    }
1462:                });
1463:                addKeyListener(new java.awt.event.KeyAdapter() {
1464:                    public void keyPressed(java.awt.event.KeyEvent evt) {
1465:                        formKeyPressed(evt);
1466:                    }
1467:
1468:                    public void keyTyped(java.awt.event.KeyEvent evt) {
1469:                        formKeyTyped(evt);
1470:                    }
1471:                });
1472:                addMouseListener(new java.awt.event.MouseAdapter() {
1473:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
1474:                        formMouseClicked(evt);
1475:                    }
1476:
1477:                    public void mousePressed(java.awt.event.MouseEvent evt) {
1478:                        formMousePressed(evt);
1479:                    }
1480:
1481:                    public void mouseReleased(java.awt.event.MouseEvent evt) {
1482:                        formMouseReleased(evt);
1483:                    }
1484:                });
1485:
1486:            }// </editor-fold>//GEN-END:initComponents
1487:
1488:            private void jCheckBoxMenuItemDefaultCellEdit1ActionPerformed(
1489:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemDefaultCellEdit1ActionPerformed
1490:                setDefaultCellMode(jCheckBoxMenuItemDefaultCellEdit1
1491:                        .isSelected());
1492:            }//GEN-LAST:event_jCheckBoxMenuItemDefaultCellEdit1ActionPerformed
1493:
1494:            private void jCheckBoxMenuItemDefaultCellEditActionPerformed(
1495:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemDefaultCellEditActionPerformed
1496:
1497:                setDefaultCellMode(jCheckBoxMenuItemDefaultCellEdit
1498:                        .isSelected());
1499:
1500:            }//GEN-LAST:event_jCheckBoxMenuItemDefaultCellEditActionPerformed
1501:
1502:            private void jMenuItemPasteActionPerformed1(
1503:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed1
1504:
1505:                getParentReportFrame().paste();
1506:
1507:            }//GEN-LAST:event_jMenuItemPasteActionPerformed1
1508:
1509:            private void jMenuItemCellPropertiesActionPerformed1(
1510:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCellPropertiesActionPerformed1
1511:                jMenuItemCellPropertiesActionPerformed(evt);
1512:            }//GEN-LAST:event_jMenuItemCellPropertiesActionPerformed1
1513:
1514:            private void jMenuItemCrosstabPropertiesActionPerformed1(
1515:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCrosstabPropertiesActionPerformed1
1516:                jMenuItemCrosstabPropertiesActionPerformed(evt);
1517:            }//GEN-LAST:event_jMenuItemCrosstabPropertiesActionPerformed1
1518:
1519:            private void jMenuItemPatternActionPerformed(
1520:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPatternActionPerformed
1521:                String pattern = "";
1522:                FieldPatternDialog pd = new FieldPatternDialog(MainFrame
1523:                        .getMainInstance(), true);
1524:                pd.setVisible(true);
1525:                if (pd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
1526:
1527:                    Enumeration selectedElementEnum = getSelectedElements()
1528:                            .elements();
1529:
1530:                    while (selectedElementEnum.hasMoreElements()) {
1531:                        ReportElement re = (ReportElement) selectedElementEnum
1532:                                .nextElement();
1533:                        if (re instanceof  TextFieldReportElement) {
1534:                            ((TextFieldReportElement) re).setPattern(pd
1535:                                    .getPattern());
1536:                        }
1537:                    }
1538:                }
1539:            }//GEN-LAST:event_jMenuItemPatternActionPerformed
1540:
1541:            private void jMenuItemTransformStaticTextActionPerformed(
1542:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTransformStaticTextActionPerformed
1543:                transformStaticInTextFields();
1544:            }//GEN-LAST:event_jMenuItemTransformStaticTextActionPerformed
1545:
1546:            private void jMenuItemPasteStyleActionPerformed(
1547:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteStyleActionPerformed
1548:                pasteStyle();
1549:            }//GEN-LAST:event_jMenuItemPasteStyleActionPerformed
1550:
1551:            private void jMenuItemCopyStyleActionPerformed(
1552:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyStyleActionPerformed
1553:                copyStyle();
1554:            }//GEN-LAST:event_jMenuItemCopyStyleActionPerformed
1555:
1556:            private void jMenuItemDeleteActionPerformed(
1557:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeleteActionPerformed
1558:                deleteSelectedElements();
1559:            }//GEN-LAST:event_jMenuItemDeleteActionPerformed
1560:
1561:            private void jMenuItemPasteActionPerformed(
1562:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
1563:                getParentReportFrame().paste();
1564:            }//GEN-LAST:event_jMenuItemPasteActionPerformed
1565:
1566:            private void jMenuItemCopyActionPerformed(
1567:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
1568:                getParentReportFrame().copy();
1569:            }//GEN-LAST:event_jMenuItemCopyActionPerformed
1570:
1571:            private void jMenuItemCutActionPerformed(
1572:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCutActionPerformed
1573:                getParentReportFrame().cut();
1574:            }//GEN-LAST:event_jMenuItemCutActionPerformed
1575:
1576:            private void jMenuItemElementPropertiesActionPerformed(
1577:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementPropertiesActionPerformed
1578:                this .getParentReportFrame().openElementPropertiesDialog();
1579:            }//GEN-LAST:event_jMenuItemElementPropertiesActionPerformed
1580:
1581:            private void jMenuItemCellPropertiesActionPerformed(
1582:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCellPropertiesActionPerformed
1583:
1584:                if (selectedCell != null) {
1585:                    editCell(selectedCell);
1586:                }
1587:
1588:            }//GEN-LAST:event_jMenuItemCellPropertiesActionPerformed
1589:
1590:            public void editCell(CrosstabCell editCell) {
1591:                CrosstabCellDialog ctd = new CrosstabCellDialog(MainFrame
1592:                        .getMainInstance(), true);
1593:                ctd.setTmpCell(editCell);
1594:                ctd.setVisible(true);
1595:                if (ctd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
1596:                    editCell.setBackcolor(ctd.getTmpCell().getBackcolor());
1597:                    editCell.setBox(ctd.getTmpCell().getBox());
1598:                    editCell.setMode(ctd.getTmpCell().getMode());
1599:                    editCell.setStyle(ctd.getTmpCell().getStyle());
1600:
1601:                    if (editCell.getWidth() != ctd.getTmpCell().getWidth()) {
1602:                        // Modify all with for cell with this column index,
1603:                        // Modify all left coords for elements of cells width index > of this column index
1604:                        // Modify all cell left
1605:
1606:                        int columnIndex = editCell.getLeftIndex();
1607:                        int delta = ctd.getTmpCell().getWidth()
1608:                                - editCell.getWidth();
1609:                        for (int i = 0; i < this .getCrosstabElement()
1610:                                .getCells().size(); ++i) {
1611:                            CrosstabCell cell = (CrosstabCell) this 
1612:                                    .getCrosstabElement().getCells().elementAt(
1613:                                            i);
1614:                            if (cell.getLeftIndex() == columnIndex
1615:                                    || cell.getRightIndex() == columnIndex + 1) {
1616:                                cell.setWidth(cell.getWidth() + delta);
1617:                            }
1618:                            if (cell.getLeftIndex() > columnIndex) {
1619:                                cell.setLeft(cell.getLeft() + delta);
1620:                                for (int j = 0; j < getCrosstabElement()
1621:                                        .getElements().size(); ++j) {
1622:                                    ReportElement re = (ReportElement) getCrosstabElement()
1623:                                            .getElements().elementAt(j);
1624:                                    if (re.getCell() == cell) {
1625:                                        re
1626:                                                .trasform(
1627:                                                        new Point(delta, 0),
1628:                                                        TransformationType.TRANSFORMATION_MOVE);
1629:                                    }
1630:                                }
1631:                            }
1632:                        }
1633:
1634:                        for (int i = columnIndex + 1; i < columns.size(); ++i) {
1635:                            int columnPosition = ((Integer) columns.get(i))
1636:                                    .intValue();
1637:                            columnPosition = columnPosition += delta;
1638:                            columns.set(i, new Integer(columnPosition));
1639:                        }
1640:                    }
1641:
1642:                    if (editCell.getHeight() != ctd.getTmpCell().getHeight()) {
1643:                        // Modify all with for cell with this column index,
1644:                        // Modify all left coords for elements of cells width index > of this column index
1645:                        // Modify all cell left
1646:
1647:                        int rowIndex = editCell.getTopIndex();
1648:                        int delta = ctd.getTmpCell().getHeight()
1649:                                - editCell.getHeight();
1650:                        for (int i = 0; i < this .getCrosstabElement()
1651:                                .getCells().size(); ++i) {
1652:                            CrosstabCell cell = (CrosstabCell) this 
1653:                                    .getCrosstabElement().getCells().elementAt(
1654:                                            i);
1655:
1656:                            if (cell.getTopIndex() == rowIndex
1657:                                    || cell.getBottomIndex() == rowIndex + 1) {
1658:                                cell.setHeight(cell.getHeight() + delta);
1659:                            } else if (cell.getTopIndex() > rowIndex) {
1660:                                cell.setTop(cell.getTop() + delta);
1661:                                for (int j = 0; j < getCrosstabElement()
1662:                                        .getElements().size(); ++j) {
1663:                                    ReportElement re = (ReportElement) getCrosstabElement()
1664:                                            .getElements().elementAt(j);
1665:                                    if (re.getCell() == cell) {
1666:                                        re
1667:                                                .trasform(
1668:                                                        new Point(0, delta),
1669:                                                        TransformationType.TRANSFORMATION_MOVE);
1670:                                    }
1671:                                }
1672:                            }
1673:                        }
1674:
1675:                        for (int i = rowIndex + 1; i < rows.size(); ++i) {
1676:                            int rowPosition = ((Integer) rows.get(i))
1677:                                    .intValue();
1678:                            rowPosition = rowPosition += delta;
1679:                            rows.set(i, new Integer(rowPosition));
1680:                        }
1681:                    }
1682:
1683:                    this .repaint();
1684:                    this .getCrosstabElement().notifyChange();
1685:                }
1686:            }
1687:
1688:            private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained
1689:
1690:            }//GEN-LAST:event_formFocusGained
1691:
1692:            private void formKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyTyped
1693:
1694:            }//GEN-LAST:event_formKeyTyped
1695:
1696:            public void panelKeyPressed(java.awt.event.KeyEvent evt) {
1697:                formKeyPressed(evt);
1698:            }
1699:
1700:            private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
1701:
1702:                if (this .getSelectedElements().size() > 0)
1703:                    evt.consume();
1704:                // Standard speed:
1705:                int x = 1, y = 1;
1706:
1707:                // Increase the speed of movement if the Shift key is pressed
1708:                if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
1709:                    x = 10;
1710:                    y = 10;
1711:                }
1712:
1713:                //if ((evt.getModifiers() & evt.ALT_MASK) != 0)
1714:                //    System.out.println("Tasto:"+evt.getKeyCode());
1715:                if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_DELETE) {
1716:                    this .deleteSelectedElements();
1717:                    return;
1718:                }
1719:                /* Begin code Robert Lamping, 12 July 2004 */
1720:                /* Short cut keys for quick alignment */
1721:                else if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
1722:                        && ((evt.getModifiers() & evt.CTRL_MASK) != 0)) {
1723:
1724:                    /* all key presses when SHIFT/CTRL are both pressed */
1725:
1726:                    /* Short cuts for alignments */
1727:                    /* most of them deactivated, since they are activated bia the menu options and their
1728:                     * short cuts
1729:                     */
1730:                    switch (evt.getKeyCode()) {
1731:                    case java.awt.event.KeyEvent.VK_S:
1732:                        /* shrink A3-A4 */
1733:                        FormatCommand.getCommand(OperationType.SHRINK)
1734:                                .execute();
1735:                        break;
1736:                    }
1737:
1738:                }
1739:                /* End code Robert Lamping, 12 July 2004 */
1740:
1741:                else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_UP) {
1742:                    y *= -1;
1743:                    x = 0;
1744:
1745:                    // Remove selected elements...
1746:                    // Up of x...
1747:                    Vector changed_elements = new Vector();
1748:                    for (Iterator i = selectedElements.iterator(); i.hasNext();) {
1749:                        ReportElement element = (ReportElement) i.next();
1750:                        element.trasform(new Point(x, y),
1751:                                TransformationType.TRANSFORMATION_MOVE);
1752:                        element.adjustCell(getCrosstabElement().getCells());
1753:                        changed_elements.add(element);
1754:                    }
1755:                    getParentReportFrame()
1756:                            .fireReportListenerReportElementsChanged(
1757:                                    new ReportElementChangedEvent(
1758:                                            getParentReportFrame(),
1759:                                            getCrosstabElement(),
1760:                                            changed_elements,
1761:                                            ReportElementChangedEvent.CHANGED));
1762:
1763:                    this .getMainFrame().getElementPropertiesDialog()
1764:                            .updateSelection();
1765:                    this .repaint();
1766:                } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_LEFT) {
1767:                    x *= -1;
1768:                    y = 0;
1769:
1770:                    // Up of x...
1771:                    Vector changed_elements = new Vector();
1772:                    for (Iterator i = selectedElements.iterator(); i.hasNext();) {
1773:                        ReportElement element = (ReportElement) i.next();
1774:                        element.trasform(new Point(x, y),
1775:                                TransformationType.TRANSFORMATION_MOVE);
1776:                        element.adjustCell(getCrosstabElement().getCells());
1777:                        changed_elements.add(element);
1778:                    }
1779:                    getParentReportFrame()
1780:                            .fireReportListenerReportElementsChanged(
1781:                                    new ReportElementChangedEvent(
1782:                                            getParentReportFrame(),
1783:                                            getCrosstabElement(),
1784:                                            changed_elements,
1785:                                            ReportElementChangedEvent.CHANGED));
1786:                    this .getMainFrame().getElementPropertiesDialog()
1787:                            .updateSelection();
1788:                    this .repaint();
1789:                } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_RIGHT) {
1790:                    y = 0;
1791:                    // Remove selected elements...
1792:                    // Up of x...
1793:                    Vector changed_elements = new Vector();
1794:                    for (Iterator i = selectedElements.iterator(); i.hasNext();) {
1795:                        ReportElement element = (ReportElement) i.next();
1796:                        element.trasform(new Point(x, y),
1797:                                TransformationType.TRANSFORMATION_MOVE);
1798:                        element.adjustCell(getCrosstabElement().getCells());
1799:                        changed_elements.add(element);
1800:                    }
1801:                    getParentReportFrame()
1802:                            .fireReportListenerReportElementsChanged(
1803:                                    new ReportElementChangedEvent(
1804:                                            getParentReportFrame(),
1805:                                            getCrosstabElement(),
1806:                                            changed_elements,
1807:                                            ReportElementChangedEvent.CHANGED));
1808:                    this .getMainFrame().getElementPropertiesDialog()
1809:                            .updateSelection();
1810:
1811:                    this .repaint();
1812:                } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_DOWN) {
1813:                    x = 0;
1814:                    // Remove selected elements...
1815:                    // Up of x...
1816:                    Vector changed_elements = new Vector();
1817:                    for (Iterator i = selectedElements.iterator(); i.hasNext();) {
1818:                        ReportElement element = (ReportElement) i.next();
1819:                        element.trasform(new Point(x, y),
1820:                                TransformationType.TRANSFORMATION_MOVE);
1821:                        element.adjustCell(getCrosstabElement().getCells());
1822:                        changed_elements.add(element);
1823:                    }
1824:                    getParentReportFrame()
1825:                            .fireReportListenerReportElementsChanged(
1826:                                    new ReportElementChangedEvent(
1827:                                            getParentReportFrame(),
1828:                                            getCrosstabElement(),
1829:                                            changed_elements,
1830:                                            ReportElementChangedEvent.CHANGED));
1831:                    this .getMainFrame().getElementPropertiesDialog()
1832:                            .updateSelection();
1833:                    this .repaint();
1834:                } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_F2) {
1835:                    // Edit static Text
1836:
1837:                    DeleteElementsOperation undoOp = new DeleteElementsOperation(
1838:                            getParentReportFrame(), getCrosstabElement());
1839:                    for (Iterator i = selectedElements.iterator(); i.hasNext();) {
1840:                        ReportElement re = (ReportElement) i.next();
1841:                        if (re instanceof  TextReportElement) {
1842:                            String te = ((TextReportElement) re).getText();
1843:                            String result = javax.swing.JOptionPane
1844:                                    .showInputDialog(this , I18n.getString(
1845:                                            "messages.enterNewValue",
1846:                                            "Please enter a new Value"), te);
1847:                            if (result != null && !result.equals("")) {
1848:                                ((TextReportElement) re).setText(result);
1849:                                undoOp.addElement(re, getCrosstabElement()
1850:                                        .getElements().indexOf(re));
1851:                                getParentReportFrame()
1852:                                        .fireReportListenerReportElementsChanged(
1853:                                                new ReportElementChangedEvent(
1854:                                                        getParentReportFrame(),
1855:                                                        re,
1856:                                                        ReportElementChangedEvent.CHANGED));
1857:                            }
1858:                        }
1859:                    }
1860:                    getParentReportFrame().addUndoOperation(undoOp);
1861:                    getMainFrame().getElementPropertiesDialog()
1862:                            .updateSelection();
1863:                    this .repaint();
1864:                } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_F3) {
1865:
1866:                    getParentReportFrame().transformStaticInTextFields();
1867:                    this .getMainFrame().getElementPropertiesDialog()
1868:                            .updateSelection();
1869:                }
1870:                /* Begin code by Robert Lamping, 12 july 2004 */
1871:                /* Copy and paste via CTRL/INS and SHIFT insert */
1872:                else if (((evt.getModifiers() & evt.CTRL_MASK) != 0)
1873:                        && evt.getKeyCode() == java.awt.event.KeyEvent.VK_INSERT) {
1874:                    getParentReportFrame().copy();
1875:                } else if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
1876:                        && evt.getKeyCode() == java.awt.event.KeyEvent.VK_INSERT) {
1877:                    getParentReportFrame().paste();
1878:                }
1879:                /* End code Robert Lamping, 12 July 2004 */
1880:
1881:            }//GEN-LAST:event_formKeyPressed
1882:
1883:            private void jMenuItemCrosstabPropertiesActionPerformed(
1884:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCrosstabPropertiesActionPerformed
1885:
1886:                it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1887:                        MainFrame.getMainInstance(), true);
1888:                cpd.setCurrentCrosstabReportElement(getCrosstabElement());
1889:                cpd.setVisible(true);
1890:
1891:            }//GEN-LAST:event_jMenuItemCrosstabPropertiesActionPerformed
1892:
1893:            private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
1894:
1895:                int mouseX = (int) evt.getPoint().getX();
1896:                int mouseY = (int) evt.getPoint().getY();
1897:
1898:                if (drag_selection_mode && evt.getButton() == evt.BUTTON1) {
1899:
1900:                    drag_selection_mode = false;
1901:                    Graphics2D gg = (Graphics2D) this .getGraphics();
1902:                    gg.setXORMode(Color.GREEN);
1903:
1904:                    Stroke s = gg.getStroke();
1905:                    gg.setStroke(selectionStroke);
1906:
1907:                    if (!first_draw_selection_rect) {
1908:                        gg.drawRect((int) Math.min(drag_selection_origin.x,
1909:                                drag_selection_end.x), (int) Math.min(
1910:                                drag_selection_origin.y, drag_selection_end.y),
1911:                                (int) Math.abs(drag_selection_origin.x
1912:                                        - drag_selection_end.x), (int) Math
1913:                                        .abs(drag_selection_origin.y
1914:                                                - drag_selection_end.y));
1915:                    }
1916:
1917:                    gg.setPaintMode();
1918:                    if (s != null) {
1919:                        gg.setStroke(s);
1920:                    }
1921:                    drag_selection_mode = false;
1922:                    first_draw_selection_rect = true;
1923:
1924:                    if ((evt.getModifiers() & evt.SHIFT_MASK) == 0) {
1925:                        setSelectedElement(null);
1926:                    }
1927:
1928:                    int delta_w = evt.getX() - drag_selection_origin.x;
1929:                    int delta_h = evt.getY() - drag_selection_origin.y;
1930:                    int delta_x = (delta_w < 0) ? delta_w : 0;
1931:                    int delta_y = (delta_h < 0) ? delta_h : 0;
1932:
1933:                    int originX = getRealDim(Math.min(drag_selection_origin.x,
1934:                            drag_selection_end.x) - 10) + 10;
1935:                    int originY = getRealDim(Math.min(drag_selection_origin.y,
1936:                            drag_selection_end.y) - 10) + 10;
1937:                    int width = getRealDim(Math.abs(delta_w));
1938:                    int height = getRealDim(Math.abs(delta_h));
1939:
1940:                    // We need logical coordinates...
1941:                    java.awt.Rectangle rect = new java.awt.Rectangle(originX,
1942:                            originY, width, height);
1943:                    boolean selection_changed = false;
1944:                    for (Iterator i = getCrosstabElement().getElements()
1945:                            .iterator(); i.hasNext();) {
1946:                        ReportElement re = (ReportElement) i.next();
1947:                        if (re.intersects(rect)) {
1948:                            if (!selection_changed)
1949:                                selection_changed = true;
1950:                            addSelectedElement(re, false);
1951:                        }
1952:                    }
1953:                    if (selection_changed) {
1954:                        fireSelectionChangedEvent();
1955:                    }
1956:
1957:                } else if (evt.getButton() == evt.BUTTON1 && cell_dragging
1958:                        && readyToDragCellVertically > 0) {
1959:                    Graphics gg = this .getGraphics();
1960:                    gg.setXORMode(Color.WHITE);
1961:                    gg.drawLine(0, mouse.y, this .getWidth(), mouse.y);
1962:                    gg.setPaintMode();
1963:
1964:                    // Calculate DELTA...
1965:                    int oldPosition = ((Integer) getRows().get(
1966:                            readyToDragCellVertically)).intValue();
1967:                    int delta = getRealDim(mouseY - 10
1968:                            - getZoomedDim(oldPosition));
1969:
1970:                    if (oldPosition + delta <= ((Integer) getRows().get(
1971:                            readyToDragCellVertically - 1)).intValue()) {
1972:                        delta = ((Integer) getRows().get(
1973:                                readyToDragCellVertically - 1)).intValue()
1974:                                - oldPosition;
1975:                    }
1976:
1977:                    // Max height = Document height - Crosstab position...
1978:                    int maxHeight = getParentReportFrame().getReport()
1979:                            .getHeight()
1980:                            - getCrosstabElement().getPosition().y;
1981:
1982:                    if (((Integer) getRows().get(getRows().size() - 1))
1983:                            .intValue()
1984:                            + delta > maxHeight) {
1985:                        delta = maxHeight
1986:                                - ((Integer) getRows()
1987:                                        .get(getRows().size() - 1)).intValue();
1988:                    }
1989:                    if (delta == 0)
1990:                        return;
1991:
1992:                    int newPosition = ((Integer) getRows().get(
1993:                            readyToDragCellVertically)).intValue()
1994:                            + delta;
1995:
1996:                    // Save relative position for all elements...
1997:                    for (int j = 0; j < getCrosstabElement().getElements()
1998:                            .size(); ++j) {
1999:                        ReportElement re = (ReportElement) getCrosstabElement()
2000:                                .getElements().elementAt(j);
2001:                        re
2002:                                .setRelativePosition(new Point(
2003:                                        re.getPosition().x
2004:                                                - re.getCell().getLeft() - 10,
2005:                                        re.getPosition().y
2006:                                                - re.getCell().getTop() - 10));
2007:                    }
2008:
2009:                    if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2010:                        // 1. Perform a reverse search for readyToDragCellVertically
2011:
2012:                        for (int i = getRows().size() - 1; i > 0; --i) {
2013:                            int position = ((Integer) getRows().get(i))
2014:                                    .intValue();
2015:                            if (oldPosition == position) {
2016:                                readyToDragCellVertically = i;
2017:                                break;
2018:                            }
2019:                        }
2020:                    }
2021:
2022:                    // Modify hight of all cell in band readyToDragCellVertically...
2023:                    Vector cells = (Vector) getRowBands().elementAt(
2024:                            readyToDragCellVertically - 1);
2025:                    for (int i = 0; i < cells.size(); ++i) {
2026:                        CrosstabCell cell = (CrosstabCell) cells.elementAt(i);
2027:                        cell.setHeight(cell.getHeight() + delta);
2028:                    }
2029:                    for (int j = readyToDragCellVertically; j < getRowBands()
2030:                            .size(); ++j) {
2031:                        cells = (Vector) getRowBands().elementAt(j);
2032:                        for (int i = 0; i < cells.size(); ++i) {
2033:                            CrosstabCell cell = (CrosstabCell) cells
2034:                                    .elementAt(i);
2035:                            if (cell.getTopIndex() >= readyToDragCellVertically) {
2036:                                cell.setTop(cell.getTop() + delta);
2037:                            } else {
2038:                                cell.setHeight(cell.getHeight() + delta);
2039:                            }
2040:                        }
2041:                    }
2042:
2043:                    // Adjust size value of all groups...
2044:                    for (int i = 0; i < getCrosstabElement().getColumnGroups()
2045:                            .size(); ++i) {
2046:                        CrosstabGroup group = (CrosstabGroup) getCrosstabElement()
2047:                                .getColumnGroups().elementAt(i);
2048:                        group.setSize(group.getHeaderCell().getHeight());
2049:                    }
2050:
2051:                    // Adjust all elements position with new cell positions...
2052:                    for (int j = 0; j < getCrosstabElement().getElements()
2053:                            .size(); ++j) {
2054:                        ReportElement re = (ReportElement) getCrosstabElement()
2055:                                .getElements().elementAt(j);
2056:                        re.getPosition().x = re.getRelativePosition().x
2057:                                + re.getCell().getLeft() + 10;
2058:                        re.getPosition().y = re.getRelativePosition().y
2059:                                + re.getCell().getTop() + 10;
2060:
2061:                        re.setPosition(re.position);
2062:                        re.trasform(new java.awt.Point(0, 0),
2063:                                TransformationType.TRANSFORMATION_RESIZE_SE);
2064:                    }
2065:
2066:                    for (int i = readyToDragCellVertically; i < getRows()
2067:                            .size(); ++i) {
2068:                        int rowPosition = ((Integer) getRows().get(i))
2069:                                .intValue()
2070:                                + delta;
2071:                        getRows().set(i, new Integer(rowPosition));
2072:                    }
2073:
2074:                    //
2075:
2076:                    cell_dragging = false;
2077:                    updateSize();
2078:                    repaint();
2079:                    getParentReportFrame().addUndoOperation(
2080:                            new CrosstabRowDraggedOperation(this ,
2081:                                    getCrosstabElement(),
2082:                                    readyToDragCellVertically, delta));
2083:                } else if (evt.getButton() == evt.BUTTON1 && cell_dragging
2084:                        && readyToDragCellHorizontally > 0) {
2085:                    Graphics gg = this .getGraphics();
2086:                    gg.setXORMode(Color.WHITE);
2087:                    gg.drawLine(mouse.x, 0, mouse.x, this .getHeight());
2088:                    gg.setPaintMode();
2089:
2090:                    // Calculate DELTA...
2091:                    int oldPosition = ((Integer) getColumns().get(
2092:                            readyToDragCellHorizontally)).intValue();
2093:                    int delta = getRealDim(mouseX - 10
2094:                            - getZoomedDim(oldPosition));
2095:
2096:                    if (oldPosition + delta <= ((Integer) getColumns().get(
2097:                            readyToDragCellHorizontally - 1)).intValue()) {
2098:                        delta = ((Integer) getColumns().get(
2099:                                readyToDragCellHorizontally - 1)).intValue()
2100:                                - oldPosition;
2101:                    }
2102:
2103:                    // Max height = Document height - Crosstab position...
2104:                    int maxWidth = getParentReportFrame().getReport()
2105:                            .getWidth()
2106:                            - getCrosstabElement().getPosition().x;
2107:
2108:                    if (((Integer) getColumns().get(getColumns().size() - 1))
2109:                            .intValue()
2110:                            + delta > maxWidth) {
2111:                        delta = maxWidth
2112:                                - ((Integer) getColumns().get(
2113:                                        getColumns().size() - 1)).intValue();
2114:                    }
2115:                    if (delta == 0)
2116:                        return;
2117:
2118:                    int newPosition = ((Integer) getColumns().get(
2119:                            readyToDragCellHorizontally)).intValue()
2120:                            + delta;
2121:
2122:                    // Save relative position for all elements...
2123:                    for (int j = 0; j < getCrosstabElement().getElements()
2124:                            .size(); ++j) {
2125:                        ReportElement re = (ReportElement) getCrosstabElement()
2126:                                .getElements().elementAt(j);
2127:                        re
2128:                                .setRelativePosition(new Point(
2129:                                        re.getPosition().x
2130:                                                - re.getCell().getLeft() - 10,
2131:                                        re.getPosition().y
2132:                                                - re.getCell().getTop() - 10));
2133:                    }
2134:
2135:                    if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2136:                        // 1. Perform a reverse search for readyToDragCellVertically
2137:
2138:                        for (int i = getColumns().size() - 1; i > 0; --i) {
2139:                            int position = ((Integer) getColumns().get(i))
2140:                                    .intValue();
2141:                            if (oldPosition == position) {
2142:                                readyToDragCellHorizontally = i;
2143:                                break;
2144:                            }
2145:                        }
2146:                    }
2147:
2148:                    // Modify hight of all cell in band readyToDragCellVertically...
2149:                    Vector cells = (Vector) getColumnBands().elementAt(
2150:                            readyToDragCellHorizontally - 1);
2151:                    for (int i = 0; i < cells.size(); ++i) {
2152:                        CrosstabCell cell = (CrosstabCell) cells.elementAt(i);
2153:                        cell.setWidth(cell.getWidth() + delta);
2154:                    }
2155:                    for (int j = readyToDragCellHorizontally; j < getRowBands()
2156:                            .size(); ++j) {
2157:                        cells = (Vector) getColumnBands().elementAt(j);
2158:                        for (int i = 0; i < cells.size(); ++i) {
2159:                            CrosstabCell cell = (CrosstabCell) cells
2160:                                    .elementAt(i);
2161:                            if (cell.getLeftIndex() >= readyToDragCellHorizontally) {
2162:                                cell.setLeft(cell.getLeft() + delta);
2163:                            } else {
2164:                                cell.setWidth(cell.getWidth() + delta);
2165:                            }
2166:                        }
2167:                    }
2168:
2169:                    // Adjust size value of all groups...
2170:                    for (int i = 0; i < getCrosstabElement().getRowGroups()
2171:                            .size(); ++i) {
2172:                        CrosstabGroup group = (CrosstabGroup) getCrosstabElement()
2173:                                .getRowGroups().elementAt(i);
2174:                        group.setSize(group.getHeaderCell().getWidth());
2175:                    }
2176:
2177:                    // Adjust all elements position with new cell positions...
2178:                    for (int j = 0; j < getCrosstabElement().getElements()
2179:                            .size(); ++j) {
2180:                        ReportElement re = (ReportElement) getCrosstabElement()
2181:                                .getElements().elementAt(j);
2182:                        re.getPosition().x = re.getRelativePosition().x
2183:                                + re.getCell().getLeft() + 10;
2184:                        re.getPosition().y = re.getRelativePosition().y
2185:                                + re.getCell().getTop() + 10;
2186:
2187:                        re.setPosition(re.position);
2188:                        re.trasform(new java.awt.Point(0, 0),
2189:                                TransformationType.TRANSFORMATION_RESIZE_SE);
2190:                    }
2191:
2192:                    for (int i = readyToDragCellHorizontally; i < getColumns()
2193:                            .size(); ++i) {
2194:                        int rowPosition = ((Integer) getColumns().get(i))
2195:                                .intValue()
2196:                                + delta;
2197:                        getColumns().set(i, new Integer(rowPosition));
2198:                    }
2199:
2200:                    cell_dragging = false;
2201:                    updateSize();
2202:                    repaint();
2203:                    getParentReportFrame().addUndoOperation(
2204:                            new CrosstabColumnDraggedOperation(this ,
2205:                                    getCrosstabElement(),
2206:                                    readyToDragCellHorizontally, delta));
2207:                } else if (evt.getButton() == evt.BUTTON1) {
2208:                    if (newObjectType != ReportElementType.NONE) {
2209:                        // The second point was clicked
2210:
2211:                        firstXORDraw = true;
2212:
2213:                        // Find the band to associate to the new element...
2214:
2215:                        int delta_w = evt.getX() - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
2216:                        int delta_h = evt.getY() - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
2217:                        int delta_x = (delta_w < 0) ? delta_w : 0;
2218:                        int delta_y = (delta_h < 0) ? delta_h : 0;
2219:
2220:                        int originX = getRealDim(Math.min(
2221:                                newObjectOrigin.x - 10, newObjectOrigin.x
2222:                                        + delta_x - 10)) + 10;
2223:                        int originY = getRealDim(Math.min(
2224:                                newObjectOrigin.y - 10, newObjectOrigin.y
2225:                                        + delta_y - 10)) + 10;
2226:                        int width = getRealDim(Math.abs(delta_w));
2227:                        int height = getRealDim(Math.abs(delta_h));
2228:
2229:                        if (newObjectType == ReportElementType.LINE_ELEMENT) {
2230:                            /* When shift button is pressed too, then there will be no align ment on the grid */
2231:                            if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2232:                                Point straight = straighten(delta_w, delta_h);
2233:                                delta_w = straight.x;
2234:                                delta_h = straight.y;
2235:                            }
2236:                        }
2237:
2238:                        CrosstabCell bname = getCellByPoint(new Point(
2239:                                getRealDim(evt.getX() - 10), getRealDim(evt
2240:                                        .getY() - 10)));
2241:
2242:                        if (bname != null) {
2243:                            ReportElement re = ReportElementFactory.create(
2244:                                    newObjectType, originX, originY,
2245:                                    getRealDim(delta_w), getRealDim(delta_h));
2246:
2247:                            if (getParentReportFrame().getReport().getStyles()
2248:                                    .size() > 0) {
2249:                                for (int i = 0; i < getParentReportFrame()
2250:                                        .getReport().getStyles().size(); ++i) {
2251:                                    Style s = (Style) getParentReportFrame()
2252:                                            .getReport().getStyles().elementAt(
2253:                                                    i);
2254:
2255:                                    if (s.getAttributeBoolean(
2256:                                            s.ATTRIBUTE_isDefault, false) == true) {
2257:                                        re.setStyle(s);
2258:                                    }
2259:                                }
2260:                            }
2261:                            /* Begin Code Robert Lamping, 13 july 2004 */
2262:                            // Element does not know about other elements, the frame does, so here we reset the key.
2263:                            // barcode becomes barcode-1, or higher depending on what the highest sub number is.
2264:                            // Same for graphcs image, or whatever initial name
2265:                            re.setKey(getParentReportFrame().getNextElementKey(
2266:                                    re.getKey()));
2267:
2268:                            /* End Code Robert Lamping, 13 july 2004 */
2269:
2270:                            re.setCell(bname);
2271:                            re.setRelativePosition(new Point(re.getPosition().x
2272:                                    - re.getCell().getLeft() - 10, re
2273:                                    .getPosition().y
2274:                                    - re.getCell().getTop() - 10));
2275:                            for (int elnum = getCrosstabElement().getElements()
2276:                                    .size() - 1; elnum >= 0; --elnum) {
2277:                                ReportElement container_re = (ReportElement) getCrosstabElement()
2278:                                        .getElements().elementAt(elnum);
2279:                                if (container_re instanceof  FrameReportElement
2280:                                        && container_re.getCell() == re
2281:                                                .getCell()) {
2282:                                    if (container_re.getBounds().contains(
2283:                                            re.getBounds())) {
2284:                                        re.setParentElement(container_re);
2285:                                        break;
2286:                                    }
2287:                                }
2288:                            }
2289:
2290:                            getCrosstabElement().getElements().addElement(re);
2291:
2292:                            getParentReportFrame()
2293:                                    .fireReportListenerReportElementsChanged(
2294:                                            new ReportElementChangedEvent(
2295:                                                    getParentReportFrame(),
2296:                                                    getCrosstabElement(),
2297:                                                    re,
2298:                                                    ReportElementChangedEvent.ADDED));
2299:
2300:                            getParentReportFrame().addUndoOperation(
2301:                                    new InsertElementOperation(
2302:                                            getParentReportFrame(),
2303:                                            getCrosstabElement(), re));
2304:                            setSelectedElement(re);
2305:
2306:                        } else {
2307:                            setSelectedElement(null);
2308:                        }
2309:                        newObjectOrigin = null;
2310:
2311:                        newObjectType = ReportElementType.NONE;
2312:
2313:                        this .setCursor(Cursor.getDefaultCursor());
2314:                        getMainFrame().setActiveTool(0);
2315:
2316:                    } else if (trasforming) {
2317:                        trasforming = false;
2318:
2319:                        this .setCursor(Cursor.getDefaultCursor());
2320:
2321:                        if (transformation_type != TransformationType.TRANSFORMATION_MOVE
2322:                                || resistenceExceeded == true) {
2323:                            Point p = new Point(transformation_origin_end);
2324:                            p.x = getRealDim(p.x);
2325:                            p.y = getRealDim(p.y);
2326:                            p.x -= getRealDim(transformation_origin.x);
2327:                            p.y -= getRealDim(transformation_origin.y);
2328:
2329:                            Enumeration e = getSelectedElements().elements();
2330:                            TransformElementsOperation undoOp = new TransformElementsOperation(
2331:                                    getMainFrame().getMainInstance()
2332:                                            .getActiveReportFrame(), this 
2333:                                            .getCrosstabElement());
2334:                            Vector changed_elements = new Vector();
2335:                            while (e.hasMoreElements()) {
2336:                                ReportElement re = (ReportElement) e
2337:                                        .nextElement();
2338:
2339:                                undoOp.addElement(re);
2340:
2341:                                re.trasform(p, transformation_type);
2342:                                re.adjustCell(getCrosstabElement().getCells());
2343:                                undoOp.captureUniqueModified(re);
2344:                                getParentReportFrame().addUndoOperation(undoOp);
2345:
2346:                                changed_elements.add(re);
2347:
2348:                            }
2349:                            if (changed_elements.size() > 0) {
2350:                                getMainFrame()
2351:                                        .getMainInstance()
2352:                                        .getActiveReportFrame()
2353:                                        .fireReportListenerReportElementsChanged(
2354:                                                new ReportElementChangedEvent(
2355:                                                        getMainFrame()
2356:                                                                .getMainInstance()
2357:                                                                .getActiveReportFrame(),
2358:                                                        getCrosstabElement(),
2359:                                                        changed_elements,
2360:                                                        ReportElementChangedEvent.CHANGED));
2361:                            }
2362:
2363:                            this .repaint();
2364:                        }
2365:
2366:                        transformation_undo_delta = new Point(0, 0);
2367:                        transformation_type = TransformationType.TRANSFORMATION_NONE;
2368:                        getMainFrame().getElementPropertiesDialog()
2369:                                .updateSelection();
2370:                    }
2371:                }
2372:
2373:                mouse.y = mouseY;
2374:                mouse.x = mouseX;
2375:
2376:            }//GEN-LAST:event_formMouseReleased
2377:
2378:            private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
2379:
2380:                int mouseX = (int) evt.getPoint().getX();
2381:                int mouseY = (int) evt.getPoint().getY();
2382:
2383:                if (drag_selection_mode == true) {
2384:                    Graphics2D gg = (Graphics2D) this .getGraphics();
2385:                    gg.setXORMode(Color.GREEN);
2386:                    Stroke s = gg.getStroke();
2387:                    gg.setStroke(selectionStroke);
2388:                    if (!first_draw_selection_rect) {
2389:                        gg.drawRect((int) Math.min(drag_selection_origin.x,
2390:                                drag_selection_end.x), (int) Math.min(
2391:                                drag_selection_origin.y, drag_selection_end.y),
2392:                                (int) Math.abs(drag_selection_origin.x
2393:                                        - drag_selection_end.x), (int) Math
2394:                                        .abs(drag_selection_origin.y
2395:                                                - drag_selection_end.y));
2396:                    }
2397:
2398:                    drag_selection_end = new java.awt.Point(evt.getX(), evt
2399:                            .getY());
2400:                    // Draw the new rectangle...
2401:                    gg.drawRect((int) Math.min(drag_selection_origin.x,
2402:                            drag_selection_end.x), (int) Math.min(
2403:                            drag_selection_origin.y, drag_selection_end.y),
2404:                            (int) Math.abs(drag_selection_origin.x
2405:                                    - drag_selection_end.x), (int) Math
2406:                                    .abs(drag_selection_origin.y
2407:                                            - drag_selection_end.y));
2408:                    gg.setPaintMode();
2409:                    first_draw_selection_rect = false;
2410:                    if (s != null)
2411:                        gg.setStroke(s);
2412:                } else if (cell_dragging && readyToDragCellVertically > 0) {
2413:                    Graphics gg = this .getGraphics();
2414:                    gg.setXORMode(Color.WHITE);
2415:                    gg.drawLine(0, mouse.y, this .getWidth(), mouse.y);
2416:                    gg.drawLine(0, mouseY, this .getWidth(), mouseY);
2417:                    gg.setPaintMode();
2418:                } else if (cell_dragging && readyToDragCellHorizontally > 0) {
2419:                    Graphics gg = this .getGraphics();
2420:                    gg.setXORMode(Color.WHITE);
2421:                    gg.drawLine(mouse.x, 0, mouse.x, this .getHeight());
2422:                    gg.drawLine(mouseX, 0, mouseX, this .getHeight());
2423:                    gg.setPaintMode();
2424:                } else if (newObjectType != ReportElementType.NONE
2425:                        && newObjectOrigin != null) {
2426:
2427:                    /* In the process of defing the second point. */
2428:
2429:                    Graphics gg = this .getGraphics();
2430:                    gg.setXORMode(Color.WHITE);
2431:                    int delta_x = 0;
2432:                    int delta_y = 0;
2433:
2434:                    if (newObjectType != ReportElementType.LINE_ELEMENT
2435:                            && !firstXORDraw) {
2436:                        delta_x = mouse.x - newObjectOrigin.x;
2437:                        delta_y = mouse.y - newObjectOrigin.y;
2438:
2439:                        delta_x = (delta_x < 0) ? delta_x : 0;
2440:                        delta_y = (delta_y < 0) ? delta_y : 0;
2441:                    }
2442:
2443:                    int delta_w = 0;
2444:                    int delta_h = 0;
2445:                    if (!firstXORDraw) {
2446:                        delta_w = mouse.x - newObjectOrigin.x;
2447:                        delta_h = mouse.y - newObjectOrigin.y;
2448:                        delta_x = (delta_w < 0) ? delta_w : 0;
2449:                        delta_y = (delta_h < 0) ? delta_h : 0;
2450:                    }
2451:
2452:                    if (newObjectType == ReportElementType.LINE_ELEMENT) {
2453:
2454:                        /* overwrite the other one, so that it disappears */
2455:                        if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2456:                            Point straight = straighten(delta_w, delta_h);
2457:                            delta_w = straight.x;
2458:                            delta_h = straight.y;
2459:                        }
2460:
2461:                        if (!firstXORDraw) {
2462:                            gg.drawLine(newObjectOrigin.x, newObjectOrigin.y,
2463:                                    newObjectOrigin.x + delta_w,
2464:                                    newObjectOrigin.y + delta_h);
2465:                        }
2466:
2467:                        delta_w = evt.getX() - newObjectOrigin.x;
2468:                        delta_h = evt.getY() - newObjectOrigin.y;
2469:
2470:                        if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2471:                            Point straight = straighten(delta_w, delta_h);
2472:                            delta_w = straight.x;
2473:                            delta_h = straight.y;
2474:                        }
2475:
2476:                        gg.drawLine(newObjectOrigin.x, newObjectOrigin.y,
2477:                                newObjectOrigin.x + delta_w, newObjectOrigin.y
2478:                                        + delta_h);
2479:                        mouse.x = newObjectOrigin.x + delta_w;
2480:                        mouse.y = newObjectOrigin.x + delta_y;
2481:
2482:                    } else if (newObjectType == ReportElementType.ELLIPSE_ELEMENT) {
2483:                        if (!firstXORDraw)
2484:                            gg.drawOval(newObjectOrigin.x + delta_x,
2485:                                    snapToGridVertically(newObjectOrigin.y
2486:                                            + delta_y), Math.abs(delta_w), Math
2487:                                            .abs(delta_h));
2488:
2489:                        delta_w = gridMultiple(evt.getX() - newObjectOrigin.x);
2490:                        delta_h = gridMultiple(evt.getY() - newObjectOrigin.y);
2491:                        delta_x = (delta_w < 0) ? delta_w : 0;
2492:                        delta_y = (delta_h < 0) ? delta_h : 0;
2493:                        gg.drawOval(newObjectOrigin.x + delta_x,
2494:                                snapToGridVertically(newObjectOrigin.y
2495:                                        + delta_y), Math.abs(delta_w), Math
2496:                                        .abs(delta_h));
2497:                    } else if (newObjectType == ReportElementType.ROUND_RECTANGLE_ELEMENT) {
2498:                        if (!firstXORDraw) {
2499:                            gg.drawRoundRect(newObjectOrigin.x + delta_x,
2500:                                    snapToGridVertically(newObjectOrigin.y
2501:                                            + delta_y), Math.abs(delta_w), Math
2502:                                            .abs(delta_h), 20, 20);
2503:                        }
2504:                        delta_w = gridMultiple(evt.getX() - newObjectOrigin.x);
2505:                        delta_h = gridMultiple(evt.getY() - newObjectOrigin.y);
2506:                        delta_x = (delta_w < 0) ? delta_w : 0;
2507:                        delta_y = (delta_h < 0) ? delta_h : 0;
2508:                        //gg.drawRect( snapToGridOrizzontally(newObjectOrigin.x+w_delta_x), snapToGridVertically(newObjectOrigin.y+delta_y), gridMultiple(Math.abs(evt.getX()-newObjectOrigin.x)), gridMultiple(Math.abs(evt.getY()-newObjectOrigin.y)));
2509:                        gg.drawRoundRect(newObjectOrigin.x + delta_x,
2510:                                snapToGridVertically(newObjectOrigin.y
2511:                                        + delta_y), Math.abs(delta_w), Math
2512:                                        .abs(delta_h), 20, 20);
2513:                    } else {
2514:                        if (!firstXORDraw) {
2515:                            gg.drawRect(newObjectOrigin.x + delta_x,
2516:                                    snapToGridVertically(newObjectOrigin.y
2517:                                            + delta_y), Math.abs(delta_w), Math
2518:                                            .abs(delta_h));
2519:                        }
2520:                        delta_w = gridMultiple(evt.getX() - newObjectOrigin.x);
2521:                        delta_h = gridMultiple(evt.getY() - newObjectOrigin.y);
2522:                        delta_x = (delta_w < 0) ? delta_w : 0;
2523:                        delta_y = (delta_h < 0) ? delta_h : 0;
2524:                        //gg.drawRect( snapToGridOrizzontally(newObjectOrigin.x+w_delta_x), snapToGridVertically(newObjectOrigin.y+delta_y), gridMultiple(Math.abs(evt.getX()-newObjectOrigin.x)), gridMultiple(Math.abs(evt.getY()-newObjectOrigin.y)));
2525:                        gg.drawRect(newObjectOrigin.x + delta_x,
2526:                                snapToGridVertically(newObjectOrigin.y
2527:                                        + delta_y), Math.abs(delta_w), Math
2528:                                        .abs(delta_h));
2529:                        //gg.drawRect( newObjectOrigin.x+delta_x, newObjectOrigin.y+delta_y, Math.abs(delta_from_origin), Math.abs(evt.getY()-newObjectOrigin.y));
2530:                    }
2531:
2532:                    firstXORDraw = false;
2533:                    gg.setPaintMode();
2534:
2535:                    //mouse.x = mouse.x + delta_from_origin;
2536:                    //mouse.y = evt.getY();
2537:                    //return;
2538:                } else if (selectedElements.size() > 0
2539:                        && newObjectType == ReportElementType.NONE
2540:                        && transformation_origin_end != null) {
2541:                    int new_transformation_origin_end_x = transformation_origin_end.x;
2542:                    int new_transformation_origin_end_y = transformation_origin_end.y;
2543:
2544:                    if (transformation_type >= 0 && trasforming) {
2545:                        Graphics gg = this .getGraphics();
2546:                        gg.setXORMode(Color.WHITE);
2547:                        if (!firstXORDrawTransforming) {
2548:                            // redraw old rectangles...
2549:                            // transformation_origin
2550:                            // transformation_origin_end
2551:                            // Pain a rectangle....
2552:
2553:                            // if no modifications is needed, return...
2554:
2555:                            // MAGNET EFFECT
2556:                            new_transformation_origin_end_y = evt.getY();
2557:                            new_transformation_origin_end_x = evt.getX();
2558:
2559:                            //if (this.isSnapToGrid()) {
2560:                            //    if (Math.abs( transformation_origin_end.x - evt.getX())%(getGridSize()*getZoomFactor())  == 0)
2561:                            //        new_transformation_origin_end_x = evt.getX();
2562:                            //    if (Math.abs( transformation_origin_end.y - evt.getY() )%(getGridSize()*getZoomFactor())  == 0)
2563:                            //        new_transformation_origin_end_y = evt.getY();
2564:                            //
2565:                            //    if (new_transformation_origin_end_x == transformation_origin_end.x &&
2566:                            //            new_transformation_origin_end_y == transformation_origin_end.y) {
2567:                            //        return;
2568:                            //    }
2569:                            //} else {
2570:                            //    new_transformation_origin_end_x = evt.getX();
2571:                            //    new_transformation_origin_end_y = evt.getY();
2572:                            //}
2573:                            Enumeration e = getSelectedElements().elements();
2574:                            while (e.hasMoreElements()) {
2575:                                ReportElement re = (ReportElement) e
2576:                                        .nextElement();
2577:                                Rectangle bounds = new Rectangle(
2578:                                        getZoomedDim(re.getPosition().x - 10) + 10,
2579:                                        getZoomedDim(re.getPosition().y - 10) + 10,
2580:                                        getZoomedDim(re.getWidth()),
2581:                                        getZoomedDim(re.getHeight()));
2582:                                // Scale rectangle...
2583:                                if (transformation_type == TransformationType.TRANSFORMATION_MOVE) {
2584:                                    // First of all we must see if the resistence was Exceeded...
2585:                                    if (resistenceExceeded) {
2586:                                        // Change location...
2587:                                        bounds
2588:                                                .translate(
2589:                                                        transformation_origin_end.x
2590:                                                                - transformation_origin.x,
2591:                                                        transformation_origin_end.y
2592:                                                                - transformation_origin.y);
2593:                                        gg.drawRect(bounds.x, bounds.y,
2594:                                                bounds.width, bounds.height);
2595:                                    }
2596:                                } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
2597:                                        || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S
2598:                                        || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) {
2599:                                    // Change location...
2600:                                    int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) ? transformation_origin_end.x
2601:                                            - transformation_origin.x
2602:                                            : 0;
2603:                                    int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S) ? transformation_origin_end.y
2604:                                            - transformation_origin.y
2605:                                            : 0;
2606:                                    bounds.setSize(Math.max(0, bounds.width
2607:                                            + x_delta), Math.max(0,
2608:                                            bounds.height + y_delta));
2609:                                    gg.drawRect(bounds.x, bounds.y,
2610:                                            bounds.width, bounds.height);
2611:                                } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
2612:                                        || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N
2613:                                        || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) {
2614:                                    // Change location...
2615:                                    int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) ? transformation_origin_end.x
2616:                                            - transformation_origin.x
2617:                                            : 0;
2618:                                    int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) ? transformation_origin_end.y
2619:                                            - transformation_origin.y
2620:                                            : 0;
2621:                                    int height_grow = Math.min(y_delta,
2622:                                            bounds.height);
2623:                                    int width_grow = Math.min(x_delta,
2624:                                            bounds.width);
2625:                                    bounds.translate(width_grow, height_grow);
2626:                                    bounds.setSize(bounds.width - width_grow,
2627:                                            bounds.height - height_grow);
2628:                                    gg.drawRect(bounds.x, bounds.y,
2629:                                            bounds.width, bounds.height);
2630:                                } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE) {
2631:                                    // Change location...
2632:                                    int x_delta = Math
2633:                                            .max(
2634:                                                    -bounds.width,
2635:                                                    (transformation_origin_end.x - transformation_origin.x));
2636:                                    int y_delta = Math
2637:                                            .min(
2638:                                                    bounds.height,
2639:                                                    (transformation_origin_end.y - transformation_origin.y));
2640:                                    bounds.y += y_delta;
2641:                                    bounds.height -= y_delta;
2642:                                    bounds.width += x_delta;
2643:                                    gg.drawRect(bounds.x, bounds.y,
2644:                                            bounds.width, bounds.height);
2645:                                } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW) {
2646:                                    // Change location...
2647:                                    int x_delta = Math
2648:                                            .min(
2649:                                                    bounds.width,
2650:                                                    (transformation_origin_end.x - transformation_origin.x));
2651:                                    int y_delta = Math
2652:                                            .max(
2653:                                                    -bounds.height,
2654:                                                    (transformation_origin_end.y - transformation_origin.y));
2655:                                    bounds.x += x_delta;
2656:                                    bounds.width -= x_delta;
2657:                                    bounds.height += y_delta;
2658:                                    gg.drawRect(bounds.x, bounds.y,
2659:                                            bounds.width, bounds.height);
2660:                                }
2661:                            }
2662:                        }
2663:
2664:                        /*
2665:                        if (Math.abs( transformation_origin_end.x - evt.getX())%(getGridSize()*getZoomFactor())  == 0)
2666:                            transformation_origin_end.x = evt.getX();
2667:                        if (Math.abs( transformation_origin_end.y - evt.getY() )%(getGridSize()*getZoomFactor())  == 0)
2668:                            transformation_origin_end.y = evt.getY();
2669:                         */
2670:                        transformation_origin_end.x = new_transformation_origin_end_x;
2671:                        transformation_origin_end.y = new_transformation_origin_end_y;
2672:
2673:                        Enumeration e = getSelectedElements().elements();
2674:                        while (e.hasMoreElements()) {
2675:                            ReportElement re = (ReportElement) e.nextElement();
2676:                            Rectangle bounds = new Rectangle(getZoomedDim(re
2677:                                    .getPosition().x - 10) + 10,
2678:                                    getZoomedDim(re.getPosition().y - 10) + 10,
2679:                                    getZoomedDim(re.getWidth()),
2680:                                    getZoomedDim(re.getHeight()));
2681:                            // Scale rectangle...
2682:                            if (transformation_type == TransformationType.TRANSFORMATION_MOVE) {
2683:                                // Change location...
2684:                                if (Math.abs(transformation_origin_end.x
2685:                                        - transformation_origin.x) > 5
2686:                                        || Math.abs(transformation_origin_end.y
2687:                                                - transformation_origin.y) > 5)
2688:                                    resistenceExceeded = true;
2689:                                if (resistenceExceeded) {
2690:                                    // Search the closest x,y that match a grid intersection...
2691:
2692:                                    int pex = gridMultiple(transformation_origin_end.x - 10) + 10;
2693:                                    int pey = gridMultiple(transformation_origin_end.y - 10) + 10;
2694:                                    int pox = gridMultiple(transformation_origin.x - 10) + 10;
2695:                                    int poy = gridMultiple(transformation_origin.y - 10) + 10;
2696:
2697:                                    //System.out.println("x: "+transformation_origin_end + " y:" + transformation_origin_end.y);
2698:
2699:                                    //this.getGraphics().drawOval( grid_multiple_x, grid_multiple_y, 5,5);
2700:
2701:                                    bounds.translate(
2702:                                            transformation_origin_end.x
2703:                                                    - transformation_origin.x,
2704:                                            transformation_origin_end.y
2705:                                                    - transformation_origin.y);
2706:                                    gg.drawRect(bounds.x, bounds.y,
2707:                                            bounds.width, bounds.height);
2708:                                }
2709:                            } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
2710:                                    || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S
2711:                                    || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) {
2712:                                // Change location...
2713:                                int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) ? transformation_origin_end.x
2714:                                        - transformation_origin.x
2715:                                        : 0;
2716:                                int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S) ? transformation_origin_end.y
2717:                                        - transformation_origin.y
2718:                                        : 0;
2719:                                bounds.setSize(Math.max(0, bounds.width
2720:                                        + x_delta), Math.max(0, bounds.height
2721:                                        + y_delta));
2722:                                gg.drawRect(bounds.x, bounds.y, bounds.width,
2723:                                        bounds.height);
2724:                            } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
2725:                                    || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N
2726:                                    || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) {
2727:                                // Change location...
2728:                                int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) ? transformation_origin_end.x
2729:                                        - transformation_origin.x
2730:                                        : 0;
2731:                                int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) ? transformation_origin_end.y
2732:                                        - transformation_origin.y
2733:                                        : 0;
2734:                                int height_grow = Math.min(y_delta,
2735:                                        bounds.height);
2736:                                int width_grow = Math
2737:                                        .min(x_delta, bounds.width);
2738:                                bounds.translate(width_grow, height_grow);
2739:                                bounds.setSize(bounds.width - width_grow,
2740:                                        bounds.height - height_grow);
2741:                                gg.drawRect(bounds.x, bounds.y, bounds.width,
2742:                                        bounds.height);
2743:                            } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE) {
2744:                                // Change location...
2745:                                int x_delta = Math
2746:                                        .max(
2747:                                                -bounds.width,
2748:                                                (transformation_origin_end.x - transformation_origin.x));
2749:                                int y_delta = Math
2750:                                        .min(
2751:                                                bounds.height,
2752:                                                (transformation_origin_end.y - transformation_origin.y));
2753:                                bounds.y += y_delta;
2754:                                bounds.height -= y_delta;
2755:                                bounds.width += x_delta;
2756:                                gg.drawRect(bounds.x, bounds.y, bounds.width,
2757:                                        bounds.height);
2758:                            } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW) {
2759:                                // Change location...
2760:                                int x_delta = Math
2761:                                        .min(
2762:                                                bounds.width,
2763:                                                (transformation_origin_end.x - transformation_origin.x));
2764:                                int y_delta = Math
2765:                                        .max(
2766:                                                -bounds.height,
2767:                                                (transformation_origin_end.y - transformation_origin.y));
2768:                                bounds.x += x_delta;
2769:                                bounds.width -= x_delta;
2770:                                bounds.height += y_delta;
2771:                                gg.drawRect(bounds.x, bounds.y, bounds.width,
2772:                                        bounds.height);
2773:                            }
2774:                        }
2775:
2776:                        firstXORDrawTransforming = false;
2777:                        gg.setPaintMode();
2778:                    }
2779:
2780:                }
2781:                mouse.y = mouseY;
2782:                mouse.x = mouseX;
2783:            }//GEN-LAST:event_formMouseDragged
2784:
2785:            private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
2786:
2787:                this .requestFocus();
2788:                int mouseX = (int) evt.getPoint().getX();
2789:                int mouseY = (int) evt.getPoint().getY();
2790:
2791:                if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() < 2) {
2792:
2793:                    if (readyToDragCellVertically > 0) {
2794:                        Graphics gg = this .getGraphics();
2795:                        gg.setXORMode(Color.WHITE);
2796:                        gg.drawLine(0, mouseY, this .getWidth(), mouseY);
2797:                        gg.setPaintMode();
2798:                        // Save
2799:                        mouse.y = mouseY;
2800:                        mouse.x = mouseX;
2801:                        cell_dragging = true;
2802:                        return;
2803:                    } else if (readyToDragCellHorizontally > 0) {
2804:                        Graphics gg = this .getGraphics();
2805:                        gg.setXORMode(Color.WHITE);
2806:                        gg.drawLine(mouseX, 0, mouseX, this .getHeight());
2807:                        gg.setPaintMode();
2808:                        // Save
2809:                        mouse.y = mouseY;
2810:                        mouse.x = mouseX;
2811:                        cell_dragging = true;
2812:                        return;
2813:                    } else if (newObjectType != ReportElementType.NONE) {
2814:                        firstXORDraw = false;
2815:                        newObjectOrigin = new Point(evt.getX(), evt.getY());
2816:                        mouse.x = newObjectOrigin.x;
2817:                        mouse.y = newObjectOrigin.y;
2818:                        return;
2819:                    }
2820:
2821:                    if (selectedElements.size() > 0
2822:                            && ((evt.getModifiers() & evt.SHIFT_MASK) == 0)) {
2823:                        // We are transformation mode?
2824:                        if (transformation_type >= 0) {
2825:                            trasforming = true;
2826:                            firstXORDrawTransforming = true;
2827:                            transformation_origin = new Point(evt.getX(), evt
2828:                                    .getY());
2829:                            transformation_undo_delta = new Point(0, 0);
2830:                            transformation_origin_end = new Point(evt.getX(),
2831:                                    evt.getY());
2832:                            return;
2833:                        }
2834:                    }
2835:
2836:                    boolean foundElement = false;
2837:                    // Look if I clicked over an element...
2838:                    for (int i = getCrosstabElement().getElements().size() - 1; i >= 0; --i) {
2839:
2840:                        ReportElement re = (ReportElement) getCrosstabElement()
2841:                                .getElements().elementAt(i);
2842:                        if ((isDefaultCellMode() == (re.getCell().getType() == CrosstabCell.NODATA_CELL))
2843:                                && re.intersects(new Point(getRealDim(evt
2844:                                        .getX() - 10) + 10, getRealDim(evt
2845:                                        .getY() - 10) + 10))) {
2846:                            foundElement = true;
2847:                            if (selectedElements.size() > 0
2848:                                    && re == ((ReportElement) selectedElements
2849:                                            .firstElement()))
2850:                                continue;
2851:
2852:                            if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2853:                                if (getSelectedElements().contains(re)) {
2854:                                    getSelectedElements().remove(re);
2855:                                    repaint();
2856:                                } else {
2857:                                    addSelectedElement(re);
2858:                                    repaint();
2859:                                }
2860:                            } else {
2861:                                setSelectedElement(re);
2862:                            }
2863:                            trasforming = true;
2864:                            firstXORDrawTransforming = true;
2865:                            transformation_origin = new Point(evt.getX(), evt
2866:                                    .getY());
2867:                            transformation_origin_end = new Point(evt.getX(),
2868:                                    evt.getY());
2869:
2870:                            //if (getMainFrame().isEMMActive())
2871:                            //    transformation_type = TransformationType.TRANSFORMATION_NONE;
2872:                            //else
2873:                            transformation_type = TransformationType.TRANSFORMATION_MOVE;
2874:
2875:                            this .setCursor(Cursor
2876:                                    .getPredefinedCursor(Cursor.MOVE_CURSOR));
2877:                        }
2878:                    }
2879:
2880:                    if (!foundElement) {
2881:                        if (getSelectedElements().size() > 0
2882:                                && (evt.getModifiers() & evt.SHIFT_MASK) == 0) {
2883:                            setSelectedElement(null);
2884:                        }
2885:
2886:                        // We can enter in drag selection mode...
2887:                        drag_selection_mode = true;
2888:                        first_draw_selection_rect = true;
2889:                        drag_selection_origin = new Point(evt.getX(), evt
2890:                                .getY());
2891:                        drag_selection_end = new java.awt.Point(evt.getX(), evt
2892:                                .getY());
2893:                    }
2894:
2895:                } else if (evt.getButton() == evt.BUTTON3) {
2896:
2897:                    if (getSelectedElements().size() > 0) {
2898:                        jMenuItemCellProperties.setEnabled(false);
2899:                        selectedCell = getCellByPoint(new Point(getRealDim(evt
2900:                                .getX() - 10), getRealDim(evt.getY() - 10)));
2901:                        jMenuItemCellProperties
2902:                                .setEnabled(selectedCell != null);
2903:
2904:                        jMenuItemCopy.setEnabled(true);
2905:                        jMenuItemCut.setEnabled(true);
2906:                        jMenuItemDelete.setEnabled(true);
2907:                        jMenuItemCopyStyle.setEnabled(true);
2908:                        jMenuItemPasteStyle.setEnabled(getMainFrame()
2909:                                .getStyleClipboard() != null);
2910:
2911:                        jMenuItemPaste.setEnabled(getMainFrame().getClipBoard()
2912:                                .size() > 0);
2913:                        jCheckBoxMenuItemDefaultCellEdit
2914:                                .setSelected(isDefaultCellMode());
2915:
2916:                        jPopupMenuCrosstabReporteElement.show(this , evt.getX(),
2917:                                evt.getY());
2918:
2919:                    } else {
2920:                        jMenuItemCellProperties1.setEnabled(true);
2921:                        selectedCell = getCellByPoint(new Point(getRealDim(evt
2922:                                .getX() - 10), getRealDim(evt.getY() - 10)));
2923:                        jMenuItemCellProperties1
2924:                                .setEnabled(selectedCell != null);
2925:                        jMenuItemPaste1.setEnabled(getMainFrame()
2926:                                .getClipBoard().size() > 0);
2927:                        jCheckBoxMenuItemDefaultCellEdit1
2928:                                .setSelected(isDefaultCellMode());
2929:
2930:                        jPopupMenuCrosstab.show(this , evt.getX(), evt.getY());
2931:                    }
2932:
2933:                }
2934:
2935:            }//GEN-LAST:event_formMousePressed
2936:
2937:            private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
2938:
2939:                if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2) {
2940:                    if (getSelectedElements().size() > 0)
2941:                        getParentReportFrame().openElementPropertiesDialog();
2942:                }
2943:
2944:            }//GEN-LAST:event_formMouseClicked
2945:
2946:            private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
2947:
2948:                double mouseX = evt.getPoint().getX();
2949:                double mouseY = evt.getPoint().getY();
2950:
2951:                readyToDragCellVertically = -1;
2952:                readyToDragCellHorizontally = -1;
2953:
2954:                try {
2955:
2956:                    if (newObjectType == ReportElementType.NONE) {
2957:                        if (getSelectedElements().size() == 0) {
2958:                            // Check if we are near to a cell line...
2959:                            for (int i = 1; i < getRows().size(); ++i) {
2960:                                int position = ((Integer) getRows().get(i))
2961:                                        .intValue();
2962:                                position = getZoomedDim(position) + 10;
2963:                                if (mouseY > position - 2
2964:                                        && mouseY < position + 2) {
2965:                                    readyToDragCellVertically = i;
2966:                                    this 
2967:                                            .setCursor(Cursor
2968:                                                    .getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
2969:                                    break;
2970:                                }
2971:                            }
2972:
2973:                            // Check if we are near to a cell line...
2974:                            for (int i = 1; readyToDragCellVertically < 0
2975:                                    && i < getColumns().size(); ++i) {
2976:                                int position = ((Integer) getColumns().get(i))
2977:                                        .intValue();
2978:                                position = getZoomedDim(position) + 10;
2979:                                if (mouseX > position - 2
2980:                                        && mouseX < position + 2) {
2981:                                    readyToDragCellHorizontally = i;
2982:                                    this 
2983:                                            .setCursor(Cursor
2984:                                                    .getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
2985:                                    break;
2986:                                }
2987:                            }
2988:
2989:                            if (readyToDragCellVertically <= 0
2990:                                    && readyToDragCellHorizontally <= 0) {
2991:                                this 
2992:                                        .setCursor(Cursor
2993:                                                .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2994:                            }
2995:                        }
2996:
2997:                        if (selectedElements.size() > 0
2998:                                && newObjectType == ReportElementType.NONE) {
2999:                            // We are trasformation mode?
3000:                            {
3001:                                // Vediamo se siamo sopra la figura...
3002:                                Enumeration e = selectedElements.elements();
3003:                                boolean found = false;
3004:                                boolean sizeall = false;
3005:                                while (!found && e.hasMoreElements()) {
3006:
3007:                                    ReportElement selectedRe = (ReportElement) e
3008:                                            .nextElement();
3009:                                    Rectangle grip = new Rectangle(
3010:                                            getZoomedDim(selectedRe.position.x - 10) - 5 + 10,
3011:                                            getZoomedDim(selectedRe.position.y - 10) - 5 + 10,
3012:                                            getZoomedDim(selectedRe.width) + 10,
3013:                                            getZoomedDim(selectedRe.height) + 10);
3014:                                    Rectangle cursor = new Rectangle(
3015:                                            evt.getX(), evt.getY(), 1, 1);
3016:
3017:                                    if (cursor.intersects(grip)) {
3018:                                        sizeall = true;
3019:                                        // Vediamo se interseca una grip...
3020:                                        grip.width = 5;
3021:                                        grip.height = 5;
3022:
3023:                                        if (cursor.intersects(grip)) {
3024:                                            this 
3025:                                                    .setCursor(Cursor
3026:                                                            .getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
3027:                                            found = true;
3028:                                            transformation_type = TransformationType.TRANSFORMATION_RESIZE_NW;
3029:                                        }
3030:
3031:                                        if (!found) {
3032:                                            grip.x = getZoomedDim(selectedRe.position.x
3033:                                                    - 10 + selectedRe.width) + 10;
3034:                                            grip.y = getZoomedDim(selectedRe.position.y - 10) + 10 - 5;
3035:                                            grip.width = 5;
3036:                                            grip.height = 5;
3037:                                            if (cursor.intersects(grip)) {
3038:                                                this 
3039:                                                        .setCursor(Cursor
3040:                                                                .getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
3041:                                                found = true;
3042:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_NE;
3043:                                            }
3044:                                        }
3045:
3046:                                        if (!found) {
3047:                                            grip.x = getZoomedDim(selectedRe.position.x - 10) + 10 - 5;
3048:                                            grip.y = getZoomedDim(selectedRe.position.y
3049:                                                    + (selectedRe.height / 2)
3050:                                                    - 10) + 10 - 2;
3051:                                            grip.width = 5;
3052:                                            grip.height = 5;
3053:                                            if (cursor.intersects(grip)) {
3054:                                                this 
3055:                                                        .setCursor(Cursor
3056:                                                                .getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
3057:                                                found = true;
3058:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_W;
3059:                                            }
3060:                                        }
3061:
3062:                                        if (!found) {
3063:                                            grip.x = getZoomedDim(selectedRe.position.x - 10) + 10 - 5;
3064:                                            grip.y = getZoomedDim(selectedRe.position.y
3065:                                                    - 10 + selectedRe.height) + 10;
3066:                                            grip.width = 5;
3067:                                            grip.height = 5;
3068:                                            if (cursor.intersects(grip)) {
3069:                                                this 
3070:                                                        .setCursor(Cursor
3071:                                                                .getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
3072:                                                found = true;
3073:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_SW;
3074:                                            }
3075:                                        }
3076:
3077:                                        if (!found) {
3078:                                            grip.x = getZoomedDim(selectedRe.position.x
3079:                                                    + (selectedRe.width / 2)
3080:                                                    - 10) + 10 - 2;
3081:                                            grip.y = getZoomedDim(selectedRe.position.y - 10) + 10 - 5;
3082:                                            grip.width = 5;
3083:                                            grip.height = 5;
3084:                                            if (cursor.intersects(grip)) {
3085:                                                this 
3086:                                                        .setCursor(Cursor
3087:                                                                .getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
3088:                                                found = true;
3089:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_N;
3090:                                            }
3091:                                        }
3092:
3093:                                        if (!found) {
3094:                                            grip.x = getZoomedDim(selectedRe.position.x
3095:                                                    + (selectedRe.width / 2)
3096:                                                    - 10) + 10 - 2;
3097:                                            grip.y = getZoomedDim(selectedRe.position.y
3098:                                                    + selectedRe.height - 10) + 10;
3099:                                            grip.width = 5;
3100:                                            grip.height = 5;
3101:                                            if (cursor.intersects(grip)) {
3102:                                                this 
3103:                                                        .setCursor(Cursor
3104:                                                                .getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
3105:                                                found = true;
3106:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_S;
3107:                                            }
3108:                                        }
3109:
3110:                                        if (!found) {
3111:                                            grip.x = getZoomedDim(selectedRe.position.x
3112:                                                    + selectedRe.width - 10) + 10;
3113:                                            grip.y = getZoomedDim(selectedRe.position.y
3114:                                                    + selectedRe.height - 10) + 10;
3115:                                            grip.width = 5;
3116:                                            grip.height = 5;
3117:                                            if (cursor.intersects(grip)) {
3118:                                                this 
3119:                                                        .setCursor(Cursor
3120:                                                                .getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
3121:                                                found = true;
3122:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_SE;
3123:                                            }
3124:                                        }
3125:
3126:                                        if (!found) {
3127:                                            grip.x = getZoomedDim(selectedRe.position.x
3128:                                                    + selectedRe.width - 10) + 10;
3129:                                            grip.y = getZoomedDim(selectedRe.position.y
3130:                                                    + (selectedRe.height / 2)
3131:                                                    - 10) + 10 - 2;
3132:                                            grip.width = 5;
3133:                                            grip.height = 5;
3134:                                            if (cursor.intersects(grip)) {
3135:                                                this 
3136:                                                        .setCursor(Cursor
3137:                                                                .getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
3138:                                                found = true;
3139:                                                transformation_type = TransformationType.TRANSFORMATION_RESIZE_E;
3140:                                            }
3141:                                        }
3142:
3143:                                        if (!found) {
3144:                                            this 
3145:                                                    .setCursor(Cursor
3146:                                                            .getPredefinedCursor(Cursor.MOVE_CURSOR));
3147:
3148:                                            if (getMainFrame().isEMMActive())
3149:                                                transformation_type = TransformationType.TRANSFORMATION_NONE;
3150:                                            else {
3151:                                                transformation_type = TransformationType.TRANSFORMATION_MOVE;
3152:                                                resistenceExceeded = false;
3153:                                            }
3154:                                        }
3155:                                    }
3156:                                }
3157:                                if (!sizeall) {
3158:                                    this .setCursor(Cursor.getDefaultCursor());
3159:                                    transformation_type = TransformationType.TRANSFORMATION_NONE;
3160:                                }
3161:                            }
3162:                        }
3163:
3164:                    } else {
3165:
3166:                    }
3167:
3168:                } catch (Exception ex) {
3169:                    ex.printStackTrace();
3170:                }
3171:            }//GEN-LAST:event_formMouseMoved
3172:
3173:            // Variables declaration - do not modify//GEN-BEGIN:variables
3174:            private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemDefaultCellEdit;
3175:            private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemDefaultCellEdit1;
3176:            private javax.swing.JMenuItem jMenuItemCellProperties;
3177:            private javax.swing.JMenuItem jMenuItemCellProperties1;
3178:            private javax.swing.JMenuItem jMenuItemCopy;
3179:            private javax.swing.JMenuItem jMenuItemCopyStyle;
3180:            private javax.swing.JMenuItem jMenuItemCrosstabProperties;
3181:            private javax.swing.JMenuItem jMenuItemCrosstabProperties1;
3182:            private javax.swing.JMenuItem jMenuItemCut;
3183:            private javax.swing.JMenuItem jMenuItemDelete;
3184:            private javax.swing.JMenuItem jMenuItemElementProperties;
3185:            private javax.swing.JMenuItem jMenuItemPaste;
3186:            private javax.swing.JMenuItem jMenuItemPaste1;
3187:            private javax.swing.JMenuItem jMenuItemPasteStyle;
3188:            private javax.swing.JMenuItem jMenuItemPattern;
3189:            private javax.swing.JMenuItem jMenuItemTransformStaticText;
3190:            private javax.swing.JPopupMenu jPopupMenuCrosstab;
3191:            private javax.swing.JPopupMenu jPopupMenuCrosstabReporteElement;
3192:            private javax.swing.JSeparator jSeparator1;
3193:            private javax.swing.JSeparator jSeparator3;
3194:            private javax.swing.JSeparator jSeparator4;
3195:
3196:            // End of variables declaration//GEN-END:variables
3197:
3198:            public List getColumns() {
3199:                return columns;
3200:            }
3201:
3202:            public void setColumns(List columns) {
3203:                this .columns = columns;
3204:            }
3205:
3206:            public List getRows() {
3207:                return rows;
3208:            }
3209:
3210:            public void setRows(List rows) {
3211:                this .rows = rows;
3212:            }
3213:
3214:            /**
3215:             *   This method fill all not defined cells with defaults taken by inherited cell...
3216:             *   The alghoritm to find the cell from wich a cell inherits its defaults works as follow:
3217:             *   1. Check for the previos row cell with the same width
3218:             *   2. Check for the previos column cell with the same height
3219:             *   An updateGrid on CrosstabReportPanel will fix all positions...
3220:             *   In this case it's not important the total position (Start/End/Node)
3221:             **/
3222:            public void addNotDefinedCells() {
3223:                if (getCrosstabElement() == null)
3224:                    return;
3225:
3226:                // First of all we have to calc what cells we have and in what position they are...
3227:                int cellGridWidth = getCrosstabElement().getColumnGroups()
3228:                        .size();
3229:                int cellGridHeight = getCrosstabElement().getRowGroups().size();
3230:
3231:                // We assume that cell D/D (detail/detail) is defined.
3232:                // Cell x,y is the cell with totalColumnGroup = colums(x) and totalRowGroup the rows(y)
3233:
3234:                for (int y = cellGridHeight; y >= 0; --y) {
3235:
3236:                    for (int x = cellGridWidth; x >= 0; --x) {
3237:
3238:                        String totalRowGroupName = "";
3239:                        if (y < cellGridHeight)
3240:                            totalRowGroupName = ((CrosstabGroup) getCrosstabElement()
3241:                                    .getRowGroups().get(y)).getName();
3242:
3243:                        String totalColumnGroupName = "";
3244:                        if (x < cellGridWidth)
3245:                            totalColumnGroupName = ((CrosstabGroup) getCrosstabElement()
3246:                                    .getColumnGroups().get(x)).getName();
3247:
3248:                        CrosstabCell cell = findCell(totalRowGroupName,
3249:                                totalColumnGroupName);
3250:
3251:                        if (cell == null) {
3252:                            // we have to find a cell on the same row that matchs the width to inherit by...
3253:                            int cellHeight = getRowHeight(totalRowGroupName);
3254:                            int cellWidth = getColumnWidth(totalColumnGroupName);
3255:
3256:                            // look for a good row cell with the same width on the same row...
3257:                            CrosstabCell templateCell = null;
3258:                            for (int k = x + 1; k < cellGridWidth; ++k) {
3259:                                templateCell = findCell(totalRowGroupName,
3260:                                        ((CrosstabGroup) getCrosstabElement()
3261:                                                .getColumnGroups().get(k))
3262:                                                .getName());
3263:                                if (templateCell == null) {
3264:                                    continue;
3265:                                }
3266:
3267:                                if (templateCell.getWidth() == cellWidth) {
3268:                                    break;
3269:                                } else {
3270:                                    templateCell = null;
3271:                                }
3272:                            }
3273:                            if (templateCell == null) {
3274:                                templateCell = findCell(totalRowGroupName, "");
3275:                                if (templateCell != null
3276:                                        && templateCell.getWidth() != cellWidth)
3277:                                    templateCell = null;
3278:                            }
3279:
3280:                            if (templateCell == null) // Look on the same column...
3281:                            {
3282:                                for (int k = y + 1; k < cellGridHeight; ++k) {
3283:                                    templateCell = findCell(
3284:                                            ((CrosstabGroup) getCrosstabElement()
3285:                                                    .getRowGroups().get(k))
3286:                                                    .getName(),
3287:                                            totalColumnGroupName);
3288:
3289:                                    if (templateCell.getHeight() == cellHeight) {
3290:                                        // FOUND IT!
3291:                                        break;
3292:                                    } else {
3293:                                        templateCell = null;
3294:                                    }
3295:                                }
3296:                                if (templateCell == null) {
3297:                                    templateCell = findCell("",
3298:                                            totalColumnGroupName);
3299:                                    if (templateCell != null
3300:                                            && templateCell.getHeight() != cellHeight)
3301:                                        templateCell = null;
3302:                                }
3303:                            }
3304:
3305:                            if (templateCell == null) {
3306:                                // Default not found!!!! Our cell will be void!
3307:                                cell = new CrosstabCell();
3308:                                cell.setParent(this .getCrosstabElement());
3309:                                cell.setWidth(cellWidth);
3310:                                cell.setHeight(cellHeight);
3311:                                cell.setColumnTotalGroup(totalColumnGroupName);
3312:                                cell.setRowTotalGroup(totalRowGroupName);
3313:                            } else {
3314:                                cell = templateCell.cloneMe();
3315:                                cell.setColumnTotalGroup(totalColumnGroupName);
3316:                                cell.setRowTotalGroup(totalRowGroupName);
3317:                                cell.setParent(this .getCrosstabElement());
3318:
3319:                                // Duplicate all elements of this cell, and reassign parent cell...
3320:                                int currentElements = getCrosstabElement()
3321:                                        .getElements().size();
3322:                                for (int i = 0; i < currentElements; ++i) {
3323:                                    ReportElement re = (ReportElement) getCrosstabElement()
3324:                                            .getElements().elementAt(i);
3325:                                    // WARNING this copy does not support container and group elements!!!
3326:                                    if (re.getCell() == templateCell) {
3327:                                        re = re.cloneMe();
3328:                                        cell
3329:                                                .setColumnTotalGroup(totalColumnGroupName);
3330:                                        cell
3331:                                                .setRowTotalGroup(totalRowGroupName);
3332:                                        re.setCell(cell);
3333:                                        getCrosstabElement().getElements().add(
3334:                                                re);
3335:                                    }
3336:                                }
3337:                            }
3338:
3339:                            getCrosstabElement().getCells().add(cell);
3340:                        }
3341:                    }
3342:                }
3343:
3344:            }
3345:
3346:            public Vector getSelectedElements() {
3347:                return selectedElements;
3348:            }
3349:
3350:            public void setSelectedElements(Vector selectedElements) {
3351:                this .selectedElements = selectedElements;
3352:            }
3353:
3354:            /**
3355:             *  Point is a point il logical coordinates, so you have to perform a conversion before call it:
3356:             *  getCellByPoint( new Point( getRealDim(x), getRealDim(y)))
3357:             *  this if you are using mouse coordinates...
3358:             **/
3359:            public CrosstabCell getCellByPoint(Point p) {
3360:
3361:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
3362:                    CrosstabCell cell = (CrosstabCell) this 
3363:                            .getCrosstabElement().getCells().elementAt(i);
3364:                    if (cell.getBounds().contains(p)
3365:                            && (isDefaultCellMode() == (cell.getType() == CrosstabCell.NODATA_CELL))) {
3366:                        return cell;
3367:                    }
3368:                }
3369:
3370:                return null;
3371:            }
3372:
3373:            public Vector getRowBands() {
3374:                return rowBands;
3375:            }
3376:
3377:            public Vector getColumnBands() {
3378:                return columnBands;
3379:            }
3380:
3381:            /**
3382:             * This method remove from selection vector elements no longer part of this crosstab
3383:             */
3384:            public void validateSelection() {
3385:                for (int i = 0; i < getSelectedElements().size(); ++i) {
3386:                    ReportElement re = (ReportElement) getSelectedElements()
3387:                            .elementAt(i);
3388:                    if (!getCrosstabElement().getElements().contains(re)) {
3389:                        getSelectedElements().remove(re);
3390:                        --i;
3391:                    }
3392:                }
3393:                // UPDATE SELECTION NOW!!!
3394:            }
3395:
3396:            /**
3397:             * Shortcut for  MainFrame.getMainInstance();
3398:             **/
3399:            public MainFrame getMainFrame() {
3400:                return MainFrame.getMainInstance();
3401:            }
3402:
3403:            public void setSelectedElement(ReportElement e) {
3404:                setSelectedElement(e, true);
3405:            }
3406:
3407:            /**
3408:             * Set the selected element
3409:             *
3410:             */
3411:            public void setSelectedElement(ReportElement el, boolean fireEvent) {
3412:
3413:                getSelectedElements().removeAllElements();
3414:
3415:                if (el != null
3416:                        && (isDefaultCellMode() == (el.getCell().getType() == CrosstabCell.NODATA_CELL))) {
3417:
3418:                    selectedElements.addElement(el);
3419:                    getMainFrame().setCutCopyEnabled(true);
3420:                } else {
3421:                    getMainFrame().setCutCopyEnabled(false);
3422:                }
3423:                repaint();
3424:
3425:                if (fireEvent) {
3426:                    fireSelectionChangedEvent();
3427:                }
3428:            }
3429:
3430:            public void addSelectedElement(ReportElement el) {
3431:                addSelectedElement(el, true);
3432:            }
3433:
3434:            /**
3435:             * Add an element to the selection...
3436:             *
3437:             */
3438:            public void addSelectedElement(ReportElement el, boolean fireEvent) {
3439:                if (selectedElements.contains(el))
3440:                    return;
3441:
3442:                if (isDefaultCellMode() != (el.getCell().getType() == CrosstabCell.NODATA_CELL))
3443:                    return;
3444:                //label1.setText("ADDED");
3445:                // Faccio una corona non selected attorno al nuovo elemento...
3446:                Rectangle rect = new Rectangle(el.position.x - 5,
3447:                        el.position.y - 5, el.width + 10, el.height + 10);
3448:                selectedElements.addElement(el);
3449:
3450:                this .repaint();
3451:                if (fireEvent) {
3452:                    fireSelectionChangedEvent();
3453:                }
3454:
3455:                getMainFrame().setCutCopyEnabled(true);
3456:            }
3457:
3458:            public int gridMultiple(int zoomedDim) {
3459:                //if (!isSnapToGrid()) {
3460:                return zoomedDim;
3461:                //}
3462:
3463:                //int zoomedGridSize = getZoomedDim(this.gridSize);
3464:                //double val = Math.abs(zoomedDim);
3465:                //if ( zoomedGridSize > 1.0 ) {
3466:                //    val =  Math.floor( ( val +  (0.5 * zoomedGridSize)) / zoomedGridSize ) * zoomedGridSize;
3467:                //}
3468:
3469:                //return (int) ( (zoomedDim >= 0) ? val : -val );
3470:            }
3471:
3472:            public int magnetEffect(List spots, int position) {
3473:                for (int i = 0; i < spots.size(); ++i) {
3474:                    int spotPoint = ((Integer) spots.get(i)).intValue();
3475:                    spotPoint = getZoomedDim(spotPoint) + 10;
3476:                    if (position > spotPoint - 5 && position < spotPoint + 5) {
3477:                        return spotPoint;
3478:                    }
3479:                }
3480:                return position;
3481:            }
3482:
3483:            /** Getter for property newObjectType.
3484:             * @return Value of property newObjectType.
3485:             *
3486:             */
3487:            public int getNewObjectType() {
3488:                return newObjectType;
3489:            }
3490:
3491:            /** Setter for property newObjectType.
3492:             * @param newObjectType New value of property newObjectType.
3493:             *
3494:             */
3495:            public void setNewObjectType(int newObjectType) {
3496:
3497:                if (this .newObjectType == newObjectType)
3498:                    return;
3499:
3500:                if (newObjectType == ReportElementType.NONE) {
3501:                    this .setCursor(java.awt.Cursor.getDefaultCursor());
3502:                } else {
3503:                    this 
3504:                            .setCursor(java.awt.Cursor
3505:                                    .getPredefinedCursor(java.awt.Cursor.CROSSHAIR_CURSOR));
3506:                }
3507:                this .newObjectType = newObjectType;
3508:            }
3509:
3510:            public Point straighten(int delta_w, int delta_h) {
3511:                // straighten on 90 % degrees
3512:                double clipAngle = 15;
3513:
3514:                double R = Math.sqrt((delta_w * delta_w) + (delta_h * delta_h));
3515:                double cos = delta_w / R;
3516:                double angle = 180 * Math.acos(cos) / Math.PI;
3517:
3518:                int repeat = (int) Math.floor((angle + (0.5 * clipAngle))
3519:                        / clipAngle);
3520:
3521:                double newAngle = repeat * clipAngle;
3522:
3523:                // keep the sign the same!
3524:                delta_h = (int) (Math.abs((R * Math.sin((newAngle / 180)
3525:                        * Math.PI)))
3526:                        * delta_h / Math.abs(delta_h));
3527:
3528:                delta_w = (int) (Math.abs((R * Math.cos((newAngle / 180)
3529:                        * Math.PI)))
3530:                        * delta_w / Math.abs(delta_w));
3531:
3532:                /*
3533:                // aligning on  the grid if necessary
3534:                if (Math.abs(delta_h) == Math.abs(delta_w) ) {
3535:                    delta_h = gridMultiple( delta_h);
3536:                    delta_w = gridMultiple( delta_w);
3537:                } else {
3538:                    if (delta_w == 0) {
3539:                        delta_h = gridMultiple( delta_h);
3540:                    }
3541:                    if (delta_h == 0) {
3542:                        delta_w = gridMultiple( delta_w);
3543:                    }
3544:                }
3545:                 */
3546:
3547:                return new Point(delta_w, delta_h);
3548:            }
3549:
3550:            /**
3551:             *  Not implemented, just returns p.
3552:             **/
3553:            public int snapToGridVertically(int p) {
3554:                return p;
3555:            }
3556:
3557:            public void deleteSelectedElements() {
3558:                // Remove selected elements...
3559:                Enumeration e = selectedElements.elements();
3560:
3561:                DeleteElementsOperation undoOp = new DeleteElementsOperation(
3562:                        getParentReportFrame(), getCrosstabElement());
3563:                Vector deletedElements = new Vector();
3564:
3565:                while (e.hasMoreElements()) {
3566:
3567:                    ReportElement re = (ReportElement) e.nextElement();
3568:
3569:                    if (getCrosstabElement().getElements().contains(re)) {
3570:                        undoOp.addElement(re, getCrosstabElement()
3571:                                .getElements().indexOf(re));
3572:                        //System.out.println("Deleting " + re + " " +  getCrosstabElement().getElements().indexOf(re));
3573:                        getCrosstabElement().getElements().remove(re);
3574:                        deletedElements.add(re);
3575:                        if (re instanceof  FrameReportElement) {
3576:                            removeSubElements(re, undoOp, deletedElements);
3577:                        }
3578:                    }
3579:                    //fireReportListenerReportElementsChanged(new ReportElementChangedEvent(this, re , ReportElementChangedEvent.REMOVED));
3580:                }
3581:
3582:                getParentReportFrame().fireReportListenerReportElementsChanged(
3583:                        new ReportElementChangedEvent(getParentReportFrame(),
3584:                                getCrosstabElement(), deletedElements,
3585:                                ReportElementChangedEvent.REMOVED));
3586:                this .setSelectedElement(null);
3587:                getParentReportFrame().addUndoOperation(undoOp);
3588:                //selectedElements.removeAllElements();
3589:
3590:                this .repaint();
3591:            }
3592:
3593:            protected void removeSubElements(ReportElement parentElement,
3594:                    DeleteElementsOperation undoOp, Vector deletedElements) {
3595:                for (int i = 0; i < getCrosstabElement().getElements().size(); ++i) {
3596:                    ReportElement re = (ReportElement) getCrosstabElement()
3597:                            .getElements().elementAt(i);
3598:                    if (re.getParentElement() == parentElement) {
3599:                        undoOp.addElement(re, getCrosstabElement()
3600:                                .getElements().indexOf(re));
3601:                        getCrosstabElement().getElements().remove(re);
3602:                        i--;
3603:                        deletedElements.add(re);
3604:                        if (re instanceof  FrameReportElement) {
3605:                            removeSubElements(re, undoOp, deletedElements);
3606:                        }
3607:                    }
3608:                }
3609:            }
3610:
3611:            public void fireSelectionChangedEvent() {
3612:
3613:                ReportElementsSelectionEvent rece = new ReportElementsSelectionEvent(
3614:                        getParentReportFrame(), getCrosstabElement(), this 
3615:                                .getSelectedElements());
3616:                this .getParentReportFrame()
3617:                        .fireReportListenerReportElementsSelectionChanged(rece);
3618:                getMainFrame().getElementPropertiesDialog().updateSelection();
3619:
3620:            }
3621:
3622:            public void copyStyle() {
3623:                // We should copy this element to use it as style template...
3624:                if (this .getSelectedElements().size() == 0)
3625:                    return;
3626:                this .getMainFrame().setStyleClipbardContent(
3627:                        ((ReportElement) this .getSelectedElements()
3628:                                .elementAt(0)).cloneMe());
3629:
3630:            }
3631:
3632:            public void pasteStyle() {
3633:                if (this .getSelectedElements().size() == 0)
3634:                    return;
3635:                if (this .getMainFrame().getStyleClipboard() == null)
3636:                    return;
3637:
3638:                // Style are relative to:
3639:                ReportElement templateElement = this .getMainFrame()
3640:                        .getStyleClipboard();
3641:
3642:                PasteStyleOperation undoOp = new PasteStyleOperation(
3643:                        getParentReportFrame(), getCrosstabElement());
3644:
3645:                Enumeration elements = getSelectedElements().elements();
3646:                while (elements.hasMoreElements()) {
3647:                    ReportElement re = (ReportElement) elements.nextElement();
3648:                    undoOp.addElement(re, re.cloneMe(), templateElement);
3649:                    getParentReportFrame().applyStyle(re, templateElement);
3650:                }
3651:                getParentReportFrame().addUndoOperation(undoOp);
3652:                getParentReportFrame()
3653:                        .fireReportListenerReportElementsSelectionChanged(
3654:                                new ReportElementsSelectionEvent(
3655:                                        getParentReportFrame(),
3656:                                        getCrosstabElement(),
3657:                                        getSelectedElements()));
3658:                this .repaint();
3659:            }
3660:
3661:            public void transformStaticInTextFields() {
3662:
3663:                String keyStaticText = (new StaticTextReportElement(0, 0, 0, 0))
3664:                        .getKey();
3665:                String keyTextField = (new TextFieldReportElement(0, 0, 0, 0))
3666:                        .getKey();
3667:                // End code Robert Lamping, 13 july 2004
3668:
3669:                // Edit static Text
3670:                Enumeration e = selectedElements.elements();
3671:
3672:                ReplacedElementsOperation undoOp = new ReplacedElementsOperation(
3673:                        getParentReportFrame(), this .getCrosstabElement());
3674:
3675:                while (e.hasMoreElements()) {
3676:                    ReportElement re = (ReportElement) e.nextElement();
3677:                    if (re instanceof  StaticTextReportElement) {
3678:                        // 1.
3679:                        TextFieldReportElement tfre = new TextFieldReportElement(
3680:                                re.getPosition().x, re.getPosition().y,
3681:                                re.width, re.height);
3682:                        tfre.setRelativePosition(new Point(re
3683:                                .getRelativePosition().x, re
3684:                                .getRelativePosition().y));
3685:                        // Set base characteristics...
3686:                        tfre.copyBaseReportElement(tfre, re);
3687:                        // Set Text characteristics...
3688:                        tfre.setBold(((TextReportElement) re).isBold());
3689:                        tfre.setUnderline(((TextReportElement) re)
3690:                                .isUnderline());
3691:                        tfre.setStrikeTrought(((TextReportElement) re)
3692:                                .isStrikeTrought());
3693:                        tfre.setItalic(((TextReportElement) re).isItalic());
3694:
3695:                        tfre.setLineSpacing(((TextReportElement) re)
3696:                                .getLineSpacing());
3697:                        tfre.setPDFFontName(((TextReportElement) re)
3698:                                .getPDFFontName());
3699:                        tfre.setPdfEncoding(((TextReportElement) re)
3700:                                .getPdfEncoding());
3701:                        tfre.setReportFont(((TextReportElement) re)
3702:                                .getReportFont());
3703:                        tfre.setRotate(((TextReportElement) re).getRotate());
3704:                        tfre.setTTFFont(((TextReportElement) re).getTTFFont());
3705:                        tfre.setVerticalAlign(((TextReportElement) re)
3706:                                .getVerticalAlign());
3707:                        tfre.setFont(((TextReportElement) re).getFont());
3708:                        tfre
3709:                                .setFontName(((TextReportElement) re)
3710:                                        .getFontName());
3711:                        tfre
3712:                                .setFontSize(((TextReportElement) re)
3713:                                        .getFontSize());
3714:
3715:                        tfre.setClassExpression("java.lang.String");
3716:
3717:                        // Begin code Robert Lamping, 13 july 2004
3718:                        // Changing key element name
3719:                        if (re.getKey().indexOf(keyStaticText + "-") == 0) {
3720:                            // key indeed begins with "staticText-"
3721:                            //Okay then request the next available key for a normal field text
3722:                            tfre.setKey(getParentReportFrame()
3723:                                    .getNextElementKey(keyTextField));
3724:                        }
3725:
3726:                        // End code Robert Lamping, 13 july 2004
3727:
3728:                        String te = ((TextReportElement) re).getText();
3729:                        String result = javax.swing.JOptionPane
3730:                                .showInputDialog(this , I18n.getString(
3731:                                        "messages.enterNewValue",
3732:                                        "Please enter a new Value"), "\"" + te
3733:                                        + "\"");
3734:                        if (result != null && !result.equals("")) {
3735:                            ((TextReportElement) tfre).setText(result);
3736:                            // 1. remove element
3737:                            int index = getCrosstabElement().getElements()
3738:                                    .indexOf(re);
3739:                            getCrosstabElement().getElements().remove(re);
3740:                            getCrosstabElement().getElements().add(index, tfre);
3741:
3742:                            int index2 = getSelectedElements().indexOf(re);
3743:                            getSelectedElements().remove(re);
3744:                            getSelectedElements().add(index2, tfre);
3745:
3746:                            // 2. add element
3747:                            undoOp.addElement(re, tfre);
3748:                            getParentReportFrame()
3749:                                    .fireReportListenerReportElementsChanged(
3750:                                            new ReportElementChangedEvent(
3751:                                                    getParentReportFrame(),
3752:                                                    getCrosstabElement(),
3753:                                                    re,
3754:                                                    ReportElementChangedEvent.REMOVED));
3755:                            getParentReportFrame()
3756:                                    .fireReportListenerReportElementsChanged(
3757:                                            new ReportElementChangedEvent(
3758:                                                    getParentReportFrame(),
3759:                                                    getCrosstabElement(),
3760:                                                    tfre,
3761:                                                    ReportElementChangedEvent.ADDED));
3762:
3763:                        }
3764:                    }
3765:                }
3766:                getParentReportFrame().addUndoOperation(undoOp);
3767:                getParentReportFrame()
3768:                        .fireReportListenerReportElementsSelectionChanged(
3769:                                new ReportElementsSelectionEvent(
3770:                                        getParentReportFrame(),
3771:                                        getCrosstabElement(),
3772:                                        getSelectedElements()));
3773:                repaint();
3774:            }
3775:
3776:            /**
3777:             *
3778:             */
3779:            public void bringToFront() {
3780:                Enumeration e = this .getSelectedElements().elements();
3781:
3782:                ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
3783:                        getParentReportFrame(), getCrosstabElement());
3784:
3785:                while (e.hasMoreElements()) {
3786:                    ReportElement element = (ReportElement) e.nextElement();
3787:
3788:                    int oldPosition = getCrosstabElement().getElements()
3789:                            .indexOf(element);
3790:                    getCrosstabElement().getElements().remove(element);
3791:                    getCrosstabElement().getElements().addElement(element);
3792:                    int newPosition = getCrosstabElement().getElements()
3793:                            .indexOf(element);
3794:                    undoOp.addElement(element, oldPosition, newPosition);
3795:                }
3796:
3797:                if (undoOp.getElements().size() > 0) {
3798:                    getParentReportFrame().addUndoOperation(undoOp);
3799:                }
3800:                this .repaint();
3801:                // We must update the tree... the order i changed...
3802:                /* TODO */
3803:            }
3804:
3805:            public void sendToBack() {
3806:                Enumeration e = this .getSelectedElements().elements();
3807:
3808:                ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
3809:                        getParentReportFrame(), getCrosstabElement());
3810:
3811:                while (e.hasMoreElements()) {
3812:                    ReportElement element = (ReportElement) e.nextElement();
3813:
3814:                    int oldPosition = getCrosstabElement().getElements()
3815:                            .indexOf(element);
3816:                    getCrosstabElement().getElements().remove(element);
3817:                    if (element.getParentElement() != null) {
3818:                        getCrosstabElement().getElements().insertElementAt(
3819:                                element,
3820:                                getCrosstabElement().getElements().indexOf(
3821:                                        element.getParentElement()) + 1);
3822:                    } else {
3823:                        getCrosstabElement().getElements().insertElementAt(
3824:                                element, 0);
3825:                    }
3826:                    int newPosition = 0;
3827:                    undoOp.addElement(element, oldPosition, newPosition);
3828:                }
3829:
3830:                if (undoOp.getElements().size() > 0) {
3831:                    getParentReportFrame().addUndoOperation(undoOp);
3832:                }
3833:                this .repaint();
3834:                // We must update the tree... the order is changed...
3835:                /* TODO */
3836:            }
3837:
3838:            public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde) {
3839:                dtde.acceptDrag(dtde.getDropAction());
3840:            }
3841:
3842:            public void dragExit(java.awt.dnd.DropTargetEvent dte) {
3843:            }
3844:
3845:            public void dragOver(java.awt.dnd.DropTargetDragEvent dtde) {
3846:                dtde.acceptDrag(dtde.getDropAction());
3847:            }
3848:
3849:            public void drop(java.awt.dnd.DropTargetDropEvent dtde) {
3850:                try {
3851:
3852:                    DropTargetContext context = dtde.getDropTargetContext();
3853:
3854:                    Transferable tr = dtde.getTransferable();
3855:
3856:                    DataFlavor[] df = tr.getTransferDataFlavors();
3857:
3858:                    if (df[0].getHumanPresentableName().equals(
3859:                            "it.businesslogic.ireport.crosstab.Measure")) {
3860:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3861:                                it.businesslogic.ireport.crosstab.Measure.class,
3862:                                it.businesslogic.ireport.crosstab.Measure.class
3863:                                        .getName());
3864:                        it.businesslogic.ireport.crosstab.Measure field = (it.businesslogic.ireport.crosstab.Measure) tr
3865:                                .getTransferData(myFlavor);
3866:                        // Add a field!!!
3867:                        //System.out.println("Field name:" + field.getName() +" from "+ field.getClassType() );
3868:
3869:                        // Create a standard field...
3870:                        this .dropNewTextField(dtde.getLocation(), "$V{"
3871:                                + field.getName() + "}", field.getClassType(),
3872:                                "Now");
3873:                    } else if (df[0]
3874:                            .getHumanPresentableName()
3875:                            .equals(
3876:                                    "it.businesslogic.ireport.crosstab.CrosstabRowGroup")) {
3877:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3878:                                it.businesslogic.ireport.crosstab.CrosstabRowGroup.class,
3879:                                it.businesslogic.ireport.crosstab.CrosstabRowGroup.class
3880:                                        .getName());
3881:                        it.businesslogic.ireport.crosstab.CrosstabGroup field = (it.businesslogic.ireport.crosstab.CrosstabGroup) tr
3882:                                .getTransferData(myFlavor);
3883:                        this .dropNewTextField(dtde.getLocation(), "$V{"
3884:                                + field.getName() + "}", field
3885:                                .getBucketExpressionClass(), "Now");
3886:                    } else if (df[0]
3887:                            .getHumanPresentableName()
3888:                            .equals(
3889:                                    "it.businesslogic.ireport.crosstab.CrosstabColumnGroup")) {
3890:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3891:                                it.businesslogic.ireport.crosstab.CrosstabColumnGroup.class,
3892:                                it.businesslogic.ireport.crosstab.CrosstabColumnGroup.class
3893:                                        .getName());
3894:                        it.businesslogic.ireport.crosstab.CrosstabGroup field = (it.businesslogic.ireport.crosstab.CrosstabGroup) tr
3895:                                .getTransferData(myFlavor);
3896:                        this .dropNewTextField(dtde.getLocation(), "$V{"
3897:                                + field.getName() + "}", field
3898:                                .getBucketExpressionClass(), "Now");
3899:                    } else if (df[0].getHumanPresentableName().equals(
3900:                            "it.businesslogic.ireport.crosstab.GroupTotal")) {
3901:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3902:                                it.businesslogic.ireport.crosstab.GroupTotal.class,
3903:                                it.businesslogic.ireport.crosstab.GroupTotal.class
3904:                                        .getName());
3905:                        it.businesslogic.ireport.crosstab.GroupTotal field = (it.businesslogic.ireport.crosstab.GroupTotal) tr
3906:                                .getTransferData(myFlavor);
3907:                        this .dropNewTextField(dtde.getLocation(), "$V{"
3908:                                + field.getVarName() + "}", field
3909:                                .getClassType(), "Now");
3910:                    } else if (df[0]
3911:                            .getHumanPresentableName()
3912:                            .equals(
3913:                                    "it.businesslogic.ireport.crosstab.CrosstabParameter")) {
3914:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3915:                                it.businesslogic.ireport.crosstab.CrosstabParameter.class,
3916:                                it.businesslogic.ireport.crosstab.CrosstabParameter.class
3917:                                        .getName());
3918:                        it.businesslogic.ireport.crosstab.CrosstabParameter field = (it.businesslogic.ireport.crosstab.CrosstabParameter) tr
3919:                                .getTransferData(myFlavor);
3920:                        this .dropNewTextField(dtde.getLocation(), "$P{"
3921:                                + field.getName() + "}", field.getClassType(),
3922:                                "Now");
3923:                    } else if (df[0].getHumanPresentableName().equals(
3924:                            "it.businesslogic.ireport.Style")) {
3925:                        java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3926:                                it.businesslogic.ireport.Style.class,
3927:                                it.businesslogic.ireport.JRParameter.class
3928:                                        .getName());
3929:                        it.businesslogic.ireport.Style var = (it.businesslogic.ireport.Style) tr
3930:                                .getTransferData(myFlavor);
3931:                        // Add a field!!!
3932:
3933:                        ReportElement re = this 
3934:                                .getElementAt(dtde.getLocation());
3935:                        if (re != null) {
3936:
3937:                            if (!getParentReportFrame().getReport().getStyles()
3938:                                    .contains(var)) {
3939:                                boolean found = false;
3940:                                // Look for a style with the same name...
3941:                                for (int i = 0; i < getParentReportFrame()
3942:                                        .getReport().getStyles().size(); ++i) {
3943:                                    Style s = (Style) getParentReportFrame()
3944:                                            .getReport().getStyles().elementAt(
3945:                                                    i);
3946:                                    if (s.getName() != null
3947:                                            && s.getName()
3948:                                                    .equals(var.getName())) {
3949:                                        var = s;
3950:                                        found = true;
3951:                                        break;
3952:                                    }
3953:                                }
3954:                                if (!found) {
3955:                                    var = new Style(var);
3956:                                    getParentReportFrame().getReport()
3957:                                            .addStyle(var);
3958:                                }
3959:                            }
3960:
3961:                            re.setStyle(var);
3962:                            getParentReportFrame()
3963:                                    .fireReportListenerReportElementsChanged(
3964:                                            new ReportElementChangedEvent(
3965:                                                    getParentReportFrame(),
3966:                                                    getCrosstabElement(),
3967:                                                    re,
3968:                                                    ReportElementChangedEvent.CHANGED));
3969:                            this .repaint();
3970:                        }
3971:                    } else {
3972:                        Class c = Class
3973:                                .forName(df[0].getHumanPresentableName());
3974:                        if (it.businesslogic.ireport.gui.library.AbstractLibraryObject.class
3975:                                .isAssignableFrom(c)) {
3976:                            java.awt.datatransfer.DataFlavor myFlavor = new java.awt.datatransfer.DataFlavor(
3977:                                    c, df[0].getHumanPresentableName());
3978:                            Object obj = tr.getTransferData(myFlavor);
3979:                            ((it.businesslogic.ireport.gui.library.AbstractLibraryObject) obj)
3980:                                    .drop(dtde);
3981:                        } else // if (.equals("it.businesslogic.ireport.JRParameter"))
3982:                        {
3983:                            //System.out.println("Dropped a "+df[0].getHumanPresentableName());
3984:                        }
3985:                    }
3986:
3987:                    context.dropComplete(true);
3988:                } catch (Exception ex) {
3989:
3990:                    ex.printStackTrace();
3991:                }
3992:            }
3993:
3994:            public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde) {
3995:            }
3996:
3997:            public TextFieldReportElement dropNewTextField(
3998:                    Point newObjectOrigin, String textfieldExpression,
3999:                    String classExpression, String time) {
4000:                TextFieldReportElement re = null;
4001:                // Find the band to associate to the new element...
4002:
4003:                CrosstabCell cell = getCellByPoint(new Point(
4004:                        getRealDim(newObjectOrigin.x - 10),
4005:                        getRealDim(newObjectOrigin.y - 10)));
4006:                if (cell == null) {
4007:
4008:                    javax.swing.JOptionPane.showMessageDialog(this , I18n
4009:                            .getString("messages.dropObjectInsideTheCell",
4010:                                    "Please drop the object inside a cell."),
4011:                            "", javax.swing.JOptionPane.WARNING_MESSAGE);
4012:                    return null;
4013:                }
4014:
4015:                int originX = cell.getLeft() + 10;
4016:                int originY = cell.getTop() + 10;
4017:                int width = cell.getWidth();
4018:                int height = cell.getHeight();
4019:
4020:                re = new TextFieldReportElement(originX, originY, width, height);
4021:                re.setRelativePosition(new Point(0, 0));
4022:
4023:                re.setCell(cell);
4024:                re.setText(textfieldExpression);
4025:                re.setMatchingClassExpression(classExpression, true);
4026:                re.setEvaluationTime(time);
4027:
4028:                getCrosstabElement().getElements().addElement(re);
4029:                getParentReportFrame().addUndoOperation(
4030:                        new InsertElementOperation(getParentReportFrame(),
4031:                                getCrosstabElement(), re));
4032:                this .setSelectedElement(re);
4033:                this .repaint();
4034:                return re;
4035:            }
4036:
4037:            public boolean isDefaultCellMode() {
4038:                return defaultCellMode;
4039:            }
4040:
4041:            public void setDefaultCellMode(boolean defaultCellMode) {
4042:                this .defaultCellMode = defaultCellMode;
4043:
4044:                if (defaultCellMode) {
4045:                    CrosstabCell noDataCell = getWhenNoDataCell();
4046:                    noDataCell.setPaintSelection(false);
4047:
4048:                    CellAnimationEffect ae = new CellAnimationEffect();
4049:                    ae.setNoDataCell(noDataCell);
4050:                    ae.setEditor(this );
4051:                    javax.swing.SwingUtilities.invokeLater(ae);
4052:                }
4053:
4054:                if (this .getSelectedElements().size() > 0) {
4055:                    this .setSelectedElement(null);
4056:                } else {
4057:                    this .invalidate();
4058:                    this .repaint();
4059:                }
4060:
4061:            }
4062:
4063:            /**
4064:             * This method returns the WhenNoDataCell (that *should* be ever present after an updateGgrid...
4065:             *
4066:             */
4067:            public CrosstabCell getWhenNoDataCell() {
4068:                for (int i = 0; i < getCrosstabElement().getCells().size(); ++i) {
4069:                    CrosstabCell cell = (CrosstabCell) getCrosstabElement()
4070:                            .getCells().elementAt(i);
4071:                    if (cell.getType() == cell.NODATA_CELL) {
4072:                        return cell;
4073:                    }
4074:                }
4075:                return null;
4076:            }
4077:
4078:            public java.util.List getOpenedNodesDocumentStructure() {
4079:                return openedNodesDocumentStructure;
4080:            }
4081:
4082:            public void setOpenedNodesDocumentStructure(
4083:                    java.util.List openedNodesDocumentStructure) {
4084:                this .openedNodesDocumentStructure = openedNodesDocumentStructure;
4085:            }
4086:
4087:            /**
4088:             * This method adds to the standard popup menu for elements all the format tool items
4089:             *
4090:             */
4091:            private void addFormatItemsToMenu(javax.swing.JComponent m) {
4092:
4093:                jMenuItemFillCell = new javax.swing.JMenuItem();
4094:                jMenuItemFillCell
4095:                        .setIcon(new javax.swing.ImageIcon(
4096:                                getClass()
4097:                                        .getResource(
4098:                                                "/it/businesslogic/ireport/icons/menu/elem_maximise.png")));
4099:                jMenuItemFillCell.setText(it.businesslogic.ireport.util.I18n
4100:                        .getString("fillCell", "Fill the cell"));
4101:                jMenuItemFillCell
4102:                        .addActionListener(new java.awt.event.ActionListener() {
4103:                            public void actionPerformed(
4104:                                    java.awt.event.ActionEvent evt) {
4105:                                FormatCommand.getCommand(
4106:                                        OperationType.ELEMENT_MAXIMIZE)
4107:                                        .execute();
4108:                            }
4109:                        });
4110:
4111:                m.add(jMenuItemFillCell);
4112:
4113:                jMenuItemFillCellH = new javax.swing.JMenuItem();
4114:                jMenuItemFillCellH
4115:                        .setIcon(new javax.swing.ImageIcon(
4116:                                getClass()
4117:                                        .getResource(
4118:                                                "/it/businesslogic/ireport/icons/menu/elem_hmaximise.png")));
4119:                jMenuItemFillCellH.setText(it.businesslogic.ireport.util.I18n
4120:                        .getString("fillCellHorizontally",
4121:                                "Fill the cell (horizontally)"));
4122:                jMenuItemFillCellH
4123:                        .addActionListener(new java.awt.event.ActionListener() {
4124:                            public void actionPerformed(
4125:                                    java.awt.event.ActionEvent evt) {
4126:                                FormatCommand.getCommand(
4127:                                        OperationType.ELEMENT_MAXIMIZE_H)
4128:                                        .execute();
4129:                            }
4130:                        });
4131:
4132:                m.add(jMenuItemFillCellH);
4133:
4134:                jMenuItemFillCellV = new javax.swing.JMenuItem();
4135:
4136:                jMenuItemFillCellV
4137:                        .setIcon(new javax.swing.ImageIcon(
4138:                                getClass()
4139:                                        .getResource(
4140:                                                "/it/businesslogic/ireport/icons/menu/elem_vmaximise.png")));
4141:                jMenuItemFillCellV.setText(it.businesslogic.ireport.util.I18n
4142:                        .getString("fillCellVertically",
4143:                                "Fill the cell (vertically)"));
4144:                jMenuItemFillCellV
4145:                        .addActionListener(new java.awt.event.ActionListener() {
4146:                            public void actionPerformed(
4147:                                    java.awt.event.ActionEvent evt) {
4148:                                FormatCommand.getCommand(
4149:                                        OperationType.ELEMENT_MAXIMIZE_V)
4150:                                        .execute();
4151:                            }
4152:                        });
4153:
4154:                m.add(jMenuItemFillCellV);
4155:
4156:                jMenuAlign = new javax.swing.JMenu();
4157:                jMenuAlign.setText(it.businesslogic.ireport.util.I18n
4158:                        .getString("align", "Align..."));
4159:
4160:                jMenuItemAlignLeft = new javax.swing.JMenuItem();
4161:
4162:                jMenuItemAlignLeft
4163:                        .setIcon(new javax.swing.ImageIcon(
4164:                                getClass()
4165:                                        .getResource(
4166:                                                "/it/businesslogic/ireport/icons/menu/elem_align_left.png")));
4167:                jMenuItemAlignLeft.setText(it.businesslogic.ireport.util.I18n
4168:                        .getString("alignLeft", "Align left"));
4169:                jMenuItemAlignLeft
4170:                        .addActionListener(new java.awt.event.ActionListener() {
4171:                            public void actionPerformed(
4172:                                    java.awt.event.ActionEvent evt) {
4173:                                getMainFrame()
4174:                                        .jMenuItemAlignLeftActionPerformed(evt);
4175:                            }
4176:                        });
4177:
4178:                jMenuAlign.add(jMenuItemAlignLeft);
4179:
4180:                jMenuItemAlignRight = new javax.swing.JMenuItem();
4181:                jMenuItemAlignRight
4182:                        .setIcon(new javax.swing.ImageIcon(
4183:                                getClass()
4184:                                        .getResource(
4185:                                                "/it/businesslogic/ireport/icons/menu/elem_align_right.png")));
4186:                jMenuItemAlignRight.setText(it.businesslogic.ireport.util.I18n
4187:                        .getString("alignRight", "Align right"));
4188:                jMenuItemAlignRight
4189:                        .addActionListener(new java.awt.event.ActionListener() {
4190:                            public void actionPerformed(
4191:                                    java.awt.event.ActionEvent evt) {
4192:                                getMainFrame()
4193:                                        .jMenuItemAlignRightActionPerformed(evt);
4194:                            }
4195:                        });
4196:
4197:                jMenuAlign.add(jMenuItemAlignRight);
4198:
4199:                jMenuItemAlignTop = new javax.swing.JMenuItem();
4200:                jMenuItemAlignTop
4201:                        .setIcon(new javax.swing.ImageIcon(
4202:                                getClass()
4203:                                        .getResource(
4204:                                                "/it/businesslogic/ireport/icons/menu/elem_align_top.png")));
4205:                jMenuItemAlignTop.setText(it.businesslogic.ireport.util.I18n
4206:                        .getString("alignTop", "Align top"));
4207:                jMenuItemAlignTop
4208:                        .addActionListener(new java.awt.event.ActionListener() {
4209:                            public void actionPerformed(
4210:                                    java.awt.event.ActionEvent evt) {
4211:                                getMainFrame()
4212:                                        .jMenuItemAlignTopActionPerformed(evt);
4213:                            }
4214:                        });
4215:
4216:                jMenuAlign.add(jMenuItemAlignTop);
4217:
4218:                jMenuItemAlignBottom = new javax.swing.JMenuItem();
4219:                jMenuItemAlignBottom
4220:                        .setIcon(new javax.swing.ImageIcon(
4221:                                getClass()
4222:                                        .getResource(
4223:                                                "/it/businesslogic/ireport/icons/menu/elem_align_bottom.png")));
4224:                jMenuItemAlignBottom.setText(it.businesslogic.ireport.util.I18n
4225:                        .getString("alignBottom", "Align bottom"));
4226:                jMenuItemAlignBottom
4227:                        .addActionListener(new java.awt.event.ActionListener() {
4228:                            public void actionPerformed(
4229:                                    java.awt.event.ActionEvent evt) {
4230:                                getMainFrame()
4231:                                        .jMenuItemAlignBottomActionPerformed(
4232:                                                evt);
4233:                            }
4234:                        });
4235:
4236:                jMenuAlign.add(jMenuItemAlignBottom);
4237:
4238:                jSeparator19 = new javax.swing.JSeparator();
4239:                jMenuAlign.add(jSeparator19);
4240:
4241:                jMenuItemAlignVerticalAxis = new javax.swing.JMenuItem();
4242:                jMenuItemAlignVerticalAxis
4243:                        .setIcon(new javax.swing.ImageIcon(
4244:                                getClass()
4245:                                        .getResource(
4246:                                                "/it/businesslogic/ireport/icons/menu/elem_center_axis.png")));
4247:                jMenuItemAlignVerticalAxis
4248:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4249:                                "alignVerticalAxis", "Align vertical axis"));
4250:                jMenuItemAlignVerticalAxis
4251:                        .addActionListener(new java.awt.event.ActionListener() {
4252:                            public void actionPerformed(
4253:                                    java.awt.event.ActionEvent evt) {
4254:                                getMainFrame()
4255:                                        .jMenuItemAlignVerticalAxisActionPerformed(
4256:                                                evt);
4257:                            }
4258:                        });
4259:
4260:                jMenuAlign.add(jMenuItemAlignVerticalAxis);
4261:
4262:                jMenuItemAlignHorizontalAxis = new javax.swing.JMenuItem();
4263:                jMenuItemAlignHorizontalAxis
4264:                        .setIcon(new javax.swing.ImageIcon(
4265:                                getClass()
4266:                                        .getResource(
4267:                                                "/it/businesslogic/ireport/icons/menu/elem_vcenter_axis.png")));
4268:                jMenuItemAlignHorizontalAxis
4269:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4270:                                "alignHorizontalAxis", "Align horizontal axis"));
4271:                jMenuItemAlignHorizontalAxis
4272:                        .addActionListener(new java.awt.event.ActionListener() {
4273:                            public void actionPerformed(
4274:                                    java.awt.event.ActionEvent evt) {
4275:                                getMainFrame()
4276:                                        .jMenuItemAlignHorizontalAxisActionPerformed(
4277:                                                evt);
4278:                            }
4279:                        });
4280:
4281:                jMenuAlign.add(jMenuItemAlignHorizontalAxis);
4282:
4283:                m.add(jMenuAlign);
4284:
4285:                jMenuSize = new javax.swing.JMenu();
4286:                jMenuSize.setText(it.businesslogic.ireport.util.I18n.getString(
4287:                        "size", "Size..."));
4288:                jMenuItemSameWidth = new javax.swing.JMenuItem();
4289:                jMenuItemSameWidth
4290:                        .setIcon(new javax.swing.ImageIcon(
4291:                                getClass()
4292:                                        .getResource(
4293:                                                "/it/businesslogic/ireport/icons/menu/elem_same_hsize.png")));
4294:                jMenuItemSameWidth.setText(it.businesslogic.ireport.util.I18n
4295:                        .getString("sameWidth", "Same width"));
4296:                jMenuItemSameWidth
4297:                        .addActionListener(new java.awt.event.ActionListener() {
4298:                            public void actionPerformed(
4299:                                    java.awt.event.ActionEvent evt) {
4300:                                getMainFrame()
4301:                                        .jMenuItemSameWidthActionPerformed(evt);
4302:                            }
4303:                        });
4304:
4305:                jMenuSize.add(jMenuItemSameWidth);
4306:
4307:                jMenuItemSameWidthMax = new javax.swing.JMenuItem();
4308:                jMenuItemSameWidthMax
4309:                        .setIcon(new javax.swing.ImageIcon(
4310:                                getClass()
4311:                                        .getResource(
4312:                                                "/it/businesslogic/ireport/icons/menu/elem_same_hsize_plus.png")));
4313:                jMenuItemSameWidthMax
4314:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4315:                                "sameWidthMax", "Same width (max)"));
4316:                jMenuItemSameWidthMax
4317:                        .addActionListener(new java.awt.event.ActionListener() {
4318:                            public void actionPerformed(
4319:                                    java.awt.event.ActionEvent evt) {
4320:                                getMainFrame()
4321:                                        .jMenuItemSameWidthMaxActionPerformed(
4322:                                                evt);
4323:                            }
4324:                        });
4325:
4326:                jMenuSize.add(jMenuItemSameWidthMax);
4327:
4328:                jMenuItemSameWidthMin = new javax.swing.JMenuItem();
4329:                jMenuItemSameWidthMin
4330:                        .setIcon(new javax.swing.ImageIcon(
4331:                                getClass()
4332:                                        .getResource(
4333:                                                "/it/businesslogic/ireport/icons/menu/elem_same_hsize_min.png")));
4334:                jMenuItemSameWidthMin
4335:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4336:                                "sameWidthMin", "Same width (min)"));
4337:                jMenuItemSameWidthMin
4338:                        .addActionListener(new java.awt.event.ActionListener() {
4339:                            public void actionPerformed(
4340:                                    java.awt.event.ActionEvent evt) {
4341:                                getMainFrame()
4342:                                        .jMenuItemSameWidthMinActionPerformed(
4343:                                                evt);
4344:                            }
4345:                        });
4346:
4347:                jMenuSize.add(jMenuItemSameWidthMin);
4348:
4349:                jSeparator17 = new javax.swing.JSeparator();
4350:                jMenuSize.add(jSeparator17);
4351:
4352:                jMenuItemSameHeight = new javax.swing.JMenuItem();
4353:                jMenuItemSameHeight
4354:                        .setIcon(new javax.swing.ImageIcon(
4355:                                getClass()
4356:                                        .getResource(
4357:                                                "/it/businesslogic/ireport/icons/menu/elem_same_vsize.png")));
4358:                jMenuItemSameHeight.setText(it.businesslogic.ireport.util.I18n
4359:                        .getString("sameHeight", "Same height"));
4360:                jMenuItemSameHeight
4361:                        .addActionListener(new java.awt.event.ActionListener() {
4362:                            public void actionPerformed(
4363:                                    java.awt.event.ActionEvent evt) {
4364:                                getMainFrame()
4365:                                        .jMenuItemSameHeightActionPerformed(evt);
4366:                            }
4367:                        });
4368:
4369:                jMenuSize.add(jMenuItemSameHeight);
4370:
4371:                jMenuItemSameHeightMin = new javax.swing.JMenuItem();
4372:                jMenuItemSameHeightMin
4373:                        .setIcon(new javax.swing.ImageIcon(
4374:                                getClass()
4375:                                        .getResource(
4376:                                                "/it/businesslogic/ireport/icons/menu/elem_same_vsize_min.png")));
4377:                jMenuItemSameHeightMin
4378:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4379:                                "sameHeightMin", "Same height (min)"));
4380:                jMenuItemSameHeightMin
4381:                        .addActionListener(new java.awt.event.ActionListener() {
4382:                            public void actionPerformed(
4383:                                    java.awt.event.ActionEvent evt) {
4384:                                getMainFrame()
4385:                                        .jMenuItemSameHeightMinActionPerformed(
4386:                                                evt);
4387:                            }
4388:                        });
4389:
4390:                jMenuSize.add(jMenuItemSameHeightMin);
4391:
4392:                jMenuItemSameHeightMax = new javax.swing.JMenuItem();
4393:                jMenuItemSameHeightMax
4394:                        .setIcon(new javax.swing.ImageIcon(
4395:                                getClass()
4396:                                        .getResource(
4397:                                                "/it/businesslogic/ireport/icons/menu/elem_same_vsize_plus.png")));
4398:                jMenuItemSameHeightMax
4399:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4400:                                "sameHeightMax", "Same height (max)"));
4401:                jMenuItemSameHeightMax
4402:                        .addActionListener(new java.awt.event.ActionListener() {
4403:                            public void actionPerformed(
4404:                                    java.awt.event.ActionEvent evt) {
4405:                                getMainFrame()
4406:                                        .jMenuItemSameHeightMaxActionPerformed(
4407:                                                evt);
4408:                            }
4409:                        });
4410:
4411:                jMenuSize.add(jMenuItemSameHeightMax);
4412:
4413:                jSeparator18 = new javax.swing.JSeparator();
4414:                jMenuSize.add(jSeparator18);
4415:
4416:                jMenuItemSameSize = new javax.swing.JMenuItem();
4417:                jMenuItemSameSize
4418:                        .setIcon(new javax.swing.ImageIcon(
4419:                                getClass()
4420:                                        .getResource(
4421:                                                "/it/businesslogic/ireport/icons/menu/elem_same_size.png")));
4422:                jMenuItemSameSize.setText(it.businesslogic.ireport.util.I18n
4423:                        .getString("sameSize", "Same size"));
4424:                jMenuItemSameSize
4425:                        .addActionListener(new java.awt.event.ActionListener() {
4426:                            public void actionPerformed(
4427:                                    java.awt.event.ActionEvent evt) {
4428:                                getMainFrame()
4429:                                        .jMenuItemSameSizeActionPerformed(evt);
4430:                            }
4431:                        });
4432:
4433:                jMenuSize.add(jMenuItemSameSize);
4434:
4435:                m.add(jMenuSize);
4436:
4437:                jMenuPosition = new javax.swing.JMenu();
4438:                jMenuPosition.setText(it.businesslogic.ireport.util.I18n
4439:                        .getString("position", "Position..."));
4440:                jMenuItemCenterH = new javax.swing.JMenuItem();
4441:                jMenuItemCenterH
4442:                        .setIcon(new javax.swing.ImageIcon(
4443:                                getClass()
4444:                                        .getResource(
4445:                                                "/it/businesslogic/ireport/icons/menu/elem_hcenter.png")));
4446:                jMenuItemCenterH.setText(it.businesslogic.ireport.util.I18n
4447:                        .getString("centerHorizontallyCellBased",
4448:                                "Center horizontally (cell based)"));
4449:                jMenuItemCenterH
4450:                        .addActionListener(new java.awt.event.ActionListener() {
4451:                            public void actionPerformed(
4452:                                    java.awt.event.ActionEvent evt) {
4453:                                getMainFrame().jMenuItemCenterHActionPerformed(
4454:                                        evt);
4455:                            }
4456:                        });
4457:
4458:                jMenuPosition.add(jMenuItemCenterH);
4459:
4460:                jMenuItemCenterV = new javax.swing.JMenuItem();
4461:                jMenuItemCenterV
4462:                        .setIcon(new javax.swing.ImageIcon(
4463:                                getClass()
4464:                                        .getResource(
4465:                                                "/it/businesslogic/ireport/icons/menu/elem_vcenter.png")));
4466:                jMenuItemCenterV.setText(it.businesslogic.ireport.util.I18n
4467:                        .getString("centerVerticallyCellBased",
4468:                                "Center vertically (cell based)"));
4469:                jMenuItemCenterV
4470:                        .addActionListener(new java.awt.event.ActionListener() {
4471:                            public void actionPerformed(
4472:                                    java.awt.event.ActionEvent evt) {
4473:                                getMainFrame().jMenuItemCenterVActionPerformed(
4474:                                        evt);
4475:                            }
4476:                        });
4477:
4478:                jMenuPosition.add(jMenuItemCenterV);
4479:
4480:                jMenuItemCenterInCell = new javax.swing.JMenuItem();
4481:                jMenuItemCenterInCell
4482:                        .setIcon(new javax.swing.ImageIcon(
4483:                                getClass()
4484:                                        .getResource(
4485:                                                "/it/businesslogic/ireport/icons/menu/elem_ccenter.png")));
4486:                jMenuItemCenterInCell
4487:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4488:                                "centerInCell", "Center in cell"));
4489:                jMenuItemCenterInCell
4490:                        .addActionListener(new java.awt.event.ActionListener() {
4491:                            public void actionPerformed(
4492:                                    java.awt.event.ActionEvent evt) {
4493:                                getMainFrame()
4494:                                        .jMenuItemCenterInBandActionPerformed(
4495:                                                evt);
4496:                            }
4497:                        });
4498:
4499:                jMenuPosition.add(jMenuItemCenterInCell);
4500:
4501:                jMenuItemJoinLeft = new javax.swing.JMenuItem();
4502:                jMenuItemJoinLeft.setText(it.businesslogic.ireport.util.I18n
4503:                        .getString("joinSidesLeft", "Join sides left"));
4504:                jMenuItemJoinLeft
4505:                        .addActionListener(new java.awt.event.ActionListener() {
4506:                            public void actionPerformed(
4507:                                    java.awt.event.ActionEvent evt) {
4508:                                getMainFrame()
4509:                                        .jMenuItemJoinLeftActionPerformed(evt);
4510:                            }
4511:                        });
4512:
4513:                jMenuPosition.add(jMenuItemJoinLeft);
4514:
4515:                jMenuItemJoinRight = new javax.swing.JMenuItem();
4516:                jMenuItemJoinRight.setText(it.businesslogic.ireport.util.I18n
4517:                        .getString("joinSidesRight", "Join sides right"));
4518:                jMenuItemJoinRight
4519:                        .addActionListener(new java.awt.event.ActionListener() {
4520:                            public void actionPerformed(
4521:                                    java.awt.event.ActionEvent evt) {
4522:                                getMainFrame()
4523:                                        .jMenuItemJoinRightActionPerformed(evt);
4524:                            }
4525:                        });
4526:
4527:                jMenuPosition.add(jMenuItemJoinRight);
4528:
4529:                m.add(jMenuPosition);
4530:
4531:                jSeparator5 = new javax.swing.JSeparator();
4532:                m.add(jSeparator5);
4533:
4534:                jMenuHSpacing = new javax.swing.JMenu();
4535:                jMenuHSpacing
4536:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4537:                                "horizontalSpacing", "Horizontal spacing..."));
4538:
4539:                jMenuItemHSMakeEqual = new javax.swing.JMenuItem();
4540:                jMenuItemHSMakeEqual.setText(it.businesslogic.ireport.util.I18n
4541:                        .getString("makeEqual", "Make equal"));
4542:                jMenuItemHSMakeEqual
4543:                        .addActionListener(new java.awt.event.ActionListener() {
4544:                            public void actionPerformed(
4545:                                    java.awt.event.ActionEvent evt) {
4546:                                getMainFrame()
4547:                                        .jMenuItemHSMakeEqualActionPerformed(
4548:                                                evt);
4549:                            }
4550:                        });
4551:
4552:                jMenuHSpacing.add(jMenuItemHSMakeEqual);
4553:
4554:                jMenuItemHSIncrease = new javax.swing.JMenuItem();
4555:                jMenuItemHSIncrease.setText(it.businesslogic.ireport.util.I18n
4556:                        .getString("increase", "Increase"));
4557:                jMenuItemHSIncrease
4558:                        .addActionListener(new java.awt.event.ActionListener() {
4559:                            public void actionPerformed(
4560:                                    java.awt.event.ActionEvent evt) {
4561:                                getMainFrame()
4562:                                        .jMenuItemHSIncreaseActionPerformed(evt);
4563:                            }
4564:                        });
4565:
4566:                jMenuHSpacing.add(jMenuItemHSIncrease);
4567:
4568:                jMenuItemHSDecrease = new javax.swing.JMenuItem();
4569:                jMenuItemHSDecrease.setText(it.businesslogic.ireport.util.I18n
4570:                        .getString("decrease", "Decrease"));
4571:                jMenuItemHSDecrease
4572:                        .addActionListener(new java.awt.event.ActionListener() {
4573:                            public void actionPerformed(
4574:                                    java.awt.event.ActionEvent evt) {
4575:                                getMainFrame()
4576:                                        .jMenuItemHSDecreaseActionPerformed(evt);
4577:                            }
4578:                        });
4579:
4580:                jMenuHSpacing.add(jMenuItemHSDecrease);
4581:
4582:                jMenuItemHSRemove = new javax.swing.JMenuItem();
4583:                jMenuItemHSRemove.setText(it.businesslogic.ireport.util.I18n
4584:                        .getString("remove", "Remove"));
4585:                jMenuItemHSRemove
4586:                        .addActionListener(new java.awt.event.ActionListener() {
4587:                            public void actionPerformed(
4588:                                    java.awt.event.ActionEvent evt) {
4589:                                getMainFrame()
4590:                                        .jMenuItemHSRemoveActionPerformed(evt);
4591:                            }
4592:                        });
4593:
4594:                jMenuHSpacing.add(jMenuItemHSRemove);
4595:
4596:                m.add(jMenuHSpacing);
4597:
4598:                jMenuVSpacing = new javax.swing.JMenu();
4599:                jMenuVSpacing.setText(it.businesslogic.ireport.util.I18n
4600:                        .getString("verticalSpacing", "Vertical spacing"));
4601:                jMenuItemVSMakeEqual = new javax.swing.JMenuItem();
4602:                jMenuItemVSMakeEqual.setText(it.businesslogic.ireport.util.I18n
4603:                        .getString("makeEqual", "Make equal"));
4604:                jMenuItemVSMakeEqual
4605:                        .addActionListener(new java.awt.event.ActionListener() {
4606:                            public void actionPerformed(
4607:                                    java.awt.event.ActionEvent evt) {
4608:                                getMainFrame()
4609:                                        .jMenuItemVSMakeEqualActionPerformed(
4610:                                                evt);
4611:                            }
4612:                        });
4613:
4614:                jMenuVSpacing.add(jMenuItemVSMakeEqual);
4615:
4616:                jMenuItemVSIncrease = new javax.swing.JMenuItem();
4617:                jMenuItemVSIncrease.setText(it.businesslogic.ireport.util.I18n
4618:                        .getString("increase", "Increase"));
4619:                jMenuItemVSIncrease
4620:                        .addActionListener(new java.awt.event.ActionListener() {
4621:                            public void actionPerformed(
4622:                                    java.awt.event.ActionEvent evt) {
4623:                                getMainFrame()
4624:                                        .jMenuItemVSIncreaseActionPerformed(evt);
4625:                            }
4626:                        });
4627:
4628:                jMenuVSpacing.add(jMenuItemVSIncrease);
4629:
4630:                jMenuItemVSDecrease = new javax.swing.JMenuItem();
4631:                jMenuItemVSDecrease.setText(it.businesslogic.ireport.util.I18n
4632:                        .getString("decrease", "Decrease"));
4633:                jMenuItemVSDecrease
4634:                        .addActionListener(new java.awt.event.ActionListener() {
4635:                            public void actionPerformed(
4636:                                    java.awt.event.ActionEvent evt) {
4637:                                getMainFrame()
4638:                                        .jMenuItemVSDecreaseActionPerformed(evt);
4639:                            }
4640:                        });
4641:
4642:                jMenuVSpacing.add(jMenuItemVSDecrease);
4643:
4644:                jMenuItemVSRemove = new javax.swing.JMenuItem();
4645:                jMenuItemVSRemove.setText(it.businesslogic.ireport.util.I18n
4646:                        .getString("remove", "Remove"));
4647:                jMenuItemVSRemove
4648:                        .addActionListener(new java.awt.event.ActionListener() {
4649:                            public void actionPerformed(
4650:                                    java.awt.event.ActionEvent evt) {
4651:                                getMainFrame()
4652:                                        .jMenuItemVSRemoveActionPerformed(evt);
4653:                            }
4654:                        });
4655:
4656:                jMenuVSpacing.add(jMenuItemVSRemove);
4657:
4658:                m.add(jMenuVSpacing);
4659:
4660:                jSeparator8 = new javax.swing.JSeparator();
4661:                m.add(jSeparator8);
4662:
4663:                jMenuItemBringToFront = new javax.swing.JMenuItem();
4664:                jMenuItemBringToFront
4665:                        .setIcon(new javax.swing.ImageIcon(
4666:                                getClass()
4667:                                        .getResource(
4668:                                                "/it/businesslogic/ireport/icons/menu/sendtofront.png")));
4669:                jMenuItemBringToFront
4670:                        .setText(it.businesslogic.ireport.util.I18n.getString(
4671:                                "bringToFront", "Bring to front"));
4672:                jMenuItemBringToFront
4673:                        .addActionListener(new java.awt.event.ActionListener() {
4674:                            public void actionPerformed(
4675:                                    java.awt.event.ActionEvent evt) {
4676:                                getMainFrame()
4677:                                        .jMenuItemBringToFrontActionPerformed(
4678:                                                evt);
4679:                            }
4680:                        });
4681:
4682:                m.add(jMenuItemBringToFront);
4683:
4684:                jMenuItemSendToBack = new javax.swing.JMenuItem();
4685:                jMenuItemSendToBack
4686:                        .setIcon(new javax.swing.ImageIcon(
4687:                                getClass()
4688:                                        .getResource(
4689:                                                "/it/businesslogic/ireport/icons/menu/sendtoback.png")));
4690:                jMenuItemSendToBack.setText(it.businesslogic.ireport.util.I18n
4691:                        .getString("sendToBack", "Send to back"));
4692:                jMenuItemSendToBack
4693:                        .addActionListener(new java.awt.event.ActionListener() {
4694:                            public void actionPerformed(
4695:                                    java.awt.event.ActionEvent evt) {
4696:                                getMainFrame()
4697:                                        .jMenuItemSendToBackActionPerformed(evt);
4698:                            }
4699:                        });
4700:
4701:                m.add(jMenuItemSendToBack);
4702:
4703:            }
4704:
4705:            public JReportFrame getParentReportFrame() {
4706:
4707:                if (parentReportFrame == null) {
4708:                    parentReportFrame = getMainFrame().getActiveReportFrame();
4709:                }
4710:
4711:                return parentReportFrame;
4712:            }
4713:
4714:            public void setParentReportFrame(JReportFrame parentReportFrame) {
4715:                this .parentReportFrame = parentReportFrame;
4716:            }
4717:
4718:            /**
4719:             * Return the element at the point location (if any...)
4720:             */
4721:            public ReportElement getElementAt(Point location) {
4722:                Point p = new Point(
4723:                        getRealDim((int) location.getX() - 10) + 10,
4724:                        getRealDim((int) location.getY() - 10) + 10);
4725:
4726:                for (int i = getCrosstabElement().getElements().size() - 1; i >= 0; --i) {
4727:                    ReportElement re = (ReportElement) getCrosstabElement()
4728:                            .getElements().elementAt(i);
4729:                    if ((isDefaultCellMode() == (re.getCell().getType() == CrosstabCell.NODATA_CELL))
4730:                            && re.intersects(p)) {
4731:                        return re;
4732:                    }
4733:                }
4734:
4735:                return null;
4736:            }
4737:
4738:            public void applyI18n() {
4739:                // Start autogenerated code ----------------------
4740:                jCheckBoxMenuItemDefaultCellEdit.setText(I18n.getString(
4741:                        "crosstabEditorPanel.checkBoxMenuItemDefaultCellEdit",
4742:                        "Edit When-No-Data default cell"));
4743:                jCheckBoxMenuItemDefaultCellEdit1.setText(I18n.getString(
4744:                        "crosstabEditorPanel.checkBoxMenuItemDefaultCellEdit1",
4745:                        "Edit When-No-Data default cell"));
4746:                // End autogenerated code ----------------------
4747:                // Start autogenerated code ----------------------
4748:                jMenuItemCellProperties.setText(I18n.getString(
4749:                        "crosstabEditorPanel.menuItemCellProperties",
4750:                        "Cell properties"));
4751:                jMenuItemCellProperties1.setText(I18n.getString(
4752:                        "crosstabEditorPanel.menuItemCellProperties1",
4753:                        "Cell properties"));
4754:                jMenuItemCopy.setText(I18n.getString(
4755:                        "crosstabEditorPanel.menuItemCopy", "Copy"));
4756:                jMenuItemCrosstabProperties.setText(I18n.getString(
4757:                        "crosstabEditorPanel.menuItemCrosstabProperties",
4758:                        "Crosstab properties"));
4759:                jMenuItemCrosstabProperties1.setText(I18n.getString(
4760:                        "crosstabEditorPanel.menuItemCrosstabProperties1",
4761:                        "Crosstab properties"));
4762:                jMenuItemCut.setText(I18n.getString(
4763:                        "crosstabEditorPanel.menuItemCut", "Cut"));
4764:                jMenuItemDelete.setText(I18n.getString(
4765:                        "crosstabEditorPanel.menuItemDelete", "Delete"));
4766:                jMenuItemPaste.setText(I18n.getString(
4767:                        "crosstabEditorPanel.menuItemPaste", "Paste"));
4768:                jMenuItemPaste1.setText(I18n.getString(
4769:                        "crosstabEditorPanel.menuItemPaste1", "Paste"));
4770:                jMenuItemPattern
4771:                        .setText(I18n.getString(
4772:                                "crosstabEditorPanel.menuItemPattern",
4773:                                "Field pattern"));
4774:                // End autogenerated code ----------------------
4775:            }
4776:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.