KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > WritableImage


1 /*********************************************************************
2 *
3 * Copyright (C) 2003 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write;
21
22 import java.io.File JavaDoc;
23
24 import jxl.biff.drawing.Drawing;
25 import jxl.biff.drawing.DrawingGroupObject;
26 import jxl.biff.drawing.DrawingGroup;
27
28 /**
29  * Allows an image to be created, or an existing image to be manipulated
30  * Note that co-ordinates and dimensions are given in cells, so that if for
31  * example the width or height of a cell which the image spans is altered,
32  * the image will have a correspondign distortion
33  */

34 public class WritableImage extends Drawing
35 {
36   /**
37    * Constructor
38    *
39    * @param x the column number at which to position the image
40    * @param y the row number at which to position the image
41    * @param width the number of columns cells which the image spans
42    * @param height the number of rows which the image spans
43    * @param image the source image file
44    */

45   public WritableImage(double x, double y,
46                        double width, double height,
47                        File JavaDoc image)
48   {
49     super(x, y, width, height, image);
50   }
51
52   /**
53    * Constructor
54    *
55    * @param x the column number at which to position the image
56    * @param y the row number at which to position the image
57    * @param width the number of columns cells which the image spans
58    * @param height the number of rows which the image spans
59    * @param image the image data
60    */

61   public WritableImage(double x, double y,
62                        double width, double height,
63                        byte[] imageData)
64   {
65     super(x, y, width, height, imageData);
66   }
67
68   /**
69    * Constructor, used when copying sheets
70    *
71    * @param d the image to copy
72    */

73   public WritableImage(DrawingGroupObject d, DrawingGroup dg)
74   {
75     super(d, dg);
76   }
77
78   /**
79    * Accessor for the image position
80    *
81    * @return the column number at which the image is positioned
82    */

83   public double getColumn()
84   {
85     return super.getX();
86   }
87
88   /**
89    * Accessor for the image position
90    *
91    * @param c the column number at which the image should be positioned
92    */

93   public void setColumn(double c)
94   {
95     super.setX(c);
96   }
97
98   /**
99    * Accessor for the image position
100    *
101    * @return the row number at which the image is positions
102    */

103   public double getRow()
104   {
105     return super.getY();
106   }
107
108   /**
109    * Accessor for the image position
110    *
111    * @param c the row number at which the image should be positioned
112    */

113   public void setRow(double c)
114   {
115     super.setY(c);
116   }
117
118   /**
119    * Accessor for the image dimensions
120    *
121    * @return the number of columns this image spans
122    */

123   public double getWidth()
124   {
125     return super.getWidth();
126   }
127
128   /**
129    * Accessor for the image dimensions
130    * Note that the actual size of the rendered image will depend on the
131    * width of the columns it spans
132    *
133    * @param c the number of columns which this image spans
134    */

135   public void setWidth(double c)
136   {
137     super.setWidth(c);
138   }
139
140   /**
141    * Accessor for the image dimensions
142    *
143    * @return the number of rows which this image spans
144    */

145   public double getHeight()
146   {
147     return super.getHeight();
148   }
149
150   /**
151    * Accessor for the image dimensions
152    * Note that the actual size of the rendered image will depend on the
153    * height of the rows it spans
154    *
155    * @param c the number of rows which this image should span
156    */

157   public void setHeight(double c)
158   {
159     super.setHeight(c);
160   }
161
162   /**
163    * Accessor for the image file
164    *
165    * @return the file which the image references
166    */

167   public File JavaDoc getImageFile()
168   {
169     return super.getImageFile();
170   }
171
172   /**
173    * Accessor for the image data
174    *
175    * @return the image data
176    */

177   public byte[] getImageData()
178   {
179     return super.getImageData();
180   }
181 }
182
Popular Tags