KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > jfreereport > reportcharts > ChartImageContainer


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12 */

13 /**
14  * ========================================
15  * <libname> : a free Java <foobar> library
16  * ========================================
17  *
18  * Project Info: http://www.jfree.org/liblayout/
19  * Project Lead: Thomas Morgner;
20  *
21  * (C) Copyright 2005, by Object Refinery Limited and Contributors.
22  *
23  * This library is free software; you can redistribute it and/or modify it under the terms
24  * of the GNU Lesser General Public License as published by the Free Software Foundation;
25  * either version 2.1 of the License, or (at your option) any later version.
26  *
27  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
28  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
29  * See the GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU Lesser General Public License along with this
32  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
33  * Boston, MA 02111-1307, USA.
34  *
35  * ---------
36  * ChartImageReference.java
37  * ---------
38  *
39  * Original Author: Thomas Morgner;
40  * Contributors: -;
41  *
42  * $Id: Anchor.java,v 1.3 2005/02/23 21:04:29 taqua Exp $
43  *
44  * Changes
45  * -------------------------
46  * 01.10.2006 : Initial version
47  */

48 package org.pentaho.plugin.jfreereport.reportcharts;
49
50 import java.awt.Image JavaDoc;
51 import java.net.URL JavaDoc;
52
53 import org.jfree.report.LocalImageContainer;
54 import org.jfree.report.URLImageContainer;
55
56 /**
57  * Creation-Date: 01.10.2006, 15:47:03
58  *
59  * @author Thomas Morgner
60  */

61 public class ChartImageContainer
62         implements URLImageContainer, LocalImageContainer
63 {
64   private static class ChartImageKey
65   {
66     private int row;
67     private String JavaDoc expressionName;
68
69     public ChartImageKey(final int row, final String JavaDoc expressionName)
70     {
71       this.row = row;
72       this.expressionName = expressionName;
73     }
74
75     public boolean equals(final Object JavaDoc o)
76     {
77       if (this == o)
78       {
79         return true;
80       }
81       if (o == null || getClass() != o.getClass())
82       {
83         return false;
84       }
85
86       final ChartImageKey that = (ChartImageKey) o;
87
88       if (row != that.row)
89       {
90         return false;
91       }
92       if (!expressionName.equals(that.expressionName))
93       {
94         return false;
95       }
96
97       return true;
98     }
99
100     public int hashCode()
101     {
102       int result;
103       result = row;
104       result = 29 * result + expressionName.hashCode();
105       return result;
106     }
107   }
108
109   private String JavaDoc target;
110   private Image JavaDoc image;
111   private int width;
112   private int height;
113   private ChartImageKey key;
114
115   public ChartImageContainer(final String JavaDoc target,
116                              final Image JavaDoc image,
117                              final int width,
118                              final int height,
119                              final int row,
120                              final String JavaDoc keyName)
121   {
122     if (target == null)
123     {
124       throw new NullPointerException JavaDoc();
125     }
126     if (image == null)
127     {
128       throw new NullPointerException JavaDoc();
129     }
130     if (keyName == null)
131     {
132       throw new NullPointerException JavaDoc();
133     }
134
135     this.target = target;
136     this.image = image;
137     this.width = width;
138     this.height = height;
139     this.key = new ChartImageKey(row, keyName);
140   }
141
142   public Object JavaDoc getIdentity()
143   {
144     return key;
145   }
146
147   public Image JavaDoc getImage()
148   {
149     return image;
150   }
151
152   public String JavaDoc getName()
153   {
154     return getSourceURLString();
155   }
156
157   public boolean isIdentifiable()
158   {
159     return true;
160   }
161
162   public int getImageHeight()
163   {
164     return height;
165   }
166
167   public int getImageWidth()
168   {
169     return width;
170   }
171
172   public float getScaleX()
173   {
174     return 1;
175   }
176
177   public float getScaleY()
178   {
179     return 1;
180   }
181
182   public URL JavaDoc getSourceURL()
183   {
184     return null;
185   }
186
187   public String JavaDoc getSourceURLString()
188   {
189     return target;
190   }
191
192   /**
193    * The URL returned by this container cannot be read.
194    *
195    * @return
196    */

197   public boolean isLoadable()
198   {
199     return false;
200   }
201 }
202
Popular Tags