KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > FillImage


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app;
31
32 import java.io.Serializable JavaDoc;
33
34 /**
35  * Describes how an image should 'fill' a particular component or region of
36  * the user interface. Includes information about the image itself, its
37  * positioning, repetition, and scrolling.
38  */

39 public class FillImage
40 implements Serializable JavaDoc {
41     
42     public static final int NO_REPEAT = 0;
43     public static final int REPEAT_HORIZONTAL = 1;
44     public static final int REPEAT_VERTICAL = 2;
45     public static final int REPEAT = 3;
46     
47     private ImageReference image;
48     private Extent horizontalOffset;
49     private Extent verticalOffset;
50     private int repeat;
51     
52     /**
53      * Creates a new <code>FillImage</code> with no horizontal/vertical
54      * offset that scrolls with content and repeats both horizontally and
55      * vertically.
56      *
57      * @param image the <code>ImageReference</code> to be displayed in the
58      * fill
59      */

60     public FillImage(ImageReference image) {
61         this(image, null, null, REPEAT);
62     }
63
64     /**
65      * Creates a new <code>FillImage</code>.
66      *
67      * @param image the <code>ImageReference</code> to be displayed in the
68      * fill
69      * @param horizontalOffset the horizontal offset of the fill image:
70      * Positive values indicate an offset from the left side of the
71      * region.
72      * Negative values indicate an offset from the right side of the
73      * region.
74      * Both fixed and percentage units are supported.
75      * @param verticalOffset the vertical offset of the fill image:
76      * Positive values indicate an offset from the top of the region.
77      * Negative values indicate an offset from the bottom of the region.
78      * Both fixed and percentage units are supported.
79      * @param repeat the repeat mode of the image, one of the following values:
80      * <ul>
81      * <li><code>NO_REPEAT</code></li>
82      * <li><code>REPEAT_HORIZONTAL</code></li>
83      * <li><code>REPEAT_VERTICAL</code></li>
84      * <li><code>REPEAT</code> (the default)</li>
85      * </ul>
86      */

87     public FillImage(ImageReference image, Extent horizontalOffset, Extent verticalOffset, int repeat) {
88         super();
89         this.image = image;
90         this.horizontalOffset = horizontalOffset;
91         this.verticalOffset = verticalOffset;
92         this.repeat = repeat;
93     }
94     
95     /**
96      * @see java.lang.Object#equals(java.lang.Object)
97      */

98     public boolean equals(Object JavaDoc o) {
99         if (!(o instanceof FillImage)) {
100             return false;
101         }
102         FillImage that = (FillImage) o;
103         if (this.repeat != that.repeat) {
104             return false;
105         }
106         if (!(this.image == that.image || (this.image != null && this.image.equals(that.image)))) {
107             return false;
108         }
109         if (!(this.horizontalOffset == that.horizontalOffset ||
110                 (this.horizontalOffset != null && this.horizontalOffset.equals(that.horizontalOffset)))) {
111             return false;
112         }
113         if (!(this.verticalOffset == that.verticalOffset ||
114                 (this.verticalOffset != null && this.verticalOffset.equals(that.verticalOffset)))) {
115             return false;
116         }
117         return true;
118     }
119     
120     /**
121      * Returns the horizontal offset of the fill image.
122      * Positive values indicate an offset from the left side of the region.
123      * Negative values indicate an offset from the right side of the region.
124      *
125      * @return the horizontal offset
126      */

127     public Extent getHorizontalOffset() {
128         return horizontalOffset;
129     }
130     /**
131      * Returns the fill image.
132      *
133      * @return the fill image
134      */

135     public ImageReference getImage() {
136         return image;
137     }
138
139     /**
140      * Returns the repetition mode of the image.
141      *
142      * @return the repetition mode, one of the following values:
143      * <ul>
144      * <li><code>NO_REPEAT</code></li>
145      * <li><code>REPEAT_HORIZONTAL</code></li>
146      * <li><code>REPEAT_VERTICAL</code></li>
147      * <li><code>REPEAT</code> (the default)</li>
148      * </ul>
149      */

150     public int getRepeat() {
151         return repeat;
152     }
153     
154     /**
155      * Returns the vertical offset of the fill image.
156      * Positive values indicate an offset from the top of the region.
157      * Negative values indicate an offset from the bottom of the region.
158      *
159      * @return the vertical offset
160      */

161     public Extent getVerticalOffset() {
162         return verticalOffset;
163     }
164 }
165
Popular Tags