0001: /*
0002: * Copyright (C) 2004 NNL Technology AB
0003: * Visit www.infonode.net for information about InfoNode(R)
0004: * products and how to contact NNL Technology AB.
0005: *
0006: * This program is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU General Public License
0008: * as published by the Free Software Foundation; either version 2
0009: * of the License, or (at your option) any later version.
0010: *
0011: * This program is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0014: * GNU General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU General Public License
0017: * along with this program; if not, write to the Free Software
0018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0019: * MA 02111-1307, USA.
0020: */
0021:
0022: // $Id: TabbedPanelProperties.java,v 1.60 2005/12/04 13:46:05 jesper Exp $
0023: package net.infonode.tabbedpanel;
0024:
0025: import net.infonode.gui.DynamicUIManager;
0026: import net.infonode.gui.DynamicUIManagerListener;
0027: import net.infonode.gui.border.HighlightBorder;
0028: import net.infonode.gui.hover.HoverListener;
0029: import net.infonode.gui.icon.button.ArrowIcon;
0030: import net.infonode.gui.icon.button.BorderIcon;
0031: import net.infonode.gui.icon.button.DropDownIcon;
0032: import net.infonode.properties.base.Property;
0033: import net.infonode.properties.gui.util.ButtonProperties;
0034: import net.infonode.properties.propertymap.*;
0035: import net.infonode.properties.types.*;
0036: import net.infonode.tabbedpanel.border.OpenContentBorder;
0037: import net.infonode.tabbedpanel.border.TabAreaLineBorder;
0038: import net.infonode.util.ArrayUtil;
0039: import net.infonode.util.Direction;
0040:
0041: import javax.swing.border.CompoundBorder;
0042: import java.awt.*;
0043: import java.awt.event.KeyEvent;
0044: import java.util.HashMap;
0045:
0046: /**
0047: * TabbedPanelProperties holds all properties for a {@link TabbedPanel}. A
0048: * TabbedPanelProperties object contains separate property objects for the
0049: * content area, the tab area, the tab area components and the buttons of
0050: * the TabbedPanel.
0051: *
0052: * @author $Author: jesper $
0053: * @version $Revision: 1.60 $
0054: * @see TabbedPanel
0055: * @see #getContentPanelProperties
0056: * @see #getTabAreaProperties
0057: * @see #getTabAreaComponentsProperties
0058: * @see #getButtonProperties
0059: */
0060: public class TabbedPanelProperties extends PropertyMapContainer {
0061: /**
0062: * A property group for all properties in TabbedPanelProperties
0063: */
0064: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
0065: "Tabbed Panel Properties",
0066: "Properties for the TabbedPanel class.");
0067:
0068: /**
0069: * Tab reorder property
0070: *
0071: * @see #setTabReorderEnabled
0072: * @see #getTabReorderEnabled
0073: */
0074: public static final BooleanProperty TAB_REORDER_ENABLED = new BooleanProperty(
0075: PROPERTIES, "Tab Reorder Enabled",
0076: "Tab reorder enabled or disabled",
0077: PropertyMapValueHandler.INSTANCE);
0078:
0079: /**
0080: * Abort drag key code property
0081: *
0082: * @see #setAbortDragKey
0083: * @see #getAbortDragKey
0084: */
0085: public static final IntegerProperty ABORT_DRAG_KEY = IntegerProperty
0086: .createPositive(PROPERTIES, "Abort Drag Key Code",
0087: "Key code for aborting drag", 3,
0088: PropertyMapValueHandler.INSTANCE);
0089:
0090: /**
0091: * Tab layout property
0092: *
0093: * @see #setTabLayoutPolicy
0094: * @see #getTabLayoutPolicy
0095: */
0096: public static final TabLayoutPolicyProperty TAB_LAYOUT_POLICY = new TabLayoutPolicyProperty(
0097: PROPERTIES, "Layout Policy", "Tab layout in tab area",
0098: PropertyMapValueHandler.INSTANCE);
0099:
0100: /**
0101: * Tab drop down list visible property
0102: *
0103: * @see #setTabDropDownListVisiblePolicy
0104: * @see #getTabDropDownListVisiblePolicy
0105: * @since ITP 1.1.0
0106: */
0107: public static final TabDropDownListVisiblePolicyProperty TAB_DROP_DOWN_LIST_VISIBLE_POLICY = new TabDropDownListVisiblePolicyProperty(
0108: PROPERTIES,
0109: "Tab Drop Down List Visible Policy",
0110: "Determins when a drop down list with tabs should be visible in the tab area",
0111: PropertyMapValueHandler.INSTANCE);
0112:
0113: /**
0114: * Tab select trigger
0115: *
0116: * @see #setTabSelectTrigger
0117: * @see #getTabSelectTrigger
0118: * @since ITP 1.1.0
0119: */
0120: public static final TabSelectTriggerProperty TAB_SELECT_TRIGGER = new TabSelectTriggerProperty(
0121: PROPERTIES, "Tab Select Trigger",
0122: "Determins when a tab should be selected",
0123: PropertyMapValueHandler.INSTANCE);
0124:
0125: /**
0126: * Tab scrolling offset property
0127: *
0128: * @see #setTabScrollingOffset
0129: * @see #getTabScrollingOffset
0130: */
0131: public static final IntegerProperty TAB_SCROLLING_OFFSET = IntegerProperty
0132: .createPositive(
0133: PROPERTIES,
0134: "Scroll Offset",
0135: "Number of pixels to be shown for the last scrolled tab",
0136: 3, PropertyMapValueHandler.INSTANCE);
0137:
0138: /**
0139: * Ensure selected visible property
0140: *
0141: * @see #setEnsureSelectedTabVisible
0142: * @see #getEnsureSelectedTabVisible
0143: */
0144: public static final BooleanProperty ENSURE_SELECTED_VISIBLE = new BooleanProperty(
0145: PROPERTIES,
0146: "Ensure Selected Visible",
0147: "Upon select, the selected tab will be scrolled into the visible area.",
0148: PropertyMapValueHandler.INSTANCE);
0149:
0150: /**
0151: * Tab area orientation property
0152: *
0153: * @see #setTabAreaOrientation
0154: * @see #getTabAreaOrientation
0155: */
0156: public static final DirectionProperty TAB_AREA_ORIENTATION = new DirectionProperty(
0157: PROPERTIES, "Tab Area Orientation",
0158: "Tab area's orientation relative to the content area.",
0159: PropertyMapValueHandler.INSTANCE);
0160:
0161: /**
0162: * Tab spacing property
0163: *
0164: * @see #setTabSpacing
0165: * @see #getTabSpacing
0166: */
0167: public static final IntegerProperty TAB_SPACING = new IntegerProperty(
0168: PROPERTIES,
0169: "Tab Spacing",
0170: "Number of pixels between tabs in tab area. A negative value will result in tab overlapping.",
0171: Integer.MIN_VALUE, Integer.MAX_VALUE, 3,
0172: PropertyMapValueHandler.INSTANCE);
0173:
0174: /**
0175: * Tab depth order.
0176: *
0177: * @see #setAutoSelectTab
0178: * @see #getAutoSelectTab
0179: * @since ITP 1.2.0
0180: */
0181: public static final TabDepthOrderPolicyProperty TAB_DEPTH_ORDER = new TabDepthOrderPolicyProperty(
0182: PROPERTIES,
0183: "Tab Depth Order",
0184: "Tabs will overlap when tab spacing is negative. Depth order tells if first tab should be the top most and the other tabs in descending order or if the first tab should be bottom most and the other tabs in ascending order.",
0185: PropertyMapValueHandler.INSTANCE);
0186:
0187: /**
0188: * Auto select tab property
0189: *
0190: * @see #setAutoSelectTab
0191: * @see #getAutoSelectTab
0192: */
0193: public static final BooleanProperty AUTO_SELECT_TAB = new BooleanProperty(
0194: PROPERTIES,
0195: "Auto Select Tab",
0196: "When enabled the first tab that i added will be selected automatically. "
0197: + "If the selected tab is removed then the tab next to the removed tab will be selected automatically.",
0198: PropertyMapValueHandler.INSTANCE);
0199:
0200: /**
0201: * If true the tab pressed with the mouse will be highlighted, otherwise it
0202: * remains unchanged.
0203: *
0204: * @see #setHighlightPressedTab
0205: * @see #getHighlightPressedTab
0206: */
0207: public static final BooleanProperty HIGHLIGHT_PRESSED_TAB = new BooleanProperty(
0208: PROPERTIES,
0209: "Highlight Pressed Tab",
0210: "If true the tab pressed with the mouse will be highlighted, otherwise it remains unchanged.",
0211: PropertyMapValueHandler.INSTANCE);
0212:
0213: /**
0214: * Tab deselectable property
0215: *
0216: * @see #setTabDeselectable
0217: * @see #getTabDeselectable
0218: */
0219: public static final BooleanProperty TAB_DESELECTABLE = new BooleanProperty(
0220: PROPERTIES,
0221: "Tab Deselectable",
0222: "When enabled the selected tab can be deselected by clicking on it.",
0223: PropertyMapValueHandler.INSTANCE);
0224:
0225: /**
0226: * Content area properties
0227: *
0228: * @see #getContentPanelProperties
0229: */
0230: public static final PropertyMapProperty CONTENT_PANEL_PROPERTIES = new PropertyMapProperty(
0231: PROPERTIES, "Content Panel Properties",
0232: "Content panel properties.",
0233: TabbedPanelContentPanelProperties.PROPERTIES);
0234:
0235: /**
0236: * Tab area properties
0237: *
0238: * @see #getTabAreaProperties
0239: */
0240: public static final PropertyMapProperty TAB_AREA_PROPERTIES = new PropertyMapProperty(
0241: PROPERTIES, "Tab Area Properties", "Tab area properties.",
0242: TabAreaProperties.PROPERTIES);
0243:
0244: /**
0245: * Tab area components properties
0246: *
0247: * @see #getTabAreaComponentsProperties
0248: * @since ITP 1.1.0
0249: */
0250: public static final PropertyMapProperty TAB_AREA_COMPONENTS_PROPERTIES = new PropertyMapProperty(
0251: PROPERTIES, "Tab Area Components Properties",
0252: "Tab area components properties.",
0253: TabAreaComponentsProperties.PROPERTIES);
0254:
0255: /**
0256: * Button properties
0257: *
0258: * @see #getButtonProperties
0259: * @since ITP 1.3.0
0260: */
0261: public static final PropertyMapProperty BUTTON_PROPERTIES = new PropertyMapProperty(
0262: PROPERTIES, "Tabbed Panel Button Properties",
0263: "Tabbed panel button properties.",
0264: TabbedPanelButtonProperties.PROPERTIES);
0265:
0266: /**
0267: * Shadow enabled property
0268: *
0269: * @see #setShadowEnabled
0270: * @see #getShadowEnabled
0271: */
0272: public static final BooleanProperty SHADOW_ENABLED = new BooleanProperty(
0273: PROPERTIES,
0274: "Shadow Enabled",
0275: "Indicates that a shadow is painted for the selected tab and the content panel.\n"
0276: + "The shadow is partially painted using alpha transparency which can be slow on some systems.",
0277: PropertyMapValueHandler.INSTANCE);
0278:
0279: /**
0280: * Hover listener property
0281: *
0282: * @see #setHoverListener
0283: * @see #getHoverListener
0284: * @since ITP 1.3.0
0285: */
0286: public static final HoverListenerProperty HOVER_LISTENER = new HoverListenerProperty(
0287: PROPERTIES,
0288: "Hover Listener",
0289: "Hover Listener to be used for tracking mouse hovering over the tabbed panel.",
0290: PropertyMapValueHandler.INSTANCE);
0291:
0292: /**
0293: * Tabbed panel hover policy.
0294: *
0295: * @see #setHoverPolicy
0296: * @see #getHoverPolicy
0297: * @since ITP 1.3.0
0298: */
0299: public static final TabbedPanelHoverPolicyProperty HOVER_POLICY = new TabbedPanelHoverPolicyProperty(
0300: PROPERTIES,
0301: "Hover Policy",
0302: "Policy for when the Tabbed Panel is considerd hovered by the mouse.",
0303: PropertyMapValueHandler.INSTANCE);
0304:
0305: /**
0306: * Paint a shadow for the tab area. If this property is set to false a
0307: * shadow is painted for the highlighted tab and the tab area components
0308: * panel.
0309: *
0310: * @see #setPaintTabAreaShadow(boolean)
0311: * @see #getPaintTabAreaShadow()
0312: */
0313: public static final BooleanProperty PAINT_TAB_AREA_SHADOW = new BooleanProperty(
0314: PROPERTIES,
0315: "Paint Tab Area Shadow",
0316: "Paint a shadow for the tab area. If this property is set to false a shadow is painted for "
0317: + "the highlighted tab and the tab area components panel.",
0318: PropertyMapValueHandler.INSTANCE);
0319:
0320: /**
0321: * Shadow size property
0322: *
0323: * @see #setShadowSize
0324: * @see #getShadowSize
0325: */
0326: public static final IntegerProperty SHADOW_SIZE = IntegerProperty
0327: .createPositive(PROPERTIES, "Shadow Size",
0328: "The size of the tab shadow.", 2,
0329: PropertyMapValueHandler.INSTANCE);
0330:
0331: /**
0332: * Shadow blend area size property
0333: *
0334: * @see #setShadowBlendAreaSize
0335: * @see #getShadowBlendAreaSize
0336: */
0337: public static final IntegerProperty SHADOW_BLEND_AREA_SIZE = IntegerProperty
0338: .createPositive(PROPERTIES, "Shadow Blend Size",
0339: "The size of the tab shadow blend area.", 2,
0340: PropertyMapValueHandler.INSTANCE);
0341:
0342: /**
0343: * Shadow color property
0344: *
0345: * @see #setShadowColor
0346: * @see #getShadowColor
0347: */
0348: public static final ColorProperty SHADOW_COLOR = new ColorProperty(
0349: PROPERTIES, "Shadow Color", "The color of the shadow.",
0350: PropertyMapValueHandler.INSTANCE);
0351:
0352: /**
0353: * Shadow strength property
0354: *
0355: * @see #setShadowStrength
0356: * @see #getShadowStrength
0357: */
0358: public static final FloatProperty SHADOW_STRENGTH = new FloatProperty(
0359: PROPERTIES,
0360: "Shadow Strength",
0361: "The strength of the shadow. 0 means the shadow color is the same as the backgound color, "
0362: + "1 means the shadow color is '"
0363: + SHADOW_COLOR
0364: + "'.", PropertyMapValueHandler.INSTANCE, 0, 1);
0365:
0366: /**
0367: * Array with all properties that controls the functional behavior
0368: */
0369: public static final Property[] FUNCTIONAL_PROPERTIES = {
0370: TAB_REORDER_ENABLED, ABORT_DRAG_KEY, TAB_LAYOUT_POLICY,
0371: ENSURE_SELECTED_VISIBLE, AUTO_SELECT_TAB, TAB_DESELECTABLE,
0372: TAB_SELECT_TRIGGER, HOVER_POLICY };
0373:
0374: /**
0375: * Array with all properties that controls the shadow
0376: */
0377: public static final Property[] SHADOW_PROPERTIES = {
0378: SHADOW_ENABLED, SHADOW_SIZE, SHADOW_BLEND_AREA_SIZE,
0379: SHADOW_COLOR, SHADOW_STRENGTH };
0380:
0381: /**
0382: * Array with all properties that controls the visual apperance except for
0383: * shadow
0384: */
0385: public static final Property[] TABS_VISUAL_PROPERTIES = {
0386: TAB_SCROLLING_OFFSET, TAB_SPACING, TAB_AREA_ORIENTATION,
0387: TAB_AREA_PROPERTIES, TAB_AREA_COMPONENTS_PROPERTIES,
0388: TAB_LAYOUT_POLICY, CONTENT_PANEL_PROPERTIES,
0389: TAB_DROP_DOWN_LIST_VISIBLE_POLICY };
0390:
0391: /**
0392: * Array with all properties that controls the visual apperance including
0393: * shadow
0394: */
0395: public static final Property[] VISUAL_PROPERTIES = (Property[]) ArrayUtil
0396: .append(TABS_VISUAL_PROPERTIES, SHADOW_PROPERTIES,
0397: new Property[TABS_VISUAL_PROPERTIES.length
0398: + SHADOW_PROPERTIES.length]);
0399:
0400: private static final TabbedPanelProperties DEFAULT_PROPERTIES = new TabbedPanelProperties(
0401: PROPERTIES.getDefaultMap());
0402:
0403: static {
0404: DynamicUIManager.getInstance().addListener(
0405: new DynamicUIManagerListener() {
0406: public void lookAndFeelChanged() {
0407: updateVisualProperties();
0408: }
0409:
0410: public void propertiesChanged() {
0411: updateVisualProperties();
0412: }
0413:
0414: public void propertiesChanging() {
0415: }
0416:
0417: public void lookAndFeelChanging() {
0418: }
0419: });
0420:
0421: updateVisualProperties();
0422: updateFunctionalProperties();
0423: }
0424:
0425: /**
0426: * Creates a properties object with default properties based on the current
0427: * look and feel
0428: *
0429: * @return properties object
0430: */
0431: public static TabbedPanelProperties getDefaultProperties() {
0432: return new TabbedPanelProperties(DEFAULT_PROPERTIES);
0433: }
0434:
0435: private static void updateVisualProperties() {
0436: PropertyMapManager.runBatch(new Runnable() {
0437: public void run() {
0438: DEFAULT_PROPERTIES
0439: .getContentPanelProperties()
0440: .getComponentProperties()
0441: .setBorder(
0442: new OpenContentBorder(TabbedUIDefaults
0443: .getDarkShadow(),
0444: TabbedUIDefaults.getHighlight()))
0445: .setInsets(
0446: TabbedUIDefaults.getContentAreaInsets())
0447: .setBackgroundColor(
0448: TabbedUIDefaults
0449: .getContentAreaBackground());
0450: DEFAULT_PROPERTIES.getContentPanelProperties()
0451: .getShapedPanelProperties().setOpaque(true);
0452:
0453: DEFAULT_PROPERTIES
0454: .getTabAreaComponentsProperties()
0455: .setStretchEnabled(false)
0456: .getComponentProperties()
0457: .setBorder(
0458: new CompoundBorder(
0459: new TabAreaLineBorder(
0460: TabbedUIDefaults
0461: .getDarkShadow()),
0462: new HighlightBorder(false,
0463: TabbedUIDefaults
0464: .getHighlight())))
0465: .setBackgroundColor(
0466: TabbedUIDefaults
0467: .getContentAreaBackground());
0468: DEFAULT_PROPERTIES.getTabAreaComponentsProperties()
0469: .getShapedPanelProperties().setOpaque(true);
0470:
0471: DEFAULT_PROPERTIES.getTabAreaProperties()
0472: .getShapedPanelProperties().setOpaque(false);
0473: }
0474: });
0475: }
0476:
0477: private static void updateFunctionalProperties() {
0478: DEFAULT_PROPERTIES
0479: .setTabReorderEnabled(false)
0480: .setAbortDragKey(KeyEvent.VK_ESCAPE)
0481: .setTabLayoutPolicy(TabLayoutPolicy.SCROLLING)
0482: .setTabDropDownListVisiblePolicy(
0483: TabDropDownListVisiblePolicy.NEVER)
0484: .setTabSelectTrigger(TabSelectTrigger.MOUSE_PRESS)
0485: .setTabScrollingOffset(10)
0486: .setTabSpacing(-1)
0487: .setTabDepthOrderPolicy(TabDepthOrderPolicy.DESCENDING)
0488: .setEnsureSelectedTabVisible(false)
0489: .setTabAreaOrientation(Direction.UP)
0490: .setAutoSelectTab(true)
0491: .setHighlightPressedTab(true)
0492:
0493: .setHoverPolicy(TabbedPanelHoverPolicy.NO_HOVERED_CHILD)
0494:
0495: .setShadowEnabled(false).setShadowSize(3)
0496: .setShadowBlendAreaSize(2).setShadowColor(Color.BLACK)
0497: .setShadowStrength(0.4F);
0498:
0499: DEFAULT_PROPERTIES.getTabAreaProperties()
0500: .setTabAreaVisiblePolicy(TabAreaVisiblePolicy.ALWAYS);
0501:
0502: HashMap buttonMap = new HashMap();
0503: buttonMap.put(Direction.DOWN, DEFAULT_PROPERTIES
0504: .getButtonProperties().getScrollDownButtonProperties());
0505: buttonMap.put(Direction.UP, DEFAULT_PROPERTIES
0506: .getButtonProperties().getScrollUpButtonProperties());
0507: buttonMap
0508: .put(Direction.RIGHT, DEFAULT_PROPERTIES
0509: .getButtonProperties()
0510: .getScrollRightButtonProperties());
0511: buttonMap.put(Direction.LEFT, DEFAULT_PROPERTIES
0512: .getButtonProperties().getScrollLeftButtonProperties());
0513:
0514: int iconSize = TabbedUIDefaults.getButtonIconSize();
0515:
0516: Direction[] directions = Direction.getDirections();
0517: for (int i = 0; i < directions.length; i++) {
0518: ArrowIcon disabledIcon = new ArrowIcon(iconSize - 2,
0519: directions[i], false);
0520: disabledIcon.setShadowEnabled(false);
0521:
0522: ((ButtonProperties) buttonMap.get(directions[i]))
0523: .setFactory(
0524: TabbedPanelDefaultButtonFactories
0525: .getScrollDownButtonFactory())
0526: .setIcon(new ArrowIcon(iconSize, directions[i]))
0527: .setDisabledIcon(new BorderIcon(disabledIcon, 1));
0528: }
0529:
0530: DEFAULT_PROPERTIES.getButtonProperties()
0531: .getTabDropDownListButtonProperties().setFactory(
0532: TabbedPanelDefaultButtonFactories
0533: .getScrollDownButtonFactory()).setIcon(
0534: new DropDownIcon(Color.black, TabbedUIDefaults
0535: .getButtonIconSize(), Direction.DOWN))
0536: .setDisabledIcon(null);
0537: }
0538:
0539: /**
0540: * Constructs an empty TabbedPanelProperties object
0541: */
0542: public TabbedPanelProperties() {
0543: super (PROPERTIES);
0544: }
0545:
0546: /**
0547: * Constructs a TabbedPanelProperties map with the given map as property
0548: * storage
0549: *
0550: * @param map map to store properties in
0551: */
0552: public TabbedPanelProperties(PropertyMap map) {
0553: super (map);
0554: }
0555:
0556: /**
0557: * Constructs a TabbedPanelProperties object that inherits its properties
0558: * from the given TabbedPanelProperties object
0559: *
0560: * @param inheritFrom TabbedPanelProperties object to inherit properties from
0561: */
0562: public TabbedPanelProperties(TabbedPanelProperties inheritFrom) {
0563: super (PropertyMapFactory.create(inheritFrom.getMap()));
0564: }
0565:
0566: /**
0567: * Adds a super object from which property values are inherited.
0568: *
0569: * @param superObject the object from which to inherit property values
0570: * @return this
0571: */
0572: public TabbedPanelProperties addSuperObject(
0573: TabbedPanelProperties super Object) {
0574: getMap().addSuperMap(super Object.getMap());
0575: return this ;
0576: }
0577:
0578: /**
0579: * Removes the last added super object.
0580: *
0581: * @return this
0582: */
0583: public TabbedPanelProperties removeSuperObject() {
0584: getMap().removeSuperMap();
0585: return this ;
0586: }
0587:
0588: /**
0589: * Removes the given super object.
0590: *
0591: * @param superObject super object to remove
0592: * @return this
0593: * @since ITP 1.3.0
0594: */
0595: public TabbedPanelProperties removeSuperObject(
0596: TabbedPanelProperties super Object) {
0597: getMap().removeSuperMap(super Object.getMap());
0598: return this ;
0599: }
0600:
0601: /**
0602: * Replaces the given super objects.
0603: *
0604: * @param oldSuperObject old super object
0605: * @param newSuperObject new super object
0606: * @return this
0607: * @since ITP 1.4.0
0608: */
0609: public TabbedPanelProperties replaceSuperObject(
0610: TabbedPanelProperties oldSuperObject,
0611: TabbedPanelProperties newSuperObject) {
0612: getMap().replaceSuperMap(oldSuperObject.getMap(),
0613: newSuperObject.getMap());
0614: return this ;
0615: }
0616:
0617: /**
0618: * <p>
0619: * Sets the shadow strength. 0 means the shadow color is the same as the
0620: * backgound color and 1 means the shadow color is the same as shadow color.
0621: * </p>
0622: * <p>
0623: * <strong>Note: </strong> This property will only have effect if shadow is
0624: * enabled.
0625: * </p>
0626: *
0627: * @param strength the strength between 0 and 1
0628: * @return this TabbedPanelProperties
0629: * @see #setShadowColor
0630: * @see #setShadowEnabled
0631: */
0632: public TabbedPanelProperties setShadowStrength(float strength) {
0633: SHADOW_STRENGTH.set(getMap(), strength);
0634: return this ;
0635: }
0636:
0637: /**
0638: * <p>
0639: * Sets the shadow blend area size, i.e. number of pixels for the shadow
0640: * color fading.
0641: * </p>
0642: * <p>
0643: * <strong>Note: </strong> This property will only have effect if shadow is
0644: * enabled.
0645: * </p>
0646: *
0647: * @param size the shadow blend area size in pixels
0648: * @return this TabbedPanelProperties
0649: * @see #setShadowEnabled
0650: */
0651: public TabbedPanelProperties setShadowBlendAreaSize(int size) {
0652: SHADOW_BLEND_AREA_SIZE.set(getMap(), size);
0653: return this ;
0654: }
0655:
0656: /**
0657: * <p>
0658: * Sets the shadow size, i.e. the width/height of the shadow in pixels.
0659: * </p>
0660: * <p>
0661: * <strong>Note: </strong> This property will only have effect if shadow is
0662: * enabled.
0663: * </p>
0664: *
0665: * @param size shadow size in pixels
0666: * @return this TabbedPanelProperties
0667: * @see #setShadowEnabled
0668: */
0669: public TabbedPanelProperties setShadowSize(int size) {
0670: SHADOW_SIZE.set(getMap(), size);
0671: return this ;
0672: }
0673:
0674: /**
0675: * <p>
0676: * Sets the shadow color.
0677: * </p>
0678: * <p>
0679: * <strong>Note: </strong> This property will only have effect if shadow is
0680: * enabled.
0681: * </p>
0682: *
0683: * @param color the shadow color
0684: * @return this TabbedPanelProperties
0685: * @see #setShadowEnabled
0686: */
0687: public TabbedPanelProperties setShadowColor(Color color) {
0688: SHADOW_COLOR.set(getMap(), color);
0689: return this ;
0690: }
0691:
0692: /**
0693: * Sets shadow enabled
0694: *
0695: * @param value true for enabled, otherwise false
0696: * @return this TabbedPanelProperties
0697: */
0698: public TabbedPanelProperties setShadowEnabled(boolean value) {
0699: SHADOW_ENABLED.set(getMap(), value);
0700: return this ;
0701: }
0702:
0703: /**
0704: * Sets if automatic selection of a tab is enabled. Automatic selection
0705: * means that if no tab is selected and a tab is added to the TabbedPanel,
0706: * then the added tab will automatically be selected. If a selected tab is
0707: * removed from the TabbedPanel then the tab next to the selected tab will
0708: * automatically be selected.
0709: *
0710: * @param value true for automactic selection, otherwise false
0711: * @return this TabbedPanelProperties
0712: */
0713: public TabbedPanelProperties setAutoSelectTab(boolean value) {
0714: AUTO_SELECT_TAB.set(getMap(), value);
0715: return this ;
0716: }
0717:
0718: /**
0719: * Sets if tab is deselectable. This means that if the selected tab is
0720: * clicked then the selected tab will be deselected. Clicking it again will
0721: * select the tab again.
0722: *
0723: * @param value true for deselectable, otherwise false
0724: * @return this TabbedPanelProperties
0725: */
0726: public TabbedPanelProperties setTabDeselectable(boolean value) {
0727: TAB_DESELECTABLE.set(getMap(), value);
0728: return this ;
0729: }
0730:
0731: /**
0732: * <p>
0733: * Sets if a tab should be made visible if it is selected, i.e. if scrolling
0734: * is enabled, a tab will be scrolled into the visible part of the tab area
0735: * when it becomes selected.
0736: * </p>
0737: * <p>
0738: * <strong>Note: </strong> This will only have effect if scolling is
0739: * enabled.
0740: * </p>
0741: *
0742: * @param value true for selected visible, otherwise false
0743: * @return this TabbedPanelProperties
0744: * @see #setTabLayoutPolicy
0745: */
0746: public TabbedPanelProperties setEnsureSelectedTabVisible(
0747: boolean value) {
0748: ENSURE_SELECTED_VISIBLE.set(getMap(), value);
0749: return this ;
0750: }
0751:
0752: /**
0753: * <p>
0754: * Sets number of pixels to be shown for the scrolled out tab next to the
0755: * first visible tab.
0756: * </p>
0757: * <p>
0758: * <strong>Note: </strong> This will only have effect if scolling is
0759: * enabled.
0760: * </p>
0761: *
0762: * @param offset number of pixels
0763: * @return this TabbedPanelProperties
0764: * @see #setTabLayoutPolicy
0765: */
0766: public TabbedPanelProperties setTabScrollingOffset(int offset) {
0767: TAB_SCROLLING_OFFSET.set(getMap(), offset);
0768: return this ;
0769: }
0770:
0771: /**
0772: * Sets if the tabs can be reordered using the mouse
0773: *
0774: * @param enabled true for enabled, otherwise disabled
0775: * @return this TabbedPanelProperties
0776: */
0777: public TabbedPanelProperties setTabReorderEnabled(boolean enabled) {
0778: TAB_REORDER_ENABLED.set(getMap(), enabled);
0779: return this ;
0780: }
0781:
0782: /**
0783: * Set to true if the tab pressed with the mouse should be highlighted,
0784: * otherwise it's not changed.
0785: *
0786: * @param highlightEnabled true if the tab pressed with the mouse should be highlighted
0787: * @return this
0788: */
0789: public TabbedPanelProperties setHighlightPressedTab(
0790: boolean highlightEnabled) {
0791: HIGHLIGHT_PRESSED_TAB.set(getMap(), highlightEnabled);
0792: return this ;
0793: }
0794:
0795: /**
0796: * <p>
0797: * Sets the key code for aborting a tab drag or reorder operation.
0798: * </p>
0799: * <p>
0800: * <strong>Note: </strong> The right mouse button can also be used to abort
0801: * the operation.
0802: * </p>
0803: *
0804: * @param keyCode key code
0805: * @return this TabbedPanelProperties
0806: */
0807: public TabbedPanelProperties setAbortDragKey(int keyCode) {
0808: ABORT_DRAG_KEY.set(getMap(), keyCode);
0809: return this ;
0810: }
0811:
0812: /**
0813: * Sets the tab layout policy for the tab area, i.e. how the line of tabs
0814: * should be laid out
0815: *
0816: * @param policy the tab area layout policy
0817: * @return this TabbedPanelProperties
0818: */
0819: public TabbedPanelProperties setTabLayoutPolicy(
0820: TabLayoutPolicy policy) {
0821: TAB_LAYOUT_POLICY.set(getMap(), policy);
0822: return this ;
0823: }
0824:
0825: /**
0826: * <p>
0827: * Sets the tab drop down list visible policy, i.e. when a drop down list
0828: * with the tabs should be visible
0829: * </p>
0830: *
0831: * <p>
0832: * The drop down list will show an icon for the tab if the tab implements
0833: * the {@link net.infonode.gui.icon.IconProvider} and the text will be retrieved by calling
0834: * toString() on the tab.
0835: * </p>
0836: *
0837: * @param policy the tab drop down list visible policy
0838: * @return this TabbedPanelProperties
0839: * @since ITP 1.1.0
0840: */
0841: public TabbedPanelProperties setTabDropDownListVisiblePolicy(
0842: TabDropDownListVisiblePolicy policy) {
0843: TAB_DROP_DOWN_LIST_VISIBLE_POLICY.set(getMap(), policy);
0844: return this ;
0845: }
0846:
0847: /**
0848: * Sets the tab select trigger, i.e. what triggers a tab selection
0849: *
0850: * @param trigger the tab select trigger
0851: * @return this TabbedPanelProperties
0852: * @since ITP 1.1.0
0853: */
0854: public TabbedPanelProperties setTabSelectTrigger(
0855: TabSelectTrigger trigger) {
0856: TAB_SELECT_TRIGGER.set(getMap(), trigger);
0857: return this ;
0858: }
0859:
0860: /**
0861: * Sets the tab area orientation, i.e. if the tab area should be placed up,
0862: * down, left or right of the content area.
0863: *
0864: * @param direction the orientation
0865: * @return this TabbedPanelProperties
0866: */
0867: public TabbedPanelProperties setTabAreaOrientation(
0868: Direction direction) {
0869: TAB_AREA_ORIENTATION.set(getMap(), direction);
0870: return this ;
0871: }
0872:
0873: /**
0874: * <p>
0875: * Sets the tab spacing, i.e. number of pixels between the tabs in the tab
0876: * area.
0877: * </p>
0878: *
0879: * <p>
0880: * This can be a negative value i.e. tabs will be overlapping each other. The
0881: * depth order can be controlled with the property TAB_DEPTH_ORDER.
0882: * </p>
0883: *
0884: * @param value number of pixels. A negative value reuslts in tabs
0885: * overlapping each other with the number of pixels.
0886: * @return this TabbedPanelProperties
0887: * @see #setTabDepthOrderPolicy
0888: */
0889: public TabbedPanelProperties setTabSpacing(int value) {
0890: TAB_SPACING.set(getMap(), value);
0891: return this ;
0892: }
0893:
0894: /**
0895: * <p>
0896: * Sets the tab depth order policy to be used when tabs are overlapping i.e.
0897: * negative tab spacing.
0898: * </p>
0899: *
0900: * <p>
0901: * If the depth order is descending, the first tab will be the top most and
0902: * the last tab the bottom most. If the depth order is ascending, then the
0903: * first tab will be the bottom most and the last tab the top most. Note that
0904: * if a tab is highlighted, it will always be shown as the top most tab.
0905: * </p>
0906: *
0907: * @param policy the tab depth order policy
0908: * @return this TabbedPanelProperties
0909: * @see #setTabSpacing
0910: * @since ITP 1.2.0
0911: */
0912: public TabbedPanelProperties setTabDepthOrderPolicy(
0913: TabDepthOrderPolicy policy) {
0914: TAB_DEPTH_ORDER.set(getMap(), policy);
0915: return this ;
0916: }
0917:
0918: /**
0919: * <p>
0920: * Gets the shadow strength. 0 means the shadow color is the same as the
0921: * backgound color and 1 means the shadow color is the same as shadow color.
0922: * </p>
0923: * <p>
0924: * <strong>Note: </strong> This property will only have effect if shadow is
0925: * enabled.
0926: * </p>
0927: *
0928: * @return the shadow strength between 0 and 1
0929: * @see #getShadowColor
0930: * @see #getShadowEnabled
0931: */
0932: public float getShadowStrength() {
0933: return SHADOW_STRENGTH.get(getMap());
0934: }
0935:
0936: /**
0937: * <p>
0938: * Gets the shadow blend area size, i.e. number of pixels for the shadow
0939: * color fading.
0940: * </p>
0941: * <p>
0942: * <strong>Note: </strong> This property will only have effect if shadow is
0943: * enabled.
0944: * </p>
0945: *
0946: * @return the shadow blend area size in pixels
0947: * @see #getShadowEnabled
0948: */
0949: public int getShadowBlendAreaSize() {
0950: return SHADOW_BLEND_AREA_SIZE.get(getMap());
0951: }
0952:
0953: /**
0954: * <p>
0955: * Gets the shadow size, i.e. the width/height of the shadow in pixels.
0956: * </p>
0957: * <p>
0958: * <strong>Note: </strong> This property will only have effect if shadow is
0959: * enabled.
0960: * </p>
0961: *
0962: * @return shadow size in pixels
0963: * @see #getShadowEnabled
0964: */
0965: public int getShadowSize() {
0966: return SHADOW_SIZE.get(getMap());
0967: }
0968:
0969: /**
0970: * <p>
0971: * Gets the shadow color.
0972: * </p>
0973: * <p>
0974: * <strong>Note: </strong> This property will only have effect if shadow is
0975: * enabled.
0976: * </p>
0977: *
0978: * @return the shadow color
0979: * @see #getShadowEnabled
0980: */
0981: public Color getShadowColor() {
0982: return SHADOW_COLOR.get(getMap());
0983: }
0984:
0985: /**
0986: * Gets shadow enabled
0987: *
0988: * @return true if shadow is enabled, otherwise false
0989: */
0990: public boolean getShadowEnabled() {
0991: return SHADOW_ENABLED.get(getMap());
0992: }
0993:
0994: /**
0995: * Gets if automatic selection of a tab is enabled. Automatic selection
0996: * means that if no tab is selected and a tab is added to the TabbedPanel,
0997: * then the added tab will automatically be selected. If a selected tab is
0998: * removed from the TabbedPanel then the tab next to the selected tab will
0999: * automatically be selected.
1000: *
1001: * @return true if automactic selection, otherwise false
1002: */
1003: public boolean getAutoSelectTab() {
1004: return AUTO_SELECT_TAB.get(getMap());
1005: }
1006:
1007: /**
1008: * Gets if the tab pressed with the mouse will be highlighted.
1009: *
1010: * @return true if the tab pressed with the mouse will be highlighted
1011: */
1012: public boolean getHighlightPressedTab() {
1013: return HIGHLIGHT_PRESSED_TAB.get(getMap());
1014: }
1015:
1016: /**
1017: * Gets if tab is deselectable. This means that if the selected tab is
1018: * clicked then the selected tab will be deselected. Clicking it again will
1019: * select the tab again.
1020: *
1021: * @return true if deselectable, otherwise false
1022: */
1023: public boolean getTabDeselectable() {
1024: return TAB_DESELECTABLE.get(getMap());
1025: }
1026:
1027: /**
1028: * <p>
1029: * Gets if a tab should be made visible if it is selected, i.e. if scrolling
1030: * is enabled, a tab will be scrolled into the visible part of the tab area
1031: * when it becomes selected.
1032: * </p>
1033: * <p>
1034: * <strong>Note: </strong> This will only have effect if scolling is
1035: * enabled.
1036: * </p>
1037: *
1038: * @return true if selected visible should be made visible, otherwise false
1039: * @see #getTabLayoutPolicy
1040: */
1041: public boolean getEnsureSelectedTabVisible() {
1042: return ENSURE_SELECTED_VISIBLE.get(getMap());
1043: }
1044:
1045: /**
1046: * Returns true if a shadow is painted for the tab area, false if a shadow
1047: * is painted for the highlighted tab and the tab area components panel.
1048: *
1049: * @return true if a shadow is painted for the tab area, false if a shadow
1050: * is painted for the highlighted tab and the tab area components
1051: * panel
1052: * @since ITP 1.1.0
1053: */
1054: public boolean getPaintTabAreaShadow() {
1055: return PAINT_TAB_AREA_SHADOW.get(getMap());
1056: }
1057:
1058: /**
1059: * Set to true if a shadow should be painted for the tab area, false if a
1060: * shadow should be painted for the highlighted tab and the tab area
1061: * components panel.
1062: *
1063: * @param paintShadow true if a shadow should be painted for the tab area, false if
1064: * a shadow should be painted for the highlighted tab and the tab
1065: * area components panel
1066: * @return this
1067: * @since ITP 1.1.0
1068: */
1069: public TabbedPanelProperties setPaintTabAreaShadow(
1070: boolean paintShadow) {
1071: PAINT_TAB_AREA_SHADOW.set(getMap(), paintShadow);
1072: return this ;
1073: }
1074:
1075: /**
1076: * <p>
1077: * Gets number of pixels to be shown for the last scrolled tab.
1078: * </p>
1079: * <p>
1080: * <strong>Note: </strong> This will only have effect if scolling is
1081: * enabled.
1082: * </p>
1083: *
1084: * @return number of pixels
1085: * @see #getTabLayoutPolicy
1086: */
1087: public int getTabScrollingOffset() {
1088: return TAB_SCROLLING_OFFSET.get(getMap());
1089: }
1090:
1091: /**
1092: * Gets if the tabs can be reorder using the mouse.
1093: *
1094: * @return true if enabled, otherwise disabled
1095: */
1096: public boolean getTabReorderEnabled() {
1097: return TAB_REORDER_ENABLED.get(getMap());
1098: }
1099:
1100: /**
1101: * <p>
1102: * Gets the key code for aborting a tab drag or reorder operation.
1103: * </p>
1104: * <p>
1105: * Note that the right mouse button can also be used to abort the operation.
1106: * </p>
1107: *
1108: * @return the key code
1109: */
1110: public int getAbortDragKey() {
1111: return ABORT_DRAG_KEY.get(getMap());
1112: }
1113:
1114: /**
1115: * Gets the tab layout policy for the tab area, i.e. how the line of tabs
1116: * should be laid out
1117: *
1118: * @return the tab area layout policy
1119: */
1120: public TabLayoutPolicy getTabLayoutPolicy() {
1121: return TAB_LAYOUT_POLICY.get(getMap());
1122: }
1123:
1124: /**
1125: * <p>
1126: * Gets the tab drop down list visible policy, i.e. when a drop down list
1127: * with the tabs should be visible.
1128: * </p>
1129: *
1130: * <p>
1131: * The drop down list will show an icon for the tab if the tab implements
1132: * the {@link net.infonode.gui.icon.IconProvider} and the text will be retrieved by calling
1133: * toString() on the tab.
1134: * </p>
1135: *
1136: * @return the tab drop down list visible policy
1137: * @since ITP 1.1.0
1138: */
1139: public TabDropDownListVisiblePolicy getTabDropDownListVisiblePolicy() {
1140: return TAB_DROP_DOWN_LIST_VISIBLE_POLICY.get(getMap());
1141: }
1142:
1143: /**
1144: * Gets the tab select trigger, i.e. what triggers a tab selection
1145: *
1146: * @return the tab select trigger
1147: * @since ITP 1.1.0
1148: */
1149: public TabSelectTrigger getTabSelectTrigger() {
1150: return TAB_SELECT_TRIGGER.get(getMap());
1151: }
1152:
1153: /**
1154: * Gets the tab area orientation, i.e. if the tab area should be placed up,
1155: * down, left or right of the content area
1156: *
1157: * @return the orientation
1158: */
1159: public Direction getTabAreaOrientation() {
1160: return TAB_AREA_ORIENTATION.get(getMap());
1161: }
1162:
1163: /**
1164: * <p>
1165: * Gets the tab spacing, i.e. number of pixels between the tabs in the tab
1166: * area.
1167: * </p>
1168: *
1169: * <p>
1170: * This can be a negative value i.e. tabs will be overlapping each other. The
1171: * depth order can be controlled with the property TAB_DEPTH_ORDER.
1172: * </p>
1173: *
1174: * @return number of pixels, can be negative i.e. tabs will be overlapping
1175: * @see #getTabDepthOrderPolicy
1176: */
1177: public int getTabSpacing() {
1178: return TAB_SPACING.get(getMap());
1179: }
1180:
1181: /**
1182: * <p>
1183: * Gets the tab depth order policy to be used when tabs are overlapping i.e.
1184: * negative tab spacing.
1185: * </p>
1186: *
1187: * <p>
1188: * If the depth order is descending, the first tab will be the top most and
1189: * the last tab the bottom most. If the depth order is ascending, then the
1190: * first tab will be the bottom most and the last tab the top most. Note that
1191: * if a tab is highlighted, it will always be shown as the top most tab.
1192: * </p>
1193: *
1194: * @return the tab depth order policy
1195: * @see #getTabSpacing
1196: * @since ITP 1.2.0
1197: */
1198: public TabDepthOrderPolicy getTabDepthOrderPolicy() {
1199: return TAB_DEPTH_ORDER.get(getMap());
1200: }
1201:
1202: /**
1203: * <p>Sets the hover listener that will be triggered when the tabbed panel is hoverd by the mouse.</p>
1204: *
1205: * <p>The hovered tabbed panel will be the source of the hover event sent to the
1206: * hover listener.</p>
1207: *
1208: * @param listener the hover listener
1209: * @return this TabbedPanelProperties
1210: * @since ITP 1.3.0
1211: */
1212: public TabbedPanelProperties setHoverListener(HoverListener listener) {
1213: HOVER_LISTENER.set(getMap(), listener);
1214: return this ;
1215: }
1216:
1217: /**
1218: * <p>Gets the hover listener that will be triggered when the tabbed panel is hovered by the mouse.</p>
1219: *
1220: * <p>The hovered tabbed panel will be the source of the hover event sent to the
1221: * hover listener.</p>
1222: *
1223: * @return the hover listener
1224: * @since ITP 1.3.0
1225: */
1226: public HoverListener getHoverListener() {
1227: return HOVER_LISTENER.get(getMap());
1228: }
1229:
1230: /**
1231: * <p>Sets the hover policy.</p>
1232: *
1233: * <p>The hover policy determines when the tabbed panel is considered hovered by the mouse and the
1234: * hover listener is called. The default hover policy is NO_HOVERED_CHILD.</p>
1235: *
1236: * @param hoverPolicy the hover policy
1237: * @return this TabbedPanelProperties
1238: * @since ITP 1.3.0
1239: */
1240: public TabbedPanelProperties setHoverPolicy(
1241: TabbedPanelHoverPolicy hoverPolicy) {
1242: HOVER_POLICY.set(getMap(), hoverPolicy);
1243: return this ;
1244: }
1245:
1246: /**
1247: * <p>Gets the hover policy.</p>
1248: *
1249: * <p>The hover policy determines when the tabbed panel is considered hovered by the mouse and the
1250: * hover listener is called. The default hover policy is NO_HOVERED_CHILD.</p>
1251: *
1252: * @return the hover policy
1253: * @since ITP 1.3.0
1254: */
1255: public TabbedPanelHoverPolicy getHoverPolicy() {
1256: return HOVER_POLICY.get(getMap());
1257: }
1258:
1259: /**
1260: * Gets the properties getMap() with properties for the tabbed panel's
1261: * content area
1262: *
1263: * @return the properties for the content area
1264: */
1265: public TabbedPanelContentPanelProperties getContentPanelProperties() {
1266: return new TabbedPanelContentPanelProperties(
1267: CONTENT_PANEL_PROPERTIES.get(getMap()));
1268: }
1269:
1270: /**
1271: * Gets the properties getMap() with properties for the tabbed panel's tab
1272: * area
1273: *
1274: * @return the properties for the tab area
1275: */
1276: public TabAreaProperties getTabAreaProperties() {
1277: return new TabAreaProperties(TAB_AREA_PROPERTIES.get(getMap()));
1278: }
1279:
1280: /**
1281: * Gets the properties getMap() with properties for the area in a tabbed
1282: * panel's tab area where the tab area components are shown.
1283: *
1284: * @return the properties for the tab area components
1285: * @since ITP 1.1.0
1286: */
1287: public TabAreaComponentsProperties getTabAreaComponentsProperties() {
1288: return new TabAreaComponentsProperties(
1289: TAB_AREA_COMPONENTS_PROPERTIES.get(getMap()));
1290: }
1291:
1292: /**
1293: * Gets the properties getMap() with properties for all the buttons in a
1294: * tabbed panel.
1295: *
1296: * @return the properties for the buttons
1297: * @since ITP 1.3.0
1298: */
1299: public TabbedPanelButtonProperties getButtonProperties() {
1300: return new TabbedPanelButtonProperties(BUTTON_PROPERTIES
1301: .get(getMap()));
1302: }
1303: }
|