001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine;
029:
030: /**
031: * @author Teodor Danciu (teodord@users.sourceforge.net)
032: * @version $Id: JRPrintAnchorIndex.java 1422 2006-10-06 16:00:11Z lucianc $
033: */
034: public class JRPrintAnchorIndex {
035:
036: /**
037: *
038: */
039: private int pageIndex = 0;
040: private JRPrintElement element = null;
041: private final int offsetX;
042: private final int offsetY;
043:
044: /**
045: * Creates an element anchor.
046: *
047: * @param page the index of the page in the report
048: * @param elem the element
049: */
050: public JRPrintAnchorIndex(int page, JRPrintElement elem) {
051: this (page, elem, 0, 0);
052: }
053:
054: /**
055: * Creates an element anchor.
056: *
057: * @param page the index of the page in the report
058: * @param elem the element
059: * @param offsetX the X offset of the element coordinates system
060: * @param offsetY the Y offset of the element coordinates system
061: * @see #getElementAbsoluteX()
062: * @see #getElementAbsoluteY()
063: */
064: public JRPrintAnchorIndex(int page, JRPrintElement elem,
065: int offsetX, int offsetY) {
066: this .pageIndex = page;
067: this .element = elem;
068: this .offsetX = offsetX;
069: this .offsetY = offsetY;
070: }
071:
072: /**
073: *
074: */
075: public int getPageIndex() {
076: return this .pageIndex;
077: }
078:
079: /**
080: *
081: */
082: public JRPrintElement getElement() {
083: return this .element;
084: }
085:
086: /**
087: * Returns the absolute (relative to the report page) X coordinate of the anchor element.
088: * <p>
089: * This can be different than {@link JRPrintElement#getX() getElement().getX()} for elements
090: * placed inside a {@link JRPrintFrame frame}.
091: * </p>
092: *
093: * @return the absolute X coordinate of the anchor element
094: */
095: public int getElementAbsoluteX() {
096: return element.getX() + offsetX;
097: }
098:
099: /**
100: * Returns the absolute (relative to the report page) Y coordinate of the anchor element.
101: * <p>
102: * This can be different than {@link JRPrintElement#getY() getElement().getY()} for elements
103: * placed inside a {@link JRPrintFrame frame}.
104: * </p>
105: *
106: * @return the absolute Y coordinate of the anchor element
107: */
108: public int getElementAbsoluteY() {
109: return element.getY() + offsetY;
110: }
111:
112: }
|