001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either 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, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * NonDynamicReplacedContentStyleSheet.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.layout.style;
030:
031: import java.awt.geom.Point2D;
032:
033: import org.jfree.report.style.AbstractStyleSheet;
034: import org.jfree.report.style.ElementStyleKeys;
035: import org.jfree.report.style.StyleKey;
036: import org.jfree.report.style.StyleSheet;
037: import org.jfree.report.util.InstanceID;
038: import org.jfree.ui.FloatDimension;
039:
040: /**
041: * A replaced content element that is contained in a 'canvas' box (which is the default for all non-inline replaced
042: * content elements) must have a minimum width and height of 100% so that it fills the whole box.
043: *
044: * @author Thomas Morgner
045: */
046: public class NonDynamicReplacedContentStyleSheet extends
047: AbstractStyleSheet {
048: private static final Float SIZE = new Float(-100);
049: private static final Float POS = new Float(0);
050: private StyleSheet parent;
051:
052: public NonDynamicReplacedContentStyleSheet(final StyleSheet parent) {
053: this .parent = parent;
054: }
055:
056: public StyleSheet getParent() {
057: return parent;
058: }
059:
060: public Object getStyleProperty(final StyleKey key,
061: final Object defaultValue) {
062: if (ElementStyleKeys.MAXIMUMSIZE.equals(key)) {
063: return new FloatDimension(-100, -100);
064: }
065: if (ElementStyleKeys.MAX_WIDTH.equals(key)) {
066: return SIZE;
067: }
068: if (ElementStyleKeys.MAX_HEIGHT.equals(key)) {
069: return SIZE;
070: }
071: if (ElementStyleKeys.MINIMUMSIZE.equals(key)) {
072: return new FloatDimension(-100, -100);
073: }
074: if (ElementStyleKeys.MIN_WIDTH.equals(key)) {
075: return SIZE;
076: }
077: if (ElementStyleKeys.MIN_HEIGHT.equals(key)) {
078: return SIZE;
079: }
080: if (ElementStyleKeys.POS_X.equals(key)) {
081: return POS;
082: }
083: if (ElementStyleKeys.POS_Y.equals(key)) {
084: return POS;
085: }
086: if (ElementStyleKeys.ABSOLUTE_POS.equals(key)) {
087: return new Point2D.Float(0, 0);
088: }
089:
090: return parent.getStyleProperty(key, defaultValue);
091: }
092:
093: public Object[] toArray(final StyleKey[] keys) {
094: final Object[] objects = (Object[]) parent.toArray(keys)
095: .clone();
096: objects[ElementStyleKeys.MIN_WIDTH.getIdentifier()] = SIZE;
097: objects[ElementStyleKeys.MIN_HEIGHT.getIdentifier()] = SIZE;
098: objects[ElementStyleKeys.MAX_WIDTH.getIdentifier()] = SIZE;
099: objects[ElementStyleKeys.MAX_HEIGHT.getIdentifier()] = SIZE;
100: objects[ElementStyleKeys.MAXIMUMSIZE.getIdentifier()] = null;
101: objects[ElementStyleKeys.MINIMUMSIZE.getIdentifier()] = null;
102: objects[ElementStyleKeys.POS_X.getIdentifier()] = POS;
103: objects[ElementStyleKeys.POS_Y.getIdentifier()] = POS;
104: objects[ElementStyleKeys.ABSOLUTE_POS.getIdentifier()] = null;
105: return objects;
106: }
107:
108: public InstanceID getId() {
109: return parent.getId();
110: }
111:
112: public long getChangeTracker() {
113: return parent.getChangeTracker();
114: }
115: }
|