001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: */
013: /**
014: * ========================================
015: * <libname> : a free Java <foobar> library
016: * ========================================
017: *
018: * Project Info: http://www.jfree.org/liblayout/
019: * Project Lead: Thomas Morgner;
020: *
021: * (C) Copyright 2005, by Object Refinery Limited and Contributors.
022: *
023: * This library is free software; you can redistribute it and/or modify it under the terms
024: * of the GNU Lesser General Public License as published by the Free Software Foundation;
025: * either version 2.1 of the License, or (at your option) any later version.
026: *
027: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
028: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
029: * See the GNU Lesser General Public License for more details.
030: *
031: * You should have received a copy of the GNU Lesser General Public License along with this
032: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
033: * Boston, MA 02111-1307, USA.
034: *
035: * ---------
036: * ChartImageReference.java
037: * ---------
038: *
039: * Original Author: Thomas Morgner;
040: * Contributors: -;
041: *
042: * $Id: Anchor.java,v 1.3 2005/02/23 21:04:29 taqua Exp $
043: *
044: * Changes
045: * -------------------------
046: * 01.10.2006 : Initial version
047: */package org.pentaho.plugin.jfreereport.reportcharts;
048:
049: import java.awt.Image;
050: import java.net.URL;
051:
052: import org.jfree.report.LocalImageContainer;
053: import org.jfree.report.URLImageContainer;
054:
055: /**
056: * Creation-Date: 01.10.2006, 15:47:03
057: *
058: * @author Thomas Morgner
059: */
060: public class ChartImageContainer implements URLImageContainer,
061: LocalImageContainer {
062: private static class ChartImageKey {
063: private int row;
064:
065: private String expressionName;
066:
067: public ChartImageKey(final int row, final String expressionName) {
068: this .row = row;
069: this .expressionName = expressionName;
070: }
071:
072: public boolean equals(final Object o) {
073: if (this == o) {
074: return true;
075: }
076: if (o == null || getClass() != o.getClass()) {
077: return false;
078: }
079:
080: final ChartImageKey that = (ChartImageKey) o;
081:
082: if (row != that.row) {
083: return false;
084: }
085: if (!expressionName.equals(that.expressionName)) {
086: return false;
087: }
088:
089: return true;
090: }
091:
092: public int hashCode() {
093: int result;
094: result = row;
095: result = 29 * result + expressionName.hashCode();
096: return result;
097: }
098: }
099:
100: private String target;
101:
102: private Image image;
103:
104: private int width;
105:
106: private int height;
107:
108: private ChartImageKey key;
109:
110: public ChartImageContainer(final String target, final Image image,
111: final int width, final int height, final int row,
112: final String keyName) {
113: if (target == null) {
114: throw new NullPointerException();
115: }
116: if (image == null) {
117: throw new NullPointerException();
118: }
119: if (keyName == null) {
120: throw new NullPointerException();
121: }
122:
123: this .target = target;
124: this .image = image;
125: this .width = width;
126: this .height = height;
127: this .key = new ChartImageKey(row, keyName);
128: }
129:
130: public Object getIdentity() {
131: return key;
132: }
133:
134: public Image getImage() {
135: return image;
136: }
137:
138: public String getName() {
139: return getSourceURLString();
140: }
141:
142: public boolean isIdentifiable() {
143: return true;
144: }
145:
146: public int getImageHeight() {
147: return height;
148: }
149:
150: public int getImageWidth() {
151: return width;
152: }
153:
154: public float getScaleX() {
155: return 1;
156: }
157:
158: public float getScaleY() {
159: return 1;
160: }
161:
162: public URL getSourceURL() {
163: return null;
164: }
165:
166: public String getSourceURLString() {
167: return target;
168: }
169:
170: /**
171: * The URL returned by this container cannot be read.
172: *
173: * @return
174: */
175: public boolean isLoadable() {
176: return false;
177: }
178: }
|