001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: ShapedPanelProperties.java,v 1.11 2005/12/04 13:46:05 jesper Exp $
023: package net.infonode.properties.gui.util;
024:
025: import net.infonode.gui.componentpainter.ComponentPainter;
026: import net.infonode.properties.propertymap.*;
027: import net.infonode.properties.types.BooleanProperty;
028: import net.infonode.properties.types.ComponentPainterProperty;
029: import net.infonode.properties.types.DirectionProperty;
030: import net.infonode.util.Direction;
031:
032: /**
033: * Properties and property values for a shaped panel, which is a panel that can have a
034: * {@link net.infonode.gui.shaped.border.ShapedBorder} and a {@link ComponentPainter}.
035: *
036: * @author $Author: jesper $
037: * @version $Revision: 1.11 $
038: */
039: public class ShapedPanelProperties extends PropertyMapContainer {
040: /**
041: * Property group for all shaped panel properties.
042: */
043: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
044: "Shaped Panel Properties", "");
045:
046: /**
047: * If true the shaped panel is opaque.
048: *
049: * @since ITP 1.4.0
050: */
051: public static final BooleanProperty OPAQUE = new BooleanProperty(
052: PROPERTIES,
053: "Opaque",
054: "If true the shaped panel is opaque. If false the shaped panel is transparent",
055: PropertyMapValueHandler.INSTANCE);
056:
057: /**
058: * If true the shaped panel is flipped horizontally.
059: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
060: */
061: public static final BooleanProperty HORIZONTAL_FLIP = new BooleanProperty(
062: PROPERTIES,
063: "Horizontal Flip",
064: "If true the shaped panel is flipped horizontally. "
065: + "Used by ComponentPainter's, ShapedBorder's etc.",
066: PropertyMapValueHandler.INSTANCE);
067:
068: /**
069: * If true the shaped panel is flipped vertically.
070: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
071: */
072: public static final BooleanProperty VERTICAL_FLIP = new BooleanProperty(
073: PROPERTIES,
074: "Vertical Flip",
075: "If true the shaped panel is flipped vertically. "
076: + "Used by ComponentPainter's, ShapedBorder's etc.",
077: PropertyMapValueHandler.INSTANCE);
078:
079: /**
080: * If true the child components of the shaped panel are clipped with the border shape.
081: */
082: public static final BooleanProperty CLIP_CHILDREN = new BooleanProperty(
083: PROPERTIES,
084: "Clip Children",
085: "If true the child components of the shaped panel are clipped with the border shape.",
086: PropertyMapValueHandler.INSTANCE);
087:
088: /**
089: * {@link ComponentPainter} that paints the shaped panel background.
090: */
091: public static final ComponentPainterProperty COMPONENT_PAINTER = new ComponentPainterProperty(
092: PROPERTIES,
093: "Component Painter",
094: "The component painter that paints the shaped panel background.",
095: PropertyMapValueHandler.INSTANCE);
096:
097: /**
098: * The direction of the shaped panel.
099: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
100: */
101: public static final DirectionProperty DIRECTION = new DirectionProperty(
102: PROPERTIES,
103: "Direction",
104: "The direction of the shaped panel. Used by ComponentPainter's, ShapedBorder's etc.",
105: PropertyMapValueHandler.INSTANCE);
106:
107: static {
108: ShapedPanelProperties properties = new ShapedPanelProperties(
109: PROPERTIES.getDefaultMap());
110:
111: properties.setHorizontalFlip(false).setVerticalFlip(false)
112: .setComponentPainter(null)
113: .setDirection(Direction.RIGHT);
114: }
115:
116: /**
117: * Creates an empty property object.
118: */
119: public ShapedPanelProperties() {
120: super (PROPERTIES);
121: }
122:
123: /**
124: * Creates a property map containing the map.
125: *
126: * @param map the property map
127: */
128: public ShapedPanelProperties(PropertyMap map) {
129: super (map);
130: }
131:
132: /**
133: * Creates a property object that inherit values from another property
134: * object.
135: *
136: * @param inheritFrom the object from which to inherit property values
137: */
138: public ShapedPanelProperties(ShapedPanelProperties inheritFrom) {
139: super (PropertyMapFactory.create(inheritFrom.getMap()));
140: }
141:
142: /**
143: * Adds a super object from which property values are inherited.
144: *
145: * @param properties the object from which to inherit property values
146: * @return this
147: */
148: public ShapedPanelProperties addSuperObject(
149: ShapedPanelProperties properties) {
150: getMap().addSuperMap(properties.getMap());
151:
152: return this ;
153: }
154:
155: /**
156: * Removes the last added super object.
157: *
158: * @return this
159: */
160: public ShapedPanelProperties removeSuperObject() {
161: getMap().removeSuperMap();
162: return this ;
163: }
164:
165: /**
166: * Removes the given super object.
167: *
168: * @param superObject super object to remove
169: * @return this
170: */
171: public ShapedPanelProperties removeSuperObject(
172: ShapedPanelProperties super Object) {
173: getMap().removeSuperMap(super Object.getMap());
174: return this ;
175: }
176:
177: /**
178: * Set to true if the shaped panel should be opaque.
179: *
180: * @param opaque true for opaque, otherwise false
181: * @since ITP 1.4.0
182: */
183: public ShapedPanelProperties setOpaque(boolean opaque) {
184: OPAQUE.set(getMap(), opaque);
185:
186: return this ;
187: }
188:
189: /**
190: * Returns true if the shaped panel should be opaque.
191: *
192: * @return true for opaque, otherwise false
193: * @since ITP 1.4.0
194: */
195: public boolean getOpaque() {
196: return OPAQUE.get(getMap());
197: }
198:
199: /**
200: * Set to true if the shaped panel should be flipped horizontally.
201: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
202: *
203: * @param flip true if the shaped panel should be flipped vertically
204: * @return this
205: */
206: public ShapedPanelProperties setHorizontalFlip(boolean flip) {
207: HORIZONTAL_FLIP.set(getMap(), flip);
208:
209: return this ;
210: }
211:
212: /**
213: * Returns true if the shaped panel is flipped horizontally.
214: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
215: *
216: * @return true if the shaped panel is flipped horizontally
217: */
218: public boolean getHorizontalFlip() {
219: return HORIZONTAL_FLIP.get(getMap());
220: }
221:
222: /**
223: * Set to true if the shaped panel should be flipped vertically.
224: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
225: *
226: * @param flip true if the shaped panel should be flipped horizontally
227: * @return this
228: */
229: public ShapedPanelProperties setVerticalFlip(boolean flip) {
230: VERTICAL_FLIP.set(getMap(), flip);
231:
232: return this ;
233: }
234:
235: /**
236: * Returns true if the shaped panel is flipped vertically.
237: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
238: *
239: * @return true if the shaped panel is flipped vertically
240: */
241: public boolean getVerticalFlip() {
242: return VERTICAL_FLIP.get(getMap());
243: }
244:
245: /**
246: * Set to true if the child components of the shaped panel should be clipped with the border shape.
247: *
248: * @param clipChildren true if the child components of the shaped panel should be clipped with the border shape
249: * @return this
250: */
251: public ShapedPanelProperties setClipChildren(boolean clipChildren) {
252: CLIP_CHILDREN.set(getMap(), clipChildren);
253: return this ;
254: }
255:
256: /**
257: * Returns true the child components of the shaped panel are clipped with the border shape.
258: *
259: * @return true the child components of the shaped panel are clipped with the border shape
260: */
261: public boolean getClipChildren() {
262: return CLIP_CHILDREN.get(getMap());
263: }
264:
265: /**
266: * Sets the painter that paints the shaped panel background.
267: *
268: * @param painter the painter that paints the shaped panel background, null for none
269: * @return this
270: */
271: public ShapedPanelProperties setComponentPainter(
272: ComponentPainter painter) {
273: COMPONENT_PAINTER.set(getMap(), painter);
274:
275: return this ;
276: }
277:
278: /**
279: * Gets the painter that paints the shaped panel background.
280: *
281: * @return the painter that paints the shaped panel background, null if none
282: */
283: public ComponentPainter getComponentPainter() {
284: return COMPONENT_PAINTER.get(getMap());
285: }
286:
287: /**
288: * Sets the direction of the shaped panel.
289: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
290: *
291: * @param direction the direction of the shaped panel
292: * @return this
293: */
294: public ShapedPanelProperties setDirection(Direction direction) {
295: DIRECTION.set(getMap(), direction);
296:
297: return this ;
298: }
299:
300: /**
301: * Gets the direction of the shaped panel.
302: * Used by {@link ComponentPainter}'s, {@link net.infonode.gui.shaped.border.ShapedBorder}'s etc.
303: *
304: * @return the direction of the shaped panel
305: */
306: public Direction getDirection() {
307: return DIRECTION.get(getMap());
308: }
309: }
|