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: * JReportFrame.java
0028: *
0029: * Created on 12 febbraio 2003, 21.51
0030: *
0031: */
0032:
0033: package it.businesslogic.ireport.gui;
0034:
0035: import bsh.Interpreter;
0036: import it.businesslogic.ireport.CrosstabReportElement;
0037: import it.businesslogic.ireport.FrameReportElement;
0038: import it.businesslogic.ireport.IReportFont;
0039: import it.businesslogic.ireport.SubReportElement;
0040: import it.businesslogic.ireport.TransformationType;
0041: import it.businesslogic.ireport.chart.gui.ChartSelectionJDialog;
0042: import it.businesslogic.ireport.crosstab.gui.CrosstabEditor;
0043: import it.businesslogic.ireport.gui.event.*;
0044: import it.businesslogic.ireport.gui.event.ReportBandChangedEvent;
0045: import it.businesslogic.ireport.gui.wizard.SubreportWizard;
0046: import it.businesslogic.ireport.undo.*;
0047: import it.businesslogic.ireport.util.*;
0048: import it.businesslogic.ireport.*;
0049: import it.businesslogic.ireport.crosstab.CrosstabCell;
0050: import it.businesslogic.ireport.crosstab.gui.CrosstabEditorPanel;
0051: import it.businesslogic.ireport.crosstab.gui.CrosstabWizardDialog;
0052: import it.businesslogic.ireport.gui.command.FormatCommand;
0053: import java.awt.event.ActionEvent;
0054: import java.awt.event.FocusEvent;
0055: import java.awt.event.FocusListener;
0056: import java.awt.event.KeyEvent;
0057: import java.awt.event.KeyListener;
0058: import java.awt.geom.*;
0059: import java.util.*;
0060: import java.awt.*;
0061: import java.awt.image.*;
0062: import java.io.File;
0063: import java.net.URL;
0064: import javax.swing.ImageIcon;
0065: import javax.swing.JMenuItem;
0066: import javax.swing.JOptionPane;
0067: import javax.swing.JTextPane;
0068: import javax.swing.SwingUtilities;
0069: import javax.swing.text.SimpleAttributeSet;
0070: import javax.swing.text.StyleConstants;
0071: import javax.swing.text.StyledDocument;
0072:
0073: /**
0074: *
0075: * @author Administrator
0076: */
0077: public class JReportFrame extends JMDIFrame implements
0078: LanguageChangedListener {
0079:
0080: static int id = 0;
0081: static java.awt.Cursor hsplit = null;
0082: //private Graphics2D offscreen = null;
0083: //private Graphics2D offscreenDoc = null;
0084: //private BufferedImage offscreenImage = null;
0085: //private BufferedImage offscreenImageDoc = null;
0086: private int offscreenWidth = 0;
0087: private Dimension offscreenDimension = null;
0088: private boolean isDocDirty = true;
0089:
0090: private MainFrame mf = null;
0091: private BufferedImage[] shadowsImages = null;
0092:
0093: /** This point rappresent coords of left top corner of the popup menu.... */
0094: private java.awt.Point popup_opened_at = null;
0095:
0096: /** true if the the user is trnsforming a new element....*/
0097: private boolean transforming = false;
0098:
0099: /** We are dragging a band ? */
0100: boolean band_dragging = false;
0101: /** We have started to drag a band from here */
0102: int band_dragging_origin = 0;
0103: /** We are dragging this band... */
0104: Band band_dragging_band = null;
0105: /** State for XOR operation in band dragging... */
0106: boolean first_draw_band = true;
0107: boolean firstXORDraw = false; //= false; // why not true?
0108: boolean firstXORDrawTransforming = false;
0109:
0110: boolean paintedXORDrawAlign = false;
0111: java.util.List paintedAlignLines = new java.util.ArrayList();
0112:
0113: int tabs = 0;
0114:
0115: private java.util.List reportProblems = new java.util.ArrayList();
0116:
0117: private TexturePaint mGridTexture = null;
0118:
0119: /**
0120: * This flag is true if we are selecting elements drawing a rectangle...
0121: */
0122: private boolean drag_selection_mode = false;
0123: /**
0124: * The origin of the selection rectangle...
0125: */
0126: private java.awt.Point drag_selection_origin = null;
0127: /**
0128: * The end of the selection rectangle...
0129: */
0130: private java.awt.Point drag_selection_end = null;
0131: /**
0132: * The flag is used to handle XOR operation on rectangle selection
0133: */
0134: private boolean first_draw_selection_rect = true;
0135:
0136: /**
0137: * Stroke to use when draw selection rectangle
0138: */
0139: private java.awt.Stroke selectionStroke = null;
0140:
0141: private JRulePanel jVerticalRule = null;
0142:
0143: private java.util.List verticalObjectsLines = new java.util.ArrayList();
0144: private java.util.List horizontalObjectsLines = new java.util.ArrayList();
0145:
0146: // Menus...
0147: private javax.swing.JMenuItem jCustomElementPropertiesMenuItem = null;
0148: private javax.swing.JMenu jMenuAlign;
0149: private javax.swing.JMenuItem jMenuItemAlignLeft;
0150: private javax.swing.JMenuItem jMenuItemAlignRight;
0151: private javax.swing.JMenuItem jMenuItemAlignTop;
0152: private javax.swing.JMenuItem jMenuItemAlignBottom;
0153: private javax.swing.JSeparator jSeparator19;
0154: private javax.swing.JMenuItem jMenuItemAlignVerticalAxis;
0155: private javax.swing.JMenuItem jMenuItemAlignHorizontalAxis;
0156: private javax.swing.JSeparator jSeparator20;
0157: private javax.swing.JMenuItem jMenuItemAlignToBandTop;
0158: private javax.swing.JMenuItem jMenuItemAlignToBandBottom;
0159: private javax.swing.JMenu jMenuSize;
0160: private javax.swing.JMenuItem jMenuItemSameWidth;
0161: private javax.swing.JMenuItem jMenuItemSameWidthMax;
0162: private javax.swing.JMenuItem jMenuItemSameWidthMin;
0163: private javax.swing.JSeparator jSeparator17;
0164: private javax.swing.JMenuItem jMenuItemSameHeight;
0165: private javax.swing.JMenuItem jMenuItemSameHeightMax;
0166: private javax.swing.JMenuItem jMenuItemSameHeightMin;
0167: private javax.swing.JSeparator jSeparator18;
0168: private javax.swing.JMenuItem jMenuItemSameSize;
0169: private javax.swing.JMenu jMenuPosition;
0170: private javax.swing.JMenuItem jMenuItemCenterH;
0171: private javax.swing.JMenuItem jMenuItemCenterV;
0172: private javax.swing.JMenuItem jMenuItemCenterInBand;
0173: private javax.swing.JMenuItem jMenuItemCenterBackground;
0174: private javax.swing.JMenuItem jMenuItemJoinLeft;
0175: private javax.swing.JMenuItem jMenuItemJoinRight;
0176: private javax.swing.JSeparator jSeparator5;
0177: private javax.swing.JMenuItem jMenuHSpacing;
0178: private javax.swing.JMenuItem jMenuItemHSMakeEqual;
0179: private javax.swing.JMenuItem jMenuItemHSIncrease;
0180: private javax.swing.JMenuItem jMenuItemHSDecrease;
0181: private javax.swing.JMenuItem jMenuItemHSRemove;
0182: private javax.swing.JMenuItem jMenuVSpacing;
0183: private javax.swing.JMenuItem jMenuItemVSMakeEqual;
0184: private javax.swing.JMenuItem jMenuItemVSIncrease;
0185: private javax.swing.JMenuItem jMenuItemVSDecrease;
0186: private javax.swing.JMenuItem jMenuItemVSRemove;
0187: private javax.swing.JSeparator jSeparator8;
0188: private javax.swing.JMenuItem jMenuItemBringToFront;
0189: private javax.swing.JMenuItem jMenuItemSendToBack;
0190: private javax.swing.JPopupMenu jPopupMenuElementMS;
0191: private javax.swing.JMenuItem jMenuItemOrganize;
0192: private javax.swing.JMenuItem jMenuItemRightMargin;
0193: private javax.swing.JMenuItem jMenuItemLeftMargin;
0194:
0195: private javax.swing.JMenuItem jMenuItemEditExpression;
0196:
0197: private JTextPane floatingTextArea = new JTextPane(); //JTextArea();
0198: private String previousFloatingTextAreaValue = "";
0199:
0200: private java.util.List openedNodesDocumentStructure = null;
0201:
0202: private TextReportElement onlineEditingTextReportElement = null;
0203:
0204: private DesignVerifyerThread designVerifyerThread = null;
0205:
0206: private Vector selectedBands = new Vector();
0207: private Vector selectedObjects = new Vector();
0208:
0209: private static int MAGNETIC_POWER = 5;
0210:
0211: /*
0212: * This variable is used to say if the resistence moving an element with mouse was
0213: * exceeded
0214: */
0215: boolean resistenceExceeded = false;
0216:
0217: Point newObjectOrigin = null;
0218:
0219: boolean trasforming = false;
0220: int transformation_type = -1;
0221: Point transformation_origin = null;
0222: Point transformation_origin_end = null;
0223: Point transformation_undo_delta = null;
0224:
0225: // Used to draw matching lines...
0226: int matchedVerticalLine = -1;
0227: int matchedHorizontalLine = -1;
0228:
0229: /** Creates new form JReportFrame */
0230: public JReportFrame(Report report) {
0231:
0232: initComponents();
0233:
0234: jMenuItemEditExpression = new JMenuItem();
0235: jMenuItemEditExpression.setIcon(new javax.swing.ImageIcon(""));
0236: jMenuItemEditExpression.setText("Edit expression");
0237: jMenuItemEditExpression
0238: .addActionListener(new java.awt.event.ActionListener() {
0239: public void actionPerformed(
0240: java.awt.event.ActionEvent evt) {
0241: jMenuItemEditExpressionActionPerformed(evt);
0242: }
0243: });
0244: jPopupMenuElement.insert(jMenuItemEditExpression, 0);
0245:
0246: jHorizontalRule.setJReportFrame(this );
0247: jHorizontalRule.repaint();
0248: jPanelReportContainer.setIgnoreRepaint(true);
0249:
0250: jVerticalRule = new JRulePanel();
0251: jVerticalRule.setType(jVerticalRule.TYPE_VERTICAL);
0252: jVerticalRule.setJReportFrame(this );
0253: jPanelVRule.add(jVerticalRule, java.awt.BorderLayout.CENTER);
0254: jVerticalRule.repaint();
0255:
0256: jCustomElementPropertiesMenuItem = new javax.swing.JMenuItem();
0257: jCustomElementPropertiesMenuItem
0258: .setText(it.businesslogic.ireport.util.I18n.getString(
0259: "customElementProperties",
0260: "Custom Element Properties"));
0261: jCustomElementPropertiesMenuItem
0262: .addActionListener(new java.awt.event.ActionListener() {
0263: public void actionPerformed(
0264: java.awt.event.ActionEvent evt) {
0265: jCustomElementPropertiesMenuItemActionPerformed(evt);
0266: }
0267: });
0268:
0269: jPopupMenuElement.add(jCustomElementPropertiesMenuItem);
0270: jPopupMenuElement.add(new javax.swing.JSeparator());
0271:
0272: addFormatItemsToMenu(jPopupMenuElement);
0273: this .windowID = id++;
0274:
0275: floatingTextArea.setOpaque(true);
0276: floatingTextArea.addFocusListener(new FocusListener() {
0277: public void focusGained(FocusEvent e) {
0278:
0279: }
0280:
0281: public void focusLost(FocusEvent e) {
0282: floatingTextAreaFocusLost();
0283: }
0284: });
0285:
0286: floatingTextArea.addKeyListener(new KeyListener() {
0287: public void keyPressed(KeyEvent e) {
0288: if (e.getKeyCode() == e.VK_ENTER
0289: && (e.getModifiers() & e.SHIFT_DOWN_MASK) == 0) {
0290: e.consume();
0291: floatingTextAreaFocusLost();
0292: }
0293: if (e.getKeyCode() == e.VK_ESCAPE) {
0294: e.consume();
0295: floatingTextAreaFocusLost(false);
0296: }
0297: }
0298:
0299: public void keyReleased(KeyEvent e) {
0300: }
0301:
0302: public void keyTyped(KeyEvent e) {
0303: }
0304: });
0305:
0306: floatingTextArea.addKeyListener(Misc.ARABIC_KEY_LISTENER);
0307:
0308: floatingTextArea.getDocument().addDocumentListener(
0309: new javax.swing.event.DocumentListener() {
0310: public void changedUpdate(
0311: javax.swing.event.DocumentEvent evt) {
0312: floatingTextChanged();
0313: }
0314:
0315: public void insertUpdate(
0316: javax.swing.event.DocumentEvent evt) {
0317: floatingTextChanged();
0318: }
0319:
0320: public void removeUpdate(
0321: javax.swing.event.DocumentEvent evt) {
0322: floatingTextChanged();
0323: }
0324: });
0325:
0326: selectionStroke = new java.awt.BasicStroke((float) (2f),
0327: java.awt.BasicStroke.CAP_BUTT,
0328: java.awt.BasicStroke.JOIN_BEVEL, 0f, new float[] { 5f,
0329: 3f }, 0f);
0330: this .setPreferredSize(new Dimension(350, 400));
0331: this .setNormalSize(new Dimension(350, 400));
0332: if (hsplit == null) {
0333: hsplit = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
0334: }
0335: this .jPanelReport.setJrf(this );
0336: this .report = report;
0337:
0338: this .newObjectType = ReportElementType.NONE;
0339: this .report = report;
0340: this .report.setReportFrame(this );
0341: this .setTitle(this .report.getName() + " "
0342: + this .report.getWidth() + "x"
0343: + this .report.getDesignHeight() + " ["
0344: + Misc.nvl(this .report.getFilename(), "unnamed") + "]");
0345: //System.out.println(this.getTitle());
0346:
0347: undoOperations = new Vector();
0348: clipboardObjects = new Vector();
0349: selectedElements = new Vector();
0350: transformation_undo_delta = new Point(0, 0);
0351:
0352: zoomFactor = 1.0;
0353:
0354: transformationMinSize = 5;
0355:
0356: undoIndex = -1;
0357:
0358: // Init images...
0359: shadowsImages = new BufferedImage[5];
0360:
0361: shadowsImages[0] = Misc.loadBufferedImageFromResources(this ,
0362: "it/businesslogic/ireport/icons/layout/sh_ur.gif");
0363: shadowsImages[1] = Misc.loadBufferedImageFromResources(this ,
0364: "it/businesslogic/ireport/icons/layout/sh_r.gif");
0365: shadowsImages[2] = Misc.loadBufferedImageFromResources(this ,
0366: "it/businesslogic/ireport/icons/layout/sh_lr.gif");
0367: shadowsImages[3] = Misc.loadBufferedImageFromResources(this ,
0368: "it/businesslogic/ireport/icons/layout/sh_d.gif");
0369: shadowsImages[4] = Misc.loadBufferedImageFromResources(this ,
0370: "it/businesslogic/ireport/icons/layout/sh_dl.gif");
0371:
0372: /*
0373: try {
0374: cursorplus = new Cursor(ResourceManager.getResource( getClass(), "cursorplus.cur"));
0375: cursorminus = new Cursor( ResourceManager.getResource(getClass(), "cursorminus.cur"));
0376: } catch (Exception ex)
0377: {}
0378:
0379: if (cursorplus == null )
0380: {
0381: if (com.ms.wfc.io.File.exists(com.ms.wfc.io.File.combine( getProgramDir(), "com\\businesslogic\\ireport\\ui\\cursorplus.cur")))
0382: cursorplus = new Cursor(com.ms.wfc.io.File.combine( getProgramDir(), "com\\businesslogic\\ireport\\ui\\cursorplus.cur"));
0383: }
0384:
0385: if (cursorminus == null )
0386: {
0387: if (com.ms.wfc.io.File.exists(com.ms.wfc.io.File.combine( getProgramDir(), "com\\businesslogic\\ireport\\ui\\cursorminus.cur")))
0388: cursorminus = new Cursor( com.ms.wfc.io.File.combine( getProgramDir(), "com\\businesslogic\\ireport\\ui\\cursorminus.cur"));
0389: }
0390:
0391: if (cursorplus == null)
0392: cursorplus = Cursor.CROSS;
0393: if (cursorminus == null)
0394: cursorminus = Cursor.CROSS;
0395: */
0396: /*
0397: Enumeration enum = report.getElements().elements();
0398: Brush br = new Brush(imageList2.getBitmap(0));
0399: while (enum.hasMoreElements())
0400: {
0401: ReportElement re = (ReportElement)enum.nextElement();
0402: re.hached = br;
0403:
0404: if (re instanceof SubReportElement)
0405: {
0406: ((SubReportElement)re).img = this.imageList4.getImage(0);
0407: }
0408: else if (re instanceof ImageReportElement )
0409: {
0410:
0411: ((ImageReportElement)re).defimg = imageList3.getBitmap(0);
0412: }
0413: }
0414: */
0415:
0416: //offscreen.setBackground(new Color(128,128,128));
0417: //setBackground(new Color(128,128,128));
0418: //Screen screen = Screen.getPrimary();
0419: offscreenDimension = Toolkit.getDefaultToolkit()
0420: .getScreenSize();
0421: //offscreenImage = new java.awt.image.BufferedImage(offscreenDimension.width, offscreenDimension.height, java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE);
0422: //offscreenImageDoc = new java.awt.image.BufferedImage(offscreenDimension.width, offscreenDimension.height, java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE);
0423: //offscreen = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(offscreenImage);
0424:
0425: //offscreen.setBackground(new Color(128,128,128));
0426: //offscreen.clearRect(0,0, offscreenDimension.width, offscreenDimension.height);
0427: //offscreen.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
0428: //offscreen.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
0429: //offscreen.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
0430:
0431: //offscreenDoc = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(offscreenImageDoc);
0432: //offscreenDoc.setBackground(new Color(128,128,128));
0433: //offscreenDoc.clearRect(0,0, offscreenDimension.width, offscreenDimension.height);
0434: //offscreenDoc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
0435: //offscreenDoc.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
0436: //offscreenDoc.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
0437: //offscreen.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
0438:
0439: //redrawAll(offscreen,new Rectangle(0,0,report.getWidth(),report.getHeight()), 0);
0440:
0441: //redrawAll( offscreen,new Rectangle(0,0,report.getWidth(),report.getHeight()), 0);
0442:
0443: this .jHorizontalScrollBar.setValue(0);
0444: this .jVerticalScrollBar.setValue(0);
0445:
0446: updateTabs();
0447:
0448: for (int i = 0; i < report.getElements().size(); ++i) {
0449: ReportElement re = (ReportElement) report.getElements()
0450: .elementAt(i);
0451: if (re instanceof CrosstabReportElement) {
0452: addCrosstabEditor((CrosstabReportElement) re);
0453: }
0454: }
0455:
0456: designVerifyerThread = new DesignVerifyerThread(this );
0457: designVerifyerThread.start();
0458: this .applyI18n();
0459: }
0460:
0461: public void floatingTextAreaFocusLost() {
0462: floatingTextAreaFocusLost(true);
0463: }
0464:
0465: public void floatingTextAreaFocusLost(boolean acceptModifications) {
0466:
0467: try {
0468: if (onlineEditingTextReportElement != null) {
0469: if (acceptModifications) {
0470: onlineEditingTextReportElement
0471: .setText(floatingTextArea.getText());
0472: ReportElementChangedEvent changedEvent = new ReportElementChangedEvent(
0473: this , getSelectedElements(),
0474: ReportElementChangedEvent.CHANGED);
0475: changedEvent.setEventSource(this );
0476: changedEvent.setPropertyChanged("text");
0477: changedEvent
0478: .setNewValue(floatingTextArea.getText());
0479: fireReportListenerReportElementsChanged(changedEvent);
0480: getMainFrame().getElementPropertiesDialog()
0481: .updateSelection();
0482: } else {
0483: floatingTextArea
0484: .setText(onlineEditingTextReportElement
0485: .getText());
0486: }
0487: }
0488:
0489: onlineEditingTextReportElement = null;
0490: getReportPanel().remove(floatingTextArea);
0491: getReportPanel().updateUI();
0492:
0493: } catch (Exception ex) {
0494: }
0495: }
0496:
0497: /**
0498: * Return the element at the point location (if any...)
0499: */
0500: public ReportElement getElementAt(Point location) {
0501: Point p = new Point(getLogicalDim((int) location.getX()
0502: + jHorizontalScrollBar.getValue() - 10) + 10,
0503: getLogicalDim((int) location.getY()
0504: + jVerticalScrollBar.getValue() - 10) + 10);
0505:
0506: for (int i = report.getElements().size() - 1; i >= 0; --i) {
0507:
0508: ReportElement re = (ReportElement) report.getElements()
0509: .elementAt(i);
0510: if (re.intersects(p)) {
0511: return re;
0512: }
0513: }
0514:
0515: return null;
0516: }
0517:
0518: public void floatingTextChanged() {
0519:
0520: }
0521:
0522: /** This method is called from within the constructor to
0523: * initialize the form.
0524: * WARNING: Do NOT modify this code. The content of this method is
0525: * always regenerated by the Form Editor.
0526: */
0527: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
0528: private void initComponents() {
0529: jPopupMenuBand = new javax.swing.JPopupMenu();
0530: jMenuItemPasteOnBand = new javax.swing.JMenuItem();
0531: jSeparator2 = new javax.swing.JSeparator();
0532: jMenuItemBandProperties = new javax.swing.JMenuItem();
0533: jPopupMenuElement = new javax.swing.JPopupMenu();
0534: jMenuItemElementProperties = new javax.swing.JMenuItem();
0535: jMenuItemElementChartProperties = new javax.swing.JMenuItem();
0536: jMenuItemElementCrosstabProperties = new javax.swing.JMenuItem();
0537: jMenuItemElementCrosstabDesignProperties = new javax.swing.JMenuItem();
0538: jMenuItemElementOpenSubreport = new javax.swing.JMenuItem();
0539: jMenuItemBandProperties1 = new javax.swing.JMenuItem();
0540: jSeparator1 = new javax.swing.JSeparator();
0541: jMenuItemCut = new javax.swing.JMenuItem();
0542: jMenuItemCopy = new javax.swing.JMenuItem();
0543: jMenuItemPaste = new javax.swing.JMenuItem();
0544: jMenuItemDelete = new javax.swing.JMenuItem();
0545: jSeparator3 = new javax.swing.JSeparator();
0546: jMenuItemGroup = new javax.swing.JMenuItem();
0547: jMenuItemUngroup = new javax.swing.JMenuItem();
0548: jSeparator6 = new javax.swing.JSeparator();
0549: jMenuItemCopyStyle = new javax.swing.JMenuItem();
0550: jMenuItemPasteStyle = new javax.swing.JMenuItem();
0551: jMenuItemTransformStaticText = new javax.swing.JMenuItem();
0552: jMenuItemPattern = new javax.swing.JMenuItem();
0553: jSeparator4 = new javax.swing.JSeparator();
0554: jTabbedPane1 = new javax.swing.JTabbedPane();
0555: jPanelSuperContainer = new javax.swing.JPanel();
0556: jPanelReportContainer = new javax.swing.JPanel();
0557: jPanelVRule = new javax.swing.JPanel();
0558: jPanelHContainerRule = new javax.swing.JPanel();
0559: jPanelCorner = new javax.swing.JPanel();
0560: jHorizontalRule = new it.businesslogic.ireport.gui.JRulePanel();
0561: jPanelReport = new it.businesslogic.ireport.gui.JReportPanel();
0562: jVerticalScrollBar = new javax.swing.JScrollBar();
0563: jPanelHScroll = new javax.swing.JPanel();
0564: jHorizontalScrollBar = new javax.swing.JScrollBar();
0565: jPanel1 = new javax.swing.JPanel();
0566:
0567: jMenuItemPasteOnBand.setIcon(new javax.swing.ImageIcon(""));
0568: jMenuItemPasteOnBand.setText("Paste here...");
0569: jMenuItemPasteOnBand
0570: .addActionListener(new java.awt.event.ActionListener() {
0571: public void actionPerformed(
0572: java.awt.event.ActionEvent evt) {
0573: jMenuItemPasteOnBandActionPerformed(evt);
0574: }
0575: });
0576: jMenuItemPasteOnBand
0577: .addMouseListener(new java.awt.event.MouseAdapter() {
0578: public void mouseClicked(
0579: java.awt.event.MouseEvent evt) {
0580: jMenuItemPasteOnBandMouseClicked(evt);
0581: }
0582: });
0583:
0584: jPopupMenuBand.add(jMenuItemPasteOnBand);
0585:
0586: jPopupMenuBand.add(jSeparator2);
0587:
0588: jMenuItemBandProperties.setIcon(new javax.swing.ImageIcon(""));
0589: jMenuItemBandProperties.setText("Band properties");
0590: jMenuItemBandProperties
0591: .addActionListener(new java.awt.event.ActionListener() {
0592: public void actionPerformed(
0593: java.awt.event.ActionEvent evt) {
0594: jMenuItemBandPropertiesActionPerformed(evt);
0595: }
0596: });
0597:
0598: jPopupMenuBand.add(jMenuItemBandProperties);
0599:
0600: jMenuItemElementProperties
0601: .setIcon(new javax.swing.ImageIcon(""));
0602: jMenuItemElementProperties.setText("Properties");
0603: jMenuItemElementProperties
0604: .addActionListener(new java.awt.event.ActionListener() {
0605: public void actionPerformed(
0606: java.awt.event.ActionEvent evt) {
0607: jMenuItemElementPropertiesActionPerformed(evt);
0608: }
0609: });
0610: jMenuItemElementProperties
0611: .addMouseListener(new java.awt.event.MouseAdapter() {
0612: public void mouseClicked(
0613: java.awt.event.MouseEvent evt) {
0614: jMenuItemElementPropertiesMouseClicked(evt);
0615: }
0616: });
0617:
0618: jPopupMenuElement.add(jMenuItemElementProperties);
0619:
0620: jMenuItemElementChartProperties
0621: .setIcon(new javax.swing.ImageIcon(""));
0622: jMenuItemElementChartProperties.setText("Chart properties");
0623: jMenuItemElementChartProperties
0624: .addActionListener(new java.awt.event.ActionListener() {
0625: public void actionPerformed(
0626: java.awt.event.ActionEvent evt) {
0627: jMenuItemElementChartPropertiesActionPerformed(evt);
0628: }
0629: });
0630:
0631: jPopupMenuElement.add(jMenuItemElementChartProperties);
0632:
0633: jMenuItemElementCrosstabProperties
0634: .setIcon(new javax.swing.ImageIcon(""));
0635: jMenuItemElementCrosstabProperties
0636: .setText("Crosstab properties");
0637: jMenuItemElementCrosstabProperties
0638: .addActionListener(new java.awt.event.ActionListener() {
0639: public void actionPerformed(
0640: java.awt.event.ActionEvent evt) {
0641: jMenuItemElementCrosstabPropertiesActionPerformed(evt);
0642: }
0643: });
0644:
0645: jPopupMenuElement.add(jMenuItemElementCrosstabProperties);
0646:
0647: jMenuItemElementCrosstabDesignProperties
0648: .setIcon(new javax.swing.ImageIcon(""));
0649: jMenuItemElementCrosstabDesignProperties
0650: .setText("Go to crosstab design tab....");
0651: jMenuItemElementCrosstabDesignProperties
0652: .addActionListener(new java.awt.event.ActionListener() {
0653: public void actionPerformed(
0654: java.awt.event.ActionEvent evt) {
0655: jMenuItemElementCrosstabPropertiesActionPerformed1(evt);
0656: }
0657: });
0658:
0659: jPopupMenuElement.add(jMenuItemElementCrosstabDesignProperties);
0660:
0661: jMenuItemElementOpenSubreport
0662: .setIcon(new javax.swing.ImageIcon(""));
0663: jMenuItemElementOpenSubreport.setText("Open subreport");
0664: jMenuItemElementOpenSubreport
0665: .addActionListener(new java.awt.event.ActionListener() {
0666: public void actionPerformed(
0667: java.awt.event.ActionEvent evt) {
0668: jMenuItemElementOpenSubreportActionPerformed1(evt);
0669: }
0670: });
0671:
0672: jPopupMenuElement.add(jMenuItemElementOpenSubreport);
0673:
0674: jMenuItemBandProperties1.setIcon(new javax.swing.ImageIcon(""));
0675: jMenuItemBandProperties1.setText("Band properties");
0676: jMenuItemBandProperties1
0677: .addActionListener(new java.awt.event.ActionListener() {
0678: public void actionPerformed(
0679: java.awt.event.ActionEvent evt) {
0680: jMenuItemBandPropertiesActionPerformed1(evt);
0681: }
0682: });
0683:
0684: jPopupMenuElement.add(jMenuItemBandProperties1);
0685:
0686: jPopupMenuElement.add(jSeparator1);
0687:
0688: jMenuItemCut
0689: .setIcon(new javax.swing.ImageIcon(
0690: getClass()
0691: .getResource(
0692: "/it/businesslogic/ireport/icons/menu/cut.png")));
0693: jMenuItemCut.setText("Cut");
0694: jMenuItemCut.setEnabled(false);
0695: jMenuItemCut
0696: .addActionListener(new java.awt.event.ActionListener() {
0697: public void actionPerformed(
0698: java.awt.event.ActionEvent evt) {
0699: jMenuItemCutActionPerformed(evt);
0700: }
0701: });
0702:
0703: jPopupMenuElement.add(jMenuItemCut);
0704:
0705: jMenuItemCopy
0706: .setIcon(new javax.swing.ImageIcon(
0707: getClass()
0708: .getResource(
0709: "/it/businesslogic/ireport/icons/menu/copy.png")));
0710: jMenuItemCopy.setText("Copy");
0711: jMenuItemCopy.setEnabled(false);
0712: jMenuItemCopy
0713: .addActionListener(new java.awt.event.ActionListener() {
0714: public void actionPerformed(
0715: java.awt.event.ActionEvent evt) {
0716: jMenuItemCopyActionPerformed(evt);
0717: }
0718: });
0719:
0720: jPopupMenuElement.add(jMenuItemCopy);
0721:
0722: jMenuItemPaste
0723: .setIcon(new javax.swing.ImageIcon(
0724: getClass()
0725: .getResource(
0726: "/it/businesslogic/ireport/icons/menu/paste.png")));
0727: jMenuItemPaste.setText("Paste");
0728: jMenuItemPaste.setEnabled(false);
0729: jMenuItemPaste
0730: .addActionListener(new java.awt.event.ActionListener() {
0731: public void actionPerformed(
0732: java.awt.event.ActionEvent evt) {
0733: jMenuItemPasteActionPerformed(evt);
0734: }
0735: });
0736:
0737: jPopupMenuElement.add(jMenuItemPaste);
0738:
0739: jMenuItemDelete
0740: .setIcon(new javax.swing.ImageIcon(
0741: getClass()
0742: .getResource(
0743: "/it/businesslogic/ireport/icons/menu/delete.png")));
0744: jMenuItemDelete.setText("Delete");
0745: jMenuItemDelete.setEnabled(false);
0746: jMenuItemDelete
0747: .addActionListener(new java.awt.event.ActionListener() {
0748: public void actionPerformed(
0749: java.awt.event.ActionEvent evt) {
0750: jMenuItemDeleteActionPerformed(evt);
0751: }
0752: });
0753:
0754: jPopupMenuElement.add(jMenuItemDelete);
0755:
0756: jPopupMenuElement.add(jSeparator3);
0757:
0758: jMenuItemGroup.setText("Group selected element(s)");
0759: jMenuItemGroup.setEnabled(false);
0760: jMenuItemGroup
0761: .addActionListener(new java.awt.event.ActionListener() {
0762: public void actionPerformed(
0763: java.awt.event.ActionEvent evt) {
0764: jMenuItemGroupActionPerformed(evt);
0765: }
0766: });
0767:
0768: jPopupMenuElement.add(jMenuItemGroup);
0769:
0770: jMenuItemUngroup.setText("Ungroup selected element(s)");
0771: jMenuItemUngroup.setEnabled(false);
0772: jMenuItemUngroup
0773: .addActionListener(new java.awt.event.ActionListener() {
0774: public void actionPerformed(
0775: java.awt.event.ActionEvent evt) {
0776: jMenuItemUngroupActionPerformed(evt);
0777: }
0778: });
0779:
0780: jPopupMenuElement.add(jMenuItemUngroup);
0781:
0782: jPopupMenuElement.add(jSeparator6);
0783:
0784: jMenuItemCopyStyle.setEnabled(false);
0785: jMenuItemCopyStyle.setLabel("Copy style");
0786: jMenuItemCopyStyle
0787: .addActionListener(new java.awt.event.ActionListener() {
0788: public void actionPerformed(
0789: java.awt.event.ActionEvent evt) {
0790: jMenuItemCopyStyleActionPerformed(evt);
0791: }
0792: });
0793:
0794: jPopupMenuElement.add(jMenuItemCopyStyle);
0795:
0796: jMenuItemPasteStyle.setEnabled(false);
0797: jMenuItemPasteStyle.setLabel("Paste style");
0798: jMenuItemPasteStyle
0799: .addActionListener(new java.awt.event.ActionListener() {
0800: public void actionPerformed(
0801: java.awt.event.ActionEvent evt) {
0802: jMenuItemPasteStyleActionPerformed(evt);
0803: }
0804: });
0805:
0806: jPopupMenuElement.add(jMenuItemPasteStyle);
0807:
0808: jMenuItemTransformStaticText
0809: .setAccelerator(javax.swing.KeyStroke.getKeyStroke(
0810: java.awt.event.KeyEvent.VK_F3, 0));
0811: jMenuItemTransformStaticText.setLabel("Transform in Textfield");
0812: jMenuItemTransformStaticText
0813: .addActionListener(new java.awt.event.ActionListener() {
0814: public void actionPerformed(
0815: java.awt.event.ActionEvent evt) {
0816: jMenuItemTransformStaticTextActionPerformed(evt);
0817: }
0818: });
0819:
0820: jPopupMenuElement.add(jMenuItemTransformStaticText);
0821:
0822: jMenuItemPattern.setText("Field pattern");
0823: jMenuItemPattern
0824: .addActionListener(new java.awt.event.ActionListener() {
0825: public void actionPerformed(
0826: java.awt.event.ActionEvent evt) {
0827: jMenuItemPatternActionPerformed(evt);
0828: }
0829: });
0830:
0831: jPopupMenuElement.add(jMenuItemPattern);
0832:
0833: jPopupMenuElement.add(jSeparator4);
0834:
0835: try {
0836: setSelected(true);
0837: } catch (java.beans.PropertyVetoException e1) {
0838: e1.printStackTrace();
0839: }
0840: addKeyListener(new java.awt.event.KeyAdapter() {
0841: public void keyPressed(java.awt.event.KeyEvent evt) {
0842: formKeyPressed(evt);
0843: }
0844: });
0845:
0846: jTabbedPane1
0847: .addChangeListener(new javax.swing.event.ChangeListener() {
0848: public void stateChanged(
0849: javax.swing.event.ChangeEvent evt) {
0850: jTabbedPane1StateChanged(evt);
0851: }
0852: });
0853:
0854: jPanelSuperContainer.setLayout(new java.awt.BorderLayout());
0855:
0856: jPanelReportContainer.setLayout(new java.awt.BorderLayout());
0857:
0858: jPanelVRule.setLayout(new java.awt.BorderLayout());
0859:
0860: jPanelVRule.setBackground(new java.awt.Color(255, 255, 255));
0861: jPanelVRule.setMaximumSize(new java.awt.Dimension(16, 32000));
0862: jPanelVRule.setMinimumSize(new java.awt.Dimension(16, 16));
0863: jPanelVRule.setPreferredSize(new java.awt.Dimension(16, 32767));
0864: jPanelReportContainer.add(jPanelVRule,
0865: java.awt.BorderLayout.WEST);
0866:
0867: jPanelHContainerRule.setLayout(new java.awt.BorderLayout());
0868:
0869: jPanelHContainerRule.setBackground(new java.awt.Color(255, 255,
0870: 255));
0871: jPanelHContainerRule.setMaximumSize(new java.awt.Dimension(
0872: 32767, 16));
0873: jPanelHContainerRule.setMinimumSize(new java.awt.Dimension(16,
0874: 16));
0875: jPanelHContainerRule.setPreferredSize(new java.awt.Dimension(
0876: 32767, 16));
0877: jPanelCorner.setLayout(null);
0878:
0879: jPanelCorner
0880: .setBorder(javax.swing.BorderFactory
0881: .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
0882: jPanelCorner.setMaximumSize(new java.awt.Dimension(16, 16));
0883: jPanelCorner.setMinimumSize(new java.awt.Dimension(16, 16));
0884: jPanelCorner.setPreferredSize(new java.awt.Dimension(16, 16));
0885: jPanelHContainerRule.add(jPanelCorner,
0886: java.awt.BorderLayout.WEST);
0887:
0888: jPanelHContainerRule.add(jHorizontalRule,
0889: java.awt.BorderLayout.CENTER);
0890:
0891: jPanelReportContainer.add(jPanelHContainerRule,
0892: java.awt.BorderLayout.NORTH);
0893:
0894: jPanelReport.setLayout(null);
0895:
0896: jPanelReport.setToolTipText("");
0897: jPanelReport
0898: .addComponentListener(new java.awt.event.ComponentAdapter() {
0899: public void componentResized(
0900: java.awt.event.ComponentEvent evt) {
0901: jPanelReportComponentResized(evt);
0902: }
0903: });
0904: jPanelReport
0905: .addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
0906: public void mouseDragged(
0907: java.awt.event.MouseEvent evt) {
0908: jPanelReportMouseDragged(evt);
0909: }
0910:
0911: public void mouseMoved(java.awt.event.MouseEvent evt) {
0912: jPanelReportMouseMoved(evt);
0913: }
0914: });
0915: jPanelReport.addKeyListener(new java.awt.event.KeyAdapter() {
0916: public void keyPressed(java.awt.event.KeyEvent evt) {
0917: jPanelReportKeyPressed(evt);
0918: }
0919: });
0920: jPanelReport
0921: .addMouseListener(new java.awt.event.MouseAdapter() {
0922: public void mousePressed(
0923: java.awt.event.MouseEvent evt) {
0924: jPanelReportMousePressed(evt);
0925: }
0926:
0927: public void mouseReleased(
0928: java.awt.event.MouseEvent evt) {
0929: jPanelReportMouseReleased(evt);
0930: }
0931: });
0932: jPanelReport
0933: .addAncestorListener(new javax.swing.event.AncestorListener() {
0934: public void ancestorMoved(
0935: javax.swing.event.AncestorEvent evt) {
0936: }
0937:
0938: public void ancestorAdded(
0939: javax.swing.event.AncestorEvent evt) {
0940: jPanelReportAncestorAdded(evt);
0941: }
0942:
0943: public void ancestorRemoved(
0944: javax.swing.event.AncestorEvent evt) {
0945: }
0946: });
0947: jPanelReport
0948: .addMouseWheelListener(new java.awt.event.MouseWheelListener() {
0949: public void mouseWheelMoved(
0950: java.awt.event.MouseWheelEvent evt) {
0951: jPanelReportMouseWheelMoved(evt);
0952: }
0953: });
0954:
0955: jPanelReportContainer.add(jPanelReport,
0956: java.awt.BorderLayout.CENTER);
0957:
0958: jPanelSuperContainer.add(jPanelReportContainer,
0959: java.awt.BorderLayout.CENTER);
0960:
0961: jVerticalScrollBar.setMaximum(0);
0962: jVerticalScrollBar
0963: .addKeyListener(new java.awt.event.KeyAdapter() {
0964: public void keyPressed(java.awt.event.KeyEvent evt) {
0965: jVerticalScrollBarKeyPressed(evt);
0966: }
0967: });
0968: jVerticalScrollBar
0969: .addMouseListener(new java.awt.event.MouseAdapter() {
0970: public void mouseReleased(
0971: java.awt.event.MouseEvent evt) {
0972: jVerticalScrollBarMouseReleased(evt);
0973: }
0974: });
0975: jVerticalScrollBar
0976: .addAdjustmentListener(new java.awt.event.AdjustmentListener() {
0977: public void adjustmentValueChanged(
0978: java.awt.event.AdjustmentEvent evt) {
0979: jVerticalScrollBarAdjustmentValueChanged(evt);
0980: }
0981: });
0982: jVerticalScrollBar
0983: .addMouseWheelListener(new java.awt.event.MouseWheelListener() {
0984: public void mouseWheelMoved(
0985: java.awt.event.MouseWheelEvent evt) {
0986: jVerticalScrollBarMouseWheelMoved(evt);
0987: }
0988: });
0989:
0990: jPanelSuperContainer.add(jVerticalScrollBar,
0991: java.awt.BorderLayout.EAST);
0992:
0993: jPanelHScroll.setLayout(new java.awt.BorderLayout());
0994:
0995: jHorizontalScrollBar.setMaximum(0);
0996: jHorizontalScrollBar
0997: .setOrientation(javax.swing.JScrollBar.HORIZONTAL);
0998: jHorizontalScrollBar
0999: .addAdjustmentListener(new java.awt.event.AdjustmentListener() {
1000: public void adjustmentValueChanged(
1001: java.awt.event.AdjustmentEvent evt) {
1002: jHorizontalScrollBarAdjustmentValueChanged(evt);
1003: }
1004: });
1005:
1006: jPanelHScroll.add(jHorizontalScrollBar,
1007: java.awt.BorderLayout.CENTER);
1008:
1009: jPanel1.setMaximumSize(new java.awt.Dimension(17, 17));
1010: jPanel1.setMinimumSize(new java.awt.Dimension(17, 17));
1011: jPanel1.setPreferredSize(new java.awt.Dimension(17, 17));
1012: jPanelHScroll.add(jPanel1, java.awt.BorderLayout.EAST);
1013:
1014: jPanelSuperContainer.add(jPanelHScroll,
1015: java.awt.BorderLayout.SOUTH);
1016:
1017: jTabbedPane1
1018: .addTab(
1019: "Main report",
1020: new javax.swing.ImageIcon(
1021: getClass()
1022: .getResource(
1023: "/it/businesslogic/ireport/icons/mainreport.png")),
1024: jPanelSuperContainer);
1025:
1026: getContentPane()
1027: .add(jTabbedPane1, java.awt.BorderLayout.CENTER);
1028:
1029: pack();
1030: }// </editor-fold>//GEN-END:initComponents
1031:
1032: private void jPanelReportMouseWheelMoved(
1033: java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_jPanelReportMouseWheelMoved
1034: jVerticalScrollBarMouseWheelMoved(evt);
1035: }//GEN-LAST:event_jPanelReportMouseWheelMoved
1036:
1037: private void jVerticalScrollBarMouseWheelMoved(
1038: java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_jVerticalScrollBarMouseWheelMoved
1039:
1040: int notches = evt.getWheelRotation();
1041:
1042: jVerticalScrollBar.setValue(jVerticalScrollBar.getValue()
1043: + (notches * 30));
1044:
1045: }//GEN-LAST:event_jVerticalScrollBarMouseWheelMoved
1046:
1047: private void jMenuItemBandPropertiesActionPerformed1(
1048: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBandPropertiesActionPerformed1
1049: jMenuItemBandPropertiesActionPerformed(evt);
1050: }//GEN-LAST:event_jMenuItemBandPropertiesActionPerformed1
1051:
1052: private void jMenuItemElementOpenSubreportActionPerformed1(
1053: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementOpenSubreportActionPerformed1
1054:
1055: if (getSelectedElements().size() > 0) {
1056: ReportElement re = (ReportElement) getSelectedElements()
1057: .elementAt(0);
1058:
1059: //System.out.println(re);
1060:
1061: if (re instanceof SubReportElement) {
1062: SubReportElement sre = (SubReportElement) re;
1063:
1064: String subreportExp = sre.getSubreportExpression();
1065: String subreportExpClass = sre
1066: .getSubreportExpressionClass();
1067:
1068: if (subreportExpClass.equals("java.lang.String")) {
1069: try {
1070: Interpreter interpreter = prepareExpressionEvaluator();
1071:
1072: subreportExp = ""
1073: + ReportQueryDialog
1074: .recursiveInterpreter(
1075: interpreter,
1076: subreportExp,
1077: getReport()
1078: .getParameters());
1079:
1080: if (subreportExp != null) {
1081: String fileName = subreportExp + "";
1082:
1083: //fileName = Misc.string_replace("/","//",fileName);
1084:
1085: if (fileName.toLowerCase().endsWith(
1086: ".jasper")) {
1087: java.util.List possibleSourceFiles = new java.util.ArrayList();
1088:
1089: possibleSourceFiles.add(fileName
1090: .substring(0,
1091: fileName.length() - 7)
1092: + ".jrxml");
1093: possibleSourceFiles.add(fileName
1094: .substring(0,
1095: fileName.length() - 7)
1096: + ".xml");
1097:
1098: // Look in the same directory as this file...
1099: File f = new File(fileName);
1100: String fname = f.getName();
1101: if (fname.length() > 7
1102: && getReport().getFilename() != null
1103: && getReport().getFilename()
1104: .length() > 0) {
1105: f = new File(getReport()
1106: .getFilename());
1107: possibleSourceFiles.add(f
1108: .getParent()
1109: + File.separator
1110: + fname.substring(0, fname
1111: .length() - 7)
1112: + ".jrxml");
1113: possibleSourceFiles.add(f
1114: .getParent()
1115: + File.separator
1116: + fname.substring(0, fname
1117: .length() - 7)
1118: + ".xml");
1119: }
1120:
1121: f = getFirstValidFile(possibleSourceFiles);
1122:
1123: if (f == null) {
1124: String message = "No one of the following possible source files for this subreport were found:\n\n";
1125: for (int i = 0; i < possibleSourceFiles
1126: .size(); ++i) {
1127: message += possibleSourceFiles
1128: .get(i)
1129: + "\n";
1130: }
1131:
1132: throw new Exception(message);
1133: }
1134:
1135: JReportFrame rf = MainFrame
1136: .getMainInstance().openFile(f);
1137: rf.setSelected(true);
1138: }
1139:
1140: }
1141:
1142: } catch (Exception ex) {
1143: JOptionPane
1144: .showMessageDialog(
1145: this ,
1146: I18n
1147: .getFormattedString(
1148: "messages.jReportFrame.errorOpeningSubreport",
1149: "I have got a problem finding the subreport:\n{0}",
1150: new Object[] { ex
1151: .getMessage() }));
1152: }
1153: }
1154: }
1155:
1156: }
1157: }//GEN-LAST:event_jMenuItemElementOpenSubreportActionPerformed1
1158:
1159: private File getFirstValidFile(java.util.List list) {
1160: for (int i = 0; i < list.size(); ++i) {
1161: String fileName = list.get(i) + "";
1162: File f = new File(fileName);
1163:
1164: if (!f.exists()) {
1165: ReportClassLoader rcl = MainFrame.getMainInstance()
1166: .getReportClassLoader();
1167: if (this .getReport().getFilename() != null) {
1168: File rfn = new File(this .getReport().getFilename());
1169: rcl.addNoRelodablePath(rfn.getParent());
1170: }
1171: try {
1172: URL url = rcl.getResource(fileName);
1173:
1174: if (url != null) {
1175: f = new File(url.getPath());
1176: if (!f.exists()) {
1177: continue;
1178: }
1179: } else {
1180: continue;
1181: }
1182: } catch (Exception ex) {
1183: continue;
1184: }
1185: }
1186:
1187: return f;
1188: }
1189:
1190: return null;
1191: }
1192:
1193: private Interpreter prepareExpressionEvaluator()
1194: throws bsh.EvalError {
1195: Interpreter interpreter = new Interpreter();
1196: interpreter.setClassLoader(interpreter.getClass()
1197: .getClassLoader());
1198: return interpreter;
1199:
1200: // return null;
1201: }
1202:
1203: private void jMenuItemElementCrosstabPropertiesActionPerformed1(
1204: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementCrosstabPropertiesActionPerformed1
1205:
1206: if (getSelectedElements().size() > 0) {
1207: ReportElement re = (ReportElement) getSelectedElements()
1208: .elementAt(0);
1209:
1210: if (re instanceof CrosstabReportElement) {
1211: setSelectedCrosstabEditor((CrosstabReportElement) re);
1212: }
1213: }
1214:
1215: }//GEN-LAST:event_jMenuItemElementCrosstabPropertiesActionPerformed1
1216:
1217: /**
1218: * Open the crosstab editor for the specified element...
1219: */
1220: public boolean setSelectedCrosstabEditor(CrosstabReportElement re) {
1221: try {
1222: if (re == null) {
1223: jTabbedPane1.setSelectedIndex(0);
1224: } else {
1225: jTabbedPane1
1226: .setSelectedComponent(getCrosstabEditor(re));
1227: }
1228: } catch (Exception ex) {
1229: return false;
1230: }
1231:
1232: return true;
1233: }
1234:
1235: private void jTabbedPane1StateChanged(
1236: javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
1237:
1238: //We have to check if the current panel is the first one or not...
1239: if (jTabbedPane1 == null || !jTabbedPane1.isVisible()
1240: || jTabbedPane1.getSelectedIndex() == 0) {
1241: MainFrame.getMainInstance().setCrosstabActive(null);
1242: MainFrame.getMainInstance().setComboBoxZoomFactor(
1243: this .zoomFactor * 100);
1244: } else {
1245: MainFrame.getMainInstance().setCrosstabActive(
1246: getSelectedCrosstabEditorPanel()
1247: .getCrosstabElement());
1248: MainFrame.getMainInstance().setComboBoxZoomFactor(
1249: this .getSelectedCrosstabEditorPanel()
1250: .getZoomFactor() * 100);
1251: }
1252:
1253: MainFrame.getMainInstance().getElementPropertiesDialog()
1254: .updateSelection();
1255: try {
1256: MainFrame.getMainInstance().updateCutAndPasteMenu(this );
1257: } catch (Exception ex) {
1258: ex.printStackTrace();
1259: }
1260:
1261: }//GEN-LAST:event_jTabbedPane1StateChanged
1262:
1263: private void jMenuItemElementCrosstabPropertiesActionPerformed(
1264: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementCrosstabPropertiesActionPerformed
1265: if (getSelectedElements().size() > 0) {
1266: ReportElement re = (ReportElement) getSelectedElements()
1267: .elementAt(0);
1268:
1269: if (re instanceof CrosstabReportElement) {
1270: it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1271: getMainFrame(), true);
1272: cpd
1273: .setCurrentCrosstabReportElement((CrosstabReportElement) re);
1274: cpd.setVisible(true);
1275: }
1276: }
1277: }//GEN-LAST:event_jMenuItemElementCrosstabPropertiesActionPerformed
1278:
1279: private void jMenuItemUngroupActionPerformed(
1280: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUngroupActionPerformed
1281: ungroupSelectedElements();
1282: }//GEN-LAST:event_jMenuItemUngroupActionPerformed
1283:
1284: private void jMenuItemGroupActionPerformed(
1285: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGroupActionPerformed
1286: groupSelectedElements();
1287: }//GEN-LAST:event_jMenuItemGroupActionPerformed
1288:
1289: public boolean groupSelectedElements() {
1290: if (getSelectedElements().size() == 0)
1291: return false;
1292: boolean sameBand = true;
1293: Band theBand = null;
1294: Enumeration selectedElementEnum = getSelectedElements()
1295: .elements();
1296:
1297: while (selectedElementEnum.hasMoreElements()) {
1298: ReportElement re = (ReportElement) selectedElementEnum
1299: .nextElement();
1300: if (theBand == null)
1301: theBand = re.getBand();
1302: else if (sameBand && theBand != re.getBand())
1303: sameBand = false;
1304:
1305: if (!sameBand)
1306: return false;
1307: }
1308:
1309: selectedElementEnum = getSelectedElements().elements();
1310: String newGroup = getReport().createChildGroup("");
1311:
1312: while (selectedElementEnum.hasMoreElements()) {
1313: ReportElement re = (ReportElement) selectedElementEnum
1314: .nextElement();
1315: String oldGroup = re.getElementGroup();
1316: if (oldGroup.length() > 0)
1317: oldGroup = "." + oldGroup;
1318: re.setElementGroup(newGroup + oldGroup);
1319: }
1320:
1321: GroupEmentsOperation undoOp = new GroupEmentsOperation(this );
1322: undoOp.setAddedGroup(newGroup);
1323:
1324: PositionedElement[] newPositionedElements = new PositionedElement[this
1325: .getSelectedElements().size()];
1326:
1327: for (int i = 0; i < this .getSelectedElements().size(); ++i) {
1328: ReportElement element = (ReportElement) getSelectedElements()
1329: .elementAt(i);
1330: int oldPosition = getReport().getElements()
1331: .indexOf(element);
1332: newPositionedElements[i] = new PositionedElement(element,
1333: oldPosition, oldPosition);
1334: }
1335:
1336: // Reorder
1337: for (int i = 0; i < this .getSelectedElements().size(); ++i) {
1338: ReportElement element = (ReportElement) getSelectedElements()
1339: .elementAt(i);
1340: int newPosition = getReport().getElements()
1341: .indexOf(element);
1342: undoOp.addElement(newPositionedElements[i].getElement(),
1343: newPositionedElements[i].getOldPosition(),
1344: newPosition);
1345: }
1346:
1347: addUndoOperation(undoOp);
1348: getReportPanel().repaint();
1349: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
1350: this , new Vector(), ReportElementChangedEvent.REMOVED));
1351: return true;
1352:
1353: }
1354:
1355: public boolean ungroupSelectedElements() {
1356: if (getSelectedElements().size() == 0)
1357: return false;
1358: boolean sameBand = true;
1359: Band theBand = null;
1360: Enumeration selectedElementEnum = getSelectedElements()
1361: .elements();
1362:
1363: while (selectedElementEnum.hasMoreElements()) {
1364: ReportElement re = (ReportElement) selectedElementEnum
1365: .nextElement();
1366: if (theBand == null)
1367: theBand = re.getBand();
1368: else if (sameBand && theBand != re.getBand())
1369: sameBand = false;
1370:
1371: if (!sameBand)
1372: return false;
1373: }
1374:
1375: selectedElementEnum = getSelectedElements().elements();
1376:
1377: UnGroupEmentsOperation undoOp = new UnGroupEmentsOperation(this );
1378:
1379: GroupPositionedElement[] newPositionedElements = new GroupPositionedElement[this
1380: .getSelectedElements().size()];
1381:
1382: for (int i = 0; i < this .getSelectedElements().size(); ++i) {
1383: ReportElement element = (ReportElement) getSelectedElements()
1384: .elementAt(i);
1385: String oldGroup = element.getElementGroup();
1386: String newGroup = oldGroup;
1387: if (newGroup.lastIndexOf(".") >= 0) {
1388: newGroup = newGroup.substring(0, newGroup
1389: .lastIndexOf("."));
1390: } else {
1391: newGroup = "";
1392: }
1393: element.setElementGroup(newGroup);
1394: int oldPosition = getReport().getElements()
1395: .indexOf(element);
1396: newPositionedElements[i] = new GroupPositionedElement(
1397: element, oldPosition, oldPosition, oldGroup,
1398: newGroup);
1399: }
1400:
1401: // Reorder
1402: for (int i = 0; i < this .getSelectedElements().size(); ++i) {
1403: ReportElement element = (ReportElement) getSelectedElements()
1404: .elementAt(i);
1405: int newPosition = getReport().getElements()
1406: .indexOf(element);
1407: undoOp.addElement(newPositionedElements[i].getElement(),
1408: newPositionedElements[i].getOldPosition(),
1409: newPosition, newPositionedElements[i]
1410: .getOldElementGroup(),
1411: newPositionedElements[i].getNewElementGroup());
1412: }
1413:
1414: addUndoOperation(undoOp);
1415: getReportPanel().repaint();
1416: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
1417: this , new Vector(), ReportElementChangedEvent.REMOVED));
1418: return true;
1419:
1420: }
1421:
1422: private void jMenuItemEditExpressionActionPerformed(
1423: java.awt.event.ActionEvent evt) {
1424:
1425: if (getSelectedElements().size() > 0) {
1426: ReportElement re = (ReportElement) getSelectedElements()
1427: .elementAt(0);
1428:
1429: if (re instanceof TextFieldReportElement) {
1430: TextFieldReportElement tfre = (TextFieldReportElement) re;
1431: ExpressionEditor ed = new ExpressionEditor();
1432: ed.setSubDataset(this .getReport());
1433: ed.setExpression(tfre.getText());
1434: ed.updateTreeEntries();
1435: ed.setVisible(true);
1436: if (ed.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
1437: tfre.setText(ed.getExpression());
1438: getReportPanel().repaint();
1439: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
1440: this , tfre,
1441: ReportElementChangedEvent.CHANGED));
1442: }
1443: }
1444: }
1445: }
1446:
1447: private void jMenuItemElementChartPropertiesActionPerformed(
1448: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementChartPropertiesActionPerformed
1449:
1450: if (getSelectedElements().size() > 0) {
1451: ReportElement re = (ReportElement) getSelectedElements()
1452: .elementAt(0);
1453:
1454: if (re instanceof ChartReportElement2) {
1455: it.businesslogic.ireport.chart.gui.ChartPropertiesDialog cpd = new it.businesslogic.ireport.chart.gui.ChartPropertiesDialog(
1456: getMainFrame(), true);
1457: cpd.setChartElement((ChartReportElement2) re);
1458: cpd.setVisible(true);
1459: }
1460: }
1461:
1462: }//GEN-LAST:event_jMenuItemElementChartPropertiesActionPerformed
1463:
1464: private void jMenuItemPatternActionPerformed(
1465: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPatternActionPerformed
1466:
1467: String pattern = "";
1468: FieldPatternDialog pd = new FieldPatternDialog(MainFrame
1469: .getMainInstance(), true);
1470: pd.setVisible(true);
1471: if (pd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
1472:
1473: Enumeration selectedElementEnum = getSelectedElements()
1474: .elements();
1475:
1476: while (selectedElementEnum.hasMoreElements()) {
1477: ReportElement re = (ReportElement) selectedElementEnum
1478: .nextElement();
1479: if (re instanceof TextFieldReportElement) {
1480: ((TextFieldReportElement) re).setPattern(pd
1481: .getPattern());
1482: }
1483: }
1484: }
1485:
1486: }//GEN-LAST:event_jMenuItemPatternActionPerformed
1487:
1488: private void jMenuItemPasteStyleActionPerformed(
1489: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteStyleActionPerformed
1490:
1491: pasteStyle();
1492:
1493: }//GEN-LAST:event_jMenuItemPasteStyleActionPerformed
1494:
1495: private void jMenuItemCopyStyleActionPerformed(
1496: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyStyleActionPerformed
1497:
1498: copyStyle();
1499:
1500: }//GEN-LAST:event_jMenuItemCopyStyleActionPerformed
1501:
1502: private void jMenuItemTransformStaticTextActionPerformed(
1503: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTransformStaticTextActionPerformed
1504: transformStaticInTextFields();
1505: }//GEN-LAST:event_jMenuItemTransformStaticTextActionPerformed
1506:
1507: private void jMenuItemDeleteActionPerformed(
1508: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeleteActionPerformed
1509: // Remove selected elements...
1510: this .deleteSelectedElements();
1511: }//GEN-LAST:event_jMenuItemDeleteActionPerformed
1512:
1513: public void delete() {
1514: if (getSelectedCrosstabEditorPanel() != null) {
1515: getSelectedCrosstabEditorPanel().deleteSelectedElements();
1516: } else {
1517: this .deleteSelectedElements();
1518: }
1519: }
1520:
1521: private void jMenuItemPasteActionPerformed(
1522: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
1523: paste();
1524: }//GEN-LAST:event_jMenuItemPasteActionPerformed
1525:
1526: private void jMenuItemCopyActionPerformed(
1527: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
1528: copy();
1529: }//GEN-LAST:event_jMenuItemCopyActionPerformed
1530:
1531: private void jMenuItemCutActionPerformed(
1532: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCutActionPerformed
1533: cut();
1534: }//GEN-LAST:event_jMenuItemCutActionPerformed
1535:
1536: private void jMenuItemBandPropertiesActionPerformed(
1537: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBandPropertiesActionPerformed
1538:
1539: if (popup_opened_at != null) {
1540:
1541: // We must find the right band...
1542: int y = getLogicalDim(popup_opened_at.y - 10
1543: + jVerticalScrollBar.getValue()) + 10;
1544: Band myBand = getReport().getBandByPosition(y);
1545:
1546: if (myBand != null) {
1547: getMainFrame().jMenuItemBandsActionPerformed(evt);
1548: getMainFrame().getBandsDialog().setSelectedBand(
1549: myBand.getName());
1550: }
1551:
1552: }
1553: }//GEN-LAST:event_jMenuItemBandPropertiesActionPerformed
1554:
1555: private void addFormatItemsToMenu(javax.swing.JComponent m) {
1556:
1557: jMenuAlign = new javax.swing.JMenu();
1558: jMenuAlign.setText(it.businesslogic.ireport.util.I18n
1559: .getString("align", "Align..."));
1560: jMenuItemAlignLeft = new javax.swing.JMenuItem();
1561: jMenuItemAlignLeft
1562: .setIcon(new javax.swing.ImageIcon(
1563: getClass()
1564: .getResource(
1565: "/it/businesslogic/ireport/icons/menu/elem_align_left.png")));
1566: jMenuItemAlignLeft.setText(it.businesslogic.ireport.util.I18n
1567: .getString("alignLeft", "Align left"));
1568: jMenuItemAlignLeft
1569: .addActionListener(new java.awt.event.ActionListener() {
1570: public void actionPerformed(
1571: java.awt.event.ActionEvent evt) {
1572: getMainFrame()
1573: .jMenuItemAlignLeftActionPerformed(evt);
1574: }
1575: });
1576:
1577: jMenuAlign.add(jMenuItemAlignLeft);
1578:
1579: jMenuItemAlignRight = new javax.swing.JMenuItem();
1580: jMenuItemAlignRight
1581: .setIcon(new javax.swing.ImageIcon(
1582: getClass()
1583: .getResource(
1584: "/it/businesslogic/ireport/icons/menu/elem_align_right.png")));
1585: jMenuItemAlignRight.setText(it.businesslogic.ireport.util.I18n
1586: .getString("alignRight", "Align right"));
1587: jMenuItemAlignRight
1588: .addActionListener(new java.awt.event.ActionListener() {
1589: public void actionPerformed(
1590: java.awt.event.ActionEvent evt) {
1591: getMainFrame()
1592: .jMenuItemAlignRightActionPerformed(evt);
1593: }
1594: });
1595:
1596: jMenuAlign.add(jMenuItemAlignRight);
1597:
1598: jMenuItemAlignTop = new javax.swing.JMenuItem();
1599: jMenuItemAlignTop
1600: .setIcon(new javax.swing.ImageIcon(
1601: getClass()
1602: .getResource(
1603: "/it/businesslogic/ireport/icons/menu/elem_align_top.png")));
1604: jMenuItemAlignTop.setText(it.businesslogic.ireport.util.I18n
1605: .getString("alignTop", "Align top"));
1606: jMenuItemAlignTop
1607: .addActionListener(new java.awt.event.ActionListener() {
1608: public void actionPerformed(
1609: java.awt.event.ActionEvent evt) {
1610: getMainFrame()
1611: .jMenuItemAlignTopActionPerformed(evt);
1612: }
1613: });
1614:
1615: jMenuAlign.add(jMenuItemAlignTop);
1616:
1617: jMenuItemAlignBottom = new javax.swing.JMenuItem();
1618: jMenuItemAlignBottom
1619: .setIcon(new javax.swing.ImageIcon(
1620: getClass()
1621: .getResource(
1622: "/it/businesslogic/ireport/icons/menu/elem_align_bottom.png")));
1623: jMenuItemAlignBottom.setText(it.businesslogic.ireport.util.I18n
1624: .getString("alignBottom", "Align bottom"));
1625: jMenuItemAlignBottom
1626: .addActionListener(new java.awt.event.ActionListener() {
1627: public void actionPerformed(
1628: java.awt.event.ActionEvent evt) {
1629: getMainFrame()
1630: .jMenuItemAlignBottomActionPerformed(
1631: evt);
1632: }
1633: });
1634:
1635: jMenuAlign.add(jMenuItemAlignBottom);
1636:
1637: jSeparator19 = new javax.swing.JSeparator();
1638: jMenuAlign.add(jSeparator19);
1639:
1640: jMenuItemAlignVerticalAxis = new javax.swing.JMenuItem();
1641: jMenuItemAlignVerticalAxis
1642: .setIcon(new javax.swing.ImageIcon(
1643: getClass()
1644: .getResource(
1645: "/it/businesslogic/ireport/icons/menu/elem_center_axis.png")));
1646: jMenuItemAlignVerticalAxis
1647: .setText(it.businesslogic.ireport.util.I18n.getString(
1648: "alignVerticalAxis", "Align vertical axis"));
1649: jMenuItemAlignVerticalAxis
1650: .addActionListener(new java.awt.event.ActionListener() {
1651: public void actionPerformed(
1652: java.awt.event.ActionEvent evt) {
1653: getMainFrame()
1654: .jMenuItemAlignVerticalAxisActionPerformed(
1655: evt);
1656: }
1657: });
1658:
1659: jMenuAlign.add(jMenuItemAlignVerticalAxis);
1660:
1661: jMenuItemAlignHorizontalAxis = new javax.swing.JMenuItem();
1662: jMenuItemAlignHorizontalAxis
1663: .setIcon(new javax.swing.ImageIcon(
1664: getClass()
1665: .getResource(
1666: "/it/businesslogic/ireport/icons/menu/elem_vcenter_axis.png")));
1667: jMenuItemAlignHorizontalAxis
1668: .setText(it.businesslogic.ireport.util.I18n.getString(
1669: "alignHorizontalAxis", "Align horizontal axis"));
1670: jMenuItemAlignHorizontalAxis
1671: .addActionListener(new java.awt.event.ActionListener() {
1672: public void actionPerformed(
1673: java.awt.event.ActionEvent evt) {
1674: getMainFrame()
1675: .jMenuItemAlignHorizontalAxisActionPerformed(
1676: evt);
1677: }
1678: });
1679:
1680: jMenuAlign.add(jMenuItemAlignHorizontalAxis);
1681:
1682: jSeparator20 = new javax.swing.JSeparator();
1683: jMenuAlign.add(jSeparator20);
1684:
1685: jMenuItemAlignToBandTop = new javax.swing.JMenuItem();
1686: jMenuItemAlignToBandTop
1687: .setText(it.businesslogic.ireport.util.I18n.getString(
1688: "alignToBandTop", "Align to band top"));
1689: jMenuItemAlignToBandTop
1690: .addActionListener(new java.awt.event.ActionListener() {
1691: public void actionPerformed(
1692: java.awt.event.ActionEvent evt) {
1693: getMainFrame()
1694: .jMenuItemAlignToBandTopActionPerformed(
1695: evt);
1696: }
1697: });
1698:
1699: jMenuAlign.add(jMenuItemAlignToBandTop);
1700:
1701: jMenuItemAlignToBandBottom = new javax.swing.JMenuItem();
1702: jMenuItemAlignToBandBottom
1703: .setText(it.businesslogic.ireport.util.I18n.getString(
1704: "alignToBandBottom", "Align to band bottom"));
1705: jMenuItemAlignToBandBottom
1706: .addActionListener(new java.awt.event.ActionListener() {
1707: public void actionPerformed(
1708: java.awt.event.ActionEvent evt) {
1709: getMainFrame()
1710: .jMenuItemAlignToBandBottomActionPerformed(
1711: evt);
1712: }
1713: });
1714:
1715: jMenuAlign.add(jMenuItemAlignToBandBottom);
1716:
1717: m.add(jMenuAlign);
1718:
1719: jMenuSize = new javax.swing.JMenu();
1720: jMenuSize.setText(it.businesslogic.ireport.util.I18n.getString(
1721: "size", "Size..."));
1722: jMenuItemSameWidth = new javax.swing.JMenuItem();
1723: jMenuItemSameWidth
1724: .setIcon(new javax.swing.ImageIcon(
1725: getClass()
1726: .getResource(
1727: "/it/businesslogic/ireport/icons/menu/elem_same_hsize.png")));
1728: jMenuItemSameWidth.setText(it.businesslogic.ireport.util.I18n
1729: .getString("sameWidth", "Same width"));
1730: jMenuItemSameWidth
1731: .addActionListener(new java.awt.event.ActionListener() {
1732: public void actionPerformed(
1733: java.awt.event.ActionEvent evt) {
1734: getMainFrame()
1735: .jMenuItemSameWidthActionPerformed(evt);
1736: }
1737: });
1738:
1739: jMenuSize.add(jMenuItemSameWidth);
1740:
1741: jMenuItemSameWidthMax = new javax.swing.JMenuItem();
1742: jMenuItemSameWidthMax
1743: .setIcon(new javax.swing.ImageIcon(
1744: getClass()
1745: .getResource(
1746: "/it/businesslogic/ireport/icons/menu/elem_same_hsize_plus.png")));
1747: jMenuItemSameWidthMax
1748: .setText(it.businesslogic.ireport.util.I18n.getString(
1749: "sameWidthMax", "Same width (max)"));
1750: jMenuItemSameWidthMax
1751: .addActionListener(new java.awt.event.ActionListener() {
1752: public void actionPerformed(
1753: java.awt.event.ActionEvent evt) {
1754: getMainFrame()
1755: .jMenuItemSameWidthMaxActionPerformed(
1756: evt);
1757: }
1758: });
1759:
1760: jMenuSize.add(jMenuItemSameWidthMax);
1761:
1762: jMenuItemSameWidthMin = new javax.swing.JMenuItem();
1763: jMenuItemSameWidthMin
1764: .setIcon(new javax.swing.ImageIcon(
1765: getClass()
1766: .getResource(
1767: "/it/businesslogic/ireport/icons/menu/elem_same_hsize_min.png")));
1768: jMenuItemSameWidthMin
1769: .setText(it.businesslogic.ireport.util.I18n.getString(
1770: "sameWidthMin", "Same width (min)"));
1771: jMenuItemSameWidthMin
1772: .addActionListener(new java.awt.event.ActionListener() {
1773: public void actionPerformed(
1774: java.awt.event.ActionEvent evt) {
1775: getMainFrame()
1776: .jMenuItemSameWidthMinActionPerformed(
1777: evt);
1778: }
1779: });
1780:
1781: jMenuSize.add(jMenuItemSameWidthMin);
1782:
1783: jSeparator17 = new javax.swing.JSeparator();
1784: jMenuSize.add(jSeparator17);
1785:
1786: jMenuItemSameHeight = new javax.swing.JMenuItem();
1787: jMenuItemSameHeight
1788: .setIcon(new javax.swing.ImageIcon(
1789: getClass()
1790: .getResource(
1791: "/it/businesslogic/ireport/icons/menu/elem_same_vsize.png")));
1792: jMenuItemSameHeight.setText(it.businesslogic.ireport.util.I18n
1793: .getString("sameHeight", "Same height"));
1794: jMenuItemSameHeight
1795: .addActionListener(new java.awt.event.ActionListener() {
1796: public void actionPerformed(
1797: java.awt.event.ActionEvent evt) {
1798: getMainFrame()
1799: .jMenuItemSameHeightActionPerformed(evt);
1800: }
1801: });
1802:
1803: jMenuSize.add(jMenuItemSameHeight);
1804:
1805: jMenuItemSameHeightMin = new javax.swing.JMenuItem();
1806: jMenuItemSameHeightMin
1807: .setIcon(new javax.swing.ImageIcon(
1808: getClass()
1809: .getResource(
1810: "/it/businesslogic/ireport/icons/menu/elem_same_vsize_min.png")));
1811: jMenuItemSameHeightMin
1812: .setText(it.businesslogic.ireport.util.I18n.getString(
1813: "sameHeightMin", "Same height (min)"));
1814: jMenuItemSameHeightMin
1815: .addActionListener(new java.awt.event.ActionListener() {
1816: public void actionPerformed(
1817: java.awt.event.ActionEvent evt) {
1818: getMainFrame()
1819: .jMenuItemSameHeightMinActionPerformed(
1820: evt);
1821: }
1822: });
1823:
1824: jMenuSize.add(jMenuItemSameHeightMin);
1825:
1826: jMenuItemSameHeightMax = new javax.swing.JMenuItem();
1827: jMenuItemSameHeightMax
1828: .setIcon(new javax.swing.ImageIcon(
1829: getClass()
1830: .getResource(
1831: "/it/businesslogic/ireport/icons/menu/elem_same_vsize_plus.png")));
1832: jMenuItemSameHeightMax
1833: .setText(it.businesslogic.ireport.util.I18n.getString(
1834: "sameHeightMax", "Same height (max)"));
1835: jMenuItemSameHeightMax
1836: .addActionListener(new java.awt.event.ActionListener() {
1837: public void actionPerformed(
1838: java.awt.event.ActionEvent evt) {
1839: getMainFrame()
1840: .jMenuItemSameHeightMaxActionPerformed(
1841: evt);
1842: }
1843: });
1844:
1845: jMenuSize.add(jMenuItemSameHeightMax);
1846:
1847: jSeparator18 = new javax.swing.JSeparator();
1848: jMenuSize.add(jSeparator18);
1849:
1850: jMenuItemSameSize = new javax.swing.JMenuItem();
1851: jMenuItemSameSize
1852: .setIcon(new javax.swing.ImageIcon(
1853: getClass()
1854: .getResource(
1855: "/it/businesslogic/ireport/icons/menu/elem_same_size.png")));
1856: jMenuItemSameSize.setText(it.businesslogic.ireport.util.I18n
1857: .getString("sameSize", "Same size"));
1858: jMenuItemSameSize
1859: .addActionListener(new java.awt.event.ActionListener() {
1860: public void actionPerformed(
1861: java.awt.event.ActionEvent evt) {
1862: getMainFrame()
1863: .jMenuItemSameSizeActionPerformed(evt);
1864: }
1865: });
1866:
1867: jMenuSize.add(jMenuItemSameSize);
1868:
1869: m.add(jMenuSize);
1870:
1871: jMenuPosition = new javax.swing.JMenu();
1872: jMenuPosition.setText(it.businesslogic.ireport.util.I18n
1873: .getString("position", "Position..."));
1874: jMenuItemCenterH = new javax.swing.JMenuItem();
1875: jMenuItemCenterH
1876: .setIcon(new javax.swing.ImageIcon(
1877: getClass()
1878: .getResource(
1879: "/it/businesslogic/ireport/icons/menu/elem_hcenter.png")));
1880: jMenuItemCenterH.setText(it.businesslogic.ireport.util.I18n
1881: .getString("centerHorizontallyBandBased",
1882: "Center horizontally (band based)"));
1883: jMenuItemCenterH
1884: .addActionListener(new java.awt.event.ActionListener() {
1885: public void actionPerformed(
1886: java.awt.event.ActionEvent evt) {
1887: getMainFrame().jMenuItemCenterHActionPerformed(
1888: evt);
1889: }
1890: });
1891:
1892: jMenuPosition.add(jMenuItemCenterH);
1893:
1894: jMenuItemCenterV = new javax.swing.JMenuItem();
1895: jMenuItemCenterV
1896: .setIcon(new javax.swing.ImageIcon(
1897: getClass()
1898: .getResource(
1899: "/it/businesslogic/ireport/icons/menu/elem_vcenter.png")));
1900: jMenuItemCenterV.setText(it.businesslogic.ireport.util.I18n
1901: .getString("centerVerticallyBandBased",
1902: "Center vertically (band based)"));
1903: jMenuItemCenterV
1904: .addActionListener(new java.awt.event.ActionListener() {
1905: public void actionPerformed(
1906: java.awt.event.ActionEvent evt) {
1907: getMainFrame().jMenuItemCenterVActionPerformed(
1908: evt);
1909: }
1910: });
1911:
1912: jMenuPosition.add(jMenuItemCenterV);
1913:
1914: jMenuItemCenterInBand = new javax.swing.JMenuItem();
1915: jMenuItemCenterInBand
1916: .setIcon(new javax.swing.ImageIcon(
1917: getClass()
1918: .getResource(
1919: "/it/businesslogic/ireport/icons/menu/elem_ccenter.png")));
1920: jMenuItemCenterInBand
1921: .setText(it.businesslogic.ireport.util.I18n.getString(
1922: "centerInBand", "Center in band"));
1923: jMenuItemCenterInBand
1924: .addActionListener(new java.awt.event.ActionListener() {
1925: public void actionPerformed(
1926: java.awt.event.ActionEvent evt) {
1927: getMainFrame()
1928: .jMenuItemCenterInBandActionPerformed(
1929: evt);
1930: }
1931: });
1932:
1933: jMenuPosition.add(jMenuItemCenterInBand);
1934:
1935: jMenuItemCenterBackground = new javax.swing.JMenuItem();
1936: jMenuItemCenterBackground
1937: .setIcon(new javax.swing.ImageIcon(
1938: getClass()
1939: .getResource(
1940: "/it/businesslogic/ireport/icons/menu/elem_bcenter.png")));
1941: jMenuItemCenterBackground
1942: .setText(it.businesslogic.ireport.util.I18n.getString(
1943: "centerInBackground", "Center in background"));
1944: jMenuItemCenterBackground
1945: .addActionListener(new java.awt.event.ActionListener() {
1946: public void actionPerformed(
1947: java.awt.event.ActionEvent evt) {
1948: getMainFrame()
1949: .jMenuItemCenterBackgroundActionPerformed(
1950: evt);
1951: }
1952: });
1953:
1954: jMenuPosition.add(jMenuItemCenterBackground);
1955:
1956: jMenuItemJoinLeft = new javax.swing.JMenuItem();
1957: jMenuItemJoinLeft.setText(it.businesslogic.ireport.util.I18n
1958: .getString("joinSidesLeft", "Join sides left"));
1959: jMenuItemJoinLeft
1960: .addActionListener(new java.awt.event.ActionListener() {
1961: public void actionPerformed(
1962: java.awt.event.ActionEvent evt) {
1963: getMainFrame()
1964: .jMenuItemJoinLeftActionPerformed(evt);
1965: }
1966: });
1967:
1968: jMenuPosition.add(jMenuItemJoinLeft);
1969:
1970: jMenuItemJoinRight = new javax.swing.JMenuItem();
1971: jMenuItemJoinRight.setText(it.businesslogic.ireport.util.I18n
1972: .getString("joinSidesRight", "Join sides right"));
1973: jMenuItemJoinRight
1974: .addActionListener(new java.awt.event.ActionListener() {
1975: public void actionPerformed(
1976: java.awt.event.ActionEvent evt) {
1977: getMainFrame()
1978: .jMenuItemJoinRightActionPerformed(evt);
1979: }
1980: });
1981:
1982: jMenuPosition.add(jMenuItemJoinRight);
1983:
1984: jMenuItemLeftMargin = new javax.swing.JMenuItem();
1985: jMenuItemLeftMargin.setText("Join left page margin");
1986: jMenuItemLeftMargin.setAccelerator(javax.swing.KeyStroke
1987: .getKeyStroke(java.awt.event.KeyEvent.VK_HOME,
1988: java.awt.event.InputEvent.SHIFT_MASK
1989: | java.awt.event.InputEvent.CTRL_MASK));
1990: jMenuItemLeftMargin
1991: .addActionListener(new java.awt.event.ActionListener() {
1992: public void actionPerformed(
1993: java.awt.event.ActionEvent evt) {
1994: getMainFrame()
1995: .jMenuItemLeftMarginActionPerformed(evt);
1996: }
1997: });
1998:
1999: jMenuPosition.add(jMenuItemLeftMargin);
2000:
2001: jMenuItemRightMargin = new javax.swing.JMenuItem();
2002: jMenuItemRightMargin.setText("Join right page margin");
2003: jMenuItemRightMargin.setAccelerator(javax.swing.KeyStroke
2004: .getKeyStroke(java.awt.event.KeyEvent.VK_END,
2005: java.awt.event.InputEvent.SHIFT_MASK
2006: | java.awt.event.InputEvent.CTRL_MASK));
2007: jMenuItemRightMargin
2008: .addActionListener(new java.awt.event.ActionListener() {
2009: public void actionPerformed(
2010: java.awt.event.ActionEvent evt) {
2011: getMainFrame()
2012: .jMenuItemRightMarginActionPerformed(
2013: evt);
2014: }
2015: });
2016:
2017: jMenuPosition.add(jMenuItemRightMargin);
2018:
2019: m.add(jMenuPosition);
2020:
2021: jSeparator5 = new javax.swing.JSeparator();
2022: m.add(jSeparator5);
2023:
2024: jMenuHSpacing = new javax.swing.JMenu();
2025: jMenuHSpacing
2026: .setText(it.businesslogic.ireport.util.I18n.getString(
2027: "horizontalSpacing", "Horizontal spacing..."));
2028:
2029: jMenuItemHSMakeEqual = new javax.swing.JMenuItem();
2030: jMenuItemHSMakeEqual.setText(it.businesslogic.ireport.util.I18n
2031: .getString("makeEqual", "Make equal"));
2032: jMenuItemHSMakeEqual
2033: .addActionListener(new java.awt.event.ActionListener() {
2034: public void actionPerformed(
2035: java.awt.event.ActionEvent evt) {
2036: getMainFrame()
2037: .jMenuItemHSMakeEqualActionPerformed(
2038: evt);
2039: }
2040: });
2041:
2042: jMenuHSpacing.add(jMenuItemHSMakeEqual);
2043:
2044: jMenuItemHSIncrease = new javax.swing.JMenuItem();
2045: jMenuItemHSIncrease.setText(it.businesslogic.ireport.util.I18n
2046: .getString("increase", "Increase"));
2047: jMenuItemHSIncrease
2048: .addActionListener(new java.awt.event.ActionListener() {
2049: public void actionPerformed(
2050: java.awt.event.ActionEvent evt) {
2051: getMainFrame()
2052: .jMenuItemHSIncreaseActionPerformed(evt);
2053: }
2054: });
2055:
2056: jMenuHSpacing.add(jMenuItemHSIncrease);
2057:
2058: jMenuItemHSDecrease = new javax.swing.JMenuItem();
2059: jMenuItemHSDecrease.setText(it.businesslogic.ireport.util.I18n
2060: .getString("decrease", "Decrease"));
2061: jMenuItemHSDecrease
2062: .addActionListener(new java.awt.event.ActionListener() {
2063: public void actionPerformed(
2064: java.awt.event.ActionEvent evt) {
2065: getMainFrame()
2066: .jMenuItemHSDecreaseActionPerformed(evt);
2067: }
2068: });
2069:
2070: jMenuHSpacing.add(jMenuItemHSDecrease);
2071:
2072: jMenuItemHSRemove = new javax.swing.JMenuItem();
2073: jMenuItemHSRemove.setText(it.businesslogic.ireport.util.I18n
2074: .getString("remove", "Remove"));
2075: jMenuItemHSRemove
2076: .addActionListener(new java.awt.event.ActionListener() {
2077: public void actionPerformed(
2078: java.awt.event.ActionEvent evt) {
2079: getMainFrame()
2080: .jMenuItemHSRemoveActionPerformed(evt);
2081: }
2082: });
2083:
2084: jMenuHSpacing.add(jMenuItemHSRemove);
2085:
2086: m.add(jMenuHSpacing);
2087:
2088: jMenuVSpacing = new javax.swing.JMenu();
2089: jMenuVSpacing.setText(it.businesslogic.ireport.util.I18n
2090: .getString("verticalSpacing", "Vertical spacing"));
2091: jMenuItemVSMakeEqual = new javax.swing.JMenuItem();
2092: jMenuItemVSMakeEqual.setText(it.businesslogic.ireport.util.I18n
2093: .getString("makeEqual", "Make equal"));
2094: jMenuItemVSMakeEqual
2095: .addActionListener(new java.awt.event.ActionListener() {
2096: public void actionPerformed(
2097: java.awt.event.ActionEvent evt) {
2098: getMainFrame()
2099: .jMenuItemVSMakeEqualActionPerformed(
2100: evt);
2101: }
2102: });
2103:
2104: jMenuVSpacing.add(jMenuItemVSMakeEqual);
2105:
2106: jMenuItemVSIncrease = new javax.swing.JMenuItem();
2107: jMenuItemVSIncrease.setText(it.businesslogic.ireport.util.I18n
2108: .getString("increase", "Increase"));
2109: jMenuItemVSIncrease
2110: .addActionListener(new java.awt.event.ActionListener() {
2111: public void actionPerformed(
2112: java.awt.event.ActionEvent evt) {
2113: getMainFrame()
2114: .jMenuItemVSIncreaseActionPerformed(evt);
2115: }
2116: });
2117:
2118: jMenuVSpacing.add(jMenuItemVSIncrease);
2119:
2120: jMenuItemVSDecrease = new javax.swing.JMenuItem();
2121: jMenuItemVSDecrease.setText(it.businesslogic.ireport.util.I18n
2122: .getString("decrease", "Decrease"));
2123: jMenuItemVSDecrease
2124: .addActionListener(new java.awt.event.ActionListener() {
2125: public void actionPerformed(
2126: java.awt.event.ActionEvent evt) {
2127: getMainFrame()
2128: .jMenuItemVSDecreaseActionPerformed(evt);
2129: }
2130: });
2131:
2132: jMenuVSpacing.add(jMenuItemVSDecrease);
2133:
2134: jMenuItemVSRemove = new javax.swing.JMenuItem();
2135: jMenuItemVSRemove.setText(it.businesslogic.ireport.util.I18n
2136: .getString("remove", "Remove"));
2137: jMenuItemVSRemove
2138: .addActionListener(new java.awt.event.ActionListener() {
2139: public void actionPerformed(
2140: java.awt.event.ActionEvent evt) {
2141: getMainFrame()
2142: .jMenuItemVSRemoveActionPerformed(evt);
2143: }
2144: });
2145:
2146: jMenuVSpacing.add(jMenuItemVSRemove);
2147:
2148: m.add(jMenuVSpacing);
2149:
2150: jSeparator8 = new javax.swing.JSeparator();
2151: m.add(jSeparator8);
2152:
2153: jMenuItemOrganize = new javax.swing.JMenuItem();
2154: //Modified by Felix Firgau for I18n on Feb 9th 2006
2155: jMenuItemOrganize.setText(it.businesslogic.ireport.util.I18n
2156: .getString("organizeAsTable", "Organize as table"));
2157: jMenuItemOrganize.setAccelerator(javax.swing.KeyStroke
2158: .getKeyStroke(java.awt.event.KeyEvent.VK_O,
2159: java.awt.event.InputEvent.SHIFT_MASK
2160: | java.awt.event.InputEvent.CTRL_MASK));
2161: jMenuItemOrganize.setIcon(new javax.swing.ImageIcon(""));
2162: jMenuItemOrganize
2163: .addActionListener(new java.awt.event.ActionListener() {
2164: public void actionPerformed(
2165: java.awt.event.ActionEvent evt) {
2166: getMainFrame()
2167: .jMenuItemOrganizeActionPerformed(evt);
2168: }
2169: });
2170:
2171: m.add(jMenuItemOrganize);
2172:
2173: jMenuItemBringToFront = new javax.swing.JMenuItem();
2174: jMenuItemBringToFront
2175: .setIcon(new javax.swing.ImageIcon(
2176: getClass()
2177: .getResource(
2178: "/it/businesslogic/ireport/icons/menu/sendtofront.png")));
2179: jMenuItemBringToFront
2180: .setText(it.businesslogic.ireport.util.I18n.getString(
2181: "bringToFront", "Bring to front"));
2182: jMenuItemBringToFront
2183: .addActionListener(new java.awt.event.ActionListener() {
2184: public void actionPerformed(
2185: java.awt.event.ActionEvent evt) {
2186: getMainFrame()
2187: .jMenuItemBringToFrontActionPerformed(
2188: evt);
2189: }
2190: });
2191:
2192: m.add(jMenuItemBringToFront);
2193:
2194: jMenuItemSendToBack = new javax.swing.JMenuItem();
2195: jMenuItemSendToBack
2196: .setIcon(new javax.swing.ImageIcon(
2197: getClass()
2198: .getResource(
2199: "/it/businesslogic/ireport/icons/menu/sendtoback.png")));
2200: jMenuItemSendToBack.setText(it.businesslogic.ireport.util.I18n
2201: .getString("sendToBack", "Send to back"));
2202: jMenuItemSendToBack
2203: .addActionListener(new java.awt.event.ActionListener() {
2204: public void actionPerformed(
2205: java.awt.event.ActionEvent evt) {
2206: getMainFrame()
2207: .jMenuItemSendToBackActionPerformed(evt);
2208: }
2209: });
2210:
2211: m.add(jMenuItemSendToBack);
2212:
2213: }
2214:
2215: private void jMenuItemElementPropertiesActionPerformed(
2216: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementPropertiesActionPerformed
2217: openElementPropertiesDialog();
2218: }//GEN-LAST:event_jMenuItemElementPropertiesActionPerformed
2219:
2220: private void jMenuItemPasteOnBandActionPerformed(
2221: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteOnBandActionPerformed
2222:
2223: if (this .popup_opened_at != null) {
2224: pasteHere(popup_opened_at);
2225: }
2226: }//GEN-LAST:event_jMenuItemPasteOnBandActionPerformed
2227:
2228: private void jMenuItemPasteOnBandMouseClicked(
2229: java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItemPasteOnBandMouseClicked
2230:
2231: }//GEN-LAST:event_jMenuItemPasteOnBandMouseClicked
2232:
2233: private void jMenuItemElementPropertiesMouseClicked(
2234: java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItemElementPropertiesMouseClicked
2235:
2236: }//GEN-LAST:event_jMenuItemElementPropertiesMouseClicked
2237:
2238: private void jVerticalScrollBarKeyPressed(
2239: java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jVerticalScrollBarKeyPressed
2240:
2241: }//GEN-LAST:event_jVerticalScrollBarKeyPressed
2242:
2243: private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
2244:
2245: }//GEN-LAST:event_formKeyPressed
2246:
2247: private void jPanelReportKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanelReportKeyPressed
2248:
2249: /*
2250: mf.logOnConsole(evt.getKeyCode() + " "+
2251: (((evt.getModifiers() & evt.CTRL_MASK) != 0 ) ? "CTL " : "") +
2252: (((evt.getModifiers() & evt.ALT_MASK) != 0 ) ? "ALT " : "") +
2253: (((evt.getModifiers() & evt.SHIFT_MASK) != 0 ) ? "SHIFT " : "") + "\n");
2254: */
2255: /*
2256: if (( evt.getModifiers() & evt.CTRL_MASK) != 0 &&
2257: evt.getKeyCode() == java.awt.event.KeyEvent.VK_Z )
2258: {
2259: .undo();
2260: return;
2261: }
2262:
2263: if (( evt.getModifiers() & evt.CTRL_MASK ) != 0 &&
2264: evt.getKeyCode() == java.awt.event.KeyEvent.VK_Y)
2265: {
2266: mf.redo();
2267: return;
2268: }
2269: */
2270:
2271: // Standard speed:
2272: int x = 1, y = 1;
2273:
2274: // Increase the speed of movement if the Shift key is pressed
2275: if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2276: x = 10;
2277: y = 10;
2278: }
2279:
2280: //if ((evt.getModifiers() & evt.ALT_MASK) != 0)
2281: // System.out.println("Tasto:"+evt.getKeyCode());
2282: if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_DELETE) {
2283: this .deleteSelectedElements();
2284: return;
2285: }
2286: /* Begin code Robert Lamping, 12 July 2004 */
2287: /* Short cut keys for quick alignment */
2288: else if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
2289: && ((evt.getModifiers() & evt.CTRL_MASK) != 0)) {
2290:
2291: /* all key presses when SHIFT/CTRL are both pressed */
2292:
2293: /* Short cuts for alignments */
2294: /* most of them deactivated, since they are activated bia the menu options and their
2295: * short cuts
2296: */
2297: switch (evt.getKeyCode()) {
2298: case java.awt.event.KeyEvent.VK_S:
2299: /* shrink A3-A4 */
2300: FormatCommand.getCommand(OperationType.SHRINK)
2301: .execute();
2302: break;
2303:
2304: // case java.awt.event.KeyEvent.VK_UP:
2305: // /* align top */
2306: // FormatCommand.getCommand(OperationType.ALIGN_TOP).execute();
2307: // break;
2308: // case java.awt.event.KeyEvent.VK_DOWN:
2309: // /* align bottom */
2310: // FormatCommand.getCommand(OperationType.ALIGN_BOTTOM).execute();
2311: // break;
2312: // case java.awt.event.KeyEvent.VK_LEFT:
2313: // /* align left */
2314: // FormatCommand.getCommand(OperationType.ALIGN_LEFT).execute();
2315: // break;
2316: // case java.awt.event.KeyEvent.VK_RIGHT:
2317: // /* align right */
2318: // FormatCommand.getCommand(OperationType.ALIGN_RIGHT).execute();
2319: // break;
2320: // case java.awt.event.KeyEvent.VK_PAGE_UP:
2321: // /* align against band top */
2322: // FormatCommand.getCommand(OperationType.ALIGN_TOP_TO_BAND).execute();
2323: // break;
2324: // case java.awt.event.KeyEvent.VK_PAGE_DOWN:
2325: // /* align against band bottom */
2326: // FormatCommand.getCommand(OperationType.ALIGN_BOTTOM_TO_BAND).execute();
2327: // break;
2328: // case java.awt.event.KeyEvent.VK_HOME:
2329: // /* align against left margin */
2330: // FormatCommand.getCommand(OperationType.ALIGN_TO_LEFT_MARGIN).execute();
2331: // break;
2332: // case java.awt.event.KeyEvent.VK_END:
2333: // /* align against right margin */
2334: // FormatCommand.getCommand(OperationType.ALIGN_TO_RIGHT_MARGIN).execute();
2335: // break;
2336: // case java.awt.event.KeyEvent.VK_L:
2337: // /* join left */
2338: // FormatCommand.getCommand(OperationType.JOIN_LEFT).execute();
2339: // break;
2340: // case java.awt.event.KeyEvent.VK_R:
2341: // /* join right */
2342: // FormatCommand.getCommand(OperationType.JOIN_RIGHT).execute();
2343: // break;
2344: // case java.awt.event.KeyEvent.VK_O:
2345: // /* organize as a table, with spacing inbetwween */
2346: // FormatCommand.getCommand(OperationType.ORGANIZE_AS_A_TABLE).execute();
2347: //
2348: // break;
2349: }
2350:
2351: }
2352: /* End code Robert Lamping, 12 July 2004 */
2353:
2354: else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_UP) {
2355: y *= -1;
2356: x = 0;
2357:
2358: // Remove selected elements...
2359: // Up of x...
2360: Vector changed_elements = new Vector();
2361: for (Iterator i = selectedElements.iterator(); i.hasNext();) {
2362: ReportElement element = (ReportElement) i.next();
2363: element.trasform(new Point(x, y),
2364: TransformationType.TRANSFORMATION_MOVE);
2365: element.adjustBand();
2366: changed_elements.add(element);
2367: }
2368: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2369: this , changed_elements,
2370: ReportElementChangedEvent.CHANGED));
2371:
2372: this .getMainFrame().getElementPropertiesDialog()
2373: .updateSelection();
2374: jPanelReport.repaint();
2375: } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_LEFT) {
2376: x *= -1;
2377: y = 0;
2378:
2379: // Up of x...
2380: Vector changed_elements = new Vector();
2381: for (Iterator i = selectedElements.iterator(); i.hasNext();) {
2382: ReportElement element = (ReportElement) i.next();
2383: element.trasform(new Point(x, y),
2384: TransformationType.TRANSFORMATION_MOVE);
2385: element.adjustBand();
2386: changed_elements.add(element);
2387: }
2388: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2389: this , changed_elements,
2390: ReportElementChangedEvent.CHANGED));
2391: this .getMainFrame().getElementPropertiesDialog()
2392: .updateSelection();
2393: jPanelReport.repaint();
2394: } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_RIGHT) {
2395: y = 0;
2396: // Remove selected elements...
2397: // Up of x...
2398: Vector changed_elements = new Vector();
2399: for (Iterator i = selectedElements.iterator(); i.hasNext();) {
2400: ReportElement element = (ReportElement) i.next();
2401: element.trasform(new Point(x, y),
2402: TransformationType.TRANSFORMATION_MOVE);
2403: element.adjustBand();
2404: changed_elements.add(element);
2405: }
2406: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2407: this , changed_elements,
2408: ReportElementChangedEvent.CHANGED));
2409: this .getMainFrame().getElementPropertiesDialog()
2410: .updateSelection();
2411:
2412: jPanelReport.repaint();
2413: } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_DOWN) {
2414: x = 0;
2415: // Remove selected elements...
2416: // Up of x...
2417: Vector changed_elements = new Vector();
2418: for (Iterator i = selectedElements.iterator(); i.hasNext();) {
2419: ReportElement element = (ReportElement) i.next();
2420: element.trasform(new Point(x, y),
2421: TransformationType.TRANSFORMATION_MOVE);
2422: element.adjustBand();
2423: changed_elements.add(element);
2424: }
2425: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2426: this , changed_elements,
2427: ReportElementChangedEvent.CHANGED));
2428: this .getMainFrame().getElementPropertiesDialog()
2429: .updateSelection();
2430: jPanelReport.repaint();
2431: } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_F2) {
2432: // Edit static Text
2433:
2434: DeleteElementsOperation undoOp = new DeleteElementsOperation(
2435: this );
2436: for (Iterator i = selectedElements.iterator(); i.hasNext();) {
2437: ReportElement re = (ReportElement) i.next();
2438: if (re instanceof TextReportElement) {
2439: if (re instanceof TextReportElement) {
2440: String te = ((TextReportElement) re).getText();
2441:
2442: ExpressionEditor ed = new ExpressionEditor();
2443: ed.setSubDataset(this .getReport());
2444: ed.setExpression(te);
2445: ed.updateTreeEntries();
2446: ed.setVisible(true);
2447: if (ed.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
2448: ((TextReportElement) re).setText(ed
2449: .getExpression());
2450: undoOp.addElement(re, getReport()
2451: .getElements().indexOf(re));
2452: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2453: this , re,
2454: ReportElementChangedEvent.CHANGED));
2455: }
2456: }
2457: }
2458: }
2459: this .addUndoOperation(undoOp);
2460: this .getMainFrame().getElementPropertiesDialog()
2461: .updateSelection();
2462: jPanelReport.repaint();
2463: } else if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_F3) {
2464:
2465: transformStaticInTextFields();
2466: this .getMainFrame().getElementPropertiesDialog()
2467: .updateSelection();
2468: }
2469: /* Begin code by Robert Lamping, 12 july 2004 */
2470: /* Copy and paste via CTRL/INS and SHIFT insert */
2471: else if (((evt.getModifiers() & evt.CTRL_MASK) != 0)
2472: && evt.getKeyCode() == java.awt.event.KeyEvent.VK_INSERT) {
2473: copy();
2474: } else if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
2475: && evt.getKeyCode() == java.awt.event.KeyEvent.VK_INSERT) {
2476: paste();
2477: }
2478: /* End code Robert Lamping, 12 July 2004 */
2479:
2480: }//GEN-LAST:event_jPanelReportKeyPressed
2481:
2482: /**
2483: * evaluateObjectType returns the Objecttype of a new Subreport
2484: * protected to be used in subclasses
2485: * added by Felix Firgau on February 21st 2007
2486: * @param newObjectType int
2487: * @param re ReportElement
2488: * @return boolean
2489: */
2490: protected boolean evaluateObjectType(int newObjectType,
2491: ReportElement re) {
2492: boolean ok = true;
2493: if (newObjectType == ReportElementType.CROSSTAB_ELEMENT) {
2494:
2495: CrosstabWizardDialog cw = new CrosstabWizardDialog(
2496: getMainFrame(), true);
2497: cw.setCrosstabReportElement((CrosstabReportElement) re);
2498: cw.setReport(this .getReport());
2499: cw.setVisible(true);
2500: ((CrosstabReportElement) re).setReport(this .getReport());
2501: addCrosstabEditor((CrosstabReportElement) re);
2502: } else if (newObjectType == ReportElementType.SUBREPORT_ELEMENT) {
2503:
2504: SubreportWizard sr = new SubreportWizard();
2505: sr.setSubReportElement((SubReportElement) re);
2506: sr.startWizard();
2507: if (sr.getBaseWizardPanel().getDialogResult() != JOptionPane.OK_OPTION)
2508: ok = false;
2509:
2510: } else if (newObjectType == ReportElementType.CHART_ELEMENT) {
2511:
2512: // New JasperReports 0.6.9 implementation...
2513: ChartSelectionJDialog csd = new ChartSelectionJDialog(this
2514: .getMainFrame(), true);
2515: csd.setVisible(true);
2516: if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
2517: ChartReportElement2 cre = (ChartReportElement2) re;
2518: cre.setChart(csd.getChart());
2519: } else {
2520: ok = false;
2521: }
2522: } else if (newObjectType == ReportElementType.BREAK_ELEMENT) {
2523:
2524: // New JasperReports 0.6.9 implementation...
2525: re.setWidth(this .getReport().getWidth()
2526: - getReport().getLeftMargin()
2527: - getReport().getRightMargin());
2528: re.getPosition().x = getReport().getLeftMargin() + 10;
2529: re.setHeight(0);
2530: re.updateBounds();
2531: if (re.getBand() == null)
2532: ok = false;
2533: }
2534:
2535: return ok;
2536: }
2537:
2538: private void jPanelReportMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelReportMouseReleased
2539:
2540: if (drag_selection_mode && evt.getButton() == evt.BUTTON1) {
2541:
2542: //Graphics2D gg = (Graphics2D)jPanelReport.getGraphics();
2543: //gg.setXORMode( ReportElement.getAlphaColor(Color.GREEN, 60) );
2544:
2545: //Stroke s = gg.getStroke();
2546: //gg.setStroke(selectionStroke);
2547:
2548: //if (!first_draw_selection_rect) {
2549: // gg.fillRect((int)Math.min( drag_selection_origin.x, drag_selection_end.x),
2550: // (int)Math.min( drag_selection_origin.y, drag_selection_end.y),
2551: // (int)Math.abs( drag_selection_origin.x - drag_selection_end.x),
2552: // (int)Math.abs( drag_selection_origin.y - drag_selection_end.y));
2553: //}
2554:
2555: //gg.setPaintMode();
2556: //if (s != null) {
2557: // gg.setStroke(s);
2558: //}
2559: drag_selection_mode = false;
2560: first_draw_selection_rect = true;
2561:
2562: if ((evt.getModifiers() & evt.SHIFT_MASK) == 0) {
2563: setSelectedElement(null);
2564: }
2565:
2566: int delta_w = evt.getX() - drag_selection_origin.x;
2567: int delta_h = evt.getY() - drag_selection_origin.y;
2568: int delta_x = (delta_w < 0) ? delta_w : 0;
2569: int delta_y = (delta_h < 0) ? delta_h : 0;
2570:
2571: if (jHorizontalScrollBar == null
2572: || jVerticalScrollBar == null
2573: || drag_selection_origin == null
2574: || drag_selection_end == null) {
2575: return;
2576: }
2577:
2578: int originX = getLogicalDim(Math.min(
2579: drag_selection_origin.x - 10
2580: + jHorizontalScrollBar.getValue(),
2581: drag_selection_end.x - 10
2582: + jHorizontalScrollBar.getValue())) + 10;
2583: int originY = getLogicalDim(Math.min(
2584: drag_selection_origin.y - 10
2585: + jVerticalScrollBar.getValue(),
2586: drag_selection_end.y - 10
2587: + jVerticalScrollBar.getValue())) + 10;
2588: int width = getLogicalDim(Math.abs(delta_w));
2589: int height = getLogicalDim(Math.abs(delta_h));
2590:
2591: // We need logical coordinates...
2592: java.awt.Rectangle rect = new java.awt.Rectangle(originX,
2593: originY, width, height);
2594: boolean selection_changed = false;
2595: for (Iterator i = getReport().getElements().iterator(); i
2596: .hasNext();) {
2597: ReportElement re = (ReportElement) i.next();
2598: if (re.intersects(rect)) {
2599: if (!selection_changed)
2600: selection_changed = true;
2601: addSelectedElement(re, false);
2602: }
2603: }
2604: if (selection_changed) {
2605: fireSelectionChangedEvent();
2606: }
2607:
2608: } else if (band_dragging && evt.getButton() == evt.BUTTON1) {
2609:
2610: band_dragging = false;
2611: jPanelReport.setCursor(Cursor
2612: .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2613:
2614: // _________ BEGIN DRAGGING REAL TIME CODE ___________________
2615: // Work with logical dimensions...
2616: int delta = getLogicalDim(evt.getY() - band_dragging_origin);
2617:
2618: int okHeight = band_dragging_band.getHeight();
2619: int requestedHeight = okHeight + delta;
2620:
2621: if (delta != 0) {
2622: BandDraggedOperation undoOp = new BandDraggedOperation(
2623: this , band_dragging_band);
2624: // Search for min_height that don't cover elements in this band...
2625:
2626: int band_h = report
2627: .getBandYLocation(band_dragging_band) + 10;
2628:
2629: int available_height = Misc.getMaxBandHeight(report,
2630: band_dragging_band);
2631:
2632: if (available_height < requestedHeight) {
2633: final int available_height_f = available_height;
2634: final int newHeight_f = requestedHeight;
2635: SwingUtilities.invokeLater(new Runnable() {
2636: public void run() {
2637: JOptionPane
2638: .showMessageDialog(
2639: MainFrame.getMainInstance(),
2640: "The band height has beed adjusted to fit the report requirements\n(max hight allowed for this band: "
2641: + available_height_f
2642: + ", requested: "
2643: + newHeight_f
2644: + ").", "Alert",
2645: JOptionPane.WARNING_MESSAGE);
2646: }
2647: });
2648:
2649: }
2650:
2651: okHeight = Math.max(0, Math.min(available_height,
2652: requestedHeight));
2653:
2654: //System.out.println("Requested: " + requestedHeight + " " + available_height);
2655:
2656: delta = okHeight - band_dragging_band.getHeight();
2657:
2658: // Redraw all under the min height...
2659: band_dragging_band.setHeight(band_dragging_band
2660: .getHeight()
2661: + delta);
2662:
2663: this
2664: .jPanelReportComponentResized(new java.awt.event.ComponentEvent(
2665: jPanelReport, 0));
2666:
2667: //this.label1.setText("DRagged: "+band_dragging_band.name +" "+delta);
2668: int edge_y = Math.min(report
2669: .getBandYLocation(band_dragging_band)
2670: + band_dragging_band.getHeight(), report
2671: .getBandYLocation(band_dragging_band)
2672: + band_dragging_band.getHeight() - delta);
2673:
2674: //e = report.getElements().elements();
2675:
2676: undoOp.setBandDelta(delta);
2677:
2678: // Adjust all elements positions...
2679: //
2680: Vector containers = new Vector();
2681: for (Iterator i = report.getElements().iterator(); i
2682: .hasNext();) {
2683: ReportElement re = (ReportElement) i.next();
2684: if (re.getParentElement() != null
2685: && re.getParentElement().position.y < edge_y + 10)
2686: continue;
2687:
2688: if (re instanceof FrameReportElement) {
2689: containers.add(re);
2690: }
2691:
2692: if (re.position.y >= edge_y + 10
2693: || (re.getParentElement() != null && re
2694: .getParentElement().position.y >= edge_y + 10)) {
2695: // I should add the distance form the base of resized band, and my element...
2696: Rectangle oldBounds = new Rectangle(re
2697: .getPosition().x, re.getPosition().y,
2698: re.getWidth(), re.getHeight());
2699:
2700: int space_before_band = band_h - re.position.y
2701: - re.height;
2702: if (band_h <= report.getBandYLocation(re.band) + 10) {
2703: space_before_band = 0;
2704: }
2705: re.setPosition(new Point(re.position.x,
2706: re.position.y + delta));
2707: //this.updateElement(re,new Rectangle(re.position.x-5,re.position.y-5-delta,re.width+10, re.height+10+delta));
2708: Rectangle newBounds = new Rectangle(re
2709: .getPosition().x, re.getPosition().y,
2710: re.getWidth(), re.getHeight());
2711: undoOp.addElement(re, oldBounds, newBounds);
2712: }
2713: }
2714: addUndoOperation(undoOp);
2715: fireReportListenerReportBandChanged(new ReportBandChangedEvent(
2716: this , band_dragging_band,
2717: ReportBandChangedEvent.CHANGED));
2718: }
2719: /*
2720: getLogicalDim(panel9.getWidth()),getLogicalDim(panel9.getHeight()));
2721: Rectangle rect = panel9.getDisplayRect(); //new Rectangle(0,0,report.getPagesize().x, report.getDesignHeight());
2722:
2723: // drag down all elements under this band...
2724: redrawAll(offscreenbm.getGraphics(),rect,0);
2725: Rectangle clipRect = panel9.getDisplayRect(); //new Rectangle(rect);
2726: //clipRect.offset(-HScrollBar1.getValue(),-VScrollBar1.getValue());
2727: //panel9.createGraphics().drawRect(clipRect,RasterOp.BLACK);
2728: panel9.createGraphics().drawImage( offscreenbm,rect, clipRect ,false);
2729: */
2730: this .getMainFrame().getDocumentStructurePanel().updateUI();
2731:
2732: jPanelReport.repaint();
2733: // _________ STOP DRAGGING REAL TIME CODE ___________________
2734: /* TODO
2735: if (selectedElements.size()>0)
2736: {
2737: MainForm mf = (MainForm)this.getMDIParent();
2738: if (mf != null)
2739: {
2740: if (mf.isPropertiesOpened())
2741: {
2742: mf.initReportForm();
2743: mf.ep.setEelement(this,getSelectedElements());
2744: mf.ep.setVisible(true);
2745: }
2746: }
2747: }
2748: TODO */
2749: }
2750:
2751: if (newObjectType != ReportElementType.NONE) {
2752: // The second point was clicked
2753:
2754: firstXORDraw = true;
2755:
2756: // Find the band to associate to the new element...
2757:
2758: int evtX = snapToGridOrizzontally(evt.getX());
2759: int evtY = snapToGridVertically(evt.getY());
2760:
2761: int delta_w = evtX - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
2762: int delta_h = evtY - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
2763: int delta_x = (delta_w < 0) ? delta_w : 0;
2764: int delta_y = (delta_h < 0) ? delta_h : 0;
2765:
2766: int originX = getLogicalDim(Math.min(newObjectOrigin.x - 10
2767: + jHorizontalScrollBar.getValue(),
2768: newObjectOrigin.x + delta_x - 10
2769: + jHorizontalScrollBar.getValue())) + 10;
2770: int originY = getLogicalDim(Math.min(newObjectOrigin.y - 10
2771: + jVerticalScrollBar.getValue(), newObjectOrigin.y
2772: + delta_y - 10 + jVerticalScrollBar.getValue())) + 10;
2773: int width = getLogicalDim(Math.abs(delta_w));
2774: int height = getLogicalDim(Math.abs(delta_h));
2775:
2776: if (newObjectType == ReportElementType.LINE_ELEMENT) {
2777: /* When shift button is pressed too, then there will be no align ment on the grid */
2778: if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
2779: Point straight = straighten(delta_w, delta_h);
2780: delta_w = straight.x;
2781: delta_h = straight.y;
2782: }
2783: }
2784:
2785: Band bname = getReport().getBandByPosition(originY);
2786:
2787: ReportElement re = ReportElementFactory.create(
2788: newObjectType, originX, originY,
2789: getLogicalDim(delta_w), getLogicalDim(delta_h));
2790:
2791: if (getReport().getStyles().size() > 0) {
2792: for (int i = 0; i < getReport().getStyles().size(); ++i) {
2793: Style s = (Style) getReport().getStyles()
2794: .elementAt(i);
2795:
2796: if (s.getAttributeBoolean(s.ATTRIBUTE_isDefault,
2797: false) == true) {
2798: re.setStyle(s);
2799: }
2800: }
2801: }
2802: /* Begin Code Robert Lamping, 13 july 2004 */
2803: // Element does not know about other elements, the frame does, so here we reset the key.
2804: // barcode becomes barcode-1, or higher depending on what the highest sub number is.
2805: // Same for graphcs image, or whatever initial name
2806: re.setKey(getNextElementKey(re.getKey()));
2807:
2808: /* End Code Robert Lamping, 13 july 2004 */
2809:
2810: re.setBand(bname);
2811:
2812: for (int elnum = getReport().getElements().size() - 1; elnum >= 0; --elnum) {
2813: ReportElement container_re = (ReportElement) getReport()
2814: .getElements().elementAt(elnum);
2815: if (container_re instanceof FrameReportElement
2816: && container_re.getBand() == re.getBand()) {
2817: if (container_re.getBounds().contains(
2818: re.getBounds())) {
2819: re.setParentElement(container_re);
2820: break;
2821: }
2822: }
2823: }
2824:
2825: /**
2826: * changed by Felix Firgau on February 21st 2007
2827: * for easier subclassing
2828: */
2829: boolean ok = evaluateObjectType(newObjectType, re);
2830:
2831: if (ok) {
2832:
2833: report.getElements().addElement(re);
2834:
2835: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2836: this , re, ReportElementChangedEvent.ADDED));
2837:
2838: addUndoOperation(new InsertElementOperation(this , re));
2839:
2840: /*
2841: if (selectedElements.size() > 0)
2842: {
2843: ReportElement oldselected = (ReportElement)selectedElements.firstElement();
2844: Rectangle rect = new Rectangle(oldselected.position.x-5,oldselected.position.y-5,oldselected.width+10, oldselected.height+10);
2845: setSelectedElement(null);
2846: redrawAll(offscreen ,rect,5);
2847: Rectangle clipRect = new Rectangle(getZoomedDim(oldselected.position.x-10)-5+10-jHorizontalScrollBar.getValue(),
2848: getZoomedDim(oldselected.position.y-10)-5+10-jVerticalScrollBar.getValue(),
2849: getZoomedDim(oldselected.width)+10,
2850: getZoomedDim(oldselected.height)+10);
2851: clipRect.translate(-jHorizontalScrollBar.getValue(),-jVerticalScrollBar.getValue());
2852:
2853: //panel9.createGraphics().drawImage( offscreenbm,clipRect, clipRect ,false);
2854: jPanelReport.getGraphics().drawImage( offscreenImage ,
2855: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
2856: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
2857: (ImageObserver)this);
2858: }
2859: */
2860: setSelectedElement(re);
2861: }
2862: newObjectOrigin = null;
2863: // Add undo operation...
2864: //UndoOperation uo = new UndoOperation(UndoOperationType.UNDO_INSERT);
2865: //uo.params.addElement(new Integer(1));
2866: //ReportElement clone = re.cloneMe();
2867:
2868: //uo.params.addElement(clone);
2869: //addUndoOperation(uo);
2870: //repaint();
2871:
2872: newObjectType = ReportElementType.NONE;
2873:
2874: jPanelReport.setCursor(Cursor.getDefaultCursor());
2875: getMainFrame().setActiveTool(0);
2876:
2877: }
2878:
2879: if (trasforming) {
2880: trasforming = false;
2881: paintedAlignLines.clear();
2882:
2883: jPanelReport.setCursor(Cursor.getDefaultCursor());
2884:
2885: if (transformation_type != TransformationType.TRANSFORMATION_MOVE
2886: || resistenceExceeded == true) {
2887: Point p = new Point(transformation_origin_end);
2888: p.x = getLogicalDim(p.x);
2889: p.y = getLogicalDim(p.y);
2890: p.x -= getLogicalDim(transformation_origin.x);
2891: p.y -= getLogicalDim(transformation_origin.y);
2892:
2893: // Now it's time to correct the deltas...
2894: // We simply have to do this correction because end coordinates can been calculated
2895: // with a strange percentage
2896:
2897: Vector selectedElementsToChange = new Vector();
2898:
2899: Enumeration e = getSelectedElements().elements();
2900: while (e.hasMoreElements()) {
2901: ReportElement re = (ReportElement) e.nextElement();
2902: if (!selectedElementsToChange.contains(re)) {
2903: selectedElementsToChange.add(re);
2904: if (transformation_type == TransformationType.TRANSFORMATION_MOVE) {
2905: if (re instanceof FrameReportElement) {
2906: // Add all child elements ..
2907: addChildElements(re,
2908: selectedElementsToChange);
2909: }
2910: }
2911: }
2912: }
2913: e = selectedElementsToChange.elements();
2914: TransformElementsOperation undoOp = new TransformElementsOperation(
2915: this );
2916: Vector changed_elements = new Vector();
2917:
2918: while (e.hasMoreElements()) {
2919: ReportElement re = (ReportElement) e.nextElement();
2920:
2921: undoOp.addElement(re);
2922:
2923: // Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
2924:
2925: if (re instanceof BreakReportElement) {
2926: Point specialP = new Point(0, p.y);
2927:
2928: if (re.getPosition().y + p.y == re.getBand()
2929: .getBandYLocation()
2930: + re.getBand().getHeight() + 10) {
2931: specialP.y = p.y - 1;
2932: }
2933: if (transformation_type == TransformationType.TRANSFORMATION_MOVE
2934: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) {
2935: re
2936: .trasform(
2937: specialP,
2938: TransformationType.TRANSFORMATION_MOVE);
2939: } else {
2940: continue;
2941: }
2942: } else {
2943: re.trasform(p, transformation_type);
2944: }
2945:
2946: // Band oldBand = re.getBand();
2947: if (re.getParentElement() == null) {
2948: re.adjustBand();
2949: }
2950: // Band newBand = re.getBand();
2951: // Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
2952: // undoOp.addElement(re, oldBounds, newBounds,oldBand,newBand);
2953:
2954: undoOp.captureUniqueModified(re);
2955: changed_elements.add(re);
2956:
2957: }
2958: addUndoOperation(undoOp);
2959: if (changed_elements.size() > 0) {
2960: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
2961: this , changed_elements,
2962: ReportElementChangedEvent.CHANGED));
2963: }
2964:
2965: jPanelReport.repaint();
2966: }
2967:
2968: /*
2969: if (p.x!=0 || p.y != 0)
2970: {
2971: UndoOperation uo = new UndoOperation(UndoOperationType.UNDO_TRANSFORMATION);
2972: uo.params.addElement(p);
2973: uo.params.addElement(new Integer( transformation_type ) );
2974: Enumeration enum = selectedElements.elements();
2975: while (enum.hasMoreElements())
2976: {
2977: uo.params.addElement(enum.nextElement());
2978: }
2979: addUndoOperation(uo);
2980: }
2981: */
2982: transformation_undo_delta = new Point(0, 0);
2983: transformation_type = TransformationType.TRANSFORMATION_NONE;
2984: /*
2985: MainForm mf = (MainForm)this.getMDIParent();
2986: if (mf != null)
2987: {
2988: if (mf.isPropertiesOpened())
2989: {
2990: mf.initReportForm();
2991: mf.ep.setEelement(this,getSelectedElements());
2992: mf.ep.setVisible(true);
2993: }
2994: }
2995: */
2996: getMainFrame().getElementPropertiesDialog()
2997: .updateSelection();
2998: }
2999:
3000: }//GEN-LAST:event_jPanelReportMouseReleased
3001:
3002: /**
3003: * Single Click
3004: * - Left button: ...
3005: * //TODO
3006: * - Right button: ...
3007: * //TODO
3008: *
3009: * Double click
3010: * - On a band split: If no elements are selected, then a double click on a band split tries to
3011: * reduce the bandheight to the enclosing rectangle around the elements in the band above the split.
3012: * Elements in the top marging are not taken into account.
3013: * - Otherwise
3014: * @param evt
3015: */
3016: private void jPanelReportMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelReportMousePressed
3017:
3018: jPanelReport.requestFocus();
3019: if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() < 2) {
3020:
3021: if (newObjectType != ReportElementType.NONE) {
3022: firstXORDraw = false;
3023: newObjectOrigin = new Point(snapToGridOrizzontally(evt
3024: .getX()), snapToGridVertically(evt.getY()));
3025: mouse.x = newObjectOrigin.x;
3026: mouse.y = newObjectOrigin.y;
3027: return;
3028: }
3029:
3030: // Begin code Robert Lamping, 18 July 2004
3031: // Zoom in interactively with SHIFT/CTRL + LEFT mouse button
3032: if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
3033: && ((evt.getModifiers() & evt.CTRL_MASK) != 0)) {
3034: // multiply zoomfactor by 2 and zoom in with current mouse position as center!
3035: //Point center = new Point(
3036: Point clickPoint = this .realPoint(evt.getX(), evt
3037: .getY());
3038: setZoomFactor(getZoomFactor() * 2);
3039: getMainFrame().setComboBoxZoomFactor(
3040: getZoomFactor() * 100);
3041: centerSelectedElements(clickPoint); // if not present use clickPoint
3042: return;
3043: }
3044: // End code Robert Lamping, 18 July 2004
3045:
3046: if (selectedElements.size() > 0
3047: && ((evt.getModifiers() & evt.SHIFT_MASK) == 0)) {
3048: // We are transformation mode?
3049: if (transformation_type >= 0) {
3050: trasforming = true;
3051: paintedAlignLines.clear();
3052: firstXORDrawTransforming = true;
3053: transformation_origin = new Point(evt.getX(), evt
3054: .getY());
3055: transformation_undo_delta = new Point(0, 0);
3056: transformation_origin_end = new Point(evt.getX(),
3057: evt.getY());
3058: updateObjectMagnetics();
3059: return;
3060: }
3061: }
3062:
3063: if (jPanelReport.getCursor() == hsplit) {
3064:
3065: first_draw_band = true;
3066: int bl = evt.getY() + jVerticalScrollBar.getValue();
3067: int y = report.getTopMargin();
3068: boolean found = false;
3069: Band band = null;
3070:
3071: if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3072: //label1.setText("Inverse search");
3073: y = report.getDesignHeight()
3074: - report.getBottomMargin();
3075: for (int b = report.getBands().size() - 1; b >= 0; --b) {
3076: band = (Band) report.getBands().elementAt(b);
3077: if (bl > getZoomedDim(y) + 10 - 3
3078: && bl < getZoomedDim(y) + 10 + 3) {
3079: break;
3080: }
3081: y -= band.getHeight();
3082: }
3083: } else {
3084: for (Iterator i = getReport().getBands().iterator(); i
3085: .hasNext();) {
3086: band = (Band) i.next();
3087: y += band.getHeight();
3088: if (bl > getZoomedDim(y) + 10 - 3
3089: && bl < getZoomedDim(y) + 10 + 3) {
3090: break;
3091: }
3092: }
3093: }
3094: if (band != null) {
3095: band_dragging = true;
3096: band_dragging_origin = evt.getY();
3097: band_dragging_band = band;
3098:
3099: //this.label1.setText(band_dragging_band.name + " band height: " +(band_dragging_band.height));
3100: return;
3101: }
3102: }
3103: for (int i = report.getElements().size() - 1; i >= 0; --i) {
3104:
3105: ReportElement re = (ReportElement) report.getElements()
3106: .elementAt(i);
3107:
3108: int treshold = 1;
3109: if (re instanceof LineReportElement)
3110: treshold = 2;
3111: treshold = Math.max(treshold, (int) getZoomFactor());
3112:
3113: Rectangle onScreenRect = new Rectangle(getZoomedDim(re
3114: .getPosition().x - 10)
3115: + 10
3116: - jHorizontalScrollBar.getValue()
3117: - treshold,
3118: getZoomedDim(re.getPosition().y - 10) + 10
3119: - jVerticalScrollBar.getValue()
3120: - treshold, getZoomedDim(re.getWidth())
3121: + 2 * treshold, getZoomedDim(re
3122: .getHeight())
3123: + 2 * treshold);
3124: if (re instanceof BreakReportElement) {
3125: onScreenRect.x = 0;
3126: onScreenRect.width = getReport().getWidth();
3127: }
3128:
3129: if (onScreenRect.contains(evt.getX(), evt.getY())) {
3130: /*
3131: if (re.intersects(new Point(getLogicalDim(evt.getX()+jHorizontalScrollBar.getValue()-10)+10,
3132: getLogicalDim(evt.getY()+jVerticalScrollBar.getValue()-10)+10)) ||
3133: (re instanceof BreakReportElement && re.intersects(new Rectangle(
3134: 0, getLogicalDim(evt.getY()+jVerticalScrollBar.getValue()-10)+10,
3135: getReport().getWidth(), 1)
3136: ))
3137: )
3138: {
3139: */
3140:
3141: if (selectedElements.size() > 0
3142: && re == ((ReportElement) selectedElements
3143: .firstElement()))
3144: return;
3145: // 1.<Cancel old corona...
3146:
3147: //if (selectedElements.size() > 0 && (( evt.getModifiers() & evt.SHIFT_MASK ) == 0))
3148: //{
3149: // setSelectedElement(null);
3150: //}
3151:
3152: if (((evt.getModifiers() & evt.SHIFT_MASK) == 0)
3153: || selectedElements.size() == 0) {
3154: //getSelectedElements().removeAllElements();
3155: setSelectedElement(re);
3156: jPanelReport.repaint();
3157: } else if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3158: if (getSelectedElements().contains(re)) {
3159: getSelectedElements().remove(re);
3160: jPanelReport.repaint();
3161: } else {
3162: addSelectedElement(re);
3163: }
3164: } else {
3165: setSelectedElement(re);
3166: }
3167: trasforming = true;
3168: updateObjectMagnetics();
3169: firstXORDrawTransforming = true;
3170: transformation_origin = new Point(evt.getX(), evt
3171: .getY());
3172: transformation_origin_end = new Point(evt.getX(),
3173: evt.getY());
3174:
3175: if (getMainFrame().isEMMActive())
3176: transformation_type = TransformationType.TRANSFORMATION_NONE;
3177: else
3178: transformation_type = TransformationType.TRANSFORMATION_MOVE;
3179:
3180: jPanelReport.setCursor(Cursor
3181: .getPredefinedCursor(Cursor.MOVE_CURSOR));
3182: return;
3183:
3184: }
3185: }
3186: getMainFrame().getElementPropertiesDialog()
3187: .updateSelection();
3188:
3189: /*
3190: if (selectedElements.size()>0 && (( evt.getModifiers() & evt.SHIFT_MASK ) == 0))
3191: {
3192: ReportElement myre = (ReportElement)selectedElements.firstElement();
3193: if (myre != null)
3194: {
3195: Rectangle rect = new Rectangle(myre.position.x-5,myre.position.y-5,myre.width+10, myre.height+10);
3196: setSelectedElement(null);
3197: }
3198: }
3199: */
3200:
3201: if ((evt.getModifiers() & evt.SHIFT_MASK) == 0
3202: && getSelectedElements().size() > 0)
3203: setSelectedElement(null);
3204:
3205: // We can enter in drag selection mode...
3206: drag_selection_mode = true;
3207: initOffscreenImage();
3208: first_draw_selection_rect = true;
3209: drag_selection_origin = new Point(evt.getX(), evt.getY());
3210: } else if (evt.getButton() == evt.BUTTON3) {
3211:
3212: // Begin code Robert Lamping, 18 July 2004
3213: // Zoom out interactively with SHIFT/CTRL = RIGHT mouse button
3214: if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
3215: && ((evt.getModifiers() & evt.CTRL_MASK) != 0)) {
3216: // divide zoomfactor by 2 and zoom in with current mouse position as center!
3217: //Point center = new Point(
3218: Point clickPoint = this .realPoint(evt.getX(), evt
3219: .getY());
3220: setZoomFactor(getZoomFactor() / 2);
3221: getMainFrame().setComboBoxZoomFactor(
3222: getZoomFactor() * 100);
3223: centerSelectedElements(clickPoint); // if not present use clickPoint
3224: return;
3225: }
3226: // End code Robert Lamping, 18 July 2004
3227:
3228: popup_opened_at = evt.getPoint();
3229: boolean found = false;
3230: //1. We must see if we are over an object...
3231: for (int i = report.getElements().size() - 1; i >= 0; --i) {
3232: ReportElement re = (ReportElement) report.getElements()
3233: .elementAt(i);
3234: if (re
3235: .intersects(new Point(
3236: getLogicalDim(evt.getX()
3237: + jHorizontalScrollBar
3238: .getValue() - 10) + 10,
3239: getLogicalDim(evt.getY()
3240: + jVerticalScrollBar.getValue()
3241: - 10) + 10))) {
3242:
3243: if (this .getSelectedElements().size() <= 1)
3244: setSelectedElement(re);
3245: // if ( this.getSelectedElements().size() > 0 && (( evt.getModifiers() & evt.SHIFT_MASK ) != 0))
3246: // {
3247: // addSelectedElement(re);
3248: // }
3249: // else
3250: // setSelectedElement(re);
3251:
3252: found = true;
3253: break;
3254: }
3255: }
3256:
3257: jMenuItemEditExpression.setVisible(false);
3258: jMenuItemElementChartProperties.setVisible(false);
3259: jMenuItemElementCrosstabProperties.setVisible(false);
3260: jMenuItemElementCrosstabDesignProperties.setVisible(false);
3261: jMenuItemElementOpenSubreport.setVisible(false);
3262: if (getSelectedElements().size() > 0) {
3263: if (getSelectedElements().elementAt(0) instanceof ChartReportElement2) {
3264: jMenuItemElementChartProperties.setVisible(true);
3265: }
3266:
3267: if (getSelectedElements().elementAt(0) instanceof CrosstabReportElement) {
3268: jMenuItemElementCrosstabProperties.setVisible(true);
3269: jMenuItemElementCrosstabDesignProperties
3270: .setVisible(true);
3271: }
3272:
3273: if (getSelectedElements().elementAt(0) instanceof SubReportElement) {
3274: jMenuItemElementOpenSubreport.setVisible(true);
3275: }
3276:
3277: if (getSelectedElements().elementAt(0) instanceof TextFieldReportElement) {
3278: jMenuItemEditExpression.setVisible(true);
3279: }
3280:
3281: this .jMenuItemCopy.setEnabled(true);
3282: this .jMenuItemCut.setEnabled(true);
3283: this .jMenuItemDelete.setEnabled(true);
3284: this .jMenuItemCopyStyle.setEnabled(true);
3285: } else {
3286: this .jMenuItemCopy.setEnabled(false);
3287: this .jMenuItemCut.setEnabled(false);
3288: this .jMenuItemDelete.setEnabled(false);
3289: this .jMenuItemCopyStyle.setEnabled(false);
3290: }
3291:
3292: if (getMainFrame().getStyleClipboard() != null) {
3293: this .jMenuItemPasteStyle.setEnabled(true);
3294: } else {
3295: this .jMenuItemPasteStyle.setEnabled(false);
3296: }
3297:
3298: if (getMainFrame().getClipBoard().size() > 0) {
3299: this .jMenuItemPaste.setEnabled(true);
3300: } else {
3301: this .jMenuItemPaste.setEnabled(false);
3302: }
3303:
3304: Enumeration selectedElementEnum = getSelectedElements()
3305: .elements();
3306: boolean allTextFields = true;
3307: boolean onGroup = false; // true if at least an element belong to a group
3308: boolean sameBand = true;
3309: Band theBand = null;
3310: while (selectedElementEnum.hasMoreElements()) {
3311: ReportElement re = (ReportElement) selectedElementEnum
3312: .nextElement();
3313: if (allTextFields
3314: && !(re instanceof TextFieldReportElement)) {
3315: allTextFields = false;
3316: }
3317:
3318: if (!onGroup && !re.getElementGroup().equals(""))
3319: onGroup = true;
3320:
3321: if (theBand == null)
3322: theBand = re.getBand();
3323: else if (sameBand && theBand != re.getBand())
3324: sameBand = false;
3325:
3326: if (!allTextFields && onGroup && !sameBand)
3327: break;
3328: }
3329:
3330: jMenuItemPattern.setEnabled(allTextFields);
3331:
3332: jMenuItemGroup.setEnabled(sameBand);
3333: jMenuItemUngroup.setEnabled(onGroup);
3334:
3335: if (found) {
3336: // we have find an element, open the contextual menu over it...
3337:
3338: if (this .getSelectedElements().size() == 1) {
3339: //Show Popup with menu for one element
3340: jMenuHSpacing.setEnabled(false);
3341: jMenuVSpacing.setEnabled(false);
3342: jPopupMenuElement.show(jPanelReport, evt.getX(),
3343: evt.getY());
3344:
3345: return;
3346: }
3347: if (this .getSelectedElements().size() > 1) {
3348: //Show Popup with special menu for more elements
3349: jMenuHSpacing.setEnabled(true);
3350: jMenuVSpacing.setEnabled(true);
3351: jPopupMenuElement.show(jPanelReport, evt.getX(),
3352: evt.getY());
3353: return;
3354: }
3355:
3356: }
3357: // Looking for the band....
3358: jPopupMenuBand.show(jPanelReport, evt.getX(), evt.getY());
3359: return;
3360: } else if (evt.getButton() == evt.BUTTON1
3361: && evt.getClickCount() == 2) {
3362:
3363: // Begin code Robert Lamping, 18 July 2004
3364: // --------------------------------------------------------------------------------
3365: // ZOOM IN
3366: // --------------------------------------------------------------------------------
3367: if (((evt.getModifiers() & evt.SHIFT_MASK) != 0)
3368: && ((evt.getModifiers() & evt.CTRL_MASK) != 0)) {
3369: Point clickPoint = this .realPoint(evt.getX(), evt
3370: .getY());
3371: setZoomFactor(getZoomFactor() * 2);
3372: getMainFrame().setComboBoxZoomFactor(
3373: getZoomFactor() * 100);
3374: centerSelectedElements(clickPoint); // if not present use clickPoint
3375: return;
3376: }
3377: // End code Robert Lamping, 18 July 2004
3378:
3379: // Begin code Robert Lamping, 24 July 2004
3380: // --------------------------------------------------------------------------------
3381: // Double click on band: move band split to lowest element in band if any.
3382: // Otherwise no action.
3383: // --------------------------------------------------------------------------------
3384:
3385: if (getSelectedElements().size() == 0) {
3386:
3387: // If there are any elements in the band just above the band limit,
3388: // then set the band height to the maximum Y position of the elements.
3389: // THis way the band just encloses the elements.
3390:
3391: // TEST: Create square in detail band. Square must be smaller than band
3392: // double click on lower detail band split.
3393: // Expected result: band height aligns under element bottom.
3394:
3395: // We must find the right band split
3396:
3397: Band band = null;
3398: int y = report.getTopMargin();
3399: int clicked_y = evt.getY()
3400: + jVerticalScrollBar.getValue();
3401: int proximity = 3;
3402:
3403: for (Iterator i = getReport().getBands().iterator(); i
3404: .hasNext();) {
3405: band = (Band) i.next();
3406: y += band.getHeight();
3407: if (clicked_y > getZoomedDim(y) + 10 - proximity
3408: && clicked_y < getZoomedDim(y) + 10
3409: + proximity) {
3410: break;
3411: }
3412: }
3413:
3414: if (band != null) {
3415: int bandHeight = band.getHeight();
3416: shrinkBand(band);
3417: if (bandHeight != band.getHeight()) {
3418: jPanelReport.repaint();
3419: return;
3420: }
3421: }
3422:
3423: } else {
3424: // double clicked within a selected element
3425: // check if you clicked on South
3426: // in case of a text element, this will reset the height to fontsize() + 2
3427:
3428: //logOnConsole( "Try to check whether you clicked on south\n");
3429: //traverse all selectedelement and check whether you clicked on south.
3430: // if so then adjust the element height to textheight + 2
3431:
3432: //int clicked_x = evt.getX() + jHorizontalScrollBar.getValue();
3433: //int clicked_y = evt.getY() + jVerticalScrollBar.getValue();
3434: //int proximity = 4 ;
3435: //Rectangle clickedRect = new Rectangle( clicked_x - proximity, clicked_y - proximity, 2* proximity, 2* proximity);
3436: //logOnConsole( "Clickpoint: " + clicked_x + " " + clicked_y + "\n");
3437:
3438: Rectangle cursor = new Rectangle(evt.getX()
3439: + jHorizontalScrollBar.getValue(), evt.getY()
3440: + jVerticalScrollBar.getValue(), 1, 1);
3441: Rectangle grip = new Rectangle();
3442: grip.width = 5;
3443: grip.height = 5;
3444:
3445: ReportElement clickedRe = null;
3446:
3447: for (Iterator i = report.getElements().iterator(); i
3448: .hasNext();) {
3449: ReportElement re = (ReportElement) i.next();
3450:
3451: // Grip settings for South:
3452: grip.x = getZoomedDim(re.position.x
3453: + (re.width / 2) - 10) + 10 - 2;
3454: grip.y = getZoomedDim(re.position.y + re.height
3455: - 10) + 10;
3456:
3457: if (cursor.intersects(grip)) {
3458: clickedRe = re;
3459: break;
3460: }
3461: }
3462:
3463: if (clickedRe != null
3464: && getMainFrame().getProperties().getProperty(
3465: "EnableTextResizeClick", "true")
3466: .equals("true")) {
3467: // logOnConsole( "South clicked of " + clickedRe.getKey() + " \n");
3468: if (clickedRe instanceof TextReportElement) {
3469: TransformElementsOperation undoOp = new TransformElementsOperation(
3470: this );
3471: TextReportElement tre = (TextReportElement) clickedRe;
3472:
3473: undoOp.addElement(tre);
3474:
3475: //Rectangle oldBounds = clickedRe.getBounds();
3476: tre.setHeight(tre.getFontSize() + 3);
3477: tre.updateBounds();
3478:
3479: //Rectangle newBounds = clickedRe.getBounds();
3480:
3481: // let the transformationElement capture its needs
3482: undoOp.captureUniqueModified(tre);
3483: // add a task to the undo operation.
3484: // undoOp.addElement(clickedRe, oldBounds, newBounds );
3485:
3486: // Pass the undo tasks to the undo cluster.
3487: addUndoOperation(undoOp);
3488:
3489: // repaint the screen
3490: jPanelReport.repaint();
3491: return;
3492: }
3493: } else {
3494: // Check if we are over a textreportelement
3495: if (getSelectedElements().size() == 1) {
3496: ReportElement re = (ReportElement) getSelectedElements()
3497: .elementAt(0);
3498: if (re instanceof TextReportElement) {
3499: TextReportElement tre = (TextReportElement) re;
3500:
3501: Rectangle textArea = new Rectangle();
3502: textArea.width = getZoomedDim(re.getWidth());
3503: textArea.height = getZoomedDim(re
3504: .getHeight());
3505: textArea.x = getZoomedDim(re.position.x - 10) + 10;
3506: textArea.y = getZoomedDim(re.position.y - 10) + 10;
3507:
3508: try {
3509:
3510: if (cursor.intersects(textArea)) {
3511: onlineEditingTextReportElement = tre;
3512: floatingTextArea.setText(tre
3513: .getText());
3514: floatingTextArea.setOpaque(true);
3515:
3516: textArea.x -= jHorizontalScrollBar
3517: .getValue();
3518: textArea.y -= jVerticalScrollBar
3519: .getValue();
3520:
3521: //floatingTextArea.setFont( new Font(tre.getFontName(), (() ? Font.BOLD : 0) & ((tre.isItalic()) ? Font.BOLD : Font.ITALIC) , (int)getZoomedDim(tre.getFontSize())));
3522: floatingTextArea.setForeground(tre
3523: .getFgcolor());
3524: floatingTextArea.setBackground(tre
3525: .getBgcolor());
3526: this .getReportPanel().add(
3527: floatingTextArea);
3528: floatingTextArea
3529: .setBounds(textArea);
3530: floatingTextArea
3531: .setSelectionStart(0);
3532: floatingTextArea
3533: .setSelectionEnd(tre
3534: .getText().length());
3535: SimpleAttributeSet set = new SimpleAttributeSet();
3536:
3537: StyledDocument doc = floatingTextArea
3538: .getStyledDocument();
3539: if (tre.getAlign().equals("Center")) {
3540: StyleConstants
3541: .setAlignment(
3542: set,
3543: StyleConstants.ALIGN_CENTER);
3544: } else if (tre.getAlign().equals(
3545: "Right")) {
3546: StyleConstants
3547: .setAlignment(
3548: set,
3549: StyleConstants.ALIGN_RIGHT);
3550: } else if (tre.getAlign().equals(
3551: "Left")) {
3552: StyleConstants
3553: .setAlignment(
3554: set,
3555: StyleConstants.ALIGN_LEFT);
3556: } else if (tre.getAlign().equals(
3557: "Justified")) {
3558: StyleConstants
3559: .setAlignment(
3560: set,
3561: StyleConstants.ALIGN_JUSTIFIED);
3562: }
3563:
3564: StyleConstants.setFontFamily(set,
3565: tre.getFontName());
3566: StyleConstants.setFontSize(set,
3567: (int) getZoomedDim(tre
3568: .getFontSize()));
3569: StyleConstants.setBold(set, tre
3570: .isBold());
3571: StyleConstants.setBold(set, tre
3572: .isItalic());
3573: StyleConstants.setStrikeThrough(
3574: set, tre.isStrikeTrought());
3575: StyleConstants.setUnderline(set,
3576: tre.isUnderline());
3577:
3578: floatingTextArea
3579: .setParagraphAttributes(
3580: set, true);
3581:
3582: this .getReportPanel().updateUI();
3583: floatingTextArea
3584: .requestFocusInWindow();
3585:
3586: //floatingTextArea.requestFocusInWindow();
3587: //floatingTextArea.invalidate();
3588: //floatingTextArea.repaint();
3589: }
3590: } catch (Exception ex) {
3591: ex.printStackTrace();
3592: }
3593: } else {
3594: openElementPropertiesDialog();
3595: }
3596: } else {
3597: openElementPropertiesDialog();
3598: }
3599: }
3600: }
3601: // End code Robert Lamping, 24 July 2004, modified june 4, 2005
3602:
3603: // otherwise try to open
3604: // openElementPropertiesDialog();
3605: }
3606: }//GEN-LAST:event_jPanelReportMousePressed
3607:
3608: private void jHorizontalScrollBarAdjustmentValueChanged(
3609: java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_jHorizontalScrollBarAdjustmentValueChanged
3610: floatingTextAreaFocusLost();
3611: isDocDirty = true;
3612: //logOnConsole( "jHorizontalScrollBar.getValue() : " + jHorizontalScrollBar.getValue() + "\n" );
3613: jPanelReport.repaint();
3614: jHorizontalRule.repaint();
3615: }//GEN-LAST:event_jHorizontalScrollBarAdjustmentValueChanged
3616:
3617: private void jPanelReportComponentResized(
3618: java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanelReportComponentResized
3619: if (jPanelReport.getWidth() >= (getZoomedDim(report.getWidth()) + 19)) {
3620: jHorizontalScrollBar.setMaximum(report.getWidth());
3621: jHorizontalScrollBar.setVisibleAmount(jHorizontalScrollBar
3622: .getMaximum());
3623: jHorizontalScrollBar.setValue(0);
3624: ////VScrollBar1_scroll(VScrollBar1, new ScrollEvent( ScrollEventType.ENDSCROLL,0));
3625: } else {
3626: jHorizontalScrollBar.setMaximum((getZoomedDim(report
3627: .getWidth()) + 19));
3628: this .jHorizontalScrollBar.setVisibleAmount(jPanelReport
3629: .getWidth());
3630: this .jHorizontalScrollBar
3631: .setBlockIncrement(this .jHorizontalScrollBar
3632: .getVisibleAmount());
3633: }
3634:
3635: if (jPanelReport.getHeight() >= getZoomedDim(report
3636: .getDesignHeight()) + 19) {
3637: jVerticalScrollBar.setMaximum(report.getDesignHeight());
3638: jVerticalScrollBar.setVisibleAmount(jVerticalScrollBar
3639: .getMaximum());
3640: jVerticalScrollBar.setValue(0);
3641: //VScrollBar1_scroll(VScrollBar1, new ScrollEvent( ScrollEventType.ENDSCROLL,0));
3642: } else {
3643: jVerticalScrollBar.setMaximum(getZoomedDim(report
3644: .getDesignHeight()) + 19);
3645: this .jVerticalScrollBar.setVisibleAmount(jPanelReport
3646: .getHeight());
3647: this .jVerticalScrollBar
3648: .setBlockIncrement(this .jVerticalScrollBar
3649: .getVisibleAmount());
3650: }
3651: // getMainFrame().updateFitToPage(this); deactivated by Robert
3652:
3653: jPanelReport.repaint();
3654: }//GEN-LAST:event_jPanelReportComponentResized
3655:
3656: private void jVerticalScrollBarMouseReleased(
3657: java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jVerticalScrollBarMouseReleased
3658:
3659: }//GEN-LAST:event_jVerticalScrollBarMouseReleased
3660:
3661: private void jVerticalScrollBarAdjustmentValueChanged(
3662: java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_jVerticalScrollBarAdjustmentValueChanged
3663:
3664: floatingTextAreaFocusLost();
3665: isDocDirty = true;
3666: jPanelReport.repaint();
3667: jVerticalRule.repaint();
3668: }//GEN-LAST:event_jVerticalScrollBarAdjustmentValueChanged
3669:
3670: private void jPanelReportMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelReportMouseDragged
3671:
3672: this .jHorizontalRule.setCursorPosition(evt.getX());
3673: this .jVerticalRule.setCursorPosition(evt.getY());
3674: if (mouse == null) {
3675: mouse = new Point();
3676: }
3677:
3678: if (drag_selection_mode == true) {
3679: Graphics2D gg = (Graphics2D) jPanelReport.getGraphics();
3680:
3681: //gg.setXORMode(ReportElement.getAlphaColor(Color.GREEN, 60));
3682: Stroke s = gg.getStroke();
3683: gg.setStroke(selectionStroke);
3684: //if (!first_draw_selection_rect) {
3685: //gg.fillRect((int)Math.min( drag_selection_origin.x, drag_selection_end.x),
3686: // (int)Math.min( drag_selection_origin.y, drag_selection_end.y),
3687: // (int)Math.abs( drag_selection_origin.x - drag_selection_end.x),
3688: // (int)Math.abs( drag_selection_origin.y - drag_selection_end.y));
3689: // gg.drawImage(offscreenImage,0,0,null);
3690: //}
3691:
3692: // Draw the new rectangle...
3693: // Create the maximum rectangle...
3694:
3695: if (drag_selection_end == null) {
3696: drag_selection_end = new Point(drag_selection_origin.x,
3697: drag_selection_origin.y);
3698: }
3699: int rx1 = drag_selection_origin.x;
3700: int rx2 = drag_selection_end.x;
3701: int ry1 = drag_selection_origin.y;
3702: int ry2 = drag_selection_end.y;
3703:
3704: Rectangle2D r_old = new Rectangle2D.Double(Math.min(rx1,
3705: rx2), Math.min(ry1, ry2), Math.abs(rx1 - rx2), Math
3706: .abs(ry1 - ry2));
3707:
3708: drag_selection_end = new java.awt.Point(evt.getX(), evt
3709: .getY());
3710: rx2 = drag_selection_end.x;
3711: ry2 = drag_selection_end.y;
3712:
3713: r_old.add(new Rectangle2D.Double(Math.min(rx1, rx2), Math
3714: .min(ry1, ry2), Math.abs(rx1 - rx2), Math.abs(ry1
3715: - ry2)));
3716:
3717: offscreenImage2g.setClip(r_old);
3718:
3719: offscreenImage2g.drawImage(offscreenImage, 0, 0, null);
3720: offscreenImage2g.setColor(ReportElement.getAlphaColor(
3721: Color.BLUE, 60));
3722: offscreenImage2g.fillRect((int) Math.min(
3723: drag_selection_origin.x, drag_selection_end.x),
3724: (int) Math.min(drag_selection_origin.y,
3725: drag_selection_end.y), (int) Math
3726: .abs(drag_selection_origin.x
3727: - drag_selection_end.x), (int) Math
3728: .abs(drag_selection_origin.y
3729: - drag_selection_end.y));
3730:
3731: offscreenImage2g.setColor(ReportElement.getAlphaColor(
3732: Color.BLUE, 255));
3733: offscreenImage2g.drawRect((int) Math.min(
3734: drag_selection_origin.x, drag_selection_end.x),
3735: (int) Math.min(drag_selection_origin.y,
3736: drag_selection_end.y), (int) Math
3737: .abs(drag_selection_origin.x
3738: - drag_selection_end.x) - 1,
3739: (int) Math.abs(drag_selection_origin.y
3740: - drag_selection_end.y) - 1);
3741:
3742: gg.setClip(r_old);
3743:
3744: gg.drawImage(offscreenImage2, 0, 0, null);
3745: //gg.setPaintMode();
3746: first_draw_selection_rect = false;
3747: if (s != null)
3748: gg.setStroke(s);
3749: }
3750:
3751: if (newObjectType == ReportElementType.NONE && !transforming) {
3752: // Is the mouse over a band line ?...
3753: if (band_dragging) {
3754: // 2. delta = Max altezza banda precedente e position delta
3755: int delta = getLogicalDim(evt.getY()
3756: - band_dragging_origin);
3757: //this.label1.setText(band_dragging_band.name + " band height: " +(band_dragging_band.height));
3758: if (delta != 0) {
3759:
3760: // Vediamo se e' possibile andare piu' su...
3761: // Non possiamo andare piu' su della banda prima...
3762: // 1. Cerchiamo la banda precedente...
3763:
3764: int min_logical_base = report.getTopMargin() + 10;
3765: int base_position = 0;// = Math.max(min_logical_base, getReport().getBandYLocation(band_dragging_band) +delta);
3766: base_position = getZoomedDim(report
3767: .getBandYLocation(band_dragging_band))
3768: + 10 - jVerticalScrollBar.getValue();
3769: Graphics gg = jPanelReport.getGraphics();
3770: gg.setXORMode(Color.WHITE);
3771: if (!first_draw_band) {
3772: gg.drawLine(0,
3773: Math.max(mouse.y, base_position),
3774: jPanelReport.getWidth(), Math.max(
3775: mouse.y, base_position));
3776:
3777: }
3778: gg.drawLine(0, Math.max(evt.getY(), base_position),
3779: jPanelReport.getWidth(), Math.max(evt
3780: .getY(), base_position));
3781: gg.setPaintMode();
3782: first_draw_band = false;
3783: //this.label1.setText(band_dragging_band.name + " band height: " +(band_dragging_band.height + delta));
3784: }
3785: }
3786: }
3787:
3788: if (newObjectType != ReportElementType.NONE
3789: && newObjectOrigin != null) {
3790:
3791: /* In the process of defing the second point. */
3792:
3793: Graphics gg = jPanelReport.getGraphics();
3794: gg.setXORMode(Color.WHITE);
3795: int delta_x = 0;
3796: int delta_y = 0;
3797:
3798: if (newObjectType != ReportElementType.LINE_ELEMENT
3799: && !firstXORDraw) {
3800: delta_x = mouse.x - newObjectOrigin.x;
3801: delta_y = mouse.y - newObjectOrigin.y;
3802:
3803: delta_x = (delta_x < 0) ? delta_x : 0;
3804: delta_y = (delta_y < 0) ? delta_y : 0;
3805: }
3806:
3807: int delta_w = 0;
3808: int delta_h = 0;
3809: if (!firstXORDraw) {
3810: int mevtX = snapToGridOrizzontally(mouse.x);
3811: int mevtY = snapToGridVertically(mouse.y);
3812:
3813: delta_w = mevtX - newObjectOrigin.x; //gridMultiple(evtX-newObjectOrigin.x);
3814: delta_h = mevtY - newObjectOrigin.y; //gridMultiple(evtY-newObjectOrigin.y);
3815: delta_x = (delta_w < 0) ? delta_w : 0;
3816: delta_y = (delta_h < 0) ? delta_h : 0;
3817: }
3818:
3819: int evtX = snapToGridOrizzontally(evt.getX());
3820: int evtY = snapToGridVertically(evt.getY());
3821:
3822: if (newObjectType == ReportElementType.LINE_ELEMENT) {
3823:
3824: /* if ( ( evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3825: if (( delta_w + delta_h ) > 0 ) {
3826: double cos = Math.PI * delta_w / Math.sqrt( (delta_w* delta_w) + (delta_h*delta_h) );
3827: logOnConsole( "Cosinus: " + cos + "\n");
3828:
3829: if ( Math.abs( cos ) > Math.abs( Math.cos(0.25 * Math.PI ) ) ) {
3830: delta_h = 0 ;
3831: }
3832: }
3833: }
3834: */
3835: /* overwrite the other one, so that it disappears */
3836:
3837: if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3838: Point straight = straighten(delta_w, delta_h);
3839: delta_w = straight.x;
3840: delta_h = straight.y;
3841: }
3842:
3843: if (!firstXORDraw) {
3844: gg.drawLine(newObjectOrigin.x, newObjectOrigin.y,
3845: newObjectOrigin.x + delta_w,
3846: newObjectOrigin.y + delta_h);
3847: }
3848:
3849: delta_w = evtX - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
3850: delta_h = evtY - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
3851:
3852: if ((evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3853: Point straight = straighten(delta_w, delta_h);
3854: delta_w = straight.x;
3855: delta_h = straight.y;
3856: }
3857:
3858: /* if ( ( evt.getModifiers() & evt.SHIFT_MASK) != 0) {
3859: if (( delta_w + delta_h ) > 0 ) {
3860: double cos = Math.PI * delta_w / Math.sqrt( (delta_w* delta_w) + (delta_h*delta_h) );
3861: logOnConsole( "Cosinus: " + cos + "\n");
3862:
3863: if ( Math.abs( cos ) > Math.abs( Math.cos(0.25 * Math.PI ) ) ) {
3864: delta_h = 0 ;
3865: }
3866: }
3867: }
3868: */
3869: gg.drawLine(newObjectOrigin.x, newObjectOrigin.y,
3870: newObjectOrigin.x + delta_w, newObjectOrigin.y
3871: + delta_h);
3872: mouse.x = newObjectOrigin.x + delta_w;
3873: mouse.y = newObjectOrigin.x + delta_y;
3874:
3875: } else if (newObjectType == ReportElementType.ELLIPSE_ELEMENT) {
3876: if (!firstXORDraw)
3877: gg.drawOval(newObjectOrigin.x + delta_x,
3878: snapToGridVertically(newObjectOrigin.y
3879: + delta_y), Math.abs(delta_w), Math
3880: .abs(delta_h));
3881:
3882: //delta_w = gridMultiple(evt.getX()-newObjectOrigin.x);
3883: //delta_h = gridMultiple(evt.getY()-newObjectOrigin.y);
3884: delta_w = evtX - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
3885: delta_h = evtY - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
3886:
3887: delta_x = (delta_w < 0) ? delta_w : 0;
3888: delta_y = (delta_h < 0) ? delta_h : 0;
3889: gg.drawOval(newObjectOrigin.x + delta_x,
3890: snapToGridVertically(newObjectOrigin.y
3891: + delta_y), Math.abs(delta_w), Math
3892: .abs(delta_h));
3893: } else if (newObjectType == ReportElementType.ROUND_RECTANGLE_ELEMENT) {
3894: if (!firstXORDraw) {
3895: gg.drawRoundRect(newObjectOrigin.x + delta_x,
3896: snapToGridVertically(newObjectOrigin.y
3897: + delta_y), Math.abs(delta_w), Math
3898: .abs(delta_h), 20, 20);
3899: }
3900: //delta_w = gridMultiple(evt.getX()-newObjectOrigin.x);
3901: //delta_h = gridMultiple(evt.getY()-newObjectOrigin.y);
3902: delta_w = evtX - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
3903: delta_h = evtY - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
3904: delta_x = (delta_w < 0) ? delta_w : 0;
3905: delta_y = (delta_h < 0) ? delta_h : 0;
3906: //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)));
3907: gg.drawRoundRect(newObjectOrigin.x + delta_x,
3908: snapToGridVertically(newObjectOrigin.y
3909: + delta_y), Math.abs(delta_w), Math
3910: .abs(delta_h), 20, 20);
3911: } else {
3912: if (!firstXORDraw) {
3913: gg.drawRect(newObjectOrigin.x + delta_x,
3914: snapToGridVertically(newObjectOrigin.y
3915: + delta_y), Math.abs(delta_w), Math
3916: .abs(delta_h));
3917: }
3918: //delta_w = gridMultiple(evt.getX()-newObjectOrigin.x);
3919: //delta_h = gridMultiple(evt.getY()-newObjectOrigin.y);
3920: delta_w = evtX - newObjectOrigin.x; //gridMultiple(evt.getX()-newObjectOrigin.x);
3921: delta_h = evtY - newObjectOrigin.y; //gridMultiple(evt.getY()-newObjectOrigin.y);
3922: delta_x = (delta_w < 0) ? delta_w : 0;
3923: delta_y = (delta_h < 0) ? delta_h : 0;
3924: //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)));
3925: gg.drawRect(newObjectOrigin.x + delta_x,
3926: snapToGridVertically(newObjectOrigin.y
3927: + delta_y), Math.abs(delta_w), Math
3928: .abs(delta_h));
3929: //gg.drawRect( newObjectOrigin.x+delta_x, newObjectOrigin.y+delta_y, Math.abs(delta_from_origin), Math.abs(evt.getY()-newObjectOrigin.y));
3930: }
3931: firstXORDraw = false;
3932:
3933: //mouse.x = mouse.x + delta_from_origin;
3934: //mouse.y = evt.getY();
3935: //return;
3936: }
3937: if (selectedElements.size() > 0
3938: && newObjectType == ReportElementType.NONE
3939: && transformation_origin_end != null) {
3940: int new_transformation_origin_end_x = transformation_origin_end.x;
3941: int new_transformation_origin_end_y = transformation_origin_end.y;
3942:
3943: if (transformation_type >= 0 && trasforming) {
3944: Graphics gg = jPanelReport.getGraphics();
3945:
3946: gg.setXORMode(Color.WHITE);
3947: int iteration = 0;
3948:
3949: if (!firstXORDrawTransforming) {
3950: // redraw old rectangles...
3951: // transformation_origin
3952: // transformation_origin_end
3953: // Pain a rectangle....
3954:
3955: // if no modifications is needed, return...
3956:
3957: //if (this.isSnapToGrid()) {
3958:
3959: new_transformation_origin_end_x = evt.getX();
3960: new_transformation_origin_end_y = evt.getY();
3961:
3962: // New code for snap to grid....
3963: new_transformation_origin_end_x = optimizeX(evt
3964: .getX(), transformation_origin.x,
3965: transformation_type,
3966: (ReportElement) getSelectedElements()
3967: .elementAt(0));
3968: new_transformation_origin_end_y = optimizeY(evt
3969: .getY(), transformation_origin.y,
3970: transformation_type,
3971: (ReportElement) getSelectedElements()
3972: .elementAt(0));
3973: /*
3974: if (Math.abs( transformation_origin_end.x - evt.getX())%(getGridSize()*getZoomFactor()) == 0)
3975: new_transformation_origin_end_x = evt.getX();
3976:
3977: if (Math.abs( transformation_origin_end.y - evt.getY() )%(getGridSize()*getZoomFactor()) == 0)
3978: new_transformation_origin_end_y = evt.getY();
3979: */
3980:
3981: if (new_transformation_origin_end_x == transformation_origin_end.x
3982: && new_transformation_origin_end_y == transformation_origin_end.y) {
3983: return;
3984: }
3985:
3986: //} else {
3987: // new_transformation_origin_end_x = evt.getX();
3988: // new_transformation_origin_end_y = evt.getY();
3989: //}
3990:
3991: Enumeration e = getSelectedElements().elements();
3992:
3993: while (e.hasMoreElements()) {
3994: iteration++;
3995: ReportElement re = (ReportElement) e
3996: .nextElement();
3997: Rectangle bounds = new Rectangle(
3998: getZoomedDim(re.getPosition().x - 10) + 10,
3999: getZoomedDim(re.getPosition().y - 10) + 10,
4000: getZoomedDim(re.getWidth()),
4001: getZoomedDim(re.getHeight()));
4002: // Scale rectangle...
4003: if (transformation_type == TransformationType.TRANSFORMATION_MOVE) {
4004: // First of all we must see if the resistence was Exceeded...
4005: if (resistenceExceeded) {
4006: // Change location...
4007: bounds
4008: .translate(
4009: transformation_origin_end.x
4010: - transformation_origin.x,
4011: transformation_origin_end.y
4012: - transformation_origin.y);
4013: gg.drawRect(bounds.x
4014: - jHorizontalScrollBar
4015: .getValue(),
4016: bounds.y
4017: - jVerticalScrollBar
4018: .getValue(),
4019: bounds.width, bounds.height);
4020: if (iteration == 1) {
4021: redrawReferenceGuides(gg);
4022: }
4023: }
4024: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
4025: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S
4026: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) {
4027: // Change location...
4028: int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) ? transformation_origin_end.x
4029: - transformation_origin.x
4030: : 0;
4031: int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S) ? transformation_origin_end.y
4032: - transformation_origin.y
4033: : 0;
4034: bounds.setSize(Math.max(0, bounds.width
4035: + x_delta), Math.max(0,
4036: bounds.height + y_delta));
4037: gg.drawRect(bounds.x
4038: - jHorizontalScrollBar.getValue(),
4039: bounds.y
4040: - jVerticalScrollBar
4041: .getValue(),
4042: bounds.width, bounds.height);
4043: if (iteration == 1) {
4044: redrawReferenceGuides(gg);
4045: }
4046: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
4047: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N
4048: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) {
4049: // Change location...
4050: int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) ? transformation_origin_end.x
4051: - transformation_origin.x
4052: : 0;
4053: int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) ? transformation_origin_end.y
4054: - transformation_origin.y
4055: : 0;
4056: int height_grow = Math.min(y_delta,
4057: bounds.height);
4058: int width_grow = Math.min(x_delta,
4059: bounds.width);
4060: bounds.translate(width_grow, height_grow);
4061: bounds.setSize(bounds.width - width_grow,
4062: bounds.height - height_grow);
4063: gg.drawRect(bounds.x
4064: - jHorizontalScrollBar.getValue(),
4065: bounds.y
4066: - jVerticalScrollBar
4067: .getValue(),
4068: bounds.width, bounds.height);
4069: if (iteration == 1) {
4070: redrawReferenceGuides(gg);
4071: }
4072: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE) {
4073: // Change location...
4074: int x_delta = Math
4075: .max(
4076: -bounds.width,
4077: (transformation_origin_end.x - transformation_origin.x));
4078: int y_delta = Math
4079: .min(
4080: bounds.height,
4081: (transformation_origin_end.y - transformation_origin.y));
4082: bounds.y += y_delta;
4083: bounds.height -= y_delta;
4084: bounds.width += x_delta;
4085: gg.drawRect(bounds.x
4086: - jHorizontalScrollBar.getValue(),
4087: bounds.y
4088: - jVerticalScrollBar
4089: .getValue(),
4090: bounds.width, bounds.height);
4091: if (iteration == 1) {
4092: redrawReferenceGuides(gg);
4093: }
4094: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW) {
4095: // Change location...
4096: int x_delta = Math
4097: .min(
4098: bounds.width,
4099: (transformation_origin_end.x - transformation_origin.x));
4100: int y_delta = Math
4101: .max(
4102: -bounds.height,
4103: (transformation_origin_end.y - transformation_origin.y));
4104: bounds.x += x_delta;
4105: bounds.width -= x_delta;
4106: bounds.height += y_delta;
4107: gg.drawRect(bounds.x
4108: - jHorizontalScrollBar.getValue(),
4109: bounds.y
4110: - jVerticalScrollBar
4111: .getValue(),
4112: bounds.width, bounds.height);
4113: if (iteration == 1) {
4114: redrawReferenceGuides(gg);
4115: }
4116: }
4117: }
4118: }
4119:
4120: /*
4121: if (Math.abs( transformation_origin_end.x - evt.getX())%(getGridSize()*getZoomFactor()) == 0)
4122: transformation_origin_end.x = evt.getX();
4123: if (Math.abs( transformation_origin_end.y - evt.getY() )%(getGridSize()*getZoomFactor()) == 0)
4124: transformation_origin_end.y = evt.getY();
4125: */
4126: transformation_origin_end.x = new_transformation_origin_end_x;
4127: transformation_origin_end.y = new_transformation_origin_end_y;
4128:
4129: Enumeration e = getSelectedElements().elements();
4130: Rectangle firsElementBound = null;
4131:
4132: iteration = 0;
4133: while (e.hasMoreElements()) {
4134: iteration++;
4135: ReportElement re = (ReportElement) e.nextElement();
4136: Rectangle bounds = new Rectangle(getZoomedDim(re
4137: .getPosition().x - 10)
4138: + 10 - jHorizontalScrollBar.getValue(),
4139: getZoomedDim(re.getPosition().y - 10) + 10
4140: - jVerticalScrollBar.getValue(),
4141: getZoomedDim(re.getWidth()),
4142: getZoomedDim(re.getHeight()));
4143: // Scale rectangle...
4144: if (transformation_type == TransformationType.TRANSFORMATION_MOVE) {
4145: // Change location...
4146: if (Math.abs(transformation_origin_end.x
4147: - transformation_origin.x) > 5
4148: || Math.abs(transformation_origin_end.y
4149: - transformation_origin.y) > 5) {
4150: resistenceExceeded = true;
4151: }
4152:
4153: if (resistenceExceeded) {
4154: // Search the closest x,y that match a grid intersection...
4155:
4156: int pex = gridMultiple(transformation_origin_end.x - 10) + 10;
4157: int pey = gridMultiple(transformation_origin_end.y - 10) + 10;
4158: int pox = gridMultiple(transformation_origin.x - 10) + 10;
4159: int poy = gridMultiple(transformation_origin.y - 10) + 10;
4160:
4161: //System.out.println("x: "+transformation_origin_end + " y:" + transformation_origin_end.y);
4162:
4163: //this.getGraphics().drawOval( grid_multiple_x, grid_multiple_y, 5,5);
4164:
4165: bounds.translate(
4166: transformation_origin_end.x
4167: - transformation_origin.x,
4168: transformation_origin_end.y
4169: - transformation_origin.y);
4170: gg.drawRect(bounds.x, bounds.y,
4171: bounds.width, bounds.height);
4172: if (iteration == 1) {
4173: paintedAlignLines = getAlignMatches(bounds);
4174: redrawReferenceGuides(gg);
4175: }
4176: }
4177: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
4178: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S
4179: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) {
4180: // Change location...
4181: int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) ? transformation_origin_end.x
4182: - transformation_origin.x
4183: : 0;
4184: int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S) ? transformation_origin_end.y
4185: - transformation_origin.y
4186: : 0;
4187: bounds.setSize(Math.max(0, bounds.width
4188: + x_delta), Math.max(0, bounds.height
4189: + y_delta));
4190: gg.drawRect(bounds.x, bounds.y, bounds.width,
4191: bounds.height);
4192: if (iteration == 1) {
4193: paintedAlignLines = getAlignMatches(bounds);
4194: redrawReferenceGuides(gg);
4195: }
4196: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
4197: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N
4198: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) {
4199: // Change location...
4200: int x_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) ? transformation_origin_end.x
4201: - transformation_origin.x
4202: : 0;
4203: int y_delta = (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) ? transformation_origin_end.y
4204: - transformation_origin.y
4205: : 0;
4206: int height_grow = Math.min(y_delta,
4207: bounds.height);
4208: int width_grow = Math
4209: .min(x_delta, bounds.width);
4210: bounds.translate(width_grow, height_grow);
4211: bounds.setSize(bounds.width - width_grow,
4212: bounds.height - height_grow);
4213: gg.drawRect(bounds.x, bounds.y, bounds.width,
4214: bounds.height);
4215: if (iteration == 1) {
4216: paintedAlignLines = getAlignMatches(bounds);
4217: redrawReferenceGuides(gg);
4218: }
4219: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE) {
4220: // Change location...
4221: int x_delta = Math
4222: .max(
4223: -bounds.width,
4224: (transformation_origin_end.x - transformation_origin.x));
4225: int y_delta = Math
4226: .min(
4227: bounds.height,
4228: (transformation_origin_end.y - transformation_origin.y));
4229: bounds.y += y_delta;
4230: bounds.height -= y_delta;
4231: bounds.width += x_delta;
4232: gg.drawRect(bounds.x, bounds.y, bounds.width,
4233: bounds.height);
4234: if (iteration == 1) {
4235: paintedAlignLines = getAlignMatches(bounds);
4236: redrawReferenceGuides(gg);
4237: }
4238: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW) {
4239: // Change location...
4240: int x_delta = Math
4241: .min(
4242: bounds.width,
4243: (transformation_origin_end.x - transformation_origin.x));
4244: int y_delta = Math
4245: .max(
4246: -bounds.height,
4247: (transformation_origin_end.y - transformation_origin.y));
4248: bounds.x += x_delta;
4249: bounds.width -= x_delta;
4250: bounds.height += y_delta;
4251: gg.drawRect(bounds.x, bounds.y, bounds.width,
4252: bounds.height);
4253: if (iteration == 1) {
4254: paintedAlignLines = getAlignMatches(bounds);
4255: redrawReferenceGuides(gg);
4256: }
4257: }
4258:
4259: firsElementBound = bounds;
4260: }
4261:
4262: firstXORDrawTransforming = false;
4263:
4264: // Check if we are aligned with other objects....
4265:
4266: gg.setPaintMode();
4267: }
4268: }
4269: mouse.x = evt.getX();
4270: mouse.y = evt.getY();
4271:
4272: }//GEN-LAST:event_jPanelReportMouseDragged
4273:
4274: private void jPanelReportMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelReportMouseMoved
4275: this .jHorizontalRule.setCursorPosition(evt.getX());
4276: this .jVerticalRule.setCursorPosition(evt.getY());
4277: if (mouse == null)
4278: mouse = new Point();
4279: if (newObjectType == ReportElementType.NONE && !transforming) {
4280: // Is the mouse over a band line ?...
4281: int bl = evt.getY() + jVerticalScrollBar.getValue();
4282: Enumeration e = report.getBands().elements();
4283: int y = report.getTopMargin();
4284: boolean found = false;
4285: while (!found && e.hasMoreElements()) {
4286: Band band = (Band) e.nextElement();
4287: y += band.getHeight();
4288: if (bl > getZoomedDim(y) + 10 - 3
4289: && bl < getZoomedDim(y) + 3 + 10) {
4290: jPanelReport.setCursor(hsplit);
4291: //this.label1.setText("Drag "+band.name);
4292: found = true;
4293: }
4294: }
4295: if (!found && jPanelReport.getCursor() == hsplit) {
4296: jPanelReport.setCursor(Cursor
4297: .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
4298: }
4299: }
4300:
4301: if (selectedElements.size() > 0
4302: && newObjectType == ReportElementType.NONE) {
4303: // We are trasformation mode?
4304: {
4305: // Vediamo se siamo sopra la figura...
4306: Enumeration e = selectedElements.elements();
4307: boolean found = false;
4308: boolean sizeall = false;
4309: while (!found && e.hasMoreElements()) {
4310:
4311: ReportElement selectedRe = (ReportElement) e
4312: .nextElement();
4313: Rectangle grip = new Rectangle(
4314: getZoomedDim(selectedRe.position.x - 10) - 5 + 10,
4315: getZoomedDim(selectedRe.position.y - 10) - 5 + 10,
4316: getZoomedDim(selectedRe.width) + 10,
4317: getZoomedDim(selectedRe.height) + 10);
4318: Rectangle cursor = new Rectangle(evt.getX()
4319: + jHorizontalScrollBar.getValue(), evt
4320: .getY()
4321: + jVerticalScrollBar.getValue(), 1, 1);
4322:
4323: if (cursor.intersects(grip)) {
4324: sizeall = true;
4325: // Vediamo se interseca una grip...
4326: grip.width = 5;
4327: grip.height = 5;
4328:
4329: if (cursor.intersects(grip)) {
4330: jPanelReport
4331: .setCursor(Cursor
4332: .getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
4333: found = true;
4334: transformation_type = TransformationType.TRANSFORMATION_RESIZE_NW;
4335: }
4336:
4337: if (!found) {
4338: grip.x = getZoomedDim(selectedRe.position.x
4339: - 10 + selectedRe.width) + 10;
4340: grip.y = getZoomedDim(selectedRe.position.y - 10) + 10 - 5;
4341: grip.width = 5;
4342: grip.height = 5;
4343: if (cursor.intersects(grip)) {
4344: jPanelReport
4345: .setCursor(Cursor
4346: .getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
4347: found = true;
4348: transformation_type = TransformationType.TRANSFORMATION_RESIZE_NE;
4349: }
4350: }
4351:
4352: if (!found) {
4353: grip.x = getZoomedDim(selectedRe.position.x - 10) + 10 - 5;
4354: grip.y = getZoomedDim(selectedRe.position.y
4355: + (selectedRe.height / 2) - 10) + 10 - 2;
4356: grip.width = 5;
4357: grip.height = 5;
4358: if (cursor.intersects(grip)) {
4359: jPanelReport
4360: .setCursor(Cursor
4361: .getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
4362: found = true;
4363: transformation_type = TransformationType.TRANSFORMATION_RESIZE_W;
4364: }
4365: }
4366:
4367: if (!found) {
4368: grip.x = getZoomedDim(selectedRe.position.x - 10) + 10 - 5;
4369: grip.y = getZoomedDim(selectedRe.position.y
4370: - 10 + selectedRe.height) + 10;
4371: grip.width = 5;
4372: grip.height = 5;
4373: if (cursor.intersects(grip)) {
4374: jPanelReport
4375: .setCursor(Cursor
4376: .getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
4377: found = true;
4378: transformation_type = TransformationType.TRANSFORMATION_RESIZE_SW;
4379: }
4380: }
4381:
4382: if (!found) {
4383: grip.x = getZoomedDim(selectedRe.position.x
4384: + (selectedRe.width / 2) - 10) + 10 - 2;
4385: grip.y = getZoomedDim(selectedRe.position.y - 10) + 10 - 5;
4386: grip.width = 5;
4387: grip.height = 5;
4388: if (cursor.intersects(grip)) {
4389: jPanelReport
4390: .setCursor(Cursor
4391: .getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
4392: found = true;
4393: transformation_type = TransformationType.TRANSFORMATION_RESIZE_N;
4394: }
4395: }
4396:
4397: if (!found) {
4398: grip.x = getZoomedDim(selectedRe.position.x
4399: + (selectedRe.width / 2) - 10) + 10 - 2;
4400: grip.y = getZoomedDim(selectedRe.position.y
4401: + selectedRe.height - 10) + 10;
4402: grip.width = 5;
4403: grip.height = 5;
4404: if (cursor.intersects(grip)) {
4405: jPanelReport
4406: .setCursor(Cursor
4407: .getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
4408: found = true;
4409: transformation_type = TransformationType.TRANSFORMATION_RESIZE_S;
4410: }
4411: }
4412:
4413: if (!found) {
4414: grip.x = getZoomedDim(selectedRe.position.x
4415: + selectedRe.width - 10) + 10;
4416: grip.y = getZoomedDim(selectedRe.position.y
4417: + selectedRe.height - 10) + 10;
4418: grip.width = 5;
4419: grip.height = 5;
4420: if (cursor.intersects(grip)) {
4421: jPanelReport
4422: .setCursor(Cursor
4423: .getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
4424: found = true;
4425: transformation_type = TransformationType.TRANSFORMATION_RESIZE_SE;
4426: }
4427: }
4428:
4429: if (!found) {
4430: grip.x = getZoomedDim(selectedRe.position.x
4431: + selectedRe.width - 10) + 10;
4432: grip.y = getZoomedDim(selectedRe.position.y
4433: + (selectedRe.height / 2) - 10) + 10 - 2;
4434: grip.width = 5;
4435: grip.height = 5;
4436: if (cursor.intersects(grip)) {
4437: jPanelReport
4438: .setCursor(Cursor
4439: .getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
4440: found = true;
4441: transformation_type = TransformationType.TRANSFORMATION_RESIZE_E;
4442: }
4443: }
4444:
4445: if (!found) {
4446: jPanelReport
4447: .setCursor(Cursor
4448: .getPredefinedCursor(Cursor.MOVE_CURSOR));
4449:
4450: if (getMainFrame().isEMMActive())
4451: transformation_type = TransformationType.TRANSFORMATION_NONE;
4452: else {
4453: transformation_type = TransformationType.TRANSFORMATION_MOVE;
4454: resistenceExceeded = false;
4455: }
4456: }
4457: }
4458: }
4459: if (!sizeall) {
4460: jPanelReport.setCursor(Cursor.getDefaultCursor());
4461: transformation_type = TransformationType.TRANSFORMATION_NONE;
4462: }
4463: }
4464: }
4465:
4466: if (getMainFrame().getProperties().getProperty(
4467: "ShowToolTipsInDesign", "false").equals("true")) {
4468: Band bbb = getReport().getBandByPosition(
4469: getLogicalDim(evt.getY()
4470: + jVerticalScrollBar.getValue() - 10) + 10);
4471: if (((ReportPanelToolTip) getReportPanel().createToolTip())
4472: .getBand() == null
4473: || ((ReportPanelToolTip) getReportPanel()
4474: .createToolTip()).getBand() != bbb) {
4475: ((ReportPanelToolTip) getReportPanel().createToolTip())
4476: .setBand(bbb);
4477: getReportPanel().setToolTipText(
4478: ((ReportPanelToolTip) getReportPanel()
4479: .createToolTip()).getTipText());
4480: }
4481: } else {
4482: getReportPanel().setToolTipText(null);
4483: }
4484:
4485: mouse.x = evt.getX();
4486: mouse.y = evt.getY();
4487:
4488: }//GEN-LAST:event_jPanelReportMouseMoved
4489:
4490: /* Unuseful...
4491: public String getToolTipByMousePosition(Point position)
4492: {
4493: Point p_to_intersect = new Point(getLogicalDim(position.x+jHorizontalScrollBar.getValue()-10)+10,getLogicalDim(position.y+jVerticalScrollBar.getValue()-10)+10);
4494: for (int i=report.getElements().size()-1; i>=0; --i) {
4495: ReportElement re = (ReportElement)report.getElements().elementAt(i);
4496: if (re.intersects(p_to_intersect)) {
4497: return "Element: " + re.getName()+"\nBand: " + re.getBand().getName();
4498: }
4499: }
4500:
4501: Band bbb = getReport().getBandByPosition( getLogicalDim(position.y+jVerticalScrollBar.getValue()-10) );
4502: if (bbb != null)
4503: {
4504: return "Band: " + bbb.getName();
4505: }
4506: return null;
4507: }
4508: */
4509: private void jPanelReportAncestorAdded(
4510: javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jPanelReportAncestorAdded
4511: // Add your handling code here:
4512: }//GEN-LAST:event_jPanelReportAncestorAdded
4513:
4514: /** Getter for property report.
4515: * @return Value of property report.
4516: *
4517: */
4518: public it.businesslogic.ireport.Report getReport() {
4519: return report;
4520: }
4521:
4522: /** Getter for property selectedElements.
4523: * @return Value of property selectedElements.
4524: *
4525: */
4526: public java.util.Vector getSelectedElements() {
4527: return selectedElements;
4528: }
4529:
4530: /** Setter for property selectedElements.
4531: * @param selectedElements New value of property selectedElements.
4532: *
4533: */
4534: public void setSelectedElements(java.util.Vector selectedElements) {
4535: this .selectedElements = selectedElements;
4536: }
4537:
4538: /** Getter for property clipboardObjects.
4539: * @return Value of property clipboardObjects.
4540: *
4541: */
4542: public java.util.Vector getClipboardObjects() {
4543: return clipboardObjects;
4544: }
4545:
4546: /** Setter for property clipboardObjects.
4547: * @param clipboardObjects New value of property clipboardObjects.
4548: *
4549: */
4550: public void setClipboardObjects(java.util.Vector clipboardObjects) {
4551: this .clipboardObjects = clipboardObjects;
4552: }
4553:
4554: // Variables declaration - do not modify//GEN-BEGIN:variables
4555: private it.businesslogic.ireport.gui.JRulePanel jHorizontalRule;
4556: private javax.swing.JScrollBar jHorizontalScrollBar;
4557: private javax.swing.JMenuItem jMenuItemBandProperties;
4558: private javax.swing.JMenuItem jMenuItemBandProperties1;
4559: private javax.swing.JMenuItem jMenuItemCopy;
4560: private javax.swing.JMenuItem jMenuItemCopyStyle;
4561: private javax.swing.JMenuItem jMenuItemCut;
4562: private javax.swing.JMenuItem jMenuItemDelete;
4563: private javax.swing.JMenuItem jMenuItemElementChartProperties;
4564: private javax.swing.JMenuItem jMenuItemElementCrosstabDesignProperties;
4565: private javax.swing.JMenuItem jMenuItemElementCrosstabProperties;
4566: private javax.swing.JMenuItem jMenuItemElementOpenSubreport;
4567: private javax.swing.JMenuItem jMenuItemElementProperties;
4568: private javax.swing.JMenuItem jMenuItemGroup;
4569: private javax.swing.JMenuItem jMenuItemPaste;
4570: private javax.swing.JMenuItem jMenuItemPasteOnBand;
4571: private javax.swing.JMenuItem jMenuItemPasteStyle;
4572: private javax.swing.JMenuItem jMenuItemPattern;
4573: private javax.swing.JMenuItem jMenuItemTransformStaticText;
4574: private javax.swing.JMenuItem jMenuItemUngroup;
4575: private javax.swing.JPanel jPanel1;
4576: private javax.swing.JPanel jPanelCorner;
4577: private javax.swing.JPanel jPanelHContainerRule;
4578: private javax.swing.JPanel jPanelHScroll;
4579: private it.businesslogic.ireport.gui.JReportPanel jPanelReport;
4580: private javax.swing.JPanel jPanelReportContainer;
4581: private javax.swing.JPanel jPanelSuperContainer;
4582: private javax.swing.JPanel jPanelVRule;
4583: private javax.swing.JPopupMenu jPopupMenuBand;
4584: private javax.swing.JPopupMenu jPopupMenuElement;
4585: private javax.swing.JSeparator jSeparator1;
4586: private javax.swing.JSeparator jSeparator2;
4587: private javax.swing.JSeparator jSeparator3;
4588: private javax.swing.JSeparator jSeparator4;
4589: private javax.swing.JSeparator jSeparator6;
4590: private javax.swing.JTabbedPane jTabbedPane1;
4591: private javax.swing.JScrollBar jVerticalScrollBar;
4592: // End of variables declaration//GEN-END:variables
4593:
4594: private Report report;
4595:
4596: private int undoIndex = -1;
4597: private Vector undoOperations;
4598: private Vector clipboardObjects;
4599: private Vector selectedElements;
4600:
4601: /**
4602: * Zoom factor used in this frame...
4603: */
4604: private double zoomFactor;
4605:
4606: /**
4607: * Actual mouse position...
4608: */
4609: private Point mouse = null;
4610:
4611: private boolean lensMode;
4612:
4613: private int newObjectType;
4614:
4615: private boolean showGrid;
4616:
4617: private int transformationMinSize;
4618:
4619: private boolean snapToGrid;
4620:
4621: private int windowID;
4622:
4623: /** Utility field used by event firing mechanism. */
4624: private javax.swing.event.EventListenerList listenerList = null;
4625:
4626: public JReportPanel getReportPanel() {
4627: return this .jPanelReport;
4628: }
4629:
4630: public void drawVoidDoc(Graphics2D g) {
4631: // Paint the background.
4632: g.setColor(new Color(128, 128, 128));
4633: // Fill a very large rectangle. Clipping will only paint what is
4634: // necessary.
4635: g.fillRect(0, 0, this .getWidth(), this .getHeight());
4636:
4637: //iR20 if (background != null)
4638: //iR20 {
4639: //iR20 g.drawImage(background.getImage(), 0,0, this);
4640: //iR20 }
4641:
4642: // Due to optimize document drawing, we use a cache. Redraw void doc only if it+
4643: // is dirty...
4644: /*
4645: if (!isDocDirty)
4646: {
4647: return;
4648: }
4649: */
4650:
4651: //g.clearRect(0,0,offscreenImageDoc.getWidth(), offscreenImageDoc.getHeight());
4652: int horizontal_scroll = jHorizontalScrollBar.getValue();
4653: int vertical_scroll = jVerticalScrollBar.getValue();
4654: int zoomed_width = getZoomedDim(report.getWidth());
4655: int design_height = report.getDesignHeight();
4656: int zoomed_height = getZoomedDim(design_height);
4657:
4658: g.setColor(Color.WHITE);
4659: g.fillRect(10 - horizontal_scroll, 10 - vertical_scroll,
4660: zoomed_width, zoomed_height);
4661: g.setColor(Color.BLACK);
4662: g.drawRect(9 - horizontal_scroll, 9 - vertical_scroll,
4663: zoomed_width, zoomed_height);
4664:
4665: // Paint shadow corner top-right
4666: g
4667: .setPaint(new TexturePaint(shadowsImages[0],
4668: new Rectangle2D.Double(zoomed_width + 10
4669: - horizontal_scroll,
4670: 9 - vertical_scroll, 9, 9)));
4671: g.fillRect(zoomed_width + 10 - horizontal_scroll,
4672: 9 - vertical_scroll, 9, 9);
4673:
4674: // Paint shadow corner top-right
4675: g
4676: .setPaint(new TexturePaint(shadowsImages[1],
4677: new Rectangle2D.Double(zoomed_width + 10
4678: - horizontal_scroll,
4679: 18 - vertical_scroll, 9, 9)));
4680: g.fillRect(zoomed_width + 10 - horizontal_scroll,
4681: 18 - vertical_scroll, 9, zoomed_height - 8);
4682:
4683: g.setPaint(new TexturePaint(shadowsImages[2],
4684: new Rectangle2D.Double(zoomed_width + 10
4685: - horizontal_scroll, zoomed_height + 10
4686: - vertical_scroll, 9, 9)));
4687: g.fillRect(zoomed_width + 10 - horizontal_scroll, zoomed_height
4688: + 10 - vertical_scroll, 9, 9);
4689:
4690: g.setPaint(new TexturePaint(shadowsImages[3],
4691: new Rectangle2D.Double(9 - horizontal_scroll,
4692: zoomed_height + 10 - vertical_scroll,
4693: zoomed_width + 2, 9)));
4694: g.fillRect(9 - horizontal_scroll, zoomed_height + 10
4695: - vertical_scroll, zoomed_width + 1, 9);
4696:
4697: g.setPaint(new TexturePaint(shadowsImages[4],
4698: new Rectangle2D.Double(9 - horizontal_scroll,
4699: zoomed_height + 10 - vertical_scroll, 9, 9)));
4700: g.fillRect(9 - horizontal_scroll, zoomed_height + 10
4701: - vertical_scroll, 9, 9);
4702:
4703: // Draw grid...
4704:
4705: g.setColor(new Color(230, 230, 230));
4706: if (this .isShowGrid()) {
4707: /*
4708:
4709: //g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,
4710: // BasicStroke.JOIN_MITER, 1,
4711: // dashPattern, 0));
4712: float[] fArray = {2f,2f};
4713: BasicStroke m_Dashed3 = new BasicStroke(1, BasicStroke.CAP_SQUARE,
4714: BasicStroke.JOIN_BEVEL, 1.0f, fArray, 0.0f);
4715: g.setStroke(m_Dashed3);
4716:
4717: int zoomed_grid_size = getZoomedDim(this.gridSize);
4718: int grid_left = 10+ zoomed_grid_size - horizontal_scroll;
4719: int line_top = 10-vertical_scroll+1;
4720: int line_bottom = getZoomedDim(design_height)+10-vertical_scroll-2;
4721:
4722: if (zoomed_grid_size>2) {
4723: int i=1;
4724: grid_left = 10 - horizontal_scroll + getZoomedDim(i*this.gridSize);
4725:
4726: while (grid_left < zoomed_width+10-horizontal_scroll) {
4727: g.drawLine(grid_left, line_top, grid_left, line_bottom);
4728: i++;
4729: grid_left = 10 - horizontal_scroll + getZoomedDim(i*this.gridSize);
4730: }
4731: }
4732:
4733: int grid_top = 10 - vertical_scroll;
4734: int line_left = 10-horizontal_scroll+1;
4735: int line_right = zoomed_width+10-horizontal_scroll-1;
4736: if (zoomed_grid_size>2) {
4737: int i=1;
4738: grid_top = 10 - vertical_scroll + getZoomedDim(i*this.gridSize);
4739: while (grid_top < line_bottom ) {
4740: g.drawLine(line_left,grid_top,line_right,grid_top);
4741: i++;
4742: grid_top = 10 - vertical_scroll + getZoomedDim(i*this.gridSize);
4743: }
4744: }
4745:
4746:
4747: */
4748: Stroke defaultStroke = g.getStroke();
4749: float[] fArray = { 2f, 2f };
4750: BasicStroke m_Dashed3 = new BasicStroke(1,
4751: BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL,
4752: 1.0f, fArray, 0.0f);
4753: g.setStroke(m_Dashed3);
4754:
4755: int zoomed_grid_size = getZoomedDim(this .getGridSize());
4756:
4757: // mGridTexture is a member of type TexturePaint
4758: if (mGridTexture == null
4759: || mGridTexture.getImage().getWidth() != zoomed_grid_size) {
4760: BufferedImage img = new BufferedImage(zoomed_grid_size,
4761: zoomed_grid_size, BufferedImage.TYPE_INT_RGB);
4762:
4763: Graphics2D g2 = img.createGraphics();
4764:
4765: g2.setColor(Color.WHITE);
4766: g2.fillRect(0, 0, zoomed_grid_size, zoomed_grid_size);
4767:
4768: g2.setColor(new Color(230, 230, 230));
4769: g2.setStroke(m_Dashed3);
4770:
4771: g2.drawLine(zoomed_grid_size - 1, 0,
4772: zoomed_grid_size - 1, zoomed_grid_size - 1);
4773:
4774: g2.drawLine(0, zoomed_grid_size - 1,
4775: zoomed_grid_size - 1, zoomed_grid_size - 1);
4776:
4777: mGridTexture = new TexturePaint(img, new Rectangle(10,
4778: 10, zoomed_grid_size, zoomed_grid_size));
4779:
4780: } // if
4781:
4782: Paint oldPaint = g.getPaint();
4783: g.setPaint(mGridTexture);
4784:
4785: g.translate(-horizontal_scroll, -vertical_scroll);
4786:
4787: g.fillRect(10, 10, zoomed_width - 1, zoomed_height - 1);
4788:
4789: g.translate(horizontal_scroll, vertical_scroll);
4790:
4791: g.setPaint(oldPaint);
4792: g.setStroke(defaultStroke);
4793: }
4794:
4795: // Draw document structure lines...
4796: g.setColor(new Color(170, 170, 255));
4797: // LEFT MARGINE LINE
4798: g.drawLine(getZoomedDim(report.getLeftMargin()) + 10
4799: - horizontal_scroll, 10 - vertical_scroll,
4800: getZoomedDim(report.getLeftMargin()) + 10
4801: - horizontal_scroll, zoomed_height + 10
4802: - vertical_scroll - 2);
4803:
4804: // RIGHT MARGIN LINE
4805: g.drawLine(getZoomedDim(report.getWidth()
4806: - report.getRightMargin())
4807: + 10 - horizontal_scroll, 10 - vertical_scroll,
4808: getZoomedDim(report.getWidth()
4809: - report.getRightMargin())
4810: + 10 - horizontal_scroll, zoomed_height + 10
4811: - vertical_scroll - 2);
4812:
4813: g.drawLine(10 - horizontal_scroll, getZoomedDim(report
4814: .getTopMargin())
4815: + 10 - vertical_scroll, zoomed_width + 10
4816: - horizontal_scroll - 2, getZoomedDim(report
4817: .getTopMargin())
4818: + 10 - vertical_scroll);
4819:
4820: g.drawLine(10 - horizontal_scroll, getZoomedDim(design_height
4821: - report.getBottomMargin())
4822: + 10 - vertical_scroll, zoomed_width + 10
4823: - horizontal_scroll - 2, getZoomedDim(design_height
4824: - report.getBottomMargin())
4825: + 10 - vertical_scroll);
4826:
4827: int y = report.getTopMargin();
4828:
4829: Band page_header = null;
4830: Band page_footer = null;
4831:
4832: Enumeration e = report.getBands().elements();
4833: while (e.hasMoreElements()) {
4834: g.setColor(new Color(170, 170, 170));
4835: Band band = (Band) e.nextElement();
4836: y += band.getHeight();
4837: g.drawLine(10 - horizontal_scroll, getZoomedDim(y) + 10
4838: - vertical_scroll, zoomed_width + 10
4839: - horizontal_scroll - 2, getZoomedDim(y) + 10
4840: - vertical_scroll);
4841:
4842: g.setFont(new Font("Arial", Font.PLAIN, getZoomedDim(20)));
4843: // We must center the text..
4844: int txt_width = g.getFontMetrics().stringWidth(
4845: band.getName()) / 2;
4846: int txt_height = g.getFontMetrics().getHeight() / 2;
4847: txt_height -= g.getFontMetrics().getMaxDescent();
4848: g.setColor(new Color(220, 220, 255));
4849: /*
4850: g.setClip(getZoomedDim(report.getLeftMargin())+10-horizontal_scroll,
4851: getZoomedDim(y-band.getHeight())+10-vertical_scroll,
4852: getZoomedDim(report.getWidth()),
4853: getZoomedDim(band.getHeight()));
4854: */
4855: //Rectangle orgClipBounds = g.getClipBounds();
4856: Java2DUtil.setClip(g, getZoomedDim(report.getLeftMargin())
4857: + 10 - horizontal_scroll, getZoomedDim(y
4858: - band.getHeight())
4859: + 10 - vertical_scroll, getZoomedDim(report
4860: .getWidth()), getZoomedDim(band.getHeight()));
4861: /*
4862: g.setClip(getZoomedDim(report.getLeftMargin())+10-horizontal_scroll,
4863: getZoomedDim(y-band.getHeight())+10-vertical_scroll,
4864: getZoomedDim(report.getWidth()),
4865: getZoomedDim(band.getHeight()));
4866: */
4867:
4868: g.drawString(band.getName(),
4869: getZoomedDim(report.getWidth() / 2) + 10
4870: - horizontal_scroll - txt_width,
4871: getZoomedDim(y) + 10 - vertical_scroll + txt_height
4872: - getZoomedDim(band.getHeight() / 2)); //, zoomed_width, getZoomedDim(band.getHeight()
4873: //g.drawLine(0, getZoomedDim(y)+10-vertical_scroll - txt_height - getZoomedDim(band.getHeight()/2), 700,getZoomedDim(y)+10-vertical_scroll - txt_height - getZoomedDim(band.getHeight()/2));
4874: //g.drawLine(0, getZoomedDim(y)+10-vertical_scroll + txt_height - getZoomedDim(band.getHeight()/2), 700,getZoomedDim(y)+10-vertical_scroll + txt_height - getZoomedDim(band.getHeight()/2));
4875:
4876: /* g.setClip(null); */
4877:
4878: //g.setClip(orgClipBounds);
4879: Java2DUtil.resetClip(g);
4880:
4881: if (band.getName().equals("pageHeader"))
4882: page_header = band;
4883: if (band.getName().equals("pageFooter"))
4884: page_footer = band;
4885: }
4886:
4887: // PAint columns...
4888: int y1 = report.getBandYLocation(report
4889: .getBandByName("columnHeader"));
4890: int y2 = report.getBandYLocation(page_footer);
4891:
4892: for (int i = 0; i < report.getColumnCount() - 1; ++i) {
4893: int x = 10 + getZoomedDim(report.getLeftMargin()
4894: + report.getColumnWidth()
4895: + i
4896: * (report.getColumnWidth() + report
4897: .getColumnSpacing()));
4898: //if (i !=0 ) {
4899: //}
4900: if (x < 10 + zoomed_width)
4901: g.drawLine(x - horizontal_scroll, getZoomedDim(y1) + 10
4902: - vertical_scroll, x - horizontal_scroll,
4903: getZoomedDim(y2) + 10 - vertical_scroll);
4904: x = 10 + getZoomedDim(report.getLeftMargin()
4905: + report.getColumnWidth()
4906: + report.getColumnSpacing()
4907: + i
4908: * (report.getColumnWidth() + report
4909: .getColumnSpacing()));
4910:
4911: if (x < 10 + zoomed_width)
4912: g.drawLine(x - horizontal_scroll, getZoomedDim(y1) + 10
4913: - vertical_scroll, x - horizontal_scroll,
4914: getZoomedDim(y2) + 10 - vertical_scroll);
4915: }
4916: /*
4917: g.setPen(new Pen(new Color(170,170,255)));
4918: g.drawLine( 10,getZoomedDim(report.topMargin)+10, getZoomedDim(report.getPagesize().x)+10, getZoomedDim(report.topMargin)+10);
4919: g.drawLine( 10,getZoomedDim(report.getDesignHeight())- getZoomedDim(report.topMargin)+10, getZoomedDim(report.getPagesize().x)+10,getZoomedDim(report.getDesignHeight())- getZoomedDim(report.topMargin)+10);
4920: */
4921: // g.setPen(new Pen(Color.BLACK ));
4922: // Draw guide lines...
4923: Stroke oldStroke = g.getStroke();
4924: g.setStroke(jHorizontalRule.getDottedStroke());
4925: g.setColor(Color.BLACK);
4926: g.setXORMode(java.awt.Color.YELLOW);
4927: for (int i = 0; i < jHorizontalRule.getGuideLines().size(); ++i) {
4928: Integer pos = (Integer) jHorizontalRule.getGuideLines()
4929: .get(i);
4930: int posI = pos.intValue();
4931: // Calc posI....
4932: posI = 10 + (int) (posI * getZoomFactor()) - getHScroll();
4933: g.drawLine(posI, 0, posI, getHeight());
4934: }
4935:
4936: for (int i = 0; i < jVerticalRule.getGuideLines().size(); ++i) {
4937: Integer pos = (Integer) jVerticalRule.getGuideLines()
4938: .get(i);
4939: int posI = pos.intValue();
4940: // Calc posI....
4941: posI = 10 + (int) (posI * getZoomFactor()) - getVScroll();
4942: g.drawLine(0, posI, getWidth(), posI);
4943: }
4944: g.setPaintMode();
4945: g.setStroke(oldStroke);
4946:
4947: isDocDirty = false;
4948: }
4949:
4950: public int getReversedZoomedDim(int dim) {
4951: if (zoomFactor == 1.0)
4952: return dim;
4953: return (int) ((double) dim / zoomFactor);
4954: }
4955:
4956: public int getZoomedDim(int dim) {
4957: if (zoomFactor == 1.0)
4958: return dim;
4959: //if (((double)dim*(double)zoom_factor)<0.5) return 1;
4960: // Truncate, don't round!!
4961: return (int) ((double) dim * zoomFactor);
4962: //return (int)Math.ceil((double)dim*zoom_factor);
4963: }
4964:
4965: public int getLogicalDim(int dim) {
4966: if (zoomFactor == 1.0)
4967: return dim;
4968: //if (Math.abs( ((double)dim/(double)zoom_factor)) < 1 &&
4969: // Math.abs( ((double)dim/(double)zoom_factor)) > 0) return 1;
4970: // Truncate, don't round!!
4971: return (int) ((double) dim / zoomFactor);
4972: //return (int)Math.ceil((double)dim/zoom_factor);
4973: }
4974:
4975: /** Getter for property zoomFactor.
4976: * @return Value of property zoomFactor.
4977: *
4978: */
4979: public double getZoomFactor() {
4980: return zoomFactor;
4981: }
4982:
4983: /** Setter for property zoomFactor.
4984: * @param zoomFactor New value of property zoomFactor.
4985: *
4986: */
4987: public void setZoomFactor(double zoomFactor) {
4988:
4989: floatingTextAreaFocusLost();
4990: if (getSelectedCrosstabEditorPanel() != null) {
4991: getSelectedCrosstabEditorPanel().setZoomFactor(zoomFactor);
4992: } else {
4993: if (this .zoomFactor != zoomFactor) {
4994: this .zoomFactor = zoomFactor;
4995: this
4996: .jPanelReportComponentResized(new java.awt.event.ComponentEvent(
4997: jPanelReport, 0));
4998: isDocDirty = true;
4999: this .getReportPanel().repaint();
5000: this .jHorizontalRule.repaint();
5001: this .jVerticalRule.repaint();
5002: }
5003: }
5004: }
5005:
5006: public void updateAntialiasMode() {
5007: this .getReportPanel().repaint();
5008: }
5009:
5010: public void paintReportPanel(Graphics g) {
5011: /*
5012: redrawAll(offscreen ,null, 0);
5013: g.drawImage( offscreenImage , 0,0, offscreenImage.getWidth(), offscreenImage.getHeight(), (ImageObserver)this);
5014: */
5015:
5016: try {
5017: Graphics2D g2 = (Graphics2D) g;
5018:
5019: if (this .getMainFrame().getProperties().getProperty(
5020: "Antialias", "true").equals("false")) {
5021:
5022: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
5023: RenderingHints.VALUE_ANTIALIAS_OFF);
5024: g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
5025: RenderingHints.VALUE_STROKE_PURE);
5026: g2.setRenderingHint(RenderingHints.KEY_DITHERING,
5027: RenderingHints.VALUE_DITHER_DISABLE);
5028: } else {
5029:
5030: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
5031: RenderingHints.VALUE_ANTIALIAS_ON);
5032: g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
5033: RenderingHints.VALUE_STROKE_DEFAULT);
5034: g2.setRenderingHint(RenderingHints.KEY_DITHERING,
5035: RenderingHints.VALUE_DITHER_ENABLE);
5036: }
5037:
5038: //long start = System.currentTimeMillis();
5039: //int number = 1;
5040: //System.out.println("redrawAll: (clip=" + g2.getClipRect() + ")");
5041: //for(int i=0; i<number; i++)
5042: //{
5043:
5044: //System.out.println("redrawAll: (clip=" + g2.getClipRect() + ")");
5045: //g2.setClip(this.getWidth()-150, 0, 150, this.getHeight());
5046: redrawAll(g2, g2.getClipRect(), 0);
5047: //}
5048: //long stop = System.currentTimeMillis();
5049: //System.out.println(number + " paints took " + ((stop - start) / 1000.0) + " seconds");
5050:
5051: } catch (Throwable ex) {
5052: ex.printStackTrace();
5053: }
5054: }
5055:
5056: /**
5057: * Return the point in component coordinate as
5058: * point inside the report.
5059: */
5060: public Point getLogicalPoint(Point p) {
5061: Point newP = new Point();
5062: newP.x = getReversedZoomedDim(p.x - 10
5063: + jHorizontalScrollBar.getValue());
5064: newP.y = getReversedZoomedDim(p.y - 10
5065: + jVerticalScrollBar.getValue());
5066: return newP;
5067: }
5068:
5069: /**
5070: * Return true if the point in component coordinate is inside the document...
5071: */
5072: public boolean isInsideDocument(Point p) {
5073: Point newP = getLogicalPoint(p);
5074: return (newP.x >= 0 && newP.x < getReport().getWidth()
5075: && newP.y >= 0 && newP.y < getReport()
5076: .getDesignHeight());
5077: }
5078:
5079: //iR20 private ImageIcon background = new javax.swing.ImageIcon(ImageIcon.class.getResource("/it/businesslogic/ireport/gui/wp.jpg" ));
5080:
5081: private void redrawAll(Graphics2D g, Rectangle clipRect, int margin) {
5082:
5083: if (isRedrawWithBufferedImage()) {
5084: g.setClip(clipRect);
5085: g.drawImage(offscreenImage, 0, 0, null);
5086: return;
5087: }
5088:
5089: //g.clearRect(0,0,offscreenImage.getWidth(), offscreenImage.getHeight());
5090: //System.out.println("redraw all "+clipRect);
5091: if (clipRect == null) {
5092: clipRect = new Rectangle(0, 0, jPanelReport.getWidth(),
5093: this .getReport().getDesignHeight());
5094: //this.getReport().getWidth()
5095: }
5096:
5097: //clipRect.x += jHorizontalScrollBar.getValue();
5098: //clipRect.y += jVerticalScrollBar.getValue();
5099: //g.setClip(clipRect);
5100:
5101: g.clearRect(0, 0, (int) clipRect.getWidth(), (int) clipRect
5102: .getHeight());
5103:
5104: /*
5105: = new Rectangle( getZoomedDim2(clipRect.x-10 - margin)+ margin +10 + jHorizontalScrollBar.getValue(),
5106: getZoomedDim2(clipRect.y-10 - margin)+ margin +10 + jVerticalScrollBar.getValue(),
5107: getZoomedDim2(clipRect.width-2*margin)+2*margin,
5108: getZoomedDim2(clipRect.height-2*margin)+2*margin);
5109: */
5110: Rectangle realRect = new Rectangle(
5111: getReversedZoomedDim(clipRect.x - 10 - margin
5112: + jHorizontalScrollBar.getValue())
5113: + margin + 10, getReversedZoomedDim(clipRect.y
5114: - 10 - margin + jVerticalScrollBar.getValue())
5115: + margin + 10,
5116: getReversedZoomedDim(clipRect.width - 2 * margin) + 2
5117: * margin, getReversedZoomedDim(clipRect.height
5118: - 2 * margin)
5119: + 2 * margin);
5120:
5121: /*
5122: realRect = new Rectangle(
5123: getZoomedDim2(clipRect.x + jHorizontalScrollBar.getValue()) + margin,
5124: getZoomedDim2(clipRect.y + jVerticalScrollBar.getValue()) + margin,
5125: getZoomedDim2(clipRect.width),
5126: getZoomedDim2(clipRect.height));
5127: */
5128:
5129: //g.setPaint(Color.CYAN);
5130: //g.fillRect( 0 ,0,offscreenWidth ,offscreenDimension.height);
5131: //
5132: // 1. Draw the void document...
5133: //g.setClip( realRect );
5134: drawVoidDoc(g);
5135:
5136: /*
5137: g.drawImage( offscreenImageDoc , clipRect.x,clipRect.y, clipRect.x + clipRect.width, clipRect.y + clipRect.height,
5138: clipRect.x,clipRect.y, clipRect.x + clipRect.width, clipRect.y + clipRect.height, (ImageObserver)this);
5139: */
5140: // g.drawImage( offscreenImageDoc , 0,0, offscreenImageDoc.getWidth(), offscreenImageDoc.getHeight(), (ImageObserver)this);
5141: //g.setClip( realRect );
5142: // 2. Draw all Reportelements...
5143: Enumeration e = report.getElements().elements();
5144: while (e.hasMoreElements()) {
5145: ReportElement re = (ReportElement) e.nextElement();
5146: if (re.intersects(realRect)
5147: || re instanceof BreakReportElement)
5148: re.drawObject(g, getZoomFactor(), jHorizontalScrollBar
5149: .getValue(), jVerticalScrollBar.getValue());
5150: }
5151:
5152: // If there's a selected element, draw a corona
5153: if (selectedElements.size() > 0) {
5154: //clipRect.x -=5;
5155: //clipRect.y -=5;
5156: //clipRect.width +=10;
5157: //clipRect.height +=10;
5158: e = selectedElements.elements();
5159: boolean master = true;
5160: while (e.hasMoreElements()) {
5161: ReportElement re = (ReportElement) e.nextElement();
5162: if (re.intersects(realRect))
5163: re.drawCorona(g, getZoomFactor(),
5164: jHorizontalScrollBar.getValue(),
5165: jVerticalScrollBar.getValue(), master);
5166: master = false;
5167: }
5168: }
5169:
5170: //g.setPaint(Color.CYAN);
5171: //g.fillRect(realRect.x, realRect.y, realRect.width-2, realRect.height-2);
5172:
5173: }
5174:
5175: public MainFrame getMainFrame() {
5176: if (mf != null)
5177: return mf;
5178: // Retrieve parent while != MainFrame
5179: Container parent = this .getDesktopPane().getParent();
5180: while (parent != null && !(parent instanceof MainFrame)) {
5181: parent = parent.getParent();
5182: }
5183: if (parent != null) {
5184: mf = (MainFrame) parent;
5185: return mf;
5186: } else
5187: return null;
5188: }
5189:
5190: /** Getter for property lensMode.
5191: * @return Value of property lensMode.
5192: *
5193: */
5194: public boolean isLensMode() {
5195: return lensMode;
5196: }
5197:
5198: /** Setter for property lensMode.
5199: * @param lensMode New value of property lensMode.
5200: *
5201: */
5202: public void setLensMode(boolean lensMode) {
5203: //
5204: if (this .lensMode == lensMode)
5205: return;
5206: if (lensMode == true)
5207: jPanelReport.setCursor(java.awt.Cursor.getDefaultCursor());
5208: else {
5209: //if (getShiftState())
5210: //if (this.is
5211: // panel9.setCursor(cursorminus );
5212: // else
5213: // panel9.setCursor(cursorplus);
5214: }
5215: this .lensMode = lensMode;
5216: }
5217:
5218: /** Getter for property newObjectType.
5219: * @return Value of property newObjectType.
5220: *
5221: */
5222: public int getNewObjectType() {
5223: return newObjectType;
5224: }
5225:
5226: /** Setter for property newObjectType.
5227: * @param newObjectType New value of property newObjectType.
5228: *
5229: */
5230: public void setNewObjectType(int newObjectType) {
5231:
5232: if (this .newObjectType == newObjectType)
5233: return;
5234:
5235: if (newObjectType == ReportElementType.NONE) {
5236: /*
5237: if (!first_draw2) panel9.createGraphics().drawLines(new Point[]{new Point(ne.x, ne.y),new Point(mouse.x, ne.y),new Point(mouse.x, mouse.y),new Point(ne.x, mouse.y),new Point(ne.x, ne.y)},RasterOp.SOURCE.xorWith(RasterOp.TARGET));
5238: first_draw2 = true;
5239: panel9.setCursor(Cursor.DEFAULT);
5240: ne = null;
5241: */
5242: jPanelReport.setCursor(java.awt.Cursor.getDefaultCursor());
5243: } else {
5244: jPanelReport
5245: .setCursor(java.awt.Cursor
5246: .getPredefinedCursor(java.awt.Cursor.CROSSHAIR_CURSOR));
5247: }
5248: this .newObjectType = newObjectType;
5249:
5250: for (int i = 1; i < jTabbedPane1.getTabCount(); ++i) {
5251: if (jTabbedPane1.getComponentAt(i) instanceof CrosstabEditor) {
5252: CrosstabEditor ce = (CrosstabEditor) jTabbedPane1
5253: .getComponentAt(i);
5254: ce.getPanelEditor().setNewObjectType(newObjectType);
5255: }
5256: }
5257: }
5258:
5259: public void setSelectedElement(ReportElement el, boolean fireEvent) {
5260: // Cancello le corone attorno a tutti gli elementi selezionati...
5261: boolean makerefreshAll = false;
5262: //if (selectedElements.size() > 0)
5263: makerefreshAll = true;
5264:
5265: getSelectedElements().removeAllElements();
5266:
5267: // getMainFrame().getElementPropertiesDialog().updateSelection();
5268: /*
5269: while (selectedElements.size() > 0)
5270: {
5271:
5272:
5273: ReportElement re = (ReportElement)selectedElements.elementAt(0);
5274: selectedElements.removeElementAt(0);
5275:
5276: if (makerefreshAll) continue;
5277:
5278: Rectangle rect = new Rectangle(re.position.x-5,re.position.y-5,re.width+10, re.height+10);
5279:
5280: redrawAll(offscreen ,rect,5);
5281: Rectangle clipRect = new Rectangle(getZoomedDim(re.position.x-10)-5+10-jHorizontalScrollBar.getValue(),
5282: getZoomedDim(re.position.y-10)-5+10-jVerticalScrollBar.getValue(),
5283: getZoomedDim(re.width)+10,
5284: getZoomedDim(re.height)+10);
5285: jPanelReport.getGraphics().drawImage( offscreenImage ,
5286: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5287: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5288: (ImageObserver)this);
5289:
5290: }
5291: */
5292:
5293: if (el != null) {
5294: Rectangle rect = new Rectangle(el.position.x - 5,
5295: el.position.y - 5, el.width + 10, el.height + 10);
5296: selectedElements.addElement(el);
5297:
5298: getMainFrame().setCutCopyEnabled(true);
5299: /*
5300: if (!makerefreshAll)
5301: {
5302: redrawAll(offscreen ,rect,5);
5303: Rectangle clipRect = new Rectangle(getZoomedDim(el.position.x-10)-5+10-jHorizontalScrollBar.getValue(),
5304: getZoomedDim(el.position.y-10)-5+10-jVerticalScrollBar.getValue(),
5305: getZoomedDim(el.width)+10,
5306: getZoomedDim(el.height)+10);
5307:
5308: jPanelReport.getGraphics().drawImage( offscreenImage ,
5309: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5310: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5311: (ImageObserver)this);
5312: }
5313: */
5314: } else {
5315: getMainFrame().setCutCopyEnabled(false);
5316: }
5317:
5318: if (makerefreshAll) {
5319: jPanelReport.repaint();
5320: }
5321:
5322: /*
5323: MainForm mf = (MainForm)this.getMDIParent();
5324: if (mf != null)
5325: {
5326: if (mf.isPropertiesOpened())
5327: {
5328: mf.initReportForm();
5329: mf.ep.setEelement(this,getSelectedElements());
5330: mf.ep.setVisible(true);
5331: }
5332: }
5333: */
5334:
5335: if (fireEvent) {
5336: ReportElementsSelectionEvent rece = new ReportElementsSelectionEvent(
5337: this , this .getSelectedElements());
5338:
5339: this .fireReportListenerReportElementsSelectionChanged(rece);
5340:
5341: getMainFrame().getElementPropertiesDialog()
5342: .updateSelection();
5343:
5344: }
5345:
5346: }
5347:
5348: public void updateObjectMagnetics() {
5349: verticalObjectsLines.clear();
5350: horizontalObjectsLines.clear();
5351:
5352: if (MainFrame.getMainInstance().getMagnetEnabled()) {
5353: Enumeration enum_rep = getReport().getElements().elements();
5354: while (enum_rep.hasMoreElements()) {
5355: ReportElement re = (ReportElement) enum_rep
5356: .nextElement();
5357: if (!getSelectedElements().contains(re)) {
5358: Integer in = new Integer(re.getPosition().x);
5359: if (!verticalObjectsLines.contains(in))
5360: verticalObjectsLines.add(in);
5361: in = new Integer(re.getPosition().x + re.getWidth());
5362: if (!verticalObjectsLines.contains(in))
5363: verticalObjectsLines.add(in);
5364:
5365: in = new Integer(re.getPosition().y);
5366: if (!horizontalObjectsLines.contains(in))
5367: horizontalObjectsLines.add(in);
5368: in = new Integer(re.getPosition().y
5369: + re.getHeight());
5370: if (!horizontalObjectsLines.contains(in))
5371: horizontalObjectsLines.add(in);
5372: }
5373: }
5374:
5375: // add bands locations...
5376: Enumeration enum_bands = getReport().getBands().elements();
5377: while (enum_bands.hasMoreElements()) {
5378: Band band = (Band) enum_bands.nextElement();
5379:
5380: Integer in = new Integer(band.getBandYLocation() + 10);
5381: if (!horizontalObjectsLines.contains(in))
5382: horizontalObjectsLines.add(in);
5383: }
5384:
5385: Integer in = new Integer(getReport().getLeftMargin() + 10);
5386: if (!verticalObjectsLines.contains(in))
5387: verticalObjectsLines.add(in);
5388:
5389: in = new Integer(getReport().getWidth()
5390: - getReport().getLeftMargin() + 10);
5391: if (!verticalObjectsLines.contains(in))
5392: verticalObjectsLines.add(in);
5393:
5394: in = new Integer(getReport().getTopMargin() + 10);
5395: if (!horizontalObjectsLines.contains(in))
5396: horizontalObjectsLines.add(in);
5397:
5398: try {
5399: MAGNETIC_POWER = Integer.parseInt(this .getMainFrame()
5400: .getProperties().getProperty("MagneticPower",
5401: "5"));
5402: } catch (Exception ex) {
5403: }
5404:
5405: } else {
5406: MAGNETIC_POWER = 0;
5407: }
5408:
5409: }
5410:
5411: public void setSelectedElement(ReportElement el) {
5412: setSelectedElement(el, true);
5413: }
5414:
5415: public void fireSelectionChangedEvent() {
5416: ReportElementsSelectionEvent rece = new ReportElementsSelectionEvent(
5417: this , this .getSelectedElements());
5418:
5419: this .fireReportListenerReportElementsSelectionChanged(rece);
5420: getMainFrame().getElementPropertiesDialog().updateSelection();
5421: }
5422:
5423: public void addSelectedElement(ReportElement el) {
5424: addSelectedElement(el, true);
5425: }
5426:
5427: public void addSelectedElement(ReportElement el, boolean fireEvent) {
5428: if (selectedElements.contains(el))
5429: return;
5430: //label1.setText("ADDED");
5431: // Faccio una corona non selected attorno al nuovo elemento...
5432: Rectangle rect = new Rectangle(el.position.x - 5,
5433: el.position.y - 5, el.width + 10, el.height + 10);
5434: selectedElements.addElement(el);
5435: /*
5436: redrawAll(offscreen ,rect,5);
5437: Rectangle clipRect = new Rectangle(getZoomedDim(el.position.x-10)-5+10-jHorizontalScrollBar.getValue(),
5438: getZoomedDim(el.position.y-10)-5+10-jVerticalScrollBar.getValue(),
5439: getZoomedDim(el.width)+10,
5440: getZoomedDim(el.height)+10);
5441: jPanelReport.getGraphics().drawImage( offscreenImage ,
5442: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5443: clipRect.x ,clipRect.y, clipRect.width,clipRect.height,
5444: (ImageObserver)this);
5445: */
5446: jPanelReport.repaint();
5447:
5448: if (fireEvent) {
5449: fireSelectionChangedEvent();
5450: }
5451:
5452: getMainFrame().setCutCopyEnabled(true);
5453: }
5454:
5455: /** Getter for property jPanelReport.
5456: * @return Value of property jPanelReport.
5457: *
5458: */
5459: public it.businesslogic.ireport.gui.JReportPanel getJPanelReport() {
5460: return jPanelReport;
5461: }
5462:
5463: /** Setter for property jPanelReport.
5464: * @param jPanelReport New value of property jPanelReport.
5465: *
5466: */
5467: public void setJPanelReport(
5468: it.businesslogic.ireport.gui.JReportPanel jPanelReport) {
5469: this .jPanelReport = jPanelReport;
5470: }
5471:
5472: /** Getter for property showGrid.
5473: * @return Value of property showGrid.
5474: *
5475: */
5476: public boolean isShowGrid() {
5477: return showGrid;
5478: }
5479:
5480: /** Setter for property showGrid.
5481: * @param showGrid New value of property showGrid.
5482: *
5483: */
5484: public void setShowGrid(boolean showGrid) {
5485:
5486: if (this .showGrid == showGrid)
5487: return;
5488:
5489: this .showGrid = showGrid;
5490: isDocDirty = true;
5491: jPanelReport.repaint();
5492: }
5493:
5494: /** Getter for property gridSize.
5495: * @return Value of property gridSize.
5496: *
5497: */
5498: public int getGridSize() {
5499: try {
5500: return Integer.parseInt(MainFrame.getMainInstance()
5501: .getProperties().getProperty("GridSize", "10"));
5502: } catch (Exception ex) {
5503: return 60;
5504: }
5505: }
5506:
5507: /** Getter for property transformationMinSize.
5508: * @return Value of property transformationMinSize.
5509: *
5510: */
5511: public int getTransformationMinSize() {
5512: return transformationMinSize;
5513: }
5514:
5515: /** Setter for property transformationMinSize.
5516: * @param transformationMinSize New value of property transformationMinSize.
5517: *
5518: */
5519: public void setTransformationMinSize(int transformationMinSize) {
5520: this .transformationMinSize = transformationMinSize;
5521: }
5522:
5523: public int snapToGridVertically(int scaledYPoint) {
5524:
5525: int real_o_y = getLogicalDim((int) (scaledYPoint
5526: + jVerticalScrollBar.getValue() - 10)) + 10;
5527:
5528: return getZoomedDim(closestXMagneticElement(real_o_y,
5529: getGridSize(), jVerticalRule.getGuideLines()) - 10)
5530: + 10 - getVScroll();
5531:
5532: /*
5533: if (!isSnapToGrid()) return scaledYPoint;
5534:
5535: int vertical_scroll = jVerticalScrollBar.getValue();
5536: int zoomed_grid_size = getZoomedDim(this.getGridSize());
5537: int grid_top = 10+ zoomed_grid_size - vertical_scroll;
5538: int design_height = report.getDesignHeight();
5539: int line_bottom = getZoomedDim(design_height)+10-vertical_scroll-2;
5540:
5541: if (zoomed_grid_size>2) {
5542: int i=1;
5543: while (grid_top < line_bottom ) {
5544: if ( Math.abs(grid_top - scaledYPoint) <= zoomed_grid_size/2) {
5545: return grid_top;
5546: }
5547: i++;
5548: grid_top = 10 - vertical_scroll + getZoomedDim(i*this.getGridSize());
5549: }
5550: }
5551: return scaledYPoint;
5552: */
5553: }
5554:
5555: public int snapToGridOrizzontally(int scaledXPoint) {
5556:
5557: int real_o_x = getLogicalDim((int) (scaledXPoint
5558: + jHorizontalScrollBar.getValue() - 10)) + 10;
5559:
5560: return getZoomedDim(closestXMagneticElement(real_o_x,
5561: getGridSize(), jHorizontalRule.getGuideLines()) - 10)
5562: + 10 - getHScroll();
5563: /*
5564: if (!isSnapToGrid()) return scaledXPoint;
5565: // get closest horizontal grid to the
5566: // get closest vetical grid to the
5567: int horizontal_scroll = jHorizontalScrollBar.getValue();
5568: //int vertical_scroll = jVerticalScrollBar.getValue();
5569: int zoomed_width = getZoomedDim(report.getWidth());
5570: //int design_height = report.getDesignHeight();
5571: //int zoomed_height = getZoomedDim(design_height);
5572: int zoomed_grid_size = getZoomedDim(this.getGridSize());
5573: int grid_left = 10+ zoomed_grid_size - horizontal_scroll;
5574:
5575: //int line_bottom = getZoomedDim(design_height)+10-vertical_scroll-2;
5576: if (zoomed_grid_size>2) {
5577: int i=1;
5578: while (grid_left < zoomed_width+10-horizontal_scroll) {
5579: if ( Math.abs(grid_left - scaledXPoint) <= zoomed_grid_size/2) {
5580: return grid_left;
5581: }
5582: i++;
5583: grid_left = 10 - horizontal_scroll + getZoomedDim(i*this.getGridSize());
5584: }
5585: }
5586: return scaledXPoint;
5587: */
5588: }
5589:
5590: public int gridMultiple(int zoomedDim) {
5591: if (!isSnapToGrid()) {
5592: return zoomedDim;
5593: }
5594:
5595: int zoomedGridSize = getZoomedDim(this .getGridSize());
5596: double val = Math.abs(zoomedDim);
5597: if (zoomedGridSize > 1.0) {
5598: val = Math.floor((val + (0.5 * zoomedGridSize))
5599: / zoomedGridSize)
5600: * zoomedGridSize;
5601: }
5602:
5603: return (int) ((zoomedDim >= 0) ? val : -val);
5604: }
5605:
5606: // no need for gridMultipleMinues
5607: /*
5608: public int gridMultipleMinus( int zoomedDim) {
5609: // Round ++...
5610: if (!isSnapToGrid()) {
5611: return zoomedDim;
5612: }
5613:
5614: int zoomed_grid_size = getZoomedDim(this.gridSize);
5615: int val = Math.abs(zoomedDim);
5616: if (val%zoomed_grid_size == 0) {
5617: return zoomedDim;
5618: }
5619: if( val%zoomed_grid_size <= zoomed_grid_size/2) {
5620: while ( val%zoomed_grid_size != 0) {
5621: val--;
5622: }
5623: }
5624: else {
5625: while ( val%zoomed_grid_size != 0) {
5626: val++;
5627: }
5628: }
5629: return (zoomedDim >= 0) ? val : -val;
5630: }
5631: */
5632:
5633: /** Getter for property snapToGrid.
5634: * @return Value of property snapToGrid.
5635: *
5636: */
5637: public boolean isSnapToGrid() {
5638: return snapToGrid;
5639: }
5640:
5641: /** Setter for property snapToGrid.
5642: * @param snapToGrid New value of property snapToGrid.
5643: *
5644: */
5645: public void setSnapToGrid(boolean snapToGrid) {
5646: this .snapToGrid = snapToGrid;
5647: }
5648:
5649: /** Getter for property isDocDirty.
5650: * @return Value of property isDocDirty.
5651: *
5652: */
5653: public boolean isIsDocDirty() {
5654: return isDocDirty;
5655: }
5656:
5657: /** Setter for property isDocDirty.
5658: * @param isDocDirty New value of property isDocDirty.
5659: *
5660: */
5661: public void setIsDocDirty(boolean isDocDirty) {
5662: this .isDocDirty = isDocDirty;
5663: }
5664:
5665: public void checkSelection(boolean repaint) {
5666: boolean needRepaint = false;
5667: for (int i = 0; i < getSelectedElements().size(); ++i) {
5668: // Delete all objects that don't exists..
5669: ReportElement selected = (ReportElement) getSelectedElements()
5670: .get(i);
5671: if (!this .getReport().getElements().contains(selected)) {
5672: getSelectedElements().removeElementAt(i);
5673: i--;
5674: needRepaint = true;
5675: }
5676: }
5677: if (repaint && needRepaint) {
5678: jPanelReport.repaint();
5679: }
5680: }
5681:
5682: /** Getter for property windowID.
5683: * @return Value of property windowID.
5684: *
5685: */
5686: public int getWindowID() {
5687: return windowID;
5688: }
5689:
5690: /** Setter for property windowID.
5691: * @param windowID New value of property windowID.
5692: *
5693: */
5694: public void setWindowID(int windowID) {
5695: this .windowID = windowID;
5696: }
5697:
5698: /** Registers ReportListener to receive events.
5699: * @param listener The listener to register.
5700: *
5701: */
5702: public synchronized void addReportListener(
5703: it.businesslogic.ireport.gui.event.ReportListener listener) {
5704: if (listenerList == null) {
5705: listenerList = new javax.swing.event.EventListenerList();
5706: }
5707: listenerList
5708: .add(
5709: it.businesslogic.ireport.gui.event.ReportListener.class,
5710: listener);
5711: }
5712:
5713: /** Removes ReportListener from the list of listeners.
5714: * @param listener The listener to remove.
5715: *
5716: */
5717: synchronized void removeReportListener(
5718: it.businesslogic.ireport.gui.event.ReportListener listener) {
5719: listenerList
5720: .remove(
5721: it.businesslogic.ireport.gui.event.ReportListener.class,
5722: listener);
5723: }
5724:
5725: /** Notifies all registered listeners about the event.
5726: *
5727: * @param event The event to be fired
5728: *
5729: */
5730: public void fireReportListenerReportElementsSelectionChanged(
5731: it.businesslogic.ireport.gui.event.ReportElementsSelectionEvent event) {
5732:
5733: if (listenerList == null)
5734: return;
5735: Object[] listeners = listenerList.getListenerList();
5736: for (int i = listeners.length - 2; i >= 0; i -= 2) {
5737: if (listeners[i] == it.businesslogic.ireport.gui.event.ReportListener.class) {
5738: ((it.businesslogic.ireport.gui.event.ReportListener) listeners[i + 1])
5739: .reportElementsSelectionChanged(event);
5740: }
5741: }
5742: }
5743:
5744: /** Notifies all registered listeners about the event.
5745: *
5746: * @param event The event to be fired
5747: *
5748: */
5749: public void fireReportListenerReportBandsSelectionChanged(
5750: it.businesslogic.ireport.gui.event.ReportBandsSelectionEvent event) {
5751:
5752: if (listenerList == null)
5753: return;
5754: Object[] listeners = listenerList.getListenerList();
5755: for (int i = listeners.length - 2; i >= 0; i -= 2) {
5756: if (listeners[i] == it.businesslogic.ireport.gui.event.ReportListener.class) {
5757:
5758: ((it.businesslogic.ireport.gui.event.ReportListener) listeners[i + 1])
5759: .reportBandsSelectionChanged(event);
5760: }
5761: }
5762: }
5763:
5764: /** Notifies all registered listeners about the event.
5765: *
5766: * @param event The event to be fired
5767: *
5768: */
5769: public void fireReportListenerReportObjectsSelectionChanged(
5770: it.businesslogic.ireport.gui.event.ReportObjectsSelectionEvent event) {
5771:
5772: if (listenerList == null)
5773: return;
5774: Object[] listeners = listenerList.getListenerList();
5775: for (int i = listeners.length - 2; i >= 0; i -= 2) {
5776: if (listeners[i] == it.businesslogic.ireport.gui.event.ReportListener.class) {
5777:
5778: ((it.businesslogic.ireport.gui.event.ReportListener) listeners[i + 1])
5779: .reportObjectsSelectionChanged(event);
5780: }
5781: }
5782: }
5783:
5784: /** Notifies all registered listeners about the event.
5785: *
5786: * @param event The event to be fired
5787: *
5788: */
5789: public void fireReportListenerReportElementsChanged(
5790: it.businesslogic.ireport.gui.event.ReportElementChangedEvent event) {
5791: if (listenerList == null)
5792: return;
5793: Object[] listeners = listenerList.getListenerList();
5794: for (int i = listeners.length - 2; i >= 0; i -= 2) {
5795: if (listeners[i] == it.businesslogic.ireport.gui.event.ReportListener.class) {
5796: ((it.businesslogic.ireport.gui.event.ReportListener) listeners[i + 1])
5797: .reportElementsChanged(event);
5798: }
5799: }
5800: }
5801:
5802: /** Notifies all registered listeners about the event.
5803: *
5804: * @param event The event to be fired
5805: *
5806: */
5807: public void fireReportListenerReportBandChanged(
5808: it.businesslogic.ireport.gui.event.ReportBandChangedEvent event) {
5809: if (listenerList == null)
5810: return;
5811: Object[] listeners = listenerList.getListenerList();
5812: for (int i = listeners.length - 2; i >= 0; i -= 2) {
5813: if (listeners[i] == it.businesslogic.ireport.gui.event.ReportListener.class) {
5814: ((it.businesslogic.ireport.gui.event.ReportListener) listeners[i + 1])
5815: .reportBandChanged(event);
5816: }
5817: }
5818: }
5819:
5820: /* Return the operation that must be invoked on undo
5821: * Return null if no undo operation is available
5822: */
5823: public UndoOperation getUndoOperation() {
5824: if (this .undoOperations.size() > 0 && undoIndex >= 0)
5825: return (UndoOperation) this .undoOperations
5826: .elementAt(undoIndex);
5827: return null;
5828: }
5829:
5830: /* This call "consume" the undo operation and update
5831: * internally the poiter of the undo list...
5832: */
5833: public void undo() {
5834: if (getUndoOperation() != null) {
5835: UndoOperation u = getUndoOperation();
5836: u.undo();
5837: this .undoIndex--;
5838:
5839: this .getReport().decrementReportChanges();
5840: getMainFrame().updateOpenedDocumentsList();
5841: }
5842: }
5843:
5844: /* This call "consume" the redo operation and update
5845: * internally the poiter of the undo list...
5846: */
5847: public void redo() {
5848: if (getRedoOperation() != null) {
5849: getRedoOperation().redo();
5850: this .undoIndex++;
5851:
5852: this .getReport().incrementReportChanges();
5853: getMainFrame().updateOpenedDocumentsList();
5854: }
5855: }
5856:
5857: /* Return the redo operation that must be invoked on redo
5858: * Return null if no redo operation is available
5859: */
5860: public UndoOperation getRedoOperation() {
5861: if (this .undoOperations.size() > undoIndex + 1)
5862: return (UndoOperation) this .undoOperations
5863: .elementAt(undoIndex + 1);
5864: return null;
5865: }
5866:
5867: public void addUndoOperation(UndoOperation undo) {
5868: // Remove all operations from the index...
5869: while (this .undoOperations.size() > undoIndex + 1) {
5870: this .undoOperations.removeElementAt(undoIndex + 1);
5871: }
5872: undoOperations.addElement(undo);
5873: undoIndex++;
5874:
5875: getReport().incrementReportChanges();
5876:
5877: /*
5878: try {
5879: getMainFrame().updateOpenedDocumentsList();
5880: } catch (Exception ex) {
5881: System.out.println( "[1]" + ex);
5882: ex.printStackTrace();
5883: }
5884: */
5885: try {
5886: getMainFrame().updateUndoMenu(this );
5887: } catch (Exception ex) {
5888: System.out.println("[2]" + ex);
5889: ex.printStackTrace();
5890: }
5891: }
5892:
5893: public void deleteSelectedElements() {
5894: // Remove selected elements...
5895: Enumeration e = selectedElements.elements();
5896:
5897: DeleteElementsOperation undoOp = new DeleteElementsOperation(
5898: this );
5899: Vector deletedElements = new Vector();
5900:
5901: while (e.hasMoreElements()) {
5902:
5903: ReportElement re = (ReportElement) e.nextElement();
5904: if (getReport().getElements().contains(re)) {
5905: undoOp.addElement(re, getReport().getElements()
5906: .indexOf(re));
5907: getReport().getElements().remove(re);
5908: deletedElements.add(re);
5909: if (re instanceof FrameReportElement) {
5910: removeSubElements(re, undoOp, deletedElements);
5911: }
5912: if (re instanceof CrosstabReportElement) {
5913: removeCrosstabEditor((CrosstabReportElement) re);
5914: }
5915: }
5916: //fireReportListenerReportElementsChanged(new ReportElementChangedEvent(this, re , ReportElementChangedEvent.REMOVED));
5917: }
5918:
5919: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
5920: this , deletedElements,
5921: ReportElementChangedEvent.REMOVED));
5922: this .setSelectedElement(null);
5923: this .addUndoOperation(undoOp);
5924: //selectedElements.removeAllElements();
5925:
5926: jPanelReport.repaint();
5927: }
5928:
5929: protected void removeSubElements(ReportElement parentElement,
5930: DeleteElementsOperation undoOp, Vector deletedElements) {
5931: for (int i = 0; i < getReport().getElements().size(); ++i) {
5932: ReportElement re = (ReportElement) getReport()
5933: .getElements().elementAt(i);
5934: if (re.getParentElement() == parentElement) {
5935: undoOp.addElement(re, getReport().getElements()
5936: .indexOf(re));
5937: getReport().getElements().remove(re);
5938: i--;
5939: deletedElements.add(re);
5940: if (re instanceof FrameReportElement) {
5941: removeSubElements(re, undoOp, deletedElements);
5942: }
5943: if (re instanceof CrosstabReportElement) {
5944: removeCrosstabEditor((CrosstabReportElement) re);
5945: }
5946:
5947: }
5948: }
5949: }
5950:
5951: public void cut() {
5952: Vector copiedElements = new Vector();
5953:
5954: Vector tmpSelectedElements = null;
5955: if (getSelectedCrosstabEditorPanel() != null) {
5956: tmpSelectedElements = getSelectedCrosstabEditorPanel()
5957: .getSelectedElements();
5958: } else {
5959: tmpSelectedElements = this .getSelectedElements();
5960: }
5961:
5962: Enumeration e = tmpSelectedElements.elements();
5963: while (e.hasMoreElements()) {
5964: ReportElement er = (ReportElement) e.nextElement();
5965: copiedElements.add(er.cloneMe());
5966: }
5967:
5968: if (copiedElements.size() > 0) {
5969: getMainFrame().setClipBoardContent(copiedElements);
5970: }
5971:
5972: // Remove selected elements...
5973: if (getSelectedCrosstabEditorPanel() != null) {
5974: getSelectedCrosstabEditorPanel().deleteSelectedElements();
5975: } else {
5976: this .deleteSelectedElements();
5977: }
5978: getMainFrame().updateCutAndPasteMenu(this );
5979:
5980: }
5981:
5982: public void copy() {
5983: Vector copiedElements = new Vector();
5984:
5985: Vector tmpSelectedElements = null;
5986: if (getSelectedCrosstabEditorPanel() != null) {
5987: tmpSelectedElements = getSelectedCrosstabEditorPanel()
5988: .getSelectedElements();
5989: } else {
5990: tmpSelectedElements = this .getSelectedElements();
5991: }
5992:
5993: Enumeration e = tmpSelectedElements.elements();
5994: while (e.hasMoreElements()) {
5995: ReportElement er = (ReportElement) e.nextElement();
5996: if (!(er instanceof CrosstabReportElement)) {
5997: copiedElements.add(er.cloneMe());
5998: }
5999: }
6000: if (copiedElements.size() > 0) {
6001: getMainFrame().setClipBoardContent(copiedElements);
6002: }
6003:
6004: getMainFrame().updateCutAndPasteMenu(this );
6005: }
6006:
6007: public void paste() {
6008: // Add elements...
6009: pasteHere(null);
6010: }
6011:
6012: public void pasteHere(Point p) {
6013: // Add elements...
6014:
6015: Enumeration e = getMainFrame().getClipBoard().elements();
6016: ReportElement container = null;
6017:
6018: Vector tmpSelectedElements = null;
6019: if (getSelectedCrosstabEditorPanel() != null) {
6020: tmpSelectedElements = getSelectedCrosstabEditorPanel()
6021: .getSelectedElements();
6022: } else {
6023: tmpSelectedElements = this .getSelectedElements();
6024: }
6025:
6026: if (tmpSelectedElements.size() > 0) {
6027: container = (ReportElement) tmpSelectedElements
6028: .elementAt(0);
6029: if (!(container instanceof FrameReportElement)) {
6030: container = null;
6031: }
6032: }
6033:
6034: if (getSelectedCrosstabEditorPanel() != null) {
6035: getSelectedCrosstabEditorPanel().setSelectedElement(null);
6036: } else {
6037: setSelectedElement(null);
6038: }
6039:
6040: Vector addedElements = new Vector();
6041:
6042: int y = 0;
6043: if (p != null) {
6044:
6045: if (getSelectedCrosstabEditorPanel() != null) {
6046: y = getSelectedCrosstabEditorPanel().getZoomedDim(
6047: p.y - 10);
6048: } else {
6049: y = getLogicalDim(p.y - 10
6050: + jVerticalScrollBar.getValue()) + 10;
6051: }
6052: }
6053:
6054: CrosstabReportElement crReportElement = null;
6055: if (getSelectedCrosstabEditorPanel() != null)
6056: crReportElement = getSelectedCrosstabEditorPanel()
6057: .getCrosstabElement();
6058:
6059: while (e.hasMoreElements()) {
6060: ReportElement re = ((ReportElement) e.nextElement())
6061: .cloneMe();
6062:
6063: re.setKey(getNextElementKey(re.getKey()));
6064:
6065: if (getSelectedCrosstabEditorPanel() != null) {
6066: if (re instanceof BreakReportElement
6067: || re instanceof ChartReportElement
6068: || re instanceof ChartReportElement2
6069: || re instanceof CrosstabReportElement
6070: || re instanceof SubReportElement)
6071: continue;
6072:
6073: CrosstabCell cell = null;
6074: if (getSelectedCrosstabEditorPanel()
6075: .isDefaultCellMode()) {
6076: cell = getSelectedCrosstabEditorPanel()
6077: .getWhenNoDataCell();
6078:
6079: } else if (p != null) {
6080: cell = getSelectedCrosstabEditorPanel()
6081: .getCellByPoint(p);
6082: if (cell == null)
6083: cell = (CrosstabCell) getSelectedCrosstabEditorPanel()
6084: .getCrosstabElement().getCells()
6085: .elementAt(0);
6086: }
6087: re.setBand(null);
6088: if (re.getCell() != null) {
6089: // Update relative position...
6090: re.setRelativePosition(new Point(re.getPosition().x
6091: - re.getCell().getLeft() - 10, re
6092: .getPosition().y
6093: - re.getCell().getTop() - 10));
6094: } else {
6095: re.setRelativePosition(new Point(0, 0));
6096: }
6097:
6098: //System.out.println(re.getRelativePosition());
6099:
6100: // Copia da cella a cella...
6101: if (cell != null) {
6102: re.setCell(cell);
6103: re.getPosition().x = re.getRelativePosition().x
6104: + re.getCell().getLeft() + 10;
6105: re.getPosition().y = re.getRelativePosition().y
6106: + re.getCell().getTop() + 10;
6107: } else if (getSelectedCrosstabEditorPanel()
6108: .getCrosstabElement().getCells().contains(
6109: re.getCell())) {
6110: re.getPosition().x += 10;
6111: re.getRelativePosition().x += 10;
6112: re.getPosition().y += 10;
6113: re.getRelativePosition().y += 10;
6114: } else {
6115: cell = (CrosstabCell) getSelectedCrosstabEditorPanel()
6116: .getCrosstabElement().getCells().elementAt(
6117: 0);
6118: re.setCell(cell);
6119: re.getPosition().x = re.getRelativePosition().x
6120: + re.getCell().getLeft() + 10;
6121: re.getPosition().y = re.getRelativePosition().y
6122: + re.getCell().getTop() + 10;
6123: }
6124:
6125: } else {
6126: String bandName = (re.getBand() == null) ? "" : re
6127: .getBand().getName();
6128: Band b = getReport().getBandByName(bandName);
6129: re.setBand(b);
6130:
6131: if (p != null) {
6132: int ylocation = getReport().getBandYLocation(b);
6133: Band myBand = null;
6134:
6135: Enumeration enum_bands = getReport().getBands()
6136: .elements();
6137: while (enum_bands.hasMoreElements()) {
6138: Band bb = (Band) enum_bands.nextElement();
6139: if (report.getBandYLocation(bb) + 10 <= y) {
6140: myBand = bb;
6141: }
6142: }
6143:
6144: if (myBand == null)
6145: return;
6146:
6147: int ylocation2 = getReport().getBandYLocation(
6148: myBand);
6149:
6150: Point location = re.getPosition();
6151: location.y += ylocation2 - ylocation;
6152:
6153: re.setBand(myBand);
6154: re.setPosition(location);
6155: } else {
6156: if (re.getPosition().y > getReport()
6157: .getDesignHeight()
6158: - getReport().getBottomMargin()) {
6159: re.getPosition().y = getReport()
6160: .getDesignHeight()
6161: - 1 - getReport().getBottomMargin();
6162: }
6163: if (b == null)
6164: b = getReport().getBandByPosition(
6165: re.getPosition().y);
6166: re.setBand(b);
6167: java.awt.Point p2 = re.getPosition();
6168: int add_x = this .getGridSize();
6169: if (re instanceof BreakReportElement)
6170: add_x = 0;
6171: re.setPosition(new java.awt.Point(p2.x + add_x,
6172: p2.y + this .getGridSize()));
6173: }
6174:
6175: if (container != null) {
6176: re.setBand(container.getBand());
6177: re.setParentElement(container);
6178: } else {
6179: re.setParentElement(null);
6180: }
6181:
6182: }
6183:
6184: if (re instanceof CrosstabReportElement) {
6185: addCrosstabEditor((CrosstabReportElement) re);
6186: }
6187: re.updateBounds();
6188:
6189: // We must find the right band to paste into...
6190: //re.setBand( bname );
6191: //
6192:
6193: addUndoOperation(new InsertElementOperation(this ,
6194: crReportElement, re));
6195:
6196: if (getSelectedCrosstabEditorPanel() != null) {
6197: crReportElement.getElements().addElement(re);
6198: getSelectedCrosstabEditorPanel().addSelectedElement(re);
6199: } else {
6200: report.getElements().addElement(re);
6201: addSelectedElement(re, false);
6202: }
6203: addedElements.add(re);
6204: }
6205:
6206: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
6207: this , crReportElement, addedElements,
6208: ReportElementChangedEvent.ADDED));
6209:
6210: if (crReportElement != null) {
6211: getSelectedCrosstabEditorPanel()
6212: .fireSelectionChangedEvent();
6213: } else {
6214: fireSelectionChangedEvent();
6215: }
6216:
6217: getMainFrame().updateCutAndPasteMenu(this );
6218:
6219: }
6220:
6221: public void openElementPropertiesDialog() {
6222: // If there is at least an element selected, open the properties window...
6223: MainFrame mainFrame = getMainFrame();
6224:
6225: if ((getSelectedCrosstabEditorPanel() != null && getSelectedCrosstabEditorPanel()
6226: .getSelectedElements().size() > 0)
6227: || getSelectedElements().size() > 0) {
6228: if (!mainFrame.getElementPropertiesDialog().isVisible()) {
6229: //mainFrame.getElementPropertiesDialog().updateSelection();
6230: mainFrame.getElementPropertiesDialog().setVisible(true);
6231: }
6232: }
6233:
6234: if (getSelectedCrosstabEditorPanel() != null)
6235: getSelectedCrosstabEditorPanel().requestFocus();
6236: else
6237: jPanelReport.requestFocus();
6238: }
6239:
6240: public void updateTitle() {
6241:
6242: this .setTitle(this .report.getName() + " "
6243: + this .report.getWidth() + "x"
6244: + this .report.getDesignHeight() + " ["
6245: + Misc.nvl(this .report.getFilename(), "unnamed") + "]");
6246:
6247: }
6248:
6249: /**
6250: *
6251: */
6252: public void bringToFront() {
6253: Enumeration e = this .getSelectedElements().elements();
6254:
6255: ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
6256: this );
6257:
6258: while (e.hasMoreElements()) {
6259: ReportElement element = (ReportElement) e.nextElement();
6260:
6261: int oldPosition = getReport().getElements()
6262: .indexOf(element);
6263: getReport().getElements().remove(element);
6264: getReport().getElements().addElement(element);
6265: int newPosition = getReport().getElements()
6266: .indexOf(element);
6267: undoOp.addElement(element, oldPosition, newPosition);
6268: }
6269:
6270: if (undoOp.getElements().size() > 0) {
6271: addUndoOperation(undoOp);
6272: }
6273: getReportPanel().repaint();
6274: // We must update the tree... the order i changed...
6275: /* TODO */
6276: }
6277:
6278: public void sendToBack() {
6279: Enumeration e = this .getSelectedElements().elements();
6280:
6281: ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
6282: this );
6283:
6284: while (e.hasMoreElements()) {
6285: ReportElement element = (ReportElement) e.nextElement();
6286:
6287: int oldPosition = getReport().getElements()
6288: .indexOf(element);
6289: getReport().getElements().remove(element);
6290: if (element.getParentElement() != null) {
6291: getReport().getElements().insertElementAt(
6292: element,
6293: getReport().getElements().indexOf(
6294: element.getParentElement()) + 1);
6295: } else {
6296: getReport().getElements().insertElementAt(element, 0);
6297: }
6298: int newPosition = 0;
6299: undoOp.addElement(element, oldPosition, newPosition);
6300: }
6301:
6302: if (undoOp.getElements().size() > 0) {
6303: addUndoOperation(undoOp);
6304: }
6305: getReportPanel().repaint();
6306: // We must update the tree... the order is changed...
6307: /* TODO */
6308: }
6309:
6310: /*
6311: public void makeOperation(int operationType) {
6312: if (getSelectedElements().isEmpty()) return;
6313:
6314: Enumeration e = getSelectedElements().elements();
6315: ReportElement re = null;
6316: FormatElementsOperation undoOp = new FormatElementsOperation(this, operationType);
6317:
6318: switch (operationType) {
6319: case OperationType.ALIGN_LEFT:
6320: int left= ((ReportElement)getSelectedElements().firstElement()).getPosition().x;
6321:
6322: while (e.hasMoreElements()){
6323: re = (ReportElement)e.nextElement();
6324: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6325: re.setPosition(new Point(left, re.getPosition().y));
6326: re.updateBounds();
6327: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6328: undoOp.addElement(re, oldBounds, newBounds );
6329: }
6330: break;
6331: case OperationType.ALIGN_RIGHT:
6332: int right= ((ReportElement)getSelectedElements().firstElement()).getPosition().x+((ReportElement)getSelectedElements().firstElement()).getWidth();
6333: while (e.hasMoreElements()){
6334: re = (ReportElement)e.nextElement();
6335: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6336: re.setPosition(new Point(right-re.getWidth(), re.getPosition().y));
6337: re.updateBounds();
6338: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6339: undoOp.addElement(re, oldBounds, newBounds );
6340: }
6341: break;
6342: case OperationType.ALIGN_TOP:
6343: int top= ((ReportElement)getSelectedElements().firstElement()).getPosition().y;
6344: while (e.hasMoreElements()){
6345: re = (ReportElement)e.nextElement();
6346: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6347: re.setPosition(new Point(re.getPosition().x, top));
6348: re.updateBounds();
6349: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6350: undoOp.addElement(re, oldBounds, newBounds );
6351: }
6352: break;
6353: case OperationType.ALIGN_BOTTOM:
6354: int bottom= ((ReportElement)getSelectedElements().firstElement()).getPosition().y+((ReportElement)getSelectedElements().firstElement()).height;
6355: while (e.hasMoreElements()){
6356: re = (ReportElement)e.nextElement();
6357: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6358: re.setPosition(new Point(re.getPosition().x, bottom-re.height));
6359: re.updateBounds();
6360: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6361: undoOp.addElement(re, oldBounds, newBounds );
6362: }
6363: break;
6364: case OperationType.ALIGN_HORIZONTAL_AXIS:
6365: re = (ReportElement)getSelectedElements().firstElement();
6366: int center = re.getPosition().y + (re.getHeight()/2);
6367: while (e.hasMoreElements()){
6368: re = (ReportElement)e.nextElement();
6369: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6370: re.setPosition(new Point(re.getPosition().x, center-(re.getHeight()/2) ));
6371: re.updateBounds();
6372: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6373: undoOp.addElement(re, oldBounds, newBounds );
6374: }
6375: break;
6376: case OperationType.ALIGN_VERTICAL_AXIS:
6377: re = (ReportElement)getSelectedElements().firstElement();
6378: center = re.getPosition().x + (re.getWidth()/2);
6379: while (e.hasMoreElements()){
6380: re = (ReportElement)e.nextElement();
6381: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6382: re.setPosition(new Point(center-(re.getWidth()/2), re.getPosition().y));
6383: re.updateBounds();
6384: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6385: undoOp.addElement(re, oldBounds, newBounds );
6386: }
6387: break;
6388: case OperationType.ALIGN_CENTER_HORIZONTALLY:
6389: case OperationType.CENTER_IN_BAND_H:
6390: re = (ReportElement)getSelectedElements().firstElement();
6391:
6392: while (e.hasMoreElements()){
6393: re = (ReportElement)e.nextElement();
6394: center = 10+this.getReport().getWidth()/2;
6395: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6396: re.setPosition(new Point(center-(re.getWidth()/2), re.getPosition().y));
6397: re.updateBounds();
6398: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6399: undoOp.addElement(re, oldBounds, newBounds );
6400: }
6401: break;
6402: case OperationType.ALIGN_CENTER_VERTICALLY:
6403: case OperationType.CENTER_IN_BAND_V:
6404: re = (ReportElement)getSelectedElements().firstElement();
6405: while (e.hasMoreElements()){
6406: re = (ReportElement)e.nextElement();
6407: center = this.report.getBandYLocation(re.getBand())+10+re.getBand().getHeight()/2;
6408: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6409: re.setPosition(new Point(re.getPosition().x, center-(re.getHeight()/2)));
6410: re.updateBounds();
6411: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6412: undoOp.addElement(re, oldBounds, newBounds );
6413: }
6414: break;
6415: case OperationType.ALIGN_CENTER:
6416: case OperationType.CENTER_IN_BAND:
6417: re = (ReportElement)getSelectedElements().firstElement();
6418: int centerx = 10+this.getReport().getWidth()/2;
6419: int centery = this.report.getBandYLocation(re.getBand())+10+re.getBand().getHeight()/2;
6420: while (e.hasMoreElements()){
6421: re = (ReportElement)e.nextElement();
6422: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6423: re.setPosition(new Point(centerx-(re.getWidth()/2), this.report.getBandYLocation(re.getBand())+10+re.getBand().getHeight()/2-(re.getHeight()/2)));
6424: re.updateBounds();
6425: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6426: undoOp.addElement(re, oldBounds, newBounds );
6427: }
6428: break;
6429: case OperationType.SAME_WIDTH:
6430: re = (ReportElement)getSelectedElements().firstElement();
6431: int width = re.getWidth();
6432: while (e.hasMoreElements()){
6433: re = (ReportElement)e.nextElement();
6434: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6435: re.trasform(new Point(width-re.getWidth(),0), TransformationType.TRANSFORMATION_RESIZE_SE);
6436: re.updateBounds();
6437: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6438: undoOp.addElement(re, oldBounds, newBounds );
6439: }
6440: break;
6441: case OperationType.SAME_WIDTH_MAX:
6442: re = (ReportElement)getSelectedElements().firstElement();
6443: // Looking for the max with...
6444: Enumeration enum2 = getSelectedElements().elements();
6445: width = re.getWidth();
6446: while (enum2.hasMoreElements()) {
6447: re = (ReportElement)enum2.nextElement();
6448: if (width <= re.getWidth()) width =re.getWidth();
6449: }
6450: while (e.hasMoreElements()){
6451: re = (ReportElement)e.nextElement();
6452: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6453: re.trasform(new Point(width-re.getWidth(),0), TransformationType.TRANSFORMATION_RESIZE_SE);
6454: re.updateBounds();
6455: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6456: undoOp.addElement(re, oldBounds, newBounds );
6457: }
6458: break;
6459: case OperationType.SAME_WIDTH_MIN:
6460: re = (ReportElement)getSelectedElements().firstElement();
6461: // Looking for the max with...
6462: enum2 = getSelectedElements().elements();
6463: width = re.getWidth();
6464: while (enum2.hasMoreElements()) {
6465: re = (ReportElement)enum2.nextElement();
6466: if (width > re.getWidth()) width =re.getWidth();
6467: }
6468: while (e.hasMoreElements()){
6469: re = (ReportElement)e.nextElement();
6470: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6471: re.trasform(new Point(width-re.getWidth(),0), TransformationType.TRANSFORMATION_RESIZE_SE);
6472: re.updateBounds();
6473: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6474: undoOp.addElement(re, oldBounds, newBounds );
6475: }
6476: break;
6477: case OperationType.SAME_HEIGHT:
6478: re = (ReportElement)getSelectedElements().firstElement();
6479: int height = re.height;
6480: while (e.hasMoreElements()){
6481: re = (ReportElement)e.nextElement();
6482: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6483: re.trasform(new Point(0,height-re.height), TransformationType.TRANSFORMATION_RESIZE_SE);
6484: re.updateBounds();
6485: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6486: undoOp.addElement(re, oldBounds, newBounds );
6487: }
6488: break;
6489: case OperationType.SAME_HEIGHT_MAX:
6490: re = (ReportElement)getSelectedElements().firstElement();
6491: height = re.getHeight();
6492: enum2 = getSelectedElements().elements();
6493: while (enum2.hasMoreElements()) {
6494: re = (ReportElement)enum2.nextElement();
6495: if (height <= re.getHeight()) height =re.getHeight();
6496: }
6497: while (e.hasMoreElements()){
6498: re = (ReportElement)e.nextElement();
6499: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6500: re.trasform(new Point(0,height-re.height), TransformationType.TRANSFORMATION_RESIZE_SE);
6501: re.updateBounds();
6502: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6503: undoOp.addElement(re, oldBounds, newBounds );
6504: }
6505: break;
6506: case OperationType.SAME_HEIGHT_MIN:
6507: re = (ReportElement)getSelectedElements().firstElement();
6508: height = re.getHeight();
6509: enum2 = getSelectedElements().elements();
6510: while (enum2.hasMoreElements()) {
6511: re = (ReportElement)enum2.nextElement();
6512: if (height > re.getHeight()) height =re.getHeight();
6513: }
6514: while (e.hasMoreElements()){
6515: re = (ReportElement)e.nextElement();
6516: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6517: re.trasform(new Point(0,height-re.height), TransformationType.TRANSFORMATION_RESIZE_SE);
6518: re.updateBounds();
6519: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6520: undoOp.addElement(re, oldBounds, newBounds );
6521: }
6522: break;
6523: case OperationType.SAME_SIZE:
6524: re = (ReportElement)getSelectedElements().firstElement();
6525: height = re.height;
6526: width = re.getWidth();
6527: while (e.hasMoreElements()){
6528: re = (ReportElement)e.nextElement();
6529: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6530: re.trasform(new Point(width-re.getWidth(),height-re.height), TransformationType.TRANSFORMATION_RESIZE_SE);
6531: re.updateBounds();
6532: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6533: undoOp.addElement(re, oldBounds, newBounds );
6534: }
6535: break;
6536: case OperationType.ALIGN_TOP_TO_BAND:
6537: while (e.hasMoreElements()){
6538: re = (ReportElement)e.nextElement();
6539: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6540: re.trasform(new Point(0,getReport().getBandYLocation( re.band)+10- re.getPosition().y), TransformationType.TRANSFORMATION_MOVE);
6541: re.updateBounds();
6542: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6543: undoOp.addElement(re, oldBounds, newBounds );
6544: }
6545: break;
6546:
6547: // Begin code Robert Lamping, 12 July 2004
6548: case OperationType.ALIGN_BOTTOM_TO_BAND:
6549: while (e.hasMoreElements()){
6550: re = (ReportElement)e.nextElement();
6551: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6552: //re.trasform(new Point(0,getReport().getBandYLocation( re.band)+10- re.getPosition().y), TransformationType.TRANSFORMATION_MOVE);
6553: re.trasform( new Point(0, getReport().getBandYLocation( re.band)+10 + re.band.getHeight() -
6554: ( re.getPosition().y + re.getHeight() ) ), TransformationType.TRANSFORMATION_MOVE);
6555: re.updateBounds();
6556: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6557: undoOp.addElement(re, oldBounds, newBounds );
6558: }
6559: break;
6560:
6561: case OperationType.ALIGN_TO_LEFT_MARGIN:
6562: int leftMargin= getReport().getLeftMargin();
6563: //((ReportElement)getSelectedElements().firstElement()).getPosition().x;
6564:
6565: while (e.hasMoreElements()){
6566: re = (ReportElement)e.nextElement();
6567: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6568: re.setPosition(new Point(leftMargin + 10, re.getPosition().y));
6569: re.updateBounds();
6570: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6571: undoOp.addElement(re, oldBounds, newBounds );
6572: }
6573: break;
6574:
6575: case OperationType.ALIGN_TO_RIGHT_MARGIN:
6576: int rightMargin= getReport().getRightMargin();
6577:
6578: while (e.hasMoreElements()){
6579: re = (ReportElement)e.nextElement();
6580: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6581: re.setPosition(new Point(this.getReport().getWidth() - rightMargin-re.getWidth()+ 10, re.getPosition().y));
6582: re.updateBounds();
6583: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6584: undoOp.addElement(re, oldBounds, newBounds );
6585: }
6586: break;
6587: case OperationType.MOVE_TO_LEFT_MARGIN:
6588: // Move all elements to the left over the distance between first element and left margin
6589: re = (ReportElement)getSelectedElements().firstElement();
6590: int deltaLeft = re.getPosition().x - getReport().getLeftMargin();
6591:
6592: while (e.hasMoreElements()){
6593: re = (ReportElement)e.nextElement();
6594: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6595: re.setPosition(new Point(re.getPosition().x + 10 - deltaLeft, re.getPosition().y));
6596: re.updateBounds();
6597: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6598: undoOp.addElement(re, oldBounds, newBounds );
6599: }
6600: break;
6601: // End code Robert Lamping, 12 July 2004
6602: case OperationType.ORGANIZE_AS_A_TABLE:
6603:
6604: e = getSelectedElements().elements();
6605: while (e.hasMoreElements()){
6606: re = (ReportElement)e.nextElement();
6607: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6608: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6609: undoOp.addElement(re, oldBounds, newBounds );
6610: }
6611:
6612: makeOperation( OperationType.ALIGN_TOP_TO_BAND);
6613: // Remove all operations from the index...
6614: while (this.undoOperations.size() > undoIndex) {
6615: this.undoOperations.removeElementAt( undoIndex);
6616: }
6617: undoIndex--;
6618: this.getReport().decrementDirty();
6619: makeOperation( OperationType.JOIN_LEFT);
6620: // Remove all operations from the index...
6621: while (this.undoOperations.size() > undoIndex) {
6622: this.undoOperations.removeElementAt( undoIndex);
6623: }
6624: undoIndex--;
6625: this.getReport().decrementDirty();
6626: makeOperation( OperationType.MOVE_TO_LEFT_MARGIN);
6627: // Remove all operations from the index...
6628: while (this.undoOperations.size() > undoIndex) {
6629: this.undoOperations.removeElementAt( undoIndex);
6630: }
6631: undoIndex--;
6632: this.getReport().decrementDirty();
6633: makeOperation( OperationType.SAME_HEIGHT_MIN);
6634: // Remove all operations from the index...
6635: while (this.undoOperations.size() > undoIndex) {
6636: this.undoOperations.removeElementAt( undoIndex);
6637: }
6638: undoIndex--;
6639: this.getReport().decrementDirty();
6640: makeOperation( OperationType.INCREASE_SPACE_H);
6641: // Remove all operations from the index...
6642: while (this.undoOperations.size() > undoIndex) {
6643: this.undoOperations.removeElementAt( undoIndex);
6644: }
6645: undoIndex--;
6646: this.getReport().decrementDirty();
6647:
6648: e = getSelectedElements().elements();
6649: int kkk = 0;
6650: while (e.hasMoreElements()){
6651: re = (ReportElement)e.nextElement();
6652: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6653: ((ElementTransformation)undoOp.getTransformations().elementAt(kkk)).newBounds = newBounds;
6654: kkk++;
6655: }
6656: break;
6657: case OperationType.JOIN_LEFT:
6658: case OperationType.REMOVE_SPACE_H:
6659: // 1 Search for all different bands...
6660:
6661: Vector used_bands = new Vector();
6662: enum2 = getSelectedElements().elements();
6663: while (enum2.hasMoreElements()) {
6664: re = (ReportElement)enum2.nextElement();
6665: if (!used_bands.contains(re.getBand())) {
6666: used_bands.add(re.getBand());
6667: }
6668: }
6669: // 2 For any bands, create a vector of elements of this bands order by left position...
6670: // 2b Set positions using the array....
6671: Enumeration bands_enum = used_bands.elements();
6672: while (bands_enum.hasMoreElements()) {
6673:
6674: Band b = (Band)bands_enum.nextElement();
6675:
6676: Vector myElements = new Vector();
6677: enum2 = getSelectedElements().elements();
6678: while (enum2.hasMoreElements()) {
6679: re = (ReportElement)enum2.nextElement();
6680: if (re.getBand() == b) {
6681: // insert this element in the right position...
6682: if (myElements.size() == 0) myElements.add(re);
6683: else {
6684: boolean inserted=false;
6685: for (int i=0; i<myElements.size(); ++i) {
6686: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6687: if (re.getPosition().x < re2.getPosition().x) {
6688: myElements.insertElementAt(re, i);
6689: inserted = true;
6690:
6691: break;
6692: }
6693: }
6694: if (!inserted)
6695: myElements.addElement(re);
6696: }
6697: }
6698: }
6699:
6700: // Repositioning elements...
6701: int actual_x =0;
6702: for (int k=0; k<myElements.size(); ++k) {
6703: re = (ReportElement)myElements.elementAt(k);
6704: if (k==0) {
6705: actual_x = ((ReportElement)myElements.elementAt(k)).getPosition().x;
6706: }
6707:
6708: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6709: re.setPosition( new Point(actual_x, re.getPosition().y) );
6710: actual_x += re.getWidth();
6711: re.updateBounds();
6712: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6713: undoOp.addElement(re, oldBounds, newBounds );
6714: }
6715: }
6716: break;
6717: case OperationType.JOIN_RIGHT:
6718:
6719: // 1 Search for all different bands...
6720:
6721: used_bands = new Vector();
6722: enum2 = getSelectedElements().elements();
6723: while (enum2.hasMoreElements()) {
6724: re = (ReportElement)enum2.nextElement();
6725: if (!used_bands.contains(re.getBand())) {
6726: used_bands.add(re.getBand());
6727: }
6728: }
6729:
6730: // 2 For any bands, create a vector of elements of this bands order by left position...
6731: // 2b Set positions using the array....
6732: bands_enum = used_bands.elements();
6733: while (bands_enum.hasMoreElements()) {
6734:
6735: Band b = (Band)bands_enum.nextElement();
6736: Vector myElements = new Vector();
6737: enum2 = getSelectedElements().elements();
6738: while (enum2.hasMoreElements()) {
6739: re = (ReportElement)enum2.nextElement();
6740: if (re.getBand() == b) {
6741: // insert this element in the right position...
6742: if (myElements.size() == 0) myElements.add(re);
6743: else {
6744: boolean inserted=false;
6745: for (int i=0; i<myElements.size(); ++i) {
6746: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6747: if (re.getPosition().x > re2.getPosition().x) {
6748: myElements.insertElementAt(re, i);
6749: inserted = true;
6750: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6751: break;
6752: }
6753: }
6754: if (!inserted)
6755: myElements.addElement(re);
6756: }
6757: }
6758: }
6759:
6760: // Repositioning elements...
6761: int actual_x =0;
6762: for (int k=0; k<myElements.size(); ++k) {
6763: re = (ReportElement)myElements.elementAt(k);
6764: if (k==0) {
6765: actual_x = re.getPosition().x+re.getWidth();
6766: }
6767:
6768: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6769: re.setPosition( new Point(actual_x-re.getWidth(), re.getPosition().y) );
6770: actual_x -= re.getWidth();
6771: re.updateBounds();
6772: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6773: undoOp.addElement(re, oldBounds, newBounds );
6774: }
6775: }
6776: break;
6777: case OperationType.EQUALS_SPACE_H:
6778: // 1. Use an ordered array...
6779: if (getSelectedElements().size() <= 1) break;
6780: Vector myElements = new Vector();
6781:
6782: enum2 = getSelectedElements().elements();
6783: while (enum2.hasMoreElements()) {
6784: re = (ReportElement)enum2.nextElement();
6785: // insert this element in the right position...
6786: if (myElements.size() == 0) myElements.add(re);
6787: else {
6788: boolean inserted=false;
6789: for (int i=0; i<myElements.size(); ++i) {
6790: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6791: if (re.getPosition().x < re2.getPosition().x) {
6792: myElements.insertElementAt(re, i);
6793: inserted = true;
6794: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6795: break;
6796: }
6797: }
6798: if (!inserted)
6799: myElements.addElement(re);
6800: }
6801: }
6802:
6803:
6804:
6805: // Find the rightest element...
6806:
6807: int total_width=0;
6808: int available_width=0;
6809: int min_x = 0;
6810: int max_x = 0;
6811: re = (ReportElement)myElements.firstElement();
6812: min_x = re.getPosition().x;
6813: max_x = re.getPosition().x+re.getWidth();
6814: enum2 = myElements.elements();
6815: ReportElement leftElement = re;
6816: ReportElement rightElement = re;
6817: while (enum2.hasMoreElements()) {
6818: re = (ReportElement)enum2.nextElement();
6819: if (min_x > re.getPosition().x) {
6820: min_x =re.getPosition().x;
6821: }
6822: if (max_x < re.getPosition().x+re.getWidth()) {
6823: max_x =re.getPosition().x+re.getWidth();
6824: rightElement = re;
6825: }
6826: available_width += re.getWidth();
6827: }
6828: available_width = max_x - min_x - available_width;
6829: available_width /= myElements.size()-1;
6830: System.out.println("Space: " + available_width);
6831:
6832: int actual_x = leftElement.getPosition().x + leftElement.getWidth() + available_width;
6833: e = myElements.elements();
6834: while (e.hasMoreElements()){
6835: re = (ReportElement)e.nextElement();
6836: if (re == leftElement) continue;
6837: if (re == rightElement) continue;
6838:
6839: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6840: re.setPosition(new Point(actual_x, re.getPosition().y) );
6841: re.updateBounds();
6842: actual_x += re.getWidth() + available_width;
6843: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6844: undoOp.addElement(re, oldBounds, newBounds );
6845: }
6846: break;
6847: case OperationType.INCREASE_SPACE_H:
6848: // 1. Use an ordered array...
6849: if (getSelectedElements().size() <= 1) break;
6850: myElements = new Vector();
6851:
6852: enum2 = getSelectedElements().elements();
6853: while (enum2.hasMoreElements()) {
6854: re = (ReportElement)enum2.nextElement();
6855: // insert this element in the right position...
6856: if (myElements.size() == 0) myElements.add(re);
6857: else {
6858: boolean inserted=false;
6859: for (int i=0; i<myElements.size(); ++i) {
6860: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6861: if (re.getPosition().x < re2.getPosition().x) {
6862: myElements.insertElementAt(re, i);
6863: inserted = true;
6864: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6865: break;
6866: }
6867: }
6868: if (!inserted)
6869: myElements.addElement(re);
6870: }
6871: }
6872:
6873: e = myElements.elements();
6874:
6875: for (int i=1; i< myElements.size(); ++i){
6876: re = (ReportElement)myElements.elementAt(i);
6877: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6878: re.setPosition(new Point(re.getPosition().x+5*i, re.getPosition().y) );
6879: re.updateBounds();
6880: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6881: undoOp.addElement(re, oldBounds, newBounds );
6882: }
6883: break;
6884: case OperationType.DECREASE_SPACE_H:
6885: // 1. Use an ordered array...
6886: if (getSelectedElements().size() <= 1) break;
6887: myElements = new Vector();
6888:
6889: enum2 = getSelectedElements().elements();
6890: while (enum2.hasMoreElements()) {
6891: re = (ReportElement)enum2.nextElement();
6892: // insert this element in the right position...
6893: if (myElements.size() == 0) myElements.add(re);
6894: else {
6895: boolean inserted=false;
6896: for (int i=0; i<myElements.size(); ++i) {
6897: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6898: if (re.getPosition().x < re2.getPosition().x) {
6899: myElements.insertElementAt(re, i);
6900: inserted = true;
6901: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6902: break;
6903: }
6904: }
6905: if (!inserted)
6906: myElements.addElement(re);
6907: }
6908: }
6909:
6910: e = myElements.elements();
6911:
6912: for (int i=1; i< myElements.size(); ++i){
6913: re = (ReportElement)myElements.elementAt(i);
6914: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6915: re.setPosition(new Point(Math.max( re.getPosition().x-5*i, ((ReportElement)myElements.elementAt(i-1)).getPosition().x), re.getPosition().y) );
6916: re.updateBounds();
6917: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6918: undoOp.addElement(re, oldBounds, newBounds );
6919: }
6920: break;
6921:
6922: case OperationType.DECREASE_SPACE_V:
6923: // 1. Use an ordered array...
6924: if (getSelectedElements().size() <= 1) break;
6925: myElements = new Vector();
6926:
6927: enum2 = getSelectedElements().elements();
6928: while (enum2.hasMoreElements()) {
6929: re = (ReportElement)enum2.nextElement();
6930: // insert this element in the right position...
6931: if (myElements.size() == 0) myElements.add(re);
6932: else {
6933: boolean inserted=false;
6934: for (int i=0; i<myElements.size(); ++i) {
6935: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6936: if (re.getPosition().y < re2.getPosition().y) {
6937: myElements.insertElementAt(re, i);
6938: inserted = true;
6939: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6940: break;
6941: }
6942: }
6943: if (!inserted)
6944: myElements.addElement(re);
6945: }
6946: }
6947:
6948: e = myElements.elements();
6949:
6950: for (int i=1; i< myElements.size(); ++i){
6951: re = (ReportElement)myElements.elementAt(i);
6952: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6953: re.setPosition(new Point(re.getPosition().x, Math.max( re.getPosition().y-5*i, ((ReportElement)myElements.elementAt(i-1)).getPosition().y)) );
6954: re.updateBounds();
6955: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6956: undoOp.addElement(re, oldBounds, newBounds );
6957: }
6958: break;
6959: case OperationType.INCREASE_SPACE_V:
6960: // 1. Use an ordered array...
6961: if (getSelectedElements().size() <= 1) break;
6962: myElements = new Vector();
6963:
6964: enum2 = getSelectedElements().elements();
6965: while (enum2.hasMoreElements()) {
6966: re = (ReportElement)enum2.nextElement();
6967: // insert this element in the right position...
6968: if (myElements.size() == 0) myElements.add(re);
6969: else {
6970: boolean inserted=false;
6971: for (int i=0; i<myElements.size(); ++i) {
6972: ReportElement re2 = (ReportElement)myElements.elementAt(i);
6973: if (re.getPosition().y < re2.getPosition().y) {
6974: myElements.insertElementAt(re, i);
6975: inserted = true;
6976: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
6977: break;
6978: }
6979: }
6980: if (!inserted)
6981: myElements.addElement(re);
6982: }
6983: }
6984:
6985: e = myElements.elements();
6986:
6987: for (int i=1; i< myElements.size(); ++i){
6988: re = (ReportElement)myElements.elementAt(i);
6989: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6990: re.setPosition(new Point(re.getPosition().x, re.getPosition().y+5*i) );
6991: re.updateBounds();
6992: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
6993: undoOp.addElement(re, oldBounds, newBounds );
6994: }
6995: break;
6996: case OperationType.REMOVE_SPACE_V:
6997: // 1. Use an ordered array...
6998: if (getSelectedElements().size() <= 1) break;
6999: myElements = new Vector();
7000:
7001: enum2 = getSelectedElements().elements();
7002: while (enum2.hasMoreElements()) {
7003: re = (ReportElement)enum2.nextElement();
7004: // insert this element in the right position...
7005: if (myElements.size() == 0) myElements.add(re);
7006: else {
7007: boolean inserted=false;
7008: for (int i=0; i<myElements.size(); ++i) {
7009: ReportElement re2 = (ReportElement)myElements.elementAt(i);
7010: if (re.getPosition().y < re2.getPosition().y) {
7011: myElements.insertElementAt(re, i);
7012: inserted = true;
7013: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
7014: break;
7015: }
7016: }
7017: if (!inserted)
7018: myElements.addElement(re);
7019: }
7020: }
7021:
7022: e = myElements.elements();
7023:
7024: for (int i=1; i< myElements.size(); ++i){
7025: re = (ReportElement)myElements.elementAt(i);
7026: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
7027: re.setPosition(new Point(re.getPosition().x, ((ReportElement)myElements.elementAt(i-1)).getPosition().y +((ReportElement)myElements.elementAt(i-1)).getHeight() ) );
7028: re.updateBounds();
7029: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
7030: undoOp.addElement(re, oldBounds, newBounds );
7031: }
7032: break;
7033: case OperationType.EQUALS_SPACE_V:
7034: // 1. Use an ordered array...
7035: if (getSelectedElements().size() <= 1) break;
7036: myElements = new Vector();
7037:
7038: enum2 = getSelectedElements().elements();
7039: while (enum2.hasMoreElements()) {
7040: re = (ReportElement)enum2.nextElement();
7041: // insert this element in the right position...
7042: if (myElements.size() == 0) myElements.add(re);
7043: else {
7044: boolean inserted=false;
7045: for (int i=0; i<myElements.size(); ++i) {
7046: ReportElement re2 = (ReportElement)myElements.elementAt(i);
7047: if (re.getPosition().y < re2.getPosition().y) {
7048: myElements.insertElementAt(re, i);
7049: inserted = true;
7050: //System.out.println("Inserito re:" + re.getPosition().x + " pos:" + i );
7051: break;
7052: }
7053: }
7054: if (!inserted)
7055: myElements.addElement(re);
7056: }
7057: }
7058:
7059:
7060:
7061: // Find the rightest element...
7062:
7063: int total_height=0;
7064: int available_height=0;
7065: int min_y = 0;
7066: int max_y = 0;
7067: re = (ReportElement)myElements.firstElement();
7068: min_y = re.getPosition().y;
7069: max_y = re.getPosition().y+re.getHeight();
7070: enum2 = myElements.elements();
7071: ReportElement topElement = re;
7072: ReportElement bottomElement = re;
7073: while (enum2.hasMoreElements()) {
7074: re = (ReportElement)enum2.nextElement();
7075: if (min_y > re.getPosition().y) {
7076: min_y =re.getPosition().y;
7077: }
7078: if (max_y < re.getPosition().y+re.getHeight()) {
7079: max_y =re.getPosition().y+re.getHeight();
7080: bottomElement = re;
7081: }
7082: available_height += re.getHeight();
7083: }
7084: available_height = max_y - min_y - available_height;
7085: available_height /= myElements.size()-1;
7086:
7087: int actual_y = topElement.getPosition().y + topElement.getHeight() + available_height;
7088: e = myElements.elements();
7089: while (e.hasMoreElements()){
7090: re = (ReportElement)e.nextElement();
7091: if (re == topElement) continue;
7092: if (re == bottomElement) continue;
7093:
7094: Rectangle oldBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
7095: re.setPosition(new Point(re.getPosition().x,actual_y) );
7096: re.updateBounds();
7097: actual_y += re.getHeight() + available_height;
7098: Rectangle newBounds = new Rectangle( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
7099: undoOp.addElement(re, oldBounds, newBounds );
7100: }
7101: break;
7102: }
7103: this.getReportPanel().repaint();
7104: addUndoOperation(undoOp);
7105: }
7106: */
7107:
7108: public TextFieldReportElement dropNewTextField(
7109: Point newObjectOrigin, String textfieldExpression,
7110: String classExpression) {
7111:
7112: return dropNewTextField(newObjectOrigin, textfieldExpression,
7113: classExpression, "Now");
7114: }
7115:
7116: public Band getBandAt(Point newObjectOrigin) {
7117: Enumeration enum_bands = report.getBands().elements();
7118: Band bname = null;
7119:
7120: int delta_h = 0;
7121: delta_h = gridMultiple(18);
7122: int delta_y = (delta_h < 0) ? delta_h : 0;
7123: int originY = getLogicalDim(Math.min(newObjectOrigin.y - 10
7124: + jVerticalScrollBar.getValue(), newObjectOrigin.y
7125: + delta_y - 10 + jVerticalScrollBar.getValue())) + 10;
7126:
7127: while (enum_bands.hasMoreElements()) {
7128: Band b = (Band) enum_bands.nextElement();
7129: if (report.getBandYLocation(b) + 10 <= originY) {
7130: bname = b;
7131: }
7132: }
7133:
7134: return bname;
7135:
7136: }
7137:
7138: public TextFieldReportElement dropNewTextField(
7139: Point newObjectOrigin, String textfieldExpression,
7140: String classExpression, String time) {
7141: TextFieldReportElement re = null;
7142: // Find the band to associate to the new element...
7143:
7144: re = new TextFieldReportElement(0, 0, 10, 10);
7145: re.setText(textfieldExpression);
7146: re.setMatchingClassExpression(classExpression, true);
7147:
7148: if (re.getClassExpression().equals("java.math.BigDecimal")
7149: || re.getClassExpression().equals("java.lang.Double")
7150: || re.getClassExpression().equals("java.lang.Float")) {
7151: re.setPattern("##0.00");
7152: }
7153:
7154: re.setEvaluationTime(time);
7155: return (TextFieldReportElement) dropReportElement(
7156: newObjectOrigin, re);
7157: }
7158:
7159: /**
7160: * Drop an element into the report.
7161: * Default dimension: 100x18
7162: */
7163: public ReportElement dropReportElement(Point newObjectOrigin,
7164: ReportElement re) {
7165: return dropReportElement(newObjectOrigin, re, 100, 18);
7166: }
7167:
7168: /**
7169: * Drop an element into the report.
7170: * Origin: the drop position
7171: */
7172: public ReportElement dropReportElement(Point newObjectOrigin,
7173: ReportElement re, int defaultWidth, int defaultHeight) {
7174:
7175: Enumeration enum_bands = report.getBands().elements();
7176: Band bname = null;
7177:
7178: int delta_w = 0;
7179: int delta_h = 0;
7180: delta_w = gridMultiple(defaultWidth);
7181: delta_h = gridMultiple(defaultHeight);
7182: int delta_x = (delta_w < 0) ? delta_w : 0;
7183: int delta_y = (delta_h < 0) ? delta_h : 0;
7184:
7185: int originX = getLogicalDim(Math.min(newObjectOrigin.x - 10
7186: + jHorizontalScrollBar.getValue(), newObjectOrigin.x
7187: + delta_x - 10 + jHorizontalScrollBar.getValue())) + 10;
7188: int originY = getLogicalDim(Math.min(newObjectOrigin.y - 10
7189: + jVerticalScrollBar.getValue(), newObjectOrigin.y
7190: + delta_y - 10 + jVerticalScrollBar.getValue())) + 10;
7191: int width = getLogicalDim(Math.abs(delta_w));
7192: int height = getLogicalDim(Math.abs(delta_h));
7193: while (enum_bands.hasMoreElements()) {
7194: Band b = (Band) enum_bands.nextElement();
7195: if (report.getBandYLocation(b) + 10 <= originY) {
7196: bname = b;
7197: }
7198: }
7199: re.setPosition(new Point(originX, originY));
7200: re.setHeight(height);
7201: re.setWidth(width);
7202:
7203: re.setBand(bname);
7204:
7205: report.getElements().addElement(re);
7206:
7207: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
7208: this , re, ReportElementChangedEvent.ADDED));
7209: addUndoOperation(new InsertElementOperation(this , re));
7210:
7211: setSelectedElement(re);
7212: jPanelReport.setCursor(Cursor.getDefaultCursor());
7213: getMainFrame().setActiveTool(0);
7214:
7215: return re;
7216:
7217: }
7218:
7219: public void moveUp() {
7220: if (this .getSelectedElements().size() == 0)
7221: return;
7222:
7223: Enumeration e = this .getSelectedElements().elements();
7224:
7225: ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
7226: this );
7227:
7228: while (e.hasMoreElements()) {
7229: ReportElement element = (ReportElement) e.nextElement();
7230:
7231: int oldPosition = getReport().getElements()
7232: .indexOf(element);
7233: getReport().moveElementUp(element);
7234: /*
7235: getReport().getElements().remove(element);
7236: int newPosition = Math.max(0, oldPosition - 1);
7237: getReport().getElements().insertElementAt(element, newPosition);
7238: */
7239: int newPosition = getReport().getElements()
7240: .indexOf(element);
7241: undoOp.addElement(element, oldPosition, newPosition);
7242: //getReport().elementGroupResort(element.getBand());
7243: }
7244:
7245: addUndoOperation(undoOp);
7246: getReportPanel().repaint();
7247: // We must update the tree... the order i changed...
7248: /* TODO */
7249: }
7250:
7251: public void moveDown() {
7252: if (getSelectedElements().size() == 0)
7253: return;
7254:
7255: ChangeEmentsOrderOperation undoOp = new ChangeEmentsOrderOperation(
7256: this );
7257:
7258: Vector selected = getSelectedElements();
7259: for (int i = selected.size() - 1; i >= 0; i--) {
7260: ReportElement element = (ReportElement) selected.get(i);
7261:
7262: int oldPosition = getReport().getElements()
7263: .indexOf(element);
7264:
7265: // 1. We have to find the first element of this band with elementGroup >=
7266: getReport().moveElementDown(element);
7267:
7268: int newPosition = getReport().getElements()
7269: .indexOf(element);
7270: undoOp.addElement(element, oldPosition, newPosition);
7271:
7272: //getReport().elementGroupResort(element.getBand());
7273: }
7274:
7275: addUndoOperation(undoOp);
7276: getReportPanel().repaint();
7277:
7278: // We must update the tree... the order i changed...
7279: /* TODO */
7280: }
7281:
7282: public void transformStaticInTextFields() {
7283: // Begin code Robert Lamping, 13 july 2004
7284: String keyStaticText = (new StaticTextReportElement(0, 0, 0, 0))
7285: .getKey();
7286: String keyTextField = (new TextFieldReportElement(0, 0, 0, 0))
7287: .getKey();
7288: // End code Robert Lamping, 13 july 2004
7289:
7290: // Edit static Text
7291: Enumeration e = selectedElements.elements();
7292:
7293: ReplacedElementsOperation undoOp = new ReplacedElementsOperation(
7294: this );
7295:
7296: while (e.hasMoreElements()) {
7297: ReportElement re = (ReportElement) e.nextElement();
7298: if (re instanceof StaticTextReportElement) {
7299: // 1.
7300: TextFieldReportElement tfre = new TextFieldReportElement(
7301: re.getPosition().x, re.getPosition().y,
7302: re.width, re.height);
7303: // Set base characteristics...
7304: tfre.copyBaseReportElement(tfre, re);
7305: // Set Text characteristics...
7306:
7307: ((StaticTextReportElement) re).getIReportFont().clone(
7308: tfre.getIReportFont());
7309: /*
7310: tfre.setBold(((TextReportElement)re).isBold() );
7311: tfre.setUnderline( ((TextReportElement)re).isUnderline() );
7312: tfre.setStrikeTrought( ((TextReportElement)re).isStrikeTrought() );
7313: tfre.setItalic( ((TextReportElement)re).isItalic() );
7314: tfre.setLineSpacing( ((TextReportElement)re).getLineSpacing() );
7315: tfre.setPDFFontName( ((TextReportElement)re).getPDFFontName() );
7316: tfre.setPdfEncoding( ((TextReportElement)re).getPdfEncoding() );
7317: tfre.setReportFont( ((TextReportElement)re).getReportFont() );
7318: tfre.setRotate( ((TextReportElement)re).getRotate() );
7319: tfre.setTTFFont( ((TextReportElement)re).getTTFFont() );
7320: tfre.setVerticalAlign( ((TextReportElement)re).getVerticalAlign());
7321: tfre.setFont( ((TextReportElement)re).getFont() );
7322: tfre.setFontName( ((TextReportElement)re).getFontName() );
7323: tfre.setFontSize(((TextReportElement)re).getFontSize() );
7324: */
7325: tfre.setClassExpression("java.lang.String");
7326:
7327: // Begin code Robert Lamping, 13 july 2004
7328: // Changing key element name
7329: if (re.getKey().indexOf(keyStaticText + "-") == 0) {
7330: // key indeed begins with "staticText-"
7331: //Okay then request the next available key for a normal field text
7332: tfre.setKey(getNextElementKey(keyTextField));
7333: }
7334: /* else{
7335: // key text begins with something else then the standard.
7336: // Leave unchanged
7337: )
7338: }
7339: */
7340: // End code Robert Lamping, 13 july 2004
7341: String te = tfre.getText();
7342: ExpressionEditor ed = new ExpressionEditor();
7343: ed.setSubDataset(this .getReport());
7344: ed.setExpression("\"" + te + "\"");
7345: ed.updateTreeEntries();
7346: ed.setVisible(true);
7347: if (ed.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
7348: tfre.setText(ed.getExpression());
7349:
7350: // 1. remove element
7351: int index = getReport().getElements().indexOf(re);
7352: getReport().getElements().remove(re);
7353: getReport().getElements().add(index, tfre);
7354:
7355: int index2 = getSelectedElements().indexOf(re);
7356: getSelectedElements().remove(re);
7357: getSelectedElements().add(index2, tfre);
7358:
7359: // 2. add element
7360: undoOp.addElement(re, tfre);
7361: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
7362: this , re, ReportElementChangedEvent.REMOVED));
7363: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
7364: this , tfre, ReportElementChangedEvent.ADDED));
7365:
7366: }
7367:
7368: }
7369: }
7370: this .addUndoOperation(undoOp);
7371: fireReportListenerReportElementsSelectionChanged(new ReportElementsSelectionEvent(
7372: this , getSelectedElements()));
7373: jPanelReport.repaint();
7374: }
7375:
7376: public void pasteStyle() {
7377: if (this .getSelectedElements().size() == 0)
7378: return;
7379: if (this .getMainFrame().getStyleClipboard() == null)
7380: return;
7381:
7382: // Style are relative to:
7383: ReportElement templateElement = this .getMainFrame()
7384: .getStyleClipboard();
7385:
7386: PasteStyleOperation undoOp = new PasteStyleOperation(this );
7387:
7388: Enumeration elements = getSelectedElements().elements();
7389: Vector changedElements = new Vector();
7390: while (elements.hasMoreElements()) {
7391: ReportElement re = (ReportElement) elements.nextElement();
7392: undoOp.addElement(re, re.cloneMe(), templateElement);
7393: changedElements.add(re);
7394: applyStyle(re, templateElement);
7395: }
7396: this .addUndoOperation(undoOp);
7397: fireReportListenerReportElementsChanged(new ReportElementChangedEvent(
7398: this , changedElements,
7399: ReportElementChangedEvent.CHANGED));
7400: jPanelReport.repaint();
7401:
7402: }
7403:
7404: public static void applyStyle(ReportElement re,
7405: ReportElement templateElement) {
7406: if (re == null || templateElement == null)
7407: return;
7408: // Colors...
7409: if (templateElement.getPropertyValue(re.BGCOLOR) != null) {
7410: re.setBgcolor(templateElement.getBgcolor());
7411: }
7412: if (templateElement.getPropertyValue(re.FGCOLOR) != null) {
7413: re.setFgcolor(templateElement.getFgcolor());
7414: }
7415:
7416: re.setStyle(templateElement.getStyle());
7417:
7418: if (re instanceof GraphicReportElement
7419: && templateElement instanceof GraphicReportElement) {
7420: re
7421: .setPropertyValue(
7422: ((GraphicReportElement) templateElement).FILL,
7423: templateElement
7424: .getPropertyValue(((GraphicReportElement) templateElement).FILL));
7425: re
7426: .setPropertyValue(
7427: ((GraphicReportElement) templateElement).PEN,
7428: templateElement
7429: .getPropertyValue(((GraphicReportElement) templateElement).PEN));
7430:
7431: }
7432: if (re instanceof TextReportElement
7433: && templateElement instanceof TextReportElement) {
7434: ((TextReportElement) re)
7435: .setFont(((TextReportElement) templateElement)
7436: .getFont());
7437:
7438: ((TextReportElement) re)
7439: .setReportFont(((TextReportElement) templateElement)
7440: .getReportFont());
7441:
7442: if (((TextReportElement) templateElement)
7443: .getPropertyValue(TextReportElement.VERTICAL_ALIGN) != null) {
7444: ((TextReportElement) re)
7445: .setVerticalAlign(((TextReportElement) templateElement)
7446: .getVerticalAlign());
7447: }
7448: if (((TextReportElement) templateElement)
7449: .getPropertyValue(TextReportElement.IS_STYLED_TEXT) != null) {
7450: ((TextReportElement) re)
7451: .setIsStyledText(((TextReportElement) templateElement)
7452: .isIsStyledText());
7453: }
7454: if (((TextReportElement) templateElement)
7455: .getPropertyValue(TextReportElement.LINE_SPACING) != null) {
7456: ((TextReportElement) re)
7457: .setLineSpacing(((TextReportElement) templateElement)
7458: .getLineSpacing());
7459: }
7460:
7461: if (((TextReportElement) templateElement)
7462: .getPropertyValue(TextReportElement.ROTATE) != null) {
7463: ((TextReportElement) re)
7464: .setRotate(((TextReportElement) templateElement)
7465: .getRotate());
7466: }
7467: if (((TextReportElement) templateElement)
7468: .getPropertyValue(TextReportElement.ALIGN) != null) {
7469: ((TextReportElement) re)
7470: .setAlign(((TextReportElement) templateElement)
7471: .getAlign());
7472: }
7473: ((TextReportElement) re)
7474: .setIReportFont((IReportFont) ((TextReportElement) templateElement)
7475: .getIReportFont().clone());
7476:
7477: }
7478:
7479: }
7480:
7481: public void copyStyle() {
7482: // We should copy this element to use it as style template...
7483: if (this .getSelectedElements().size() == 0)
7484: return;
7485: this .getMainFrame().setStyleClipbardContent(
7486: ((ReportElement) this .getSelectedElements()
7487: .elementAt(0)).cloneMe());
7488:
7489: }
7490:
7491: public void updateScrollBars() {
7492: jPanelReportComponentResized(null);
7493: }
7494:
7495: // Begin code by Robert Lamping, 12 July 2004
7496: public String getNextElementKey(String keyElement) {
7497: int maxKey = 0;
7498: String prefix = keyElement;
7499:
7500: // check if there is already a "-"
7501: // if so shorten keyElement and assign to prefix
7502: if (prefix.indexOf("-") > 0) {
7503: prefix = prefix.substring(0, prefix.indexOf("-"));
7504: }
7505: prefix = prefix + "-";
7506:
7507: int pos = prefix.indexOf("-") + 1;
7508:
7509: for (Iterator i = report.getElements().iterator(); i.hasNext();) {
7510: ReportElement re = (ReportElement) i.next();
7511: if (re.getKey().indexOf(prefix) == 0) {
7512: try {
7513: int elementNum = (int) Integer.valueOf(
7514: re.getKey().substring(pos)).intValue();
7515: maxKey = maxKey < elementNum ? elementNum : maxKey;
7516: } catch (NumberFormatException err) {
7517: // do nothing.
7518: // string behind contained something else than a number
7519: }
7520: }
7521: }
7522:
7523: /* if (maxKey == 0) {
7524: if (report.getElements().size() > 0 ) {
7525: // all keys were renamed to something else
7526: maxKey = report.getElements().size() ;
7527: }
7528: // else: No elements present: all deleted or start of new document.
7529: }
7530: */
7531:
7532: return (prefix + (maxKey + 1));
7533: }
7534:
7535: // End code by Robert Lamping, 12 July 2004
7536:
7537: // Begin code by Robert Lamping, 16 July 2004
7538: public void centerSelectedElements() {
7539: centerSelectedElements(null);
7540: }
7541:
7542: public void centerSelectedElements(Point center) {
7543:
7544: // This action is done after zooming in or out.
7545: // logOnConsole ("centerSelectedElements \n");
7546: if (getSelectedElements().size() > 0) {
7547: double minX = 999999999.0; //a very high value
7548: double minY = 999999999.0; //a very high value
7549: double maxX = 0.0;
7550: double maxY = 0.0;
7551: double centerX = 0.0;
7552: double centerY = 0.0;
7553: boolean intersects = true;
7554: Rectangle rect = new Rectangle(realPoint(0.0, 0.0),
7555: new Dimension(this .getWidth(), this .getHeight()));
7556:
7557: for (Iterator i = this .getSelectedElements().iterator(); i
7558: .hasNext();) {
7559: ReportElement re = (ReportElement) i.next();
7560:
7561: minY = Math.min(minY, re.getPosition().y - 10);
7562: minX = Math.min(minX, re.getPosition().x - 10);
7563:
7564: maxY = Math.max(maxY, re.getPosition().y
7565: + re.getHeight() - 10);
7566: maxX = Math.max(maxX, re.getPosition().x
7567: + re.getWidth() - 10);
7568:
7569: }
7570: centerX = ((minX + maxX) / 2);
7571: centerY = ((minY + maxY) / 2);
7572:
7573: repositionScrollBars(new Point((int) centerX, (int) centerY));
7574:
7575: } else {
7576: // test: place object in Center, do not select, zoom in with 200%
7577: // and check whether is more or less in the center.
7578: if (center != null) {
7579: repositionScrollBars(center);
7580: }
7581:
7582: }
7583: this .setIsDocDirty(false);
7584:
7585: }
7586:
7587: /**
7588: * Try to reposition the scrollbars so that the point is in the center of the visible screen
7589: * If it is not possible to center it, this method will at least make sure
7590: * the point is visible.
7591: **/
7592:
7593: public void repositionScrollBars(Point center) {
7594: try {
7595: if (jHorizontalScrollBar.getVisibleAmount() < jHorizontalScrollBar
7596: .getMaximum()) {
7597: double horbarvalue = this .jHorizontalScrollBar
7598: .getMaximum()
7599: * center.x / this .report.getWidth();
7600: this .jHorizontalScrollBar
7601: .setValue((int) (horbarvalue - (0.5 * jHorizontalScrollBar
7602: .getVisibleAmount())));
7603: }
7604: if (jVerticalScrollBar.getVisibleAmount() < jVerticalScrollBar
7605: .getMaximum()) {
7606: double verbarvalue = this .jVerticalScrollBar
7607: .getMaximum()
7608: * center.y / this .report.getDesignHeight();
7609: this .jVerticalScrollBar
7610: .setValue((int) (verbarvalue - (0.5 * jVerticalScrollBar
7611: .getVisibleAmount())));
7612: }
7613: } catch (Exception ex) {
7614: /* Do nothing */
7615: }
7616: }
7617:
7618: /**
7619: * calculates center of visible (white) canvas (=report) .
7620: */
7621: public Point getCurrentCenter() {
7622: double centerX = 0.0;
7623: double centerY = 0.0;
7624:
7625: if (jVerticalScrollBar.getVisibleAmount() >= jVerticalScrollBar
7626: .getMaximum()) {
7627: centerY = 0; // this.getReport().getDesignHeight() / 2;
7628: } else {
7629: centerY = (double) this .jVerticalScrollBar.getValue();
7630: centerY += 0.5 * (double) this .jVerticalScrollBar
7631: .getVisibleAmount();
7632: centerY /= (double) this .jVerticalScrollBar.getMaximum();
7633: centerY *= (double) this .getReport().getDesignHeight();
7634: }
7635:
7636: if (jHorizontalScrollBar.getVisibleAmount() >= jHorizontalScrollBar
7637: .getMaximum()) {
7638: //canvas width < frame boundary
7639: // so take report width
7640: centerX = 0; // this.getReport().getWidth() / 2;
7641: } else {
7642: centerX = (double) this .jHorizontalScrollBar.getValue();
7643: centerX += 0.5 * (double) this .jHorizontalScrollBar
7644: .getVisibleAmount();
7645: centerX /= (double) this .jHorizontalScrollBar.getMaximum();
7646: centerX *= (double) this .getReport().getWidth();
7647: }
7648: return new Point((int) centerX, (int) centerY);
7649:
7650: }
7651:
7652: public void logOnConsole(String s) {
7653: this .getMainFrame().logOnConsole(s);
7654: }
7655:
7656: public Point realPoint(double deltaX, double deltaY) {
7657: ;
7658: double centerX = 0.0;
7659: double centerY = 0.0;
7660:
7661: centerX = (double) this .jHorizontalScrollBar.getValue();
7662: centerX += (double) deltaX;
7663: centerX /= (double) this .jHorizontalScrollBar.getMaximum();
7664: centerX *= (double) this .getReport().getWidth();
7665:
7666: centerY = (double) this .jVerticalScrollBar.getValue();
7667: centerY += (double) deltaY;
7668: centerY /= (double) this .jVerticalScrollBar.getMaximum();
7669: centerY *= (double) this .getReport().getDesignHeight();
7670:
7671: return new Point((int) centerX, (int) centerY);
7672: }
7673:
7674: public java.util.Vector getBandElements(Band band) {
7675: Vector bandElements = new Vector();
7676:
7677: for (Iterator i = getReport().getElements().iterator(); i
7678: .hasNext();) {
7679: ReportElement re = (ReportElement) i.next();
7680: if (re.getBand().equals(band)) {
7681: bandElements.addElement(re);
7682: }
7683: }
7684: return bandElements;
7685: }
7686:
7687: /**
7688: * Resize the band, as a result of dragging or double click
7689: * @param Band band The band you wish to resize
7690: * @param int delta The change in height (plus or min)
7691: * @param Boolean include (TRUE: move elements in current band too)
7692: * @author: Robert Lamping, 24 july 2004
7693: */
7694: public void resizeBand(Band band, int delta, boolean include) {
7695:
7696: BandDraggedOperation undoOp = new BandDraggedOperation(this ,
7697: band);
7698: // Adjustband Height.
7699: band.setHeight(band.getHeight() + delta);
7700: // pass the change in bandheight to the undo operation
7701: undoOp.setBandDelta(delta);
7702:
7703: // adjust all elements that are positioned in the remaining bands.
7704: int edge_y = 0;
7705:
7706: if (include) {
7707: edge_y = band.getBandYLocation() + band.getHeight() + delta;
7708: } else {
7709: edge_y = band.getBandYLocation() + band.getHeight();
7710: }
7711:
7712: for (Iterator i = report.getElements().iterator(); i.hasNext();) {
7713: ReportElement re = (ReportElement) i.next();
7714: if (re.getParentElement() != null)
7715: continue;
7716: //logOnConsole( "re.position : " + re.position + "\n");
7717: //logOnConsole( "edge_y : " + edge_y + "\n");
7718: //logOnConsole( "edge_y + 10 : " + (edge_y + 10) + "\n");
7719: if (re.position.y >= edge_y + 10) {
7720: // get the current position for the undo operation
7721: Rectangle oldBounds = re.getBounds();
7722: re.setPosition(new Point(re.getPosition().x, re
7723: .getPosition().y
7724: + delta));
7725: // get the new position for the undo operation
7726: Rectangle newBounds = re.getBounds();
7727: // add another task to the undo operation.
7728: undoOp.addElement(re, oldBounds, newBounds);
7729: }
7730: }
7731: // Pass all undo tasks to the undo cluster.
7732: addUndoOperation(undoOp);
7733:
7734: fireReportListenerReportBandChanged(new ReportBandChangedEvent(
7735: this , band, ReportBandChangedEvent.CHANGED));
7736: }
7737:
7738: /**
7739: * Shrink the band to just hold the elements in it
7740: * No action if no elements present in band.
7741: * @param Band band The band you wish to shrink
7742: * @author: Robert Lamping, 24 july 2004
7743: */
7744: public void shrinkBand(Band band) {
7745:
7746: int maxY = 0;
7747: // Go through the list of elements and add elements if they belong to the band
7748: for (Iterator i = getBandElements(band).iterator(); i.hasNext();) {
7749: ReportElement re = (ReportElement) i.next();
7750: maxY = Math.max(maxY, re.position.y + re.height);
7751: if (re instanceof LineReportElement) {
7752: /* a line can not be displayed if position on a band boundary */
7753: /* A lines height ==0 , that is why */
7754: maxY = Math.max(maxY, re.position.y + re.height + 1);
7755:
7756: } else {
7757: maxY = Math.max(maxY, re.position.y + re.height);
7758:
7759: }
7760: }
7761:
7762: if (maxY > 0) {
7763: /* There was an element in the band, so changing the band height is allowed */
7764: // Calculate delta
7765: int delta = maxY - band.getBandYLocation() - 10
7766: - band.getHeight();
7767: resizeBand(band, delta, false); // false: do not included items in the band.
7768: // Work done. nothing else
7769: }
7770: }
7771:
7772: public Point straighten(int delta_w, int delta_h) {
7773: // straighten on 90 % degrees
7774: double clipAngle = 15;
7775:
7776: double R = Math.sqrt((delta_w * delta_w) + (delta_h * delta_h));
7777: double cos = delta_w / R;
7778: double angle = 180 * Math.acos(cos) / Math.PI;
7779:
7780: int repeat = (int) Math.floor((angle + (0.5 * clipAngle))
7781: / clipAngle);
7782:
7783: double newAngle = repeat * clipAngle;
7784:
7785: // keep the sign the same!
7786: delta_h = (int) (Math.abs((R * Math.sin((newAngle / 180)
7787: * Math.PI)))
7788: * delta_h / Math.abs(delta_h));
7789:
7790: delta_w = (int) (Math.abs((R * Math.cos((newAngle / 180)
7791: * Math.PI)))
7792: * delta_w / Math.abs(delta_w));
7793:
7794: // aligning on the grid if necessary
7795: if (Math.abs(delta_h) == Math.abs(delta_w)) {
7796: delta_h = gridMultiple(delta_h);
7797: delta_w = gridMultiple(delta_w);
7798: } else {
7799: if (delta_w == 0) {
7800: delta_h = gridMultiple(delta_h);
7801: }
7802: if (delta_h == 0) {
7803: delta_w = gridMultiple(delta_w);
7804: }
7805: }
7806:
7807: return new Point(delta_w, delta_h);
7808: }
7809:
7810: public java.awt.Image getImage() {
7811: java.awt.image.BufferedImage img = new BufferedImage(
7812: getReport().getWidth() * 2 + 20, getReport()
7813: .getDesignHeight() * 2 + 20,
7814: BufferedImage.TYPE_INT_ARGB);
7815: GraphicsEnvironment grenv = GraphicsEnvironment
7816: .getLocalGraphicsEnvironment();
7817: Graphics2D g2d = grenv.createGraphics(img);
7818: int oldVscroll = jVerticalScrollBar.getValue();
7819: int oldHscroll = jHorizontalScrollBar.getValue();
7820:
7821: jVerticalScrollBar.setValue(0);
7822: jHorizontalScrollBar.setValue(0);
7823:
7824: double oldZoom = this .zoomFactor;
7825: this .zoomFactor = 2;
7826:
7827: try {
7828:
7829: g2d.setClip(0, 0, getReport().getWidth() * 2 + 20,
7830: getReport().getDesignHeight() * 2 + 20);
7831: this .paintReportPanel(g2d);
7832: /*
7833: com.keypoint.PngEncoder png_enc = new com.keypoint.PngEncoder(img);
7834: byte[] buf = png_enc.pngEncode();
7835: java.io.FileOutputStream fos = new java.io.FileOutputStream("C:\\tmp.png");
7836: fos.write(buf);
7837: fos.close();
7838: */
7839: } catch (Exception ex) {
7840: ex.printStackTrace();
7841: }
7842: this .zoomFactor = oldZoom;
7843: jVerticalScrollBar.setValue(oldVscroll);
7844: jHorizontalScrollBar.setValue(oldHscroll);
7845:
7846: return img;
7847:
7848: }
7849:
7850: public java.util.List getOpenedNodesDocumentStructure() {
7851: return openedNodesDocumentStructure;
7852: }
7853:
7854: public void setOpenedNodesDocumentStructure(
7855: java.util.List openedNodesDocumentStructure) {
7856: this .openedNodesDocumentStructure = openedNodesDocumentStructure;
7857: }
7858:
7859: public void addCrosstabEditor(CrosstabReportElement re) {
7860: CrosstabEditor crosstabEditor = new CrosstabEditor(re);
7861: jTabbedPane1
7862: .addTab(
7863: re.getName(),
7864: new javax.swing.ImageIcon(
7865: getClass()
7866: .getResource(
7867: "/it/businesslogic/ireport/icons/crosstab.png")),
7868: crosstabEditor);
7869: tabs++;
7870: updateTabs();
7871: }
7872:
7873: public CrosstabEditor getCrosstabEditor(CrosstabReportElement re) {
7874: if (re != null) {
7875: for (int i = 1; i < jTabbedPane1.getTabCount(); ++i) {
7876: if (jTabbedPane1.getComponentAt(i) instanceof CrosstabEditor) {
7877: CrosstabEditor ce = (CrosstabEditor) jTabbedPane1
7878: .getComponentAt(i);
7879: if (ce.getCrosstabElement() == re) {
7880: return ce;
7881: }
7882: }
7883: }
7884: }
7885: return null;
7886: }
7887:
7888: public void removeCrosstabEditor(CrosstabReportElement re) {
7889:
7890: if (re != null) {
7891: for (int i = 1; i < jTabbedPane1.getTabCount(); ++i) {
7892: if (jTabbedPane1.getComponentAt(i) instanceof CrosstabEditor) {
7893: CrosstabEditor ce = (CrosstabEditor) jTabbedPane1
7894: .getComponentAt(i);
7895: if (ce.getCrosstabElement() == re) {
7896: jTabbedPane1.remove(i);
7897: tabs--;
7898: break;
7899: }
7900: }
7901: }
7902: }
7903:
7904: updateTabs();
7905:
7906: }
7907:
7908: public void updateTabs() {
7909: if (tabs == 0 && jTabbedPane1.isVisible()) {
7910: jTabbedPane1.setVisible(false);
7911: getContentPane().remove(jTabbedPane1);
7912: getContentPane().add(jPanelSuperContainer,
7913: java.awt.BorderLayout.CENTER);
7914: jPanelSuperContainer.updateUI();
7915: } else if (tabs > 0 && !jTabbedPane1.isVisible()) {
7916: jTabbedPane1.setVisible(true);
7917: getContentPane().remove(jPanelSuperContainer);
7918: jTabbedPane1
7919: .insertTab(
7920: I18n.getString("jReportFrame.mainReport",
7921: "Main report"),
7922: new javax.swing.ImageIcon(
7923: getClass()
7924: .getResource(
7925: "/it/businesslogic/ireport/icons/mainreport.png")),
7926: jPanelSuperContainer, I18n.getString(
7927: "jReportFrame.mainReport.tooltip",
7928: "Main report editor"), 0);
7929: jTabbedPane1.setSelectedIndex(0);
7930: getContentPane().add(jTabbedPane1,
7931: java.awt.BorderLayout.CENTER);
7932: jTabbedPane1.updateUI();
7933: }
7934:
7935: this .updateUI();
7936: // This trick force the recalculation of the window position
7937: try {
7938: if (this .isMaximum()) {
7939: //this.setMaximum(false);
7940: //this.setMaximum(true);
7941: }
7942: } catch (Exception ex) {
7943: ex.printStackTrace();
7944: }
7945: }
7946:
7947: public CrosstabEditorPanel getSelectedCrosstabEditorPanel() {
7948: if (tabs > 0) {
7949: int i = jTabbedPane1.getSelectedIndex();
7950: if (jTabbedPane1.getComponentAt(i) instanceof CrosstabEditor) {
7951: CrosstabEditor ce = (CrosstabEditor) jTabbedPane1
7952: .getComponentAt(i);
7953: return ce.getPanelEditor();
7954: }
7955: }
7956: return null;
7957: }
7958:
7959: //Added by Felix Firgau on 9th Feb 2006
7960: public void applyI18n() {
7961: // Start autogenerated code ----------------------
7962: jMenuItemRightMargin.setText(I18n.getString(
7963: "jReportFrame.menuItemRightMargin",
7964: "Join right page margin"));
7965: jMenuItemLeftMargin.setText(I18n.getString(
7966: "jReportFrame.menuItemLeftMargin",
7967: "Join left page margin"));
7968: jMenuItemBandProperties1.setText(I18n.getString(
7969: "jReportFrame.menuItemBandProperties1",
7970: "Band properties"));
7971: jMenuItemElementChartProperties.setText(I18n.getString(
7972: "jReportFrame.menuItemElementChartProperties",
7973: "Chart properties"));
7974: jMenuItemElementCrosstabDesignProperties
7975: .setText(I18n
7976: .getString(
7977: "jReportFrame.menuItemElementCrosstabDesignProperties",
7978: "Go to crosstab design tab...."));
7979: jMenuItemElementCrosstabProperties.setText(I18n.getString(
7980: "jReportFrame.menuItemElementCrosstabProperties",
7981: "Crosstab properties"));
7982: jMenuItemElementOpenSubreport.setText(I18n.getString(
7983: "jReportFrame.menuItemElementOpenSubreport",
7984: "Open subreport"));
7985: jMenuItemEditExpression.setText(I18n.getString(
7986: "jReportFrame.menuItemElementEditExpression",
7987: "Edit Expression"));
7988:
7989: // End autogenerated code ----------------------
7990: jMenuItemPasteOnBand.setText(it.businesslogic.ireport.util.I18n
7991: .getString("pasteHere", "Paste here"));
7992: jMenuItemBandProperties
7993: .setText(it.businesslogic.ireport.util.I18n.getString(
7994: "bandProperties", "Band properties"));
7995: jMenuItemCut.setText(it.businesslogic.ireport.util.I18n
7996: .getString("cut", "Cut"));
7997: jMenuItemCopy.setText(it.businesslogic.ireport.util.I18n
7998: .getString("copy", "Copy"));
7999: jMenuItemPaste.setText(it.businesslogic.ireport.util.I18n
8000: .getString("paste", "Paste"));
8001: jMenuItemDelete.setText(it.businesslogic.ireport.util.I18n
8002: .getString("delete", "Delete"));
8003: jMenuItemGroup.setText(it.businesslogic.ireport.util.I18n
8004: .getString("groupSelectedElements",
8005: "Group selected elements"));
8006: jMenuItemUngroup.setText(it.businesslogic.ireport.util.I18n
8007: .getString("ungroupSelectedElements",
8008: "Ungroup selected elements"));
8009: jMenuItemCopyStyle.setText(it.businesslogic.ireport.util.I18n
8010: .getString("copyStyle", "Copy style"));
8011: jMenuItemPasteStyle.setText(it.businesslogic.ireport.util.I18n
8012: .getString("pasteStyle", "Paste style"));
8013: jMenuItemElementProperties
8014: .setText(it.businesslogic.ireport.util.I18n.getString(
8015: "properties", "Properties"));
8016: jMenuItemPattern.setText(it.businesslogic.ireport.util.I18n
8017: .getString("fieldPattern", "Field pattern"));
8018:
8019: if (jTabbedPane1.getTabCount() >= 1) {
8020: jTabbedPane1.setTitleAt(0, I18n.getString(
8021: "jReportFrame.mainReport", "Main report"));
8022: jTabbedPane1.setToolTipTextAt(0, I18n.getString(
8023: "jReportFrame.mainReport.tooltip",
8024: "Main report editor"));
8025: }
8026: }
8027:
8028: public void languageChanged(LanguageChangedEvent evt) {
8029:
8030: this .applyI18n();
8031: }//End
8032:
8033: /**
8034: * This method returns the correct mouse x checking for magnetic points like
8035: * a grid or a magnetic line...
8036: * The magnetism affects ever only the main element in a selection, in this way all elements
8037: * in a selection share the same delta_x and delta_y in a transformation.
8038: *
8039: * mouse_x = the current position of the mouse
8040: * original_x = the original mouse position when the transformation started...
8041: */
8042: protected int optimizeX(int mouse_x, int original_x,
8043: int transformation_type, ReportElement referenceElement) {
8044: int real_o_x = getLogicalDim((int) (original_x
8045: + jHorizontalScrollBar.getValue() - 10));
8046: int real_x = getLogicalDim(mouse_x
8047: + jHorizontalScrollBar.getValue() - 10);
8048: int gz = getGridSize();
8049: int x_delta = real_x - real_o_x;
8050:
8051: // 1. Calc delta between the current position and the first good snap...
8052: if (transformation_type == TransformationType.TRANSFORMATION_MOVE
8053: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
8054: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW
8055: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_W) {
8056: // Get the minimum x to bring the left corner on a valid magnetic line or
8057: // on the grid...
8058: int x_mag_ele = closestXMagneticElement(referenceElement
8059: .getPosition().x
8060: + x_delta, gz, jHorizontalRule.getGuideLines());
8061: x_delta = x_mag_ele - referenceElement.getPosition().x;
8062: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE
8063: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
8064: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_E) {
8065:
8066: int x_mag_ele = closestXMagneticElement(referenceElement
8067: .getPosition().x
8068: + referenceElement.getWidth() + x_delta, gz,
8069: jHorizontalRule.getGuideLines());
8070: x_delta = x_mag_ele - referenceElement.getPosition().x
8071: - referenceElement.getWidth();
8072:
8073: }
8074:
8075: real_x = real_o_x + x_delta;
8076:
8077: if (real_x != real_o_x) {
8078: return 10 - jHorizontalScrollBar.getValue()
8079: + getZoomedDim(real_x);
8080: }
8081:
8082: return original_x;
8083: }
8084:
8085: /**
8086: * Find the closest grid or magnetic line to this x...
8087: * * x must be in logical size + 10
8088: */
8089: private int closestXMagneticElement(int x, int gsize,
8090: java.util.List magneticLines) {
8091: // If using grid....
8092: int optimizedx = x;
8093: matchedVerticalLine = -1;
8094:
8095: if (magneticLines != null) {
8096: for (int i = 0; i < magneticLines.size(); ++i) {
8097: int line = ((Integer) magneticLines.get(i)).intValue() + 10;
8098: if (x < line + MAGNETIC_POWER
8099: && x > line - MAGNETIC_POWER)
8100: return line;
8101: }
8102: }
8103:
8104: if (isSnapToGrid()) {
8105: optimizedx = x - 10;
8106: int grid_positions = optimizedx / gsize;
8107: int rest = optimizedx % gsize;
8108: if (rest > gsize / 2)
8109: grid_positions++;
8110: optimizedx = 10 + (grid_positions * gsize);
8111: return optimizedx;
8112: }
8113:
8114: // If using magnetic lines....
8115: // Check for magnetic lines....
8116:
8117: // Snap to objects...
8118: if (verticalObjectsLines != null) {
8119: for (int i = 0; i < verticalObjectsLines.size(); ++i) {
8120: int line = ((Integer) verticalObjectsLines.get(i))
8121: .intValue();
8122:
8123: if (x < line + MAGNETIC_POWER
8124: && x > line - MAGNETIC_POWER) {
8125: matchedVerticalLine = line;
8126: return line;
8127: }
8128: }
8129: }
8130:
8131: return x;
8132: }
8133:
8134: /**
8135: * This method returns the correct mouse x checking for magnetic points like
8136: * a grid or a magnetic line...
8137: * The magnetism affects ever only the main element in a selection, in this way all elements
8138: * in a selection share the same delta_x and delta_y in a transformation.
8139: *
8140: * mouse_x = the current position of the mouse
8141: * original_x = the original mouse position when the transformation started...
8142: */
8143: protected int optimizeY(int mouse_y, int original_y,
8144: int transformation_type, ReportElement referenceElement) {
8145: int real_o_y = getLogicalDim((int) (original_y
8146: + jVerticalScrollBar.getValue() - 10));
8147: int real_y = getLogicalDim(mouse_y
8148: + jVerticalScrollBar.getValue() - 10);
8149: int gz = getGridSize();
8150: int y_delta = real_y - real_o_y;
8151:
8152: // 1. Calc delta between the current position and the first good snap...
8153: if (transformation_type == TransformationType.TRANSFORMATION_MOVE
8154: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_NW
8155: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_NE
8156: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_N) {
8157: // Get the minimum x to bring the left corner on a valid magnetic line or
8158: // on the grid...
8159: int y_mag_ele = closestYMagneticElement(referenceElement
8160: .getPosition().y
8161: + y_delta, gz, jVerticalRule.getGuideLines());
8162: y_delta = y_mag_ele - referenceElement.getPosition().y;
8163: } else if (transformation_type == TransformationType.TRANSFORMATION_RESIZE_SE
8164: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_SW
8165: || transformation_type == TransformationType.TRANSFORMATION_RESIZE_S) {
8166:
8167: int y_mag_ele = closestYMagneticElement(referenceElement
8168: .getPosition().y
8169: + referenceElement.getHeight() + y_delta, gz,
8170: jVerticalRule.getGuideLines());
8171: y_delta = y_mag_ele - referenceElement.getPosition().y
8172: - referenceElement.getHeight();
8173:
8174: }
8175:
8176: real_y = real_o_y + y_delta;
8177:
8178: if (real_y != real_o_y) {
8179: return 10 - jVerticalScrollBar.getValue()
8180: + getZoomedDim(real_y);
8181: }
8182:
8183: return original_y;
8184: }
8185:
8186: /**
8187: * Find the closest grid or magnetic line to this x...
8188: * x must be in logical size + 10
8189: */
8190: private int closestYMagneticElement(int y, int gsize,
8191: java.util.List magneticLines) {
8192: // If using grid....
8193: int optimizedy = y;
8194:
8195: matchedHorizontalLine = -1;
8196:
8197: if (magneticLines != null) {
8198: for (int i = 0; i < magneticLines.size(); ++i) {
8199: int line = ((Integer) magneticLines.get(i)).intValue() + 10;
8200: if (y < line + MAGNETIC_POWER
8201: && y > line - MAGNETIC_POWER)
8202: return line;
8203: }
8204: }
8205:
8206: if (isSnapToGrid()) {
8207: optimizedy = y - 10;
8208: int grid_positions = optimizedy / gsize;
8209: int rest = optimizedy % gsize;
8210: if (rest > gsize / 2)
8211: grid_positions++;
8212: optimizedy = 10 + (grid_positions * gsize);
8213: return optimizedy;
8214: }
8215:
8216: // Snap to objects...
8217:
8218: if (horizontalObjectsLines != null) {
8219: for (int i = 0; i < horizontalObjectsLines.size(); ++i) {
8220: int line = ((Integer) horizontalObjectsLines.get(i))
8221: .intValue();
8222:
8223: if (y < line + MAGNETIC_POWER
8224: && y > line - MAGNETIC_POWER) {
8225: matchedHorizontalLine = line;
8226: return line;
8227: }
8228: }
8229: }
8230:
8231: // If using magnetic lines....
8232: // Check for magnetic lines....
8233:
8234: return y;
8235: }
8236:
8237: /**
8238: * On close event.
8239: * Please return true on force.
8240: * Return false to stop the window close.
8241: *
8242: * Overrided from JMDIFrame
8243: */
8244: public boolean closingFrame(boolean force) {
8245: if (force)
8246: return true;
8247: JReportFrame jrf = this ;
8248: MainFrame.getMainInstance().setActiveReportForm(jrf);
8249:
8250: boolean saveIt = false;
8251: if (jrf.getReport().isModified()
8252: && !MainFrame.getMainInstance().getProperties()
8253: .getProperty("AskToSave", "true").equals(
8254: "false")) {
8255: String message = I18n
8256: .getString("messages.jReportFrame.saveReport",
8257: "Would you like to save the report before exiting?");
8258: String caption = I18n.getString(
8259: "messages.jReportFrame.unsavedFileUnchanged",
8260: "Unsaved file (Unchanged)");
8261: if (jrf.getReport().isModified()) {
8262: caption = I18n.getString(
8263: "messages.jReportFrame.unsavedFileChanged",
8264: "Unsaved file (Changed)");
8265: }
8266:
8267: int ret = javax.swing.JOptionPane.showConfirmDialog(this ,
8268: message, caption,
8269: javax.swing.JOptionPane.YES_NO_CANCEL_OPTION);
8270:
8271: switch (ret) {
8272: case javax.swing.JOptionPane.YES_OPTION:
8273: saveIt = true;
8274: break;
8275: case javax.swing.JOptionPane.NO_OPTION:
8276: saveIt = false;
8277: break;
8278: default:
8279: return false;
8280: }
8281: }
8282:
8283: if (saveIt) {
8284: java.awt.event.ActionEvent ae = new java.awt.event.ActionEvent(
8285: this , 0, "");
8286: MainFrame.getMainInstance()
8287: .jMenuItemSaveActionPerformed(ae);
8288: if (jrf.getReport().isModified())
8289: return false;
8290: }
8291: return true;
8292: }
8293:
8294: public int getHScroll() {
8295: return jHorizontalScrollBar.getValue();
8296: }
8297:
8298: public int getVScroll() {
8299: return jVerticalScrollBar.getValue();
8300: }
8301:
8302: public void repaintRules() {
8303: jHorizontalRule.repaint();
8304: jVerticalRule.repaint();
8305: }
8306:
8307: public void updateGridSize(int newValue) {
8308: this .repaint();
8309: }
8310:
8311: public void addChildElements(ReportElement parentRe, Vector elements) {
8312: Enumeration e = getReport().getElements().elements();
8313: while (e.hasMoreElements()) {
8314: ReportElement re = (ReportElement) e.nextElement();
8315:
8316: if (re.getParentElement() == parentRe
8317: && !elements.contains(re)) {
8318: elements.add(re);
8319: if (re instanceof FrameReportElement) {
8320: // Add all child elements ..
8321: addChildElements(re, elements);
8322: }
8323: }
8324: }
8325: }
8326:
8327: public java.util.List getReportProblems() {
8328: return reportProblems;
8329: }
8330:
8331: public void setReportProblems(java.util.List reportProblems) {
8332: this .reportProblems = reportProblems;
8333: }
8334:
8335: public Vector getSelectedBands() {
8336: return selectedBands;
8337: }
8338:
8339: public void setSelectedBands(Vector selectedBands) {
8340: this .selectedBands = selectedBands;
8341: fireReportListenerReportBandsSelectionChanged(new ReportBandsSelectionEvent(
8342: this , null, getSelectedBands()));
8343: }
8344:
8345: /**
8346: * Returns the objects selected in the document structure
8347: */
8348: public Vector getSelectedObjects() {
8349: return selectedObjects;
8350: }
8351:
8352: /**
8353: * Set the selected objects. A ReportObjectSelectionEvent is fired...
8354: */
8355: public void setSelectedObjects(Vector selectedObjects) {
8356: this .selectedObjects = selectedObjects;
8357: fireReportListenerReportObjectsSelectionChanged(new ReportObjectsSelectionEvent(
8358: this , null, getSelectedObjects()));
8359: }
8360:
8361: private java.util.List getAlignMatches(Rectangle bounds) {
8362:
8363: java.util.List list = new java.util.ArrayList();
8364:
8365: java.util.List listHorizontals = new java.util.ArrayList();
8366: java.util.List listVerticals = new java.util.ArrayList();
8367:
8368: // 1. transform the bound in a real rectangle...
8369: int originX = getLogicalDim(bounds.x - 10
8370: + jHorizontalScrollBar.getValue()) + 10;
8371: int originY = getLogicalDim(bounds.y - 10
8372: + jVerticalScrollBar.getValue()) + 10;
8373: int width = getLogicalDim(bounds.width);
8374: int height = getLogicalDim(bounds.height);
8375:
8376: if (matchedVerticalLine > 0) {
8377:
8378: int minY = originY;
8379: int maxY = originY + height;
8380: // find the minimum value for X where Y = matchedVerticalLine....
8381: Enumeration enum_ele = this .getReport().getElements()
8382: .elements();
8383: while (enum_ele.hasMoreElements()) {
8384: ReportElement re = (ReportElement) enum_ele
8385: .nextElement();
8386: if (getSelectedElements().contains(re))
8387: continue;
8388:
8389: if (re.getPosition().x == matchedVerticalLine
8390: || re.getPosition().x + re.getWidth() == matchedVerticalLine) // Same X
8391: {
8392: minY = Math.min(re.getPosition().y, minY);
8393: maxY = Math.max(
8394: re.getPosition().y + re.getHeight(), maxY);
8395: }
8396: }
8397: int x = getZoomedDim(matchedVerticalLine - 10) + 10
8398: - jHorizontalScrollBar.getValue();
8399: Line2D line = new Line2D.Double(x, 10
8400: - jVerticalScrollBar.getValue()
8401: + getZoomedDim(minY - 10) - 20, x, 10
8402: - jVerticalScrollBar.getValue()
8403: + getZoomedDim(maxY - 10) + 20);
8404: list.add(line);
8405: matchedVerticalLine = -1;
8406: }
8407:
8408: if (matchedHorizontalLine > 0) {
8409:
8410: int minX = originX;
8411: int maxX = originX + width;
8412: // find the minimum value for X where Y = matchedVerticalLine....
8413: Enumeration enum_ele = this .getReport().getElements()
8414: .elements();
8415: while (enum_ele.hasMoreElements()) {
8416: ReportElement re = (ReportElement) enum_ele
8417: .nextElement();
8418: if (getSelectedElements().contains(re))
8419: continue;
8420:
8421: if (re.getPosition().y == matchedHorizontalLine
8422: || re.getPosition().y + re.getHeight() == matchedHorizontalLine) // Same Y
8423: {
8424: minX = Math.min(re.getPosition().x, minX);
8425: maxX = Math.max(re.getPosition().x + re.getWidth(),
8426: maxX);
8427: }
8428: }
8429: int y = 10 - jVerticalScrollBar.getValue()
8430: + getZoomedDim(matchedHorizontalLine - 10);
8431: Line2D line = new Line2D.Double(getZoomedDim(minX - 10)
8432: + 10 - jVerticalScrollBar.getValue() - 20, y,
8433: getZoomedDim(maxX - 10) + 10
8434: - jVerticalScrollBar.getValue() + 20, y);
8435: list.add(line);
8436: matchedHorizontalLine = -1;
8437: }
8438:
8439: return list;
8440: }
8441:
8442: public void redrawReferenceGuides(Graphics gg) {
8443: if (paintedAlignLines.size() > 0) {
8444: try {
8445:
8446: gg.setXORMode(new Color(112, 91, 22));
8447: Stroke st = ((Graphics2D) gg).getStroke();
8448: ((Graphics2D) gg).setStroke(ReportElement.getPenStroke(
8449: "Dotted", null, 1));
8450:
8451: for (int dj = 0; dj < paintedAlignLines.size(); ++dj) {
8452: java.awt.geom.Line2D line = (java.awt.geom.Line2D) paintedAlignLines
8453: .get(dj);
8454: ((Graphics2D) gg).draw(line);
8455: //System.out.println("Removed" + line.getP1() + " " + line.getP2());
8456: }
8457: ((Graphics2D) gg).setStroke(st);
8458: } catch (Exception ex) {
8459:
8460: }
8461: }
8462:
8463: gg.setXORMode(Color.WHITE);
8464: }
8465:
8466: BufferedImage offscreenImage = null;
8467: BufferedImage offscreenImage2 = null;
8468: Graphics2D offscreenImage2g = null;
8469:
8470: private void initOffscreenImage() {
8471: offscreenImage = null;
8472: offscreenImage2 = null;
8473: int w = jPanelReport.getWidth();
8474: int h = jPanelReport.getHeight();
8475: offscreenImage = new BufferedImage(w, h,
8476: BufferedImage.TYPE_INT_ARGB);
8477: offscreenImage2 = new BufferedImage(w, h,
8478: BufferedImage.TYPE_INT_ARGB);
8479: GraphicsEnvironment grenv = GraphicsEnvironment
8480: .getLocalGraphicsEnvironment();
8481: Graphics2D g2d = grenv.createGraphics(offscreenImage);
8482: offscreenImage2g = grenv.createGraphics(offscreenImage2);
8483: this .paintReportPanel(g2d);
8484: g2d.dispose();
8485:
8486: //jPanelReport.getGraphics().drawImage(offscreenImage,0,0,null);
8487:
8488: //jPanelReport.getGraphics().drawLine(0,0,400,400);
8489: }
8490:
8491: private boolean redrawWithBufferedImage = false;
8492:
8493: public boolean isRedrawWithBufferedImage() {
8494: return redrawWithBufferedImage;
8495: }
8496:
8497: public void setRedrawWithBufferedImage(boolean b) {
8498:
8499: if (b && !isRedrawWithBufferedImage()) {
8500: initOffscreenImage();
8501: }
8502: this .redrawWithBufferedImage = redrawWithBufferedImage;
8503: }
8504:
8505: public void jCustomElementPropertiesMenuItemActionPerformed(
8506: ActionEvent evt) {
8507:
8508: if (this .getSelectedElements().size() == 0)
8509: return;
8510: PropertiesDialog pd = new PropertiesDialog(MainFrame
8511: .getMainInstance(), true);
8512:
8513: ReportElement re = (ReportElement) getSelectedElements().get(0);
8514: pd.setProperties(re.getElementProperties());
8515: pd.setVisible(true);
8516: if (pd.getDialogResult() == JOptionPane.OK_OPTION) {
8517: re.setElementProperties(pd.getProperties());
8518: getReport().incrementReportChanges();
8519: }
8520: }
8521:
8522: }
|