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: * ReportElement.java
0028: *
0029: */
0030:
0031: package it.businesslogic.ireport;
0032:
0033: import it.businesslogic.ireport.crosstab.CrosstabCell;
0034: import it.businesslogic.ireport.gui.MainFrame;
0035: import it.businesslogic.ireport.util.*;
0036:
0037: import java.awt.*;
0038: import java.awt.geom.*;
0039: import java.awt.geom.Rectangle2D.Double;
0040: import java.awt.image.*;
0041:
0042: import java.util.Iterator;
0043: import java.util.Vector;
0044: import javax.swing.ImageIcon;
0045:
0046: public class ReportElement extends IReportHashMapBean {
0047:
0048: private static ImageIcon gripIcon = new ImageIcon(
0049: ReportElement.class
0050: .getResource("/it/businesslogic/ireport/icons/grip.png"));
0051:
0052: static int id_gen = 1;
0053:
0054: private int elementID = 0;
0055:
0056: /**
0057: * Key for element properties handled using the IReportHashMapBean
0058: */
0059: public static final String BGCOLOR = "BGCOLOR";
0060: public static final String FGCOLOR = "FGCOLOR";
0061: public static final String MODE = "MODE"; // transparent or opaque...
0062: public static final String REMOVE_LINE_WHEN_BLANK = "REMOVE_LINE_WHEN_BLANK";
0063: public static final String PRINT_REPEATED_VALUES = "PRINT_REPEATED_VALUES";
0064: public static final String PRINT_IN_FIRST_WHOLE_BAND = "DEFAULT_PRINT_IN_FIRST_WHOLE_BAND";
0065: public static final String PRINT_WHEN_DETAIL_OVERFLOW = "PRINT_WHEN_DETAIL_OVERFLOW";
0066: public static final String POSITION_TYPE = "POSITION_TYPE";
0067:
0068: /**
0069: * Default values. If a value can change for different elements,
0070: * it is not listed here (i.e. MODE).
0071: */
0072: public static final Color DEFAULT_BGCOLOR = Color.WHITE;
0073: public static final Color DEFAULT_FGCOLOR = Color.BLACK;
0074: public static final boolean DEFAULT_REMOVE_LINE_WHEN_BLANK = false;
0075: public static final boolean DEFAULT_PRINT_REPEATED_VALUES = true;
0076: public static final boolean DEFAULT_PRINT_IN_FIRST_WHOLE_BAND = false;
0077: public static final boolean DEFAULT_PRINT_WHEN_DETAIL_OVERFLOW = false;
0078: public static final String DEFAULT_POSITION_TYPE = "FixRelativeToTop";
0079:
0080: /**
0081: * Values that can be overridden by subclasses....
0082: */
0083: public String transparentDefault = "Opaque";
0084:
0085: public java.util.List elementProperties = new java.util.ArrayList();
0086:
0087: public java.util.List getElementProperties() {
0088: return elementProperties;
0089: }
0090:
0091: public void setElementProperties(java.util.List elementProperties) {
0092: this .elementProperties = elementProperties;
0093: }
0094:
0095: public String name;
0096: public Point position;
0097:
0098: /**
0099: * Relative position is used in crosstab editor only
0100: **/
0101: private Point relativePosition;
0102: public int width;
0103: public int height;
0104: Rectangle bounds;
0105: public static BufferedImage hached = null;
0106: public Band band;
0107: private CrosstabCell cell;
0108:
0109: public String printWhenExpression = "";
0110: //public String positionType = "FixRelativeToTop";
0111: //public boolean isPrintRepeatedValues = true;
0112: //public boolean isRemoveLineWhenBlank = false;
0113: //public boolean isPrintInFirstWholeBand = false;
0114: //public boolean isPrintWhenDetailOverflows = false;
0115:
0116: public static Color lightcolor;
0117:
0118: public String printWhenGroupChanges = "";
0119: double zoom_factor = 1.0;
0120:
0121: protected String stretchType;
0122: private String elementGroup = "";
0123: public Vector intersections = new Vector();
0124:
0125: private Style style = null;
0126:
0127: private ReportElement parentElement = null;
0128:
0129: /**
0130: * Creates a new ReportElement object.
0131: *
0132: * @param x DOCUMENT ME!
0133: * @param y DOCUMENT ME!
0134: * @param width DOCUMENT ME!
0135: * @param height DOCUMENT ME!
0136: */
0137: public ReportElement(int x, int y, int width, int height) {
0138:
0139: if (hached == null) {
0140: hached = Misc.loadBufferedImageFromResources(
0141: new java.awt.Panel(),
0142: "it/businesslogic/ireport/icons/layout/hached.gif");
0143: }
0144:
0145: this .position = new Point(x, y);
0146: this .setRelativePosition(new Point(x, y));
0147: this .width = Math.abs(width);
0148: this .height = Math.abs(height);
0149:
0150: bounds = new Rectangle(position.x, position.y, width, height);
0151: name = "element-" + id_gen;
0152: setElementID(id_gen);
0153: id_gen++;
0154: this .hached = hached;
0155:
0156: if (lightcolor == null) {
0157: String lc = MainFrame.getMainInstance().getProperties()
0158: .getProperty("NewViewBorderColor");
0159: try {
0160: lightcolor = new java.awt.Color(Integer.parseInt(lc));
0161: } catch (Exception ex) {
0162: lightcolor = Color.LIGHT_GRAY;
0163: }
0164: }
0165:
0166: stretchType = "NoStretch";
0167: }
0168:
0169: /**
0170: * DOCUMENT ME!
0171: *
0172: * @param g DOCUMENT ME!
0173: * @param zoom_factor DOCUMENT ME!
0174: * @param x_shift_origin DOCUMENT ME!
0175: * @param y_shift_origin DOCUMENT ME!
0176: */
0177: public void drawObject(Graphics2D g, double zoom_factor,
0178: int x_shift_origin, int y_shift_origin) {
0179: position.x -= 10;
0180: position.y -= 10;
0181: x_shift_origin -= 10;
0182: y_shift_origin -= 10;
0183:
0184: this .zoom_factor = zoom_factor;
0185:
0186: //g.setPaint( new TexturePaint( red, new Rectangle2D.Double( zoomed_width+10-horizontal_scroll,9-vertical_scroll,9,9)));
0187: g.fillRect(getZoomedDim(position.x) - x_shift_origin,
0188: getZoomedDim(position.y) - y_shift_origin,
0189: getZoomedDim(width), getZoomedDim(height));
0190:
0191: //g.drawRect(getZoomedDim(position.x)-x_shift_origin, getZoomedDim(position.y)-y_shift_origin, getZoomedDim(width), getZoomedDim(height));
0192: position.x += 10;
0193: position.y += 10;
0194: x_shift_origin += 10;
0195: y_shift_origin += 10;
0196:
0197: drawGraphicsElement(g, "2Point", zoom_factor, x_shift_origin,
0198: y_shift_origin);
0199: drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin);
0200: }
0201:
0202: /**
0203: * DOCUMENT ME!
0204: *
0205: * @param g DOCUMENT ME!
0206: * @param pen DOCUMENT ME!
0207: * @param zoom_factor DOCUMENT ME!
0208: * @param x_shift_origin DOCUMENT ME!
0209: * @param y_shift_origin DOCUMENT ME!
0210: */
0211: public void drawGraphicsElement(Graphics2D g, String pen,
0212: double zoom_factor, int x_shift_origin, int y_shift_origin) {
0213: drawGraphicsElement(g, pen, zoom_factor, x_shift_origin,
0214: y_shift_origin, 0);
0215: }
0216:
0217: /**
0218: * DOCUMENT ME!
0219: *
0220: * @param g DOCUMENT ME!
0221: * @param pen DOCUMENT ME!
0222: * @param zoom_factor DOCUMENT ME!
0223: * @param x_shift_origin DOCUMENT ME!
0224: * @param y_shift_origin DOCUMENT ME!
0225: * @param radius DOCUMENT ME!
0226: */
0227: public void drawGraphicsElement(Graphics2D g, String pen,
0228: double zoom_factor, int x_shift_origin, int y_shift_origin,
0229: int radius) {
0230:
0231: int correction = (zoom_factor <= 1 && (pen.equals("Thin")
0232: || pen.equals("1Point") || pen.equals("Dotted"))) ? -1
0233: : 0;
0234: int xy_correction = (zoom_factor <= 1 && pen.equals("Dotted")) ? 1
0235: : 0;
0236:
0237: Pen thePen = null;
0238: if (this instanceof GraphicReportElement) {
0239: thePen = ((GraphicReportElement) this ).getPen();
0240: }
0241: Stroke stroke = getPenStroke(pen, thePen, zoom_factor);
0242: g.setColor(this .getFgcolor());
0243:
0244: this .zoom_factor = zoom_factor;
0245:
0246: if (stroke == null
0247: || (pen == null && pen.equalsIgnoreCase("None"))) {
0248: return;
0249: }
0250:
0251: position.x -= 10;
0252: position.y -= 10;
0253: x_shift_origin -= 10;
0254: y_shift_origin -= 10;
0255:
0256: Stroke oldStroke = g.getStroke();
0257: g.setStroke(stroke);
0258:
0259: if (radius != 0) {
0260: g.drawRoundRect(getZoomedDim(position.x) - x_shift_origin
0261: + xy_correction, getZoomedDim(position.y)
0262: - y_shift_origin + xy_correction,
0263: getZoomedDim(width) + correction,
0264: getZoomedDim(height) + correction,
0265: getZoomedDim(radius), getZoomedDim(radius));
0266: } else {
0267: g.drawRect(getZoomedDim(position.x) - x_shift_origin
0268: + xy_correction, getZoomedDim(position.y)
0269: - y_shift_origin + xy_correction,
0270: getZoomedDim(width) + correction,
0271: getZoomedDim(height) + correction);
0272: }
0273:
0274: position.x += 10;
0275: position.y += 10;
0276:
0277: g.setStroke(oldStroke);
0278: }
0279:
0280: /**
0281: * DOCUMENT ME!
0282: *
0283: * @param g DOCUMENT ME!
0284: * @param zoom_factor DOCUMENT ME!
0285: * @param x_shift_origin DOCUMENT ME!
0286: * @param y_shift_origin DOCUMENT ME!
0287: */
0288: public void drawBorder(Graphics2D g, double zoom_factor,
0289: int x_shift_origin, int y_shift_origin) {
0290: drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin, null);
0291: }
0292:
0293: /**
0294: * DOCUMENT ME!
0295: *
0296: * @param g DOCUMENT ME!
0297: * @param zoom_factor DOCUMENT ME!
0298: * @param x_shift_origin DOCUMENT ME!
0299: * @param y_shift_origin DOCUMENT ME!
0300: * @param box DOCUMENT ME!
0301: */
0302: public void drawBorder(Graphics2D g, double zoom_factor,
0303: int x_shift_origin, int y_shift_origin, Box box) {
0304: this .zoom_factor = zoom_factor;
0305:
0306: int correction = -1; //(zoom_factor <= 1)
0307: //? -1
0308: //: 0;
0309:
0310: position.x -= 10;
0311: position.y -= 10;
0312: x_shift_origin -= 10;
0313: y_shift_origin -= 10;
0314:
0315: Stroke oldStroke = g.getStroke();
0316:
0317: boolean b_insideBand = insideBand();
0318:
0319: if (box == null || !b_insideBand) {
0320:
0321: if (b_insideBand) {
0322: g.setColor(lightcolor);
0323: } else {
0324: g.setColor(Color.RED);
0325: }
0326:
0327: g.drawRect(getZoomedDim(position.x) - x_shift_origin,
0328: getZoomedDim(position.y) - y_shift_origin,
0329: getZoomedDim(width) + correction,
0330: getZoomedDim(height) + correction);
0331: } else {
0332:
0333: // Left side
0334: boolean insideBand = insideBand();
0335: int ax = getZoomedDim(position.x) - x_shift_origin;
0336: int ay = getZoomedDim(position.y) - y_shift_origin;
0337: int bx = ax + getZoomedDim(width) + correction;
0338: int by = ay + getZoomedDim(height) + correction;
0339:
0340: Stroke newBoxStroke = null;
0341:
0342: Pen pen = null;
0343:
0344: if (box.getLeftPen() != null
0345: && box.getLeftPen().getLineColor() != null)
0346: g.setColor(box.getLeftPen().getLineColor());
0347: else if (box.getLeftBorderColor() != null) {
0348: g.setColor(box.getLeftBorderColor());
0349: } else {
0350: g.setColor(lightcolor);
0351: }
0352:
0353: if ((newBoxStroke = getPenStroke(box.getLeftBorder(), box
0354: .getLeftPen(), zoom_factor)) != null) {
0355: g.setStroke(newBoxStroke);
0356: g.drawLine(ax, ay, ax, by);
0357: }
0358:
0359: //else g.setStroke(oldStroke);
0360: if (box.getTopPen() != null
0361: && box.getTopPen().getLineColor() != null)
0362: g.setColor(box.getTopPen().getLineColor());
0363: else if (box.getTopBorderColor() != null) {
0364: g.setColor(box.getTopBorderColor());
0365: } else {
0366: g.setColor(lightcolor);
0367: }
0368:
0369: if ((newBoxStroke = getPenStroke(box.getTopBorder(), box
0370: .getTopPen(), zoom_factor)) != null) {
0371: g.setStroke(newBoxStroke);
0372: g.drawLine(ax, ay, bx, ay);
0373: }
0374:
0375: if (box.getRightPen() != null
0376: && box.getRightPen().getLineColor() != null)
0377: g.setColor(box.getRightPen().getLineColor());
0378: else if (box.getRightBorderColor() != null) {
0379: g.setColor(box.getRightBorderColor());
0380: } else {
0381: g.setColor(lightcolor);
0382: }
0383:
0384: if ((newBoxStroke = getPenStroke(box.getRightBorder(), box
0385: .getRightPen(), zoom_factor)) != null) {
0386: g.setStroke(newBoxStroke);
0387: g.drawLine(bx, ay, bx, by);
0388: }
0389:
0390: if (box.getBottomPen() != null
0391: && box.getBottomPen().getLineColor() != null)
0392: g.setColor(box.getBottomPen().getLineColor());
0393: else if (box.getBottomBorderColor() != null) {
0394: g.setColor(box.getBottomBorderColor());
0395: } else {
0396: g.setColor(lightcolor);
0397: }
0398:
0399: if ((newBoxStroke = getPenStroke(box.getBottomBorder(), box
0400: .getBottomPen(), zoom_factor)) != null) {
0401: g.setStroke(newBoxStroke);
0402: g.drawLine(ax, by, bx, by);
0403: }
0404:
0405: g.setStroke(oldStroke);
0406: }
0407:
0408: position.x += 10;
0409: position.y += 10;
0410: x_shift_origin += 10;
0411: y_shift_origin += 10;
0412: }
0413:
0414: public static Color getAlphaColor(Color c, int alpha) {
0415: return new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
0416: }
0417:
0418: public void writeGrip(Graphics2D g, int x, int y) {
0419: g.drawImage(gripIcon.getImage(), x - 3, y - 3, gripIcon
0420: .getImageObserver());
0421: g.fillRect(x, y, 5, 5);
0422: }
0423:
0424: /**
0425: * DOCUMENT ME!
0426: *
0427: * @param g DOCUMENT ME!
0428: * @param zoom_factor DOCUMENT ME!
0429: * @param x_shift_origin DOCUMENT ME!
0430: * @param y_shift_origin DOCUMENT ME!
0431: * @param selected DOCUMENT ME!
0432: */
0433: public void drawCorona(Graphics2D g, double zoom_factor,
0434: int x_shift_origin, int y_shift_origin, boolean selected) {
0435: this .zoom_factor = zoom_factor;
0436:
0437: // draw a corona...
0438: position.x -= 10;
0439: position.y -= 10;
0440: x_shift_origin -= 10;
0441: y_shift_origin -= 10;
0442:
0443: Rectangle rInteger = new Rectangle(getZoomedDim(position.x) - 3
0444: - x_shift_origin, getZoomedDim(position.y) - 3
0445: - y_shift_origin, getZoomedDim(width) + 6,
0446: getZoomedDim(height) + 6);
0447:
0448: Rectangle2D r = new java.awt.geom.Rectangle2D.Double(rInteger
0449: .getX(), rInteger.getY(), rInteger.getWidth(), rInteger
0450: .getHeight());
0451:
0452: Rectangle2D r2 = new java.awt.geom.Rectangle2D.Double(rInteger
0453: .getX() + 2.0, rInteger.getY() + 2.0, rInteger
0454: .getWidth() - 4.0, rInteger.getHeight() - 4.0);
0455:
0456: // new Rectangle2D.Double(
0457: // getZoomedDim(position.x) - x_shift_origin-1,
0458: // getZoomedDim(position.y) - y_shift_origin-1,
0459: // getZoomedDim(width) + 2, getZoomedDim(height)+ 2);
0460: java.awt.geom.Area area = new Area(r);
0461: area.exclusiveOr(new Area(r2));
0462:
0463: /*
0464: if (hached == null)
0465: {
0466: g.fill(area);
0467: }
0468: else
0469: {
0470: g.setPaint(new java.awt.TexturePaint(hached,
0471: new Rectangle2D.Double(0, 0,
0472: 2, 2)));
0473: g.fill(area);
0474: }
0475: */
0476:
0477: g.setPaint(new Color(255, 175, 0, 200));
0478: g.fill(area);
0479:
0480: // draw grips...
0481: g.setPaint(getAlphaColor(Color.BLUE, 80));
0482:
0483: if (!selected) {
0484: g.setPaint(getAlphaColor(Color.GRAY, 80));
0485: }
0486:
0487: // checking overlaps slows down the repainting
0488: if (intersectsElements()) {
0489:
0490: if (enclosesOtherElement()) {
0491: g.setPaint(getAlphaColor(Color.PINK, 80));
0492: } else {
0493: g.setPaint(getAlphaColor(Color.GREEN, 80));
0494: }
0495:
0496: }
0497:
0498: if (!insideBand()) {
0499: g.setPaint(getAlphaColor(Color.RED, 80));
0500: }
0501:
0502: writeGrip(g, getZoomedDim(position.x) - 5 - x_shift_origin,
0503: getZoomedDim(position.y) - 5 - y_shift_origin);
0504:
0505: writeGrip(g, getZoomedDim(position.x) - 5 - x_shift_origin,
0506: getZoomedDim(position.y) - 5 - y_shift_origin);
0507:
0508: writeGrip(g, getZoomedDim(position.x + width) - x_shift_origin,
0509: getZoomedDim(position.y) - 5 - y_shift_origin);
0510:
0511: writeGrip(g, getZoomedDim(position.x + width) - x_shift_origin,
0512: getZoomedDim(position.y + height) - y_shift_origin);
0513:
0514: writeGrip(g, getZoomedDim(position.x) - 5 - x_shift_origin,
0515: getZoomedDim(position.y + height) - y_shift_origin);
0516:
0517: writeGrip(g, getZoomedDim(position.x + (width / 2)) - 2
0518: - x_shift_origin, getZoomedDim(position.y) - 5
0519: - y_shift_origin);
0520:
0521: writeGrip(g, getZoomedDim(position.x + (width / 2)) - 2
0522: - x_shift_origin, getZoomedDim(position.y + height)
0523: - y_shift_origin);
0524:
0525: writeGrip(g, getZoomedDim(position.x) - 5 - x_shift_origin,
0526: getZoomedDim(position.y + (height / 2)) - 2
0527: - y_shift_origin);
0528: writeGrip(g, getZoomedDim(position.x + width) - x_shift_origin,
0529: getZoomedDim(position.y + (height / 2)) - 2
0530: - y_shift_origin);
0531:
0532: position.x += 10;
0533: position.y += 10;
0534: }
0535:
0536: /**
0537: * DOCUMENT ME!
0538: *
0539: * @return DOCUMENT ME!
0540: */
0541: public boolean enclosesOtherElement() {
0542:
0543: for (Iterator i = intersections.iterator(); i.hasNext();) {
0544:
0545: ReportElement e = (ReportElement) i.next();
0546:
0547: if (bounds.contains(e.bounds)) {
0548:
0549: return true;
0550: }
0551: }
0552:
0553: return false;
0554: }
0555:
0556: /**
0557: * DOCUMENT ME!
0558: *
0559: * @return DOCUMENT ME!
0560: */
0561: public boolean intersectsElements() {
0562:
0563: int oldHeight = 0;
0564: boolean result = false;
0565:
0566: // do not stop after you found an intersection
0567: // list them all so that
0568: // later on you can see whether one is hidden or enclosed by the
0569: // current element.
0570: Iterator i = null;
0571: if (band == null && cell == null)
0572: return false;
0573: if (band != null)
0574: i = band.getParent().getElements().iterator();
0575: else
0576: i = cell.getParent().getElements().iterator();
0577: for (; i.hasNext();) {
0578:
0579: ReportElement e = (ReportElement) i.next();
0580:
0581: // do not compare with 'this' reportElement
0582: if (!this .equals(e)) {
0583: oldHeight = e.height;
0584:
0585: // make lines a little heigher,so that they can intersect
0586: // with a rectangle
0587: if (e.height == 0) {
0588: e.height = 10;
0589: }
0590:
0591: if (e.bounds.intersects(bounds)) {
0592:
0593: // store the intersecting rectangle
0594: this .intersections.add(e);
0595: result = true;
0596: }
0597:
0598: e.height = oldHeight;
0599: }
0600: }
0601:
0602: return result;
0603: }
0604:
0605: /**
0606: * DOCUMENT ME!
0607: *
0608: * @param p DOCUMENT ME!
0609: * @return DOCUMENT ME!
0610: */
0611: public boolean intersects(Point p) {
0612:
0613: Rectangle r = new Rectangle(bounds);
0614:
0615: if (height == 0) {
0616: r.height = 10;
0617: r.y -= 5;
0618: }
0619:
0620: if (width == 0) {
0621: r.width = 10;
0622: r.x -= 5;
0623: }
0624:
0625: return r.intersects(p.x, p.y, 1, 1);
0626: }
0627:
0628: /**
0629: * DOCUMENT ME!
0630: *
0631: * @return DOCUMENT ME!
0632: */
0633: public boolean insideBandReal() {
0634: position.x -= 10;
0635: position.y -= 10;
0636:
0637: boolean result = insideBand();
0638:
0639: position.x += 10;
0640: position.y += 10;
0641:
0642: return result;
0643: }
0644:
0645: /**
0646: * DOCUMENT ME!
0647: *
0648: * @return DOCUMENT ME!
0649: */
0650: public boolean insideBand() {
0651:
0652: if (band == null) {
0653: if (cell != null) {
0654: return cell.getBounds().contains(
0655: new Rectangle(getPosition().x, getPosition().y,
0656: width, height));
0657: }
0658: return false;
0659: }
0660:
0661: int yband = band.getBandYLocation();
0662:
0663: // lower left corner of element is below the band.
0664: // This is not a real problem....
0665: if (position.y - yband < 0) {
0666: // return false;
0667: }
0668:
0669: // lower left corner of element is left from the left margin
0670: // This is not a real problem
0671: if (position.x - band.getParent().getLeftMargin() < 0) {
0672: // return false;
0673: }
0674:
0675: // with element on the bottom the element is too high for the band
0676: if (position.y - yband + height > band.getHeight()) {
0677: return false;
0678: }
0679:
0680: // with element on the left margin, the width is larger than usable width of page.
0681: if (position.x - band.getParent().getLeftMargin() + width > band
0682: .getUsableWidth()) {
0683: return false;
0684: }
0685:
0686: return true;
0687: }
0688:
0689: /**
0690: * DOCUMENT ME!
0691: *
0692: * @param r2 DOCUMENT ME!
0693: * @return DOCUMENT ME!
0694: */
0695: public boolean intersects(Rectangle r2) {
0696:
0697: Rectangle r = new Rectangle(bounds);
0698:
0699: if (height == 0) {
0700: r.height = 10;
0701: r.y -= 5;
0702: }
0703:
0704: if (width == 0) {
0705: r.width = 10;
0706: r.x -= 5;
0707: }
0708:
0709: return r.intersects(r2);
0710: }
0711:
0712: /**
0713: * DOCUMENT ME!
0714: *
0715: * @param p DOCUMENT ME!
0716: */
0717: public void setPosition(Point p) {
0718:
0719: if (p == null) {
0720:
0721: return;
0722: }
0723:
0724: if (p.x == position.x && p.y == position.y) {
0725:
0726: return;
0727: }
0728:
0729: position.x = p.x;
0730: position.y = p.y;
0731: bounds = new Rectangle(position.x, position.y, width, height);
0732: }
0733:
0734: /**
0735: * DOCUMENT ME!
0736: *
0737: * @param delta DOCUMENT ME!
0738: * @param type DOCUMENT ME!
0739: * @return DOCUMENT ME!
0740: */
0741: public Point trasform(Point delta, int type) {
0742:
0743: if (delta == null) {
0744:
0745: return null;
0746: }
0747:
0748: Point result = new Point(delta);
0749: int old_x = 0;
0750: int old_y = 0;
0751:
0752: if (type == TransformationType.TRANSFORMATION_MOVE) {
0753: position.x += delta.x;
0754: position.y += delta.y;
0755: } else if (type == TransformationType.TRANSFORMATION_RESIZE_E) {
0756: old_x = width;
0757: width += delta.x;
0758:
0759: if (width < 0) {
0760: width = 0;
0761: }
0762:
0763: result.x = width - old_x;
0764: } else if (type == TransformationType.TRANSFORMATION_RESIZE_W) {
0765: old_x = width;
0766:
0767: int d = Math.min(delta.x, width);
0768: width -= d;
0769: position.x += d;
0770: result.x = d;
0771: } else if (type == TransformationType.TRANSFORMATION_RESIZE_N) {
0772:
0773: int d = Math.min(delta.y, height);
0774: height -= d;
0775: position.y += d;
0776: result.y = d;
0777: } else if (type == TransformationType.TRANSFORMATION_RESIZE_S) {
0778: old_y = height;
0779: height += delta.y;
0780:
0781: if (height < 0) {
0782: height = 0;
0783: }
0784:
0785: result.y = height - old_y;
0786: } else if (type == TransformationType.TRANSFORMATION_RESIZE_SE) {
0787: old_y = height;
0788: old_x = width;
0789: height += delta.y;
0790:
0791: if (height < 0) {
0792: height = 0;
0793: }
0794:
0795: width += delta.x;
0796:
0797: if (width < 0) {
0798: width = 0;
0799: }
0800:
0801: result.x = width - old_x;
0802: result.y = height - old_y;
0803: } else if (type == TransformationType.TRANSFORMATION_RESIZE_SW) {
0804: old_y = height;
0805: height += delta.y;
0806:
0807: if (height < 0) {
0808: height = 0;
0809: }
0810:
0811: int d = Math.min(delta.x, width);
0812: width -= d;
0813: position.x += d;
0814: result.x = d;
0815: result.y = height - old_y;
0816: } else if (type == TransformationType.TRANSFORMATION_RESIZE_NE) {
0817: old_x = width;
0818:
0819: int d = Math.min(delta.y, height);
0820: height -= d;
0821: position.y += d;
0822: width += delta.x;
0823:
0824: if (width < 0) {
0825: width = 0;
0826: }
0827:
0828: result.x = width - old_x;
0829: result.y = d;
0830: } else if (type == TransformationType.TRANSFORMATION_RESIZE_NW) {
0831:
0832: int d = Math.min(delta.y, height);
0833: height -= d;
0834: position.y += d;
0835: result.y = d;
0836: d = Math.min(delta.x, width);
0837: width -= d;
0838: position.x += d;
0839: result.x = d;
0840: }
0841:
0842: bounds = new Rectangle(position.x, position.y, width, height);
0843:
0844: if (getCell() != null
0845: && type != TransformationType.TRANSFORMATION_RESIZE_SE) {
0846: setRelativePosition(new Point(getPosition().x
0847: - getCell().getLeft() - 10, getPosition().y
0848: - getCell().getTop() - 10));
0849: }
0850:
0851: return result;
0852: }
0853:
0854: /**
0855: * Try to move the element to another band if the element is placed
0856: * entirely within the band.
0857: *
0858: */
0859: public void adjustBand() {
0860: if (band == null)
0861: return;
0862: position.x -= 10;
0863: position.y -= 10;
0864:
0865: for (Iterator i = band.getParent().getBands().iterator(); i
0866: .hasNext();) {
0867:
0868: Band b = (Band) i.next();
0869:
0870: if (position.y - band.getParent().getBandYLocation(b) >= 0) {
0871:
0872: if (position.y - band.getParent().getBandYLocation(b)
0873: + height <= b.getHeight()) {
0874:
0875: // element is within this band.
0876: band = b;
0877:
0878: break;
0879: }
0880: }
0881: }
0882:
0883: position.x += 10;
0884: position.y += 10;
0885: }
0886:
0887: public void adjustCell(Vector cells) {
0888: if (getCell().getType() == CrosstabCell.NODATA_CELL)
0889: return;
0890: for (int i = 0; i < cells.size(); ++i) {
0891: CrosstabCell tmpCell = (CrosstabCell) cells.elementAt(i);
0892: if (tmpCell.getType() == CrosstabCell.NODATA_CELL)
0893: continue;
0894: if (tmpCell.getBounds().contains(
0895: new Point(getPosition().x - 10,
0896: getPosition().y - 10))) {
0897: this .setCell(tmpCell);
0898: setRelativePosition(new Point(getPosition().x
0899: - getCell().getLeft() - 10, getPosition().y
0900: - getCell().getTop() - 10));
0901: return;
0902: }
0903: }
0904: }
0905:
0906: /**
0907: * this methos adjust the relativo position respect to the parent cell.
0908: * If parent cell is null, nothing is done.
0909: * You should call this method after a brute setPosition
0910: */
0911: public void updateRelativePosition() {
0912: if (getCell() == null)
0913: return;
0914: setRelativePosition(new Point(getPosition().x
0915: - getCell().getLeft() - 10, getPosition().y
0916: - getCell().getTop() - 10));
0917: }
0918:
0919: /*
0920: * This method should be called when you modify height, width,
0921: * or position manually.
0922: */
0923:
0924: /**
0925: * DOCUMENT ME!
0926: */
0927: public void updateBounds() {
0928: bounds = new Rectangle(position.x, position.y, width, height);
0929: }
0930:
0931: /**
0932: * DOCUMENT ME!
0933: *
0934: * @param delta DOCUMENT ME!
0935: * @param type DOCUMENT ME!
0936: * @return DOCUMENT ME!
0937: */
0938: public Point trasformTest(Point delta, int type) {
0939:
0940: if (delta == null) {
0941:
0942: return null;
0943: }
0944:
0945: Point result = new Point(delta);
0946: int old_x = 0;
0947: int old_y = 0;
0948:
0949: if (type == TransformationType.TRANSFORMATION_MOVE) {
0950: } else if (type == TransformationType.TRANSFORMATION_RESIZE_E) {
0951: old_x = width;
0952: old_x += delta.x;
0953:
0954: if (old_x < 0) {
0955: old_x = 0;
0956: }
0957:
0958: result.x = old_x - width;
0959: } else if (type == TransformationType.TRANSFORMATION_RESIZE_W) {
0960: result.x = Math.min(delta.x, width);
0961: } else if (type == TransformationType.TRANSFORMATION_RESIZE_N) {
0962: result.y = Math.min(delta.y, height);
0963: } else if (type == TransformationType.TRANSFORMATION_RESIZE_S) {
0964: old_y = height;
0965: old_y += delta.y;
0966:
0967: if (old_y < 0) {
0968: old_y = 0;
0969: }
0970:
0971: result.y = old_y - height;
0972: } else if (type == TransformationType.TRANSFORMATION_RESIZE_SE) {
0973: old_y = height;
0974: old_x = width;
0975: old_y += delta.y;
0976:
0977: if (old_y < 0) {
0978: old_y = 0;
0979: }
0980:
0981: old_x += delta.x;
0982:
0983: if (old_x < 0) {
0984: old_x = 0;
0985: }
0986:
0987: result.x = old_x - width;
0988: result.y = old_y - height;
0989: } else if (type == TransformationType.TRANSFORMATION_RESIZE_SW) {
0990: old_y = height;
0991: old_y += delta.y;
0992:
0993: if (old_y < 0) {
0994: old_y = 0;
0995: }
0996:
0997: result.x = Math.min(delta.x, width);
0998: result.y = old_y - height;
0999: } else if (type == TransformationType.TRANSFORMATION_RESIZE_NE) {
1000: old_x = width;
1001: result.y = Math.min(delta.y, height);
1002: old_x += delta.x;
1003:
1004: if (old_x < 0) {
1005: old_x = 0;
1006: }
1007:
1008: result.x = old_x - width;
1009: } else if (type == TransformationType.TRANSFORMATION_RESIZE_NW) {
1010: result.y = Math.min(delta.y, height);
1011: result.x = Math.min(delta.x, width);
1012: }
1013:
1014: return result;
1015: }
1016:
1017: /**
1018: * DOCUMENT ME!
1019: *
1020: * @return DOCUMENT ME!
1021: */
1022: public String toString() {
1023: if (band == null)
1024: return "" + name;
1025: else {
1026: if (getParentElement() == null) {
1027: return name
1028: + " ["
1029: + (position.x
1030: - band.getParent().getRightMargin() - 10)
1031: + ","
1032: + (position.y - band.getBandYLocation() - 10)
1033: + "]";
1034: } else {
1035: return name
1036: + " ["
1037: + (position.x - getParentElement()
1038: .getPosition().x)
1039: + ","
1040: + (position.y - getParentElement()
1041: .getPosition().y) + "]";
1042: }
1043: }
1044: }
1045:
1046: /**
1047: * DOCUMENT ME!
1048: *
1049: * @param dim DOCUMENT ME!
1050: * @return DOCUMENT ME!
1051: */
1052: public int getZoomedDim(int dim) {
1053:
1054: if (zoom_factor == 1.0) {
1055:
1056: return dim;
1057: }
1058:
1059: //if (((double)dim*(double)zoom_factor)<0.5) return 1;
1060: // Truncate, don't round!!
1061: return (int) ((double) dim * zoom_factor);
1062:
1063: //return (int)Math.ceil((double)dim*zoom_factor);
1064: }
1065:
1066: /**
1067: * DOCUMENT ME!
1068: *
1069: * @param dim DOCUMENT ME!
1070: * @return DOCUMENT ME!
1071: */
1072: public double getZoomedDim(double dim) {
1073:
1074: if (zoom_factor == 1.0) {
1075:
1076: return dim;
1077: }
1078:
1079: //if (((double)dim*(double)zoom_factor)<0.5) return 1;
1080: // Truncate, don't round!!
1081: return ((double) dim * zoom_factor);
1082:
1083: //return (int)Math.ceil((double)dim*zoom_factor);
1084: }
1085:
1086: /**
1087: * DOCUMENT ME!
1088: *
1089: * @param dim DOCUMENT ME!
1090: * @return DOCUMENT ME!
1091: */
1092: public int getLogicalDim(int dim) {
1093:
1094: if (zoom_factor == 1.0) {
1095:
1096: return dim;
1097: }
1098:
1099: //if (Math.abs( ((double)dim/(double)zoom_factor)) < 1 &&
1100: // Math.abs( ((double)dim/(double)zoom_factor)) > 0) return 1;
1101: // Truncate, don't round!!
1102: return (int) ((double) dim / zoom_factor);
1103:
1104: //return (int)Math.ceil((double)dim/zoom_factor);
1105: }
1106:
1107: /**
1108: * DOCUMENT ME!
1109: *
1110: * @return DOCUMENT ME!
1111: */
1112: public ReportElement cloneMe() {
1113:
1114: ReportElement newReportElement = new ReportElement(position.x,
1115: position.y, width, height);
1116: newReportElement.name = new String(name);
1117: newReportElement.band = band;
1118: newReportElement.cell = cell;
1119: newReportElement.parentElement = parentElement;
1120:
1121: copyElementPropertiesTo(newReportElement);
1122:
1123: return newReportElement;
1124: }
1125:
1126: /**
1127: * DOCUMENT ME!
1128: *
1129: * @param newReportElement DOCUMENT ME!
1130: */
1131: public void copyElementPropertiesTo(ReportElement newReportElement) {
1132: newReportElement.printWhenExpression = printWhenExpression;
1133:
1134: newReportElement.setPropertyValue(POSITION_TYPE, this
1135: .getPropertyValue(POSITION_TYPE));
1136: newReportElement.setPropertyValue(REMOVE_LINE_WHEN_BLANK, this
1137: .getPropertyValue(REMOVE_LINE_WHEN_BLANK));
1138: newReportElement.setPropertyValue(PRINT_REPEATED_VALUES, this
1139: .getPropertyValue(PRINT_REPEATED_VALUES));
1140: newReportElement.setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND,
1141: this .getPropertyValue(PRINT_IN_FIRST_WHOLE_BAND));
1142: newReportElement.setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW,
1143: this .getPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW));
1144: }
1145:
1146: /**
1147: * DOCUMENT ME!
1148: *
1149: * @param s1 DOCUMENT ME!
1150: * @param s2 DOCUMENT ME!
1151: * @param s3 DOCUMENT ME!
1152: * @return DOCUMENT ME!
1153: */
1154: public static String string_replace(String s1, String s2, String s3) {
1155:
1156: String string = "";
1157: string = "";
1158:
1159: if (s2 == null || s3 == null || s2.length() == 0) {
1160:
1161: return s3;
1162: }
1163:
1164: int pos_i = 0; // posizione corrente.
1165: int pos_f = 0; // posizione corrente finale
1166:
1167: int len = s2.length();
1168:
1169: while ((pos_f = s3.indexOf(s2, pos_i)) >= 0) {
1170: string += s3.substring(pos_i, pos_f) + s1;
1171:
1172: //+string.substring(pos+ s2.length());
1173: pos_f = pos_i = pos_f + len;
1174:
1175: }
1176:
1177: string += s3.substring(pos_i);
1178:
1179: return string;
1180: }
1181:
1182: public Stroke getPenStroke(String penName, double zoom_factor) {
1183: Pen thePen = null;
1184: if (this instanceof GraphicReportElement) {
1185: thePen = ((GraphicReportElement) this ).getPen();
1186: }
1187: return getPenStroke(penName, thePen, zoom_factor);
1188: }
1189:
1190: /**
1191: * DOCUMENT ME!
1192: *
1193: * @param pen DOCUMENT ME!
1194: * @param zoom_factor DOCUMENT ME!
1195: * @return DOCUMENT ME!
1196: */
1197: public static Stroke getPenStroke(String penName, Pen pen,
1198: double zoom_factor) {
1199: if (pen != null) {
1200: if (pen.getLineWidth() == 0)
1201: return null;
1202:
1203: if (pen.getLineStyle() != null) {
1204: float penWidth = (float) (pen.getLineWidth() * zoom_factor);
1205: if (pen.getLineStyle().equals("Solid")) {
1206: return (Stroke) new BasicStroke(
1207: (float) (penWidth * zoom_factor));
1208: } else if (pen.getLineStyle().equals("Dashed")) {
1209: return (Stroke) new BasicStroke((float) (penWidth),
1210: BasicStroke.CAP_BUTT,
1211: BasicStroke.JOIN_BEVEL, 0f, new float[] {
1212: Math.max(1f, 5f * penWidth),
1213: Math.max(1f, 3f * penWidth) }, 0f);
1214: } else if (pen.getLineStyle().equals("Dotted")) {
1215: return (Stroke) new BasicStroke((float) (penWidth),
1216: BasicStroke.CAP_BUTT,
1217: BasicStroke.JOIN_BEVEL, 0f, new float[] {
1218: Math.max(1f, 1f * penWidth),
1219: Math.max(1f, 1f * penWidth) }, 0f);
1220: } else if (pen.getLineStyle().equals("Double")) {
1221:
1222: float side = (float) (penWidth * zoom_factor);
1223: Stroke s1 = (Stroke) new ShapeStroke(
1224: new Rectangle2D.Float(0, 0, side, side),
1225: 1f * penWidth);
1226: Stroke s2 = (Stroke) new ShapeStroke(
1227: new Rectangle2D.Float(0, side / 2, side,
1228: side / 3), 1f * penWidth);
1229:
1230: return new CompoundStroke(s1, s2,
1231: CompoundStroke.SUBTRACT);
1232: }
1233:
1234: }
1235:
1236: }
1237:
1238: if (penName == null || penName.equals("None")) {
1239:
1240: return null;
1241: }
1242:
1243: if (penName.equals("Dotted")) {
1244:
1245: return (Stroke) new BasicStroke((float) (1f * zoom_factor),
1246: BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0f,
1247: new float[] { 5f, 3f }, 0f);
1248: } else if (penName.equals("2Point")) {
1249:
1250: return (Stroke) new BasicStroke((float) (2f * zoom_factor));
1251: } else if (penName.equals("3Point")) {
1252:
1253: return (Stroke) new BasicStroke((float) (3f * zoom_factor));
1254: } else if (penName.equals("4Point")) {
1255:
1256: return (Stroke) new BasicStroke((float) (4f * zoom_factor));
1257: } else if (penName.equals("Thin")) {
1258:
1259: return (Stroke) new BasicStroke((float) (1f * zoom_factor));
1260: } else //if (pen.equals("1Point"))
1261: {
1262:
1263: return (Stroke) new BasicStroke((float) (1f * zoom_factor));
1264: }
1265: }
1266:
1267: /**
1268: * Getter for property width.
1269: *
1270: * @return Value of property width.
1271: */
1272: public int getWidth() {
1273:
1274: return width;
1275: }
1276:
1277: /**
1278: * Setter for property width.
1279: *
1280: * @param width New value of property width.
1281: */
1282: public void setWidth(int width) {
1283: this .width = width;
1284: updateBounds();
1285: }
1286:
1287: /**
1288: * Getter for property height.
1289: *
1290: * @return Value of property height.
1291: */
1292: public int getHeight() {
1293:
1294: return height;
1295: }
1296:
1297: /**
1298: * Setter for property height.
1299: *
1300: * @param height New value of property height.
1301: */
1302: public void setHeight(int height) {
1303: this .height = height;
1304: updateBounds();
1305: }
1306:
1307: /**
1308: * Getter for property position.
1309: *
1310: * @return Value of property position.
1311: */
1312: public java.awt.Point getPosition() {
1313:
1314: return position;
1315: }
1316:
1317: /**
1318: * Getter for property band.
1319: *
1320: * @return Value of property band.
1321: */
1322: public it.businesslogic.ireport.Band getBand() {
1323:
1324: return band;
1325: }
1326:
1327: /**
1328: * Setter for property band.
1329: *
1330: * @param band New value of property band.
1331: */
1332: public void setBand(it.businesslogic.ireport.Band band) {
1333: this .band = band;
1334: }
1335:
1336: /**
1337: * Getter for property transparent.
1338: *
1339: * @return Value of property transparent.
1340: */
1341: public java.lang.String getTransparent() {
1342:
1343: if (getStringValue(MODE, null) == null) {
1344: // Look for a fgcolor in the stylesheet...
1345: if (getStyle() != null) {
1346: return getStyle().getAttributeString(
1347: getStyle().ATTRIBUTE_mode, transparentDefault,
1348: true);
1349: }
1350: }
1351: return getStringValue(MODE, transparentDefault);
1352: }
1353:
1354: /**
1355: * Setter for property transparent.
1356: *
1357: * @param transparent New value of property transparent.
1358: */
1359: public void setTransparent(java.lang.String transparent) {
1360: setPropertyValue(MODE, transparent);
1361: }
1362:
1363: /**
1364: * Getter for property positionType.
1365: *
1366: * @return Value of property positionType.
1367: */
1368: public java.lang.String getPositionType() {
1369:
1370: return getStringValue(POSITION_TYPE, DEFAULT_POSITION_TYPE);
1371: }
1372:
1373: /**
1374: * Setter for property positionType.
1375: *
1376: * @param positionType New value of property positionType.
1377: */
1378: public void setPositionType(java.lang.String positionType) {
1379: setPropertyValue(POSITION_TYPE, positionType);
1380: }
1381:
1382: /**
1383: * Getter for property isPrintInFirstWholeBand.
1384: *
1385: * @return Value of property isPrintInFirstWholeBand.
1386: */
1387: public boolean isIsPrintInFirstWholeBand() {
1388:
1389: return getBooleanValue(PRINT_IN_FIRST_WHOLE_BAND,
1390: DEFAULT_PRINT_IN_FIRST_WHOLE_BAND);
1391: }
1392:
1393: /**
1394: * Setter for property isPrintInFirstWholeBand.
1395: *
1396: * @param isPrintInFirstWholeBand New value of property
1397: * isPrintInFirstWholeBand.
1398: */
1399: public void setIsPrintInFirstWholeBand(
1400: boolean isPrintInFirstWholeBand) {
1401: setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND, ""
1402: + isPrintInFirstWholeBand);
1403: }
1404:
1405: /**
1406: * Getter for property printWhenExpression.
1407: *
1408: * @return Value of property printWhenExpression.
1409: */
1410: public java.lang.String getPrintWhenExpression() {
1411:
1412: return printWhenExpression;
1413: }
1414:
1415: /**
1416: * Setter for property printWhenExpression.
1417: *
1418: * @param printWhenExpression New value of property printWhenExpression.
1419: */
1420: public void setPrintWhenExpression(
1421: java.lang.String printWhenExpression) {
1422: this .printWhenExpression = printWhenExpression;
1423: }
1424:
1425: /**
1426: * Getter for property isPrintRepeatedValues.
1427: *
1428: * @return Value of property isPrintRepeatedValues.
1429: */
1430: public boolean isIsPrintRepeatedValues() {
1431:
1432: return getBooleanValue(PRINT_REPEATED_VALUES,
1433: DEFAULT_PRINT_REPEATED_VALUES);
1434: }
1435:
1436: /**
1437: * Setter for property isPrintRepeatedValues.
1438: *
1439: * @param isPrintRepeatedValues New value of property
1440: * isPrintRepeatedValues.
1441: */
1442: public void setIsPrintRepeatedValues(boolean isPrintRepeatedValues) {
1443: setPropertyValue(PRINT_REPEATED_VALUES, ""
1444: + isPrintRepeatedValues);
1445: }
1446:
1447: /**
1448: * Getter for property fgcolor.
1449: *
1450: * @return Value of property fgcolor.
1451: */
1452: public java.awt.Color getFgcolor() {
1453: if (getColorValue(FGCOLOR, null) == null) {
1454: // Look for a fgcolor in the stylesheet...
1455: if (getStyle() != null) {
1456: return getStyle().getAttributeColor(
1457: getStyle().ATTRIBUTE_forecolor,
1458: DEFAULT_FGCOLOR, true);
1459: }
1460: }
1461: return getColorValue(FGCOLOR, DEFAULT_FGCOLOR);
1462: }
1463:
1464: /**
1465: * Setter for property fgcolor.
1466: *
1467: * @param fgcolor New value of property fgcolor.
1468: */
1469: public void setFgcolor(java.awt.Color fgcolor) {
1470: setPropertyValue(FGCOLOR, fgcolor);
1471: }
1472:
1473: /**
1474: * Getter for property bgcolor.
1475: *
1476: * @return Value of property bgcolor.
1477: */
1478: public java.awt.Color getBgcolor() {
1479:
1480: if (getColorValue(BGCOLOR, null) == null) {
1481: // Look for a fgcolor in the stylesheet...
1482: if (getStyle() != null) {
1483: return getStyle().getAttributeColor(
1484: getStyle().ATTRIBUTE_backcolor,
1485: DEFAULT_BGCOLOR, true);
1486: }
1487: }
1488: return getColorValue(BGCOLOR, DEFAULT_BGCOLOR);
1489: }
1490:
1491: /**
1492: * Setter for property bgcolor.
1493: *
1494: * @param bgcolor New value of property bgcolor.
1495: */
1496: public void setBgcolor(java.awt.Color bgcolor) {
1497: setPropertyValue(BGCOLOR, bgcolor);
1498: }
1499:
1500: /**
1501: * Getter for property isRemoveLineWhenBlank.
1502: *
1503: * @return Value of property isRemoveLineWhenBlank.
1504: */
1505: public boolean isIsRemoveLineWhenBlank() {
1506:
1507: return getBooleanValue(REMOVE_LINE_WHEN_BLANK,
1508: DEFAULT_REMOVE_LINE_WHEN_BLANK);
1509: }
1510:
1511: /**
1512: * Setter for property isRemoveLineWhenBlank.
1513: *
1514: * @param isRemoveLineWhenBlank New value of property
1515: * isRemoveLineWhenBlank.
1516: */
1517: public void setIsRemoveLineWhenBlank(boolean isRemoveLineWhenBlank) {
1518: setPropertyValue(REMOVE_LINE_WHEN_BLANK, ""
1519: + isRemoveLineWhenBlank);
1520: }
1521:
1522: /**
1523: * Getter for property printWhenGroupChanges.
1524: *
1525: * @return Value of property printWhenGroupChanges.
1526: */
1527: public java.lang.String getPrintWhenGroupChanges() {
1528:
1529: return printWhenGroupChanges;
1530: }
1531:
1532: /**
1533: * Setter for property printWhenGroupChanges.
1534: *
1535: * @param printWhenGroupChanges New value of property
1536: * printWhenGroupChanges.
1537: */
1538: public void setPrintWhenGroupChanges(
1539: java.lang.String printWhenGroupChanges) {
1540: this .printWhenGroupChanges = printWhenGroupChanges;
1541: }
1542:
1543: /**
1544: * Getter for property name.
1545: *
1546: * @return Value of property name.
1547: */
1548: public java.lang.String getName() {
1549:
1550: return name;
1551: }
1552:
1553: /**
1554: * Setter for property name.
1555: *
1556: * @param name New value of property name.
1557: */
1558: public void setName(java.lang.String name) {
1559: this .name = name;
1560: }
1561:
1562: /**
1563: * Getter for property isPrintWhenDetailOverflows.
1564: *
1565: * @return Value of property isPrintWhenDetailOverflows.
1566: */
1567: public boolean isIsPrintWhenDetailOverflows() {
1568:
1569: return getBooleanValue(PRINT_WHEN_DETAIL_OVERFLOW,
1570: DEFAULT_PRINT_WHEN_DETAIL_OVERFLOW);
1571: }
1572:
1573: /**
1574: * Setter for property isPrintWhenDetailOverflows.
1575: *
1576: * @param isPrintWhenDetailOverflows New value of property
1577: * isPrintWhenDetailOverflows.
1578: */
1579: public void setIsPrintWhenDetailOverflows(
1580: boolean isPrintWhenDetailOverflows) {
1581: setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW, ""
1582: + isPrintWhenDetailOverflows);
1583: }
1584:
1585: /**
1586: * DOCUMENT ME!
1587: *
1588: * @param destination DOCUMENT ME!
1589: * @param source DOCUMENT ME!
1590: */
1591: public void copyBaseReportElement(ReportElement destination,
1592: ReportElement source) {
1593:
1594: // Canonical report elements....
1595: destination.setName(new String(source.getName()));
1596:
1597: destination.setPropertyValue(FGCOLOR, this
1598: .getPropertyValue(FGCOLOR));
1599: destination.setPropertyValue(BGCOLOR, this
1600: .getPropertyValue(BGCOLOR));
1601:
1602: destination.setBand(source.getBand());
1603: destination.setCell(source.getCell());
1604: destination
1605: .setPositionType(new String(source.getPositionType()));
1606:
1607: destination.setPropertyValue(REMOVE_LINE_WHEN_BLANK, this
1608: .getPropertyValue(REMOVE_LINE_WHEN_BLANK));
1609: destination.setPropertyValue(PRINT_REPEATED_VALUES, this
1610: .getPropertyValue(PRINT_REPEATED_VALUES));
1611: destination.setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND, this
1612: .getPropertyValue(PRINT_IN_FIRST_WHOLE_BAND));
1613: destination.setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW, this
1614: .getPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW));
1615: destination.setPropertyValue(MODE, this .getPropertyValue(MODE));
1616: destination.setStretchType(source.getStretchType());
1617:
1618: destination.setStyle(this .getStyle());
1619:
1620: destination.setPrintWhenExpression(new String(source
1621: .getPrintWhenExpression()));
1622: destination.setPrintWhenGroupChanges(new String(source
1623: .getPrintWhenGroupChanges()));
1624:
1625: }
1626:
1627: /**
1628: * Getter for property key.
1629: *
1630: * @return Value of property key.
1631: */
1632: public java.lang.String getKey() {
1633:
1634: return name;
1635: }
1636:
1637: /**
1638: * Setter for property key.
1639: *
1640: * @param key New value of property key.
1641: */
1642: public void setKey(java.lang.String key) {
1643: this .name = key;
1644: }
1645:
1646: /**
1647: * Getter for property stretchType.
1648: *
1649: * @return Value of property stretchType.
1650: */
1651: public java.lang.String getStretchType() {
1652:
1653: return stretchType;
1654: }
1655:
1656: /**
1657: * Setter for property stretchType.
1658: *
1659: * @param stretchType New value of property stretchType.
1660: */
1661: public void setStretchType(java.lang.String stretchType) {
1662: this .stretchType = stretchType;
1663: }
1664:
1665: /**
1666: * Getter for property bounds.
1667: *
1668: * @return Value of property bounds.
1669: */
1670: public java.awt.Rectangle getBounds() {
1671:
1672: return bounds;
1673: }
1674:
1675: /**
1676: * Setter for property bounds.
1677: *
1678: * @param bounds New value of property bounds.
1679: */
1680: public void setBounds(java.awt.Rectangle bounds) {
1681: this .position.x = bounds.x;
1682: this .position.y = bounds.y;
1683: this .width = bounds.width;
1684: this .height = bounds.height;
1685: this .updateBounds();
1686: }
1687:
1688: /**
1689: * DOCUMENT ME!
1690: *
1691: * @param groupname DOCUMENT ME!
1692: */
1693: public void addToGroup(String groupname) {
1694:
1695: if (getElementGroup() == null || getElementGroup().equals("")) {
1696: setElementGroup(getElementGroup() + groupname);
1697: } else {
1698: setElementGroup(groupname + "." + getElementGroup());
1699: }
1700: }
1701:
1702: /**
1703: * DOCUMENT ME!
1704: *
1705: * @param groupname DOCUMENT ME!
1706: */
1707: public void removeFromGroup(String groupname) {
1708:
1709: if (getElementGroup() == null || getElementGroup().equals("")) {
1710:
1711: return;
1712: }
1713:
1714: if (getElementGroup().startsWith(groupname)) {
1715: setElementGroup(getElementGroup().substring(
1716: groupname.length()));
1717:
1718: if (getElementGroup().startsWith(".")) {
1719: setElementGroup(getElementGroup().substring(1));
1720: }
1721: }
1722: }
1723:
1724: /**
1725: * DOCUMENT ME!
1726: */
1727: public void removeFromAllGroups() {
1728: setElementGroup("");
1729: }
1730:
1731: public String getElementGroup() {
1732: return elementGroup;
1733: }
1734:
1735: public void setElementGroup(String elementGroup) {
1736: this .elementGroup = elementGroup;
1737: }
1738:
1739: public ReportElement getParentElement() {
1740: return parentElement;
1741: }
1742:
1743: public void setParentElement(ReportElement parentElement) {
1744: this .parentElement = parentElement;
1745: }
1746:
1747: public int getElementID() {
1748: return elementID;
1749: }
1750:
1751: public void setElementID(int elementID) {
1752: this .elementID = elementID;
1753: }
1754:
1755: public Style getStyle() {
1756: return style;
1757: }
1758:
1759: public void setStyle(Style style) {
1760: this .style = style;
1761: if (style != null) {
1762: //this.setBgcolor( style.getAttributeColor( style.ATTRIBUTE_backcolor,getBgcolor(), true) );
1763: //this.setFgcolor( style.getAttributeColor( style.ATTRIBUTE_forecolor,getFgcolor(), true) );
1764: //this.setTransparent( style.getAttributeString( style.ATTRIBUTE_mode, getTransparent(), true) );
1765: }
1766: }
1767:
1768: public CrosstabCell getCell() {
1769: return cell;
1770: }
1771:
1772: public void setCell(CrosstabCell cell) {
1773: this .cell = cell;
1774: }
1775:
1776: public Point getRelativePosition() {
1777: return relativePosition;
1778: }
1779:
1780: public void setRelativePosition(Point relativePosition) {
1781: this.relativePosition = relativePosition;
1782: }
1783:
1784: }
|