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: TitledTabStateProperties.java,v 1.24 2005/02/16 11:28:15 jesper Exp $
023: package net.infonode.tabbedpanel.titledtab;
024:
025: import net.infonode.properties.gui.util.ComponentProperties;
026: import net.infonode.properties.gui.util.ShapedPanelProperties;
027: import net.infonode.properties.propertymap.*;
028: import net.infonode.properties.types.*;
029: import net.infonode.util.Alignment;
030: import net.infonode.util.Direction;
031:
032: import javax.swing.*;
033:
034: /**
035: * TitledTabStateProperties holds all properties that are unique for a titled tab state.
036: *
037: * @author $Author: jesper $
038: * @version $Revision: 1.24 $
039: * @see TitledTab
040: * @see TitledTabProperties
041: */
042: public class TitledTabStateProperties extends PropertyMapContainer {
043: /**
044: * A property group for all properties in TitledTabStateProperties
045: */
046: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
047: "State Properties", "");
048:
049: /**
050: * Icon property
051: *
052: * @see #setIcon
053: * @see #getIcon
054: */
055: public static final IconProperty ICON = new IconProperty(
056: PROPERTIES, "Icon", "Icon",
057: PropertyMapValueHandler.INSTANCE);
058:
059: /**
060: * Text property
061: *
062: * @see #setText
063: * @see #getText
064: */
065: public static final StringProperty TEXT = new StringProperty(
066: PROPERTIES, "Text", "Text",
067: PropertyMapValueHandler.INSTANCE);
068:
069: /**
070: * Icon text gap property
071: *
072: * @see #setIconTextGap
073: * @see #getIconTextGap
074: */
075: public static final IntegerProperty ICON_TEXT_GAP = IntegerProperty
076: .createPositive(PROPERTIES, "Icon Text Gap",
077: "Number of pixels between icon and text.", 2,
078: PropertyMapValueHandler.INSTANCE);
079:
080: /**
081: * Tool tip text property
082: *
083: * @see #setToolTipText
084: * @see #getToolTipText
085: */
086: public static final StringProperty TOOL_TIP_TEXT = new StringProperty(
087: PROPERTIES, "Tool Tip Text", "Tool tip text",
088: PropertyMapValueHandler.INSTANCE);
089:
090: /**
091: * Tool tip enabled property
092: *
093: * @see #setToolTipEnabled
094: * @see #getToolTipEnabled
095: */
096: public static final BooleanProperty TOOL_TIP_ENABLED = new BooleanProperty(
097: PROPERTIES, "Tool Tip Enabled",
098: "Tool tip enabled or disabled",
099: PropertyMapValueHandler.INSTANCE);
100:
101: /**
102: * Icon visible property
103: *
104: * @see #setIconVisible
105: * @see #getIconVisible
106: * @since ITP 1.1.0
107: */
108: public static final BooleanProperty ICON_VISIBLE = new BooleanProperty(
109: PROPERTIES, "Icon Visible", "Icon visible or not visible",
110: PropertyMapValueHandler.INSTANCE);
111:
112: /**
113: * Text visible property
114: *
115: * @see #setTextVisible
116: * @see #getTextVisible
117: * @since ITP 1.1.0
118: */
119: public static final BooleanProperty TEXT_VISIBLE = new BooleanProperty(
120: PROPERTIES, "Text Visible", "Text visible or not visible",
121: PropertyMapValueHandler.INSTANCE);
122:
123: /**
124: * Title component visible property
125: *
126: * @see #setTitleComponentVisible
127: * @see #getTitleComponentVisible
128: * @since ITP 1.1.0
129: */
130: public static final BooleanProperty TITLE_COMPONENT_VISIBLE = new BooleanProperty(
131: PROPERTIES, "Title Component Visible",
132: "Title component visible or not visible",
133: PropertyMapValueHandler.INSTANCE);
134:
135: /**
136: * Horizontal alignment property
137: *
138: * @see #setHorizontalAlignment
139: * @see #getHorizontalAlignment
140: */
141: public static final AlignmentProperty HORIZONTAL_ALIGNMENT = new AlignmentProperty(
142: PROPERTIES, "Horizontal Alignment",
143: "Horizontal alignment for the icon and text.",
144: PropertyMapValueHandler.INSTANCE, Alignment
145: .getHorizontalAlignments());
146:
147: /**
148: * Vertical alignment property
149: *
150: * @see #setVerticalAlignment
151: * @see #getVerticalAlignment
152: */
153: public static final AlignmentProperty VERTICAL_ALIGNMENT = new AlignmentProperty(
154: PROPERTIES, "Vertical Alignment",
155: "Vertical alignment for the icon and text.",
156: PropertyMapValueHandler.INSTANCE, Alignment
157: .getVerticalAlignments());
158:
159: /**
160: * Icon text relative alignment property
161: *
162: * @see #setIconTextRelativeAlignment
163: * @see #getIconTextRelativeAlignment
164: */
165: public static final AlignmentProperty ICON_TEXT_RELATIVE_ALIGNMENT = new AlignmentProperty(
166: PROPERTIES, "Icon Text Relative Alignment",
167: "Icon horizontal alignment relative to text.",
168: PropertyMapValueHandler.INSTANCE, new Alignment[] {
169: Alignment.LEFT, Alignment.RIGHT });
170:
171: /**
172: * Text title component gap property
173: *
174: * @see #setTextTitleComponentGap
175: * @see #getTextTitleComponentGap
176: */
177: public static final IntegerProperty TEXT_TITLE_COMPONENT_GAP = IntegerProperty
178: .createPositive(
179: PROPERTIES,
180: "Text Title Component Gap",
181: "Number of pixels between text and title component.",
182: 2, PropertyMapValueHandler.INSTANCE);
183:
184: /**
185: * Title component text relative alignment property
186: *
187: * @see #setTitleComponentTextRelativeAlignment
188: * @see #getTitleComponentTextRelativeAlignment
189: */
190: public static final AlignmentProperty TITLE_COMPONENT_TEXT_RELATIVE_ALIGNMENT = new AlignmentProperty(
191: PROPERTIES,
192: "Title Component Text Relative Alignment",
193: "Title component horizontal alignment relative to text and icon.",
194: PropertyMapValueHandler.INSTANCE, new Alignment[] {
195: Alignment.LEFT, Alignment.RIGHT });
196:
197: /**
198: * Direction property
199: *
200: * @see #setDirection
201: * @see #getDirection
202: */
203: public static final DirectionProperty DIRECTION = new DirectionProperty(
204: PROPERTIES, "Direction", "Direction for tab contents",
205: PropertyMapValueHandler.INSTANCE);
206:
207: /**
208: * Tab component properties.
209: */
210: public static final PropertyMapProperty COMPONENT_PROPERTIES = new PropertyMapProperty(
211: PROPERTIES, "Component Properties",
212: "Tab component properties.", ComponentProperties.PROPERTIES);
213:
214: /**
215: * Tab shaped panel properties.
216: *
217: * @since ITP 1.2.0
218: */
219: public static final PropertyMapProperty SHAPED_PANEL_PROPERTIES = new PropertyMapProperty(
220: PROPERTIES, "Shaped Panel Properties",
221: "Tab shaped panel properties.",
222: ShapedPanelProperties.PROPERTIES);
223:
224: /**
225: * Constructs an empty TitledTabStateProperties object
226: */
227: public TitledTabStateProperties() {
228: super (PROPERTIES);
229: }
230:
231: /**
232: * Constructs a TitledTabStateProperties map with the give map as property storage
233: *
234: * @param map map to store properties in
235: */
236: public TitledTabStateProperties(PropertyMap map) {
237: super (map);
238: }
239:
240: /**
241: * Constructs a TitledTabStateProperties object that inherits its properties from the given TitledTabStateProperties object
242: *
243: * @param inheritFrom TitledTabStateProperties object to inherit properties from
244: */
245: public TitledTabStateProperties(TitledTabStateProperties inheritFrom) {
246: super (PropertyMapFactory.create(inheritFrom.getMap()));
247: }
248:
249: /**
250: * Adds a super object from which property values are inherited.
251: *
252: * @param superObject the object from which to inherit property values
253: * @return this
254: */
255: public TitledTabStateProperties addSuperObject(
256: TitledTabStateProperties super Object) {
257: getMap().addSuperMap(super Object.getMap());
258: return this ;
259: }
260:
261: /**
262: * Removes the last added super object.
263: *
264: * @return this
265: */
266: public TitledTabStateProperties removeSuperObject() {
267: getMap().removeSuperMap();
268: return this ;
269: }
270:
271: /**
272: * Removes the given super object.
273: *
274: * @param superObject super object to remove
275: * @return this
276: * @since ITP 1.3.0
277: */
278: public TitledTabStateProperties removeSuperObject(
279: TitledTabStateProperties super Object) {
280: getMap().removeSuperMap(super Object.getMap());
281: return this ;
282: }
283:
284: /**
285: * Sets the icon
286: *
287: * @param icon icon or null for no icon
288: * @return this TitledTabStateProperties
289: */
290: public TitledTabStateProperties setIcon(Icon icon) {
291: ICON.set(getMap(), icon);
292: return this ;
293: }
294:
295: /**
296: * Gets the icon
297: *
298: * @return icon or null if no icon
299: */
300: public Icon getIcon() {
301: return ICON.get(getMap());
302: }
303:
304: /**
305: * Sets the text
306: *
307: * @param text text or null for no text
308: * @return this TitledTabStateProperties
309: */
310: public TitledTabStateProperties setText(String text) {
311: TEXT.set(getMap(), text);
312: return this ;
313: }
314:
315: /**
316: * Gets the text
317: *
318: * @return text or null if no text
319: */
320: public String getText() {
321: return TEXT.get(getMap());
322: }
323:
324: /**
325: * Sets the gap in pixels between the icon and the text
326: *
327: * @param gap number of pixels
328: * @return this TitledTabStateProperties
329: */
330: public TitledTabStateProperties setIconTextGap(int gap) {
331: ICON_TEXT_GAP.set(getMap(), gap);
332: return this ;
333: }
334:
335: /**
336: * Gets the gap in pixels between the icon and the text
337: *
338: * @return number of pixels
339: */
340: public int getIconTextGap() {
341: return ICON_TEXT_GAP.get(getMap());
342: }
343:
344: /**
345: * Sets the tool tip text
346: *
347: * @param text tool tip text
348: * @return this TitledTabStateProperties
349: */
350: public TitledTabStateProperties setToolTipText(String text) {
351: TOOL_TIP_TEXT.set(getMap(), text);
352: return this ;
353: }
354:
355: /**
356: * Gets the tool tip text
357: *
358: * @return tool tip text
359: */
360: public String getToolTipText() {
361: return TOOL_TIP_TEXT.get(getMap());
362: }
363:
364: /**
365: * Sets if tool tip text is enabled or disabled
366: *
367: * @param enabled true for enabled, otherwise false
368: * @return this TitledTabStateProperties
369: */
370: public TitledTabStateProperties setToolTipEnabled(boolean enabled) {
371: TOOL_TIP_ENABLED.set(getMap(), enabled);
372: return this ;
373: }
374:
375: /**
376: * Gets if tool tip text is enabled or disabled
377: *
378: * @return true if enabled, otherwise false
379: */
380: public boolean getToolTipEnabled() {
381: return TOOL_TIP_ENABLED.get(getMap());
382: }
383:
384: /**
385: * Sets if icon is visible or not visible
386: *
387: * @param visible true for visible, otherwise false
388: * @return this TitledTabStateProperties
389: * @since ITP 1.1.0
390: */
391: public TitledTabStateProperties setIconVisible(boolean visible) {
392: ICON_VISIBLE.set(getMap(), visible);
393: return this ;
394: }
395:
396: /**
397: * Gets if icon is visible or not visible
398: *
399: * @return true if visible, otherwise false
400: * @since ITP 1.1.0
401: */
402: public boolean getIconVisible() {
403: return ICON_VISIBLE.get(getMap());
404: }
405:
406: /**
407: * Sets if text is visible or not visible
408: *
409: * @param visible true for visible, otherwise false
410: * @return this TitledTabStateProperties
411: * @since ITP 1.1.0
412: */
413: public TitledTabStateProperties setTextVisible(boolean visible) {
414: TEXT_VISIBLE.set(getMap(), visible);
415: return this ;
416: }
417:
418: /**
419: * Gets if text is visible or not visible
420: *
421: * @return true if visible, otherwise false
422: * @since ITP 1.1.0
423: */
424: public boolean getTextVisible() {
425: return TEXT_VISIBLE.get(getMap());
426: }
427:
428: /**
429: * Sets if title component is visible or not visible
430: *
431: * @param visible true for enabled, otherwise false
432: * @return this TitledTabStateProperties
433: * @since ITP 1.1.0
434: */
435: public TitledTabStateProperties setTitleComponentVisible(
436: boolean visible) {
437: TITLE_COMPONENT_VISIBLE.set(getMap(), visible);
438: return this ;
439: }
440:
441: /**
442: * Gets if title component is visible or not visible
443: *
444: * @return true if enabled, otherwise false
445: * @since ITP 1.1.0
446: */
447: public boolean getTitleComponentVisible() {
448: return TITLE_COMPONENT_VISIBLE.get(getMap());
449: }
450:
451: /**
452: * Sets the text's and icon's horizontal alignment
453: *
454: * @param alignment text and icon alignment
455: * @return this TitledTabStateProperties
456: */
457: public TitledTabStateProperties setHorizontalAlignment(
458: Alignment alignment) {
459: HORIZONTAL_ALIGNMENT.set(getMap(), alignment);
460: return this ;
461: }
462:
463: /**
464: * Gets the text's and icon's horizontal alignment
465: *
466: * @return text and icon alignment
467: */
468: public Alignment getHorizontalAlignment() {
469: return HORIZONTAL_ALIGNMENT.get(getMap());
470: }
471:
472: /**
473: * Sets the text's and icon's vertical alignment
474: *
475: * @param alignment text and icon horizontal alignment
476: * @return this TitledTabStateProperties
477: */
478: public TitledTabStateProperties setVerticalAlignment(
479: Alignment alignment) {
480: VERTICAL_ALIGNMENT.set(getMap(), alignment);
481: return this ;
482: }
483:
484: /**
485: * Gets the text's and icon's vertical alignment
486: *
487: * @return text and icon vertical alignment
488: */
489: public Alignment getVerticalAlignment() {
490: return VERTICAL_ALIGNMENT.get(getMap());
491: }
492:
493: /**
494: * Sets the icon alignment relative to the text. Makes it possible to switch
495: * places between text and icon.
496: *
497: * @param alignment icon alignment relative to text
498: * @return this TitledTabStateProperties
499: */
500: public TitledTabStateProperties setIconTextRelativeAlignment(
501: Alignment alignment) {
502: ICON_TEXT_RELATIVE_ALIGNMENT.set(getMap(), alignment);
503: return this ;
504: }
505:
506: /**
507: * Gets the icon alignment relative to the text.
508: *
509: * @return icon alignment relative to text
510: */
511: public Alignment getIconTextRelativeAlignment() {
512: return ICON_TEXT_RELATIVE_ALIGNMENT.get(getMap());
513: }
514:
515: /**
516: * Sets the gap in pixels between the text/icon and the title component
517: *
518: * @param gap number of pixels
519: * @return this TitledTabStateProperties
520: */
521: public TitledTabStateProperties setTextTitleComponentGap(int gap) {
522: TEXT_TITLE_COMPONENT_GAP.set(getMap(), gap);
523: return this ;
524: }
525:
526: /**
527: * Gets the gap in pixels between the text/icon and the title component
528: *
529: * @return number of pixels
530: */
531: public int getTextTitleComponentGap() {
532: return TEXT_TITLE_COMPONENT_GAP.get(getMap());
533: }
534:
535: /**
536: * Sets the title components alignment relative to the text/icon
537: *
538: * @param alignment title component alignment relative to text/icon
539: * @return this TitledTabStateProperties
540: */
541: public TitledTabStateProperties setTitleComponentTextRelativeAlignment(
542: Alignment alignment) {
543: TITLE_COMPONENT_TEXT_RELATIVE_ALIGNMENT
544: .set(getMap(), alignment);
545: return this ;
546: }
547:
548: /**
549: * Gets the title components alignment relative to the text/icon
550: *
551: * @return title component alignment relative to text/icon
552: */
553: public Alignment getTitleComponentTextRelativeAlignment() {
554: return TITLE_COMPONENT_TEXT_RELATIVE_ALIGNMENT.get(getMap());
555: }
556:
557: /**
558: * Sets the direction, i.e. the line layout of the titled tab's components. The text
559: * and icon will be rotated in the given direction and the title component will be
560: * moved.
561: *
562: * @param direction direction
563: * @return this TitledTabStateProperties
564: */
565: public TitledTabStateProperties setDirection(Direction direction) {
566: DIRECTION.set(getMap(), direction);
567: return this ;
568: }
569:
570: /**
571: * Gets the direction, i.e. the line layout of the titled tab components. The text
572: * and icon are rotated in the given direction and the title component will be moved.
573: *
574: * @return direction
575: */
576: public Direction getDirection() {
577: return DIRECTION.get(getMap());
578: }
579:
580: /**
581: * Gets the component properties.
582: *
583: * @return component properties
584: */
585: public ComponentProperties getComponentProperties() {
586: return new ComponentProperties(COMPONENT_PROPERTIES
587: .get(getMap()));
588: }
589:
590: /**
591: * Gets the shaped panel properties.
592: *
593: * @return shaped panel properties
594: * @since ITP 1.2.0
595: */
596: public ShapedPanelProperties getShapedPanelProperties() {
597: return new ShapedPanelProperties(SHAPED_PANEL_PROPERTIES
598: .get(getMap()));
599: }
600: }
|