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: * ImageElement.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report;
030:
031: import org.jfree.report.style.ElementStyleKeys;
032:
033: /**
034: * Used to draw images. References to the Images must be given as ImageContainer. If you
035: * use the <code>ImageElementFactory</code> implementations, the necessary wrapping is
036: * done for you, if needed.
037: * <p/>
038: *
039: * @author Thomas Morgner
040: */
041: public class ImageElement extends Element {
042: /**
043: * A string for the content type.
044: */
045: public static final String CONTENT_TYPE = "image/generic";
046:
047: /**
048: * Constructs a image element.
049: */
050: public ImageElement() {
051: }
052:
053: /**
054: * Returns the content type, in this case 'image/generic'.
055: *
056: * @return the content type.
057: */
058: public String getContentType() {
059: return ImageElement.CONTENT_TYPE;
060: }
061:
062: /**
063: * Returns true if the image should be scaled, and false otherwise.
064: *
065: * @return true or false.
066: */
067: public boolean isScale() {
068: return getStyle().getBooleanStyleProperty(
069: ElementStyleKeys.SCALE);
070: }
071:
072: /**
073: * Sets a flag that controls whether the image should be scaled to fit the element
074: * bounds.
075: *
076: * @param scale the flag.
077: */
078: public void setScale(final boolean scale) {
079: getStyle().setBooleanStyleProperty(ElementStyleKeys.SCALE,
080: scale);
081: }
082:
083: /**
084: * Returns true if the image's aspect ratio should be preserved, and false otherwise.
085: *
086: * @return true or false.
087: */
088: public boolean isKeepAspectRatio() {
089: return getStyle().getBooleanStyleProperty(
090: ElementStyleKeys.KEEP_ASPECT_RATIO);
091: }
092:
093: /**
094: * Sets a flag that controls whether the shape's aspect ratio should be preserved.
095: *
096: * @param kar the flag.
097: */
098: public void setKeepAspectRatio(final boolean kar) {
099: getStyle().setBooleanStyleProperty(
100: ElementStyleKeys.KEEP_ASPECT_RATIO, kar);
101: }
102: }
|