001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * FormatCommandRemoveSpaceV.java
028: *
029: * Created on 9 mei 2005, 21:36
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.command;
034:
035: import it.businesslogic.ireport.Band;
036: import it.businesslogic.ireport.OperationType;
037: import it.businesslogic.ireport.ReportElement;
038: import java.awt.Point;
039: import java.util.Enumeration;
040: import java.util.Iterator;
041: import java.util.Vector;
042:
043: /**
044: *
045: *
046: */
047: public class FormatCommandRemoveSpaceV extends FormatCommand {
048: int actual_y;
049: int available_height;
050: Band activeBand;
051: ReportElement bottomElement;
052: Vector myElements = null;
053: Vector bands = null;
054:
055: {
056: operationType = OperationType.EQUALS_SPACE_V;
057: }
058:
059: boolean preCondition() {
060: activeBand = (Band) ((ReportElement) this .getSelectedElements()
061: .firstElement()).getBand();
062: int counter = 0;
063:
064: for (Iterator i = this .getSelectedElements().iterator(); i
065: .hasNext();) {
066: ReportElement re = (ReportElement) i.next();
067: if (re.getBand() == activeBand) {
068: counter++;
069: }
070: }
071: return (counter > 1);
072:
073: }
074:
075: void preparation() {
076: available_height = 0;
077: }
078:
079: void executeDeeper() {
080: // resetEnumeration();
081: preparation();
082:
083: bands = getBands();
084:
085: for (Iterator h = bands.iterator(); h.hasNext();) {
086: Band b = (Band) h.next();
087: Vector bandElements = getBandElements(b);
088: bandElements = sortYX(bandElements.elements());
089:
090: if (bandElements.size() > 1) {
091: ReportElement re = (ReportElement) bandElements
092: .firstElement();
093: actual_y = re.getPosition().y + re.getHeight()
094: + available_height;
095:
096: // the highest element in the band doesn't have to be moved
097: bandElements.removeElement(re);
098:
099: processElements(bandElements.elements());
100: }
101: }
102: }
103:
104: public void modify() {
105: re.setPosition(new Point(re.getPosition().x, actual_y));
106: actual_y += re.getHeight() + available_height;
107: }
108:
109: }
|