001: /*
002: * @(#)Overlay.java 3/2/2006
003: *
004: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
005: */
006: package com.jidesoft.swing;
007:
008: import javax.swing.*;
009: import java.awt.*;
010:
011: /**
012: * <code>Overlayable</code> provides a way to add a number of components on top of another component as the overlay components.
013: * Usually we make a component implementing Overlayable interface although it is not required.
014: * This interface will allow user to add/remove other components as overlay components and set their location independently.
015: */
016: public interface Overlayable extends SwingConstants {
017: /**
018: * Client property. If a component has this property, the property will be an Overlyable. The component
019: * is the actual component of the Overlayable.
020: */
021: public static final String CLIENT_PROPERTY_OVERLAYABLE = "Overlayable.overlayable";
022:
023: /**
024: * Adds an overlay component to the center.
025: *
026: * @param component the overlay component.
027: */
028: void addOverlayComponent(JComponent component);
029:
030: /**
031: * Adds an overlay component at the specified location. The location could be one of the following values.
032: * <ul>
033: * <li>{@link SwingConstants#CENTER}
034: * <li>{@link SwingConstants#SOUTH}
035: * <li>{@link SwingConstants#NORTH}
036: * <li>{@link SwingConstants#WEST}
037: * <li>{@link SwingConstants#EAST}
038: * <li>{@link SwingConstants#NORTH_EAST}
039: * <li>{@link SwingConstants#NORTH_WEST}
040: * <li>{@link SwingConstants#SOUTH_EAST}
041: * <li>{@link SwingConstants#SOUTH_WEST}
042: * </ul>
043: *
044: * @param component the overlay component.
045: * @param location the overlay location.
046: */
047: void addOverlayComponent(JComponent component, int location);
048:
049: /**
050: * Adds an overlay component at the specified location. The location could be one of the following values.
051: * <ul>
052: * <li>{@link SwingConstants#CENTER}
053: * <li>{@link SwingConstants#SOUTH}
054: * <li>{@link SwingConstants#NORTH}
055: * <li>{@link SwingConstants#WEST}
056: * <li>{@link SwingConstants#EAST}
057: * <li>{@link SwingConstants#NORTH_EAST}
058: * <li>{@link SwingConstants#NORTH_WEST}
059: * <li>{@link SwingConstants#SOUTH_EAST}
060: * <li>{@link SwingConstants#SOUTH_WEST}
061: * </ul>
062: *
063: * @param component the overlay component.
064: * @param location the overlay location.
065: * @param index the overlay index. 0 means the first overlay component. -1 means the last overlay component.
066: */
067: void addOverlayComponent(JComponent component, int location,
068: int index);
069:
070: /**
071: * Removes an overlay component that was added before.
072: *
073: * @param component
074: */
075: void removeOverlayComponent(JComponent component);
076:
077: /**
078: * Gets the overlay component.
079: *
080: * @return the overlay component.
081: */
082: JComponent[] getOverlayComponents();
083:
084: /**
085: * Sets the overlay component location. The valid values are defined in SwingConstants. They are
086: * <ul>
087: * <li>{@link SwingConstants#CENTER}
088: * <li>{@link SwingConstants#SOUTH}
089: * <li>{@link SwingConstants#NORTH}
090: * <li>{@link SwingConstants#WEST}
091: * <li>{@link SwingConstants#EAST}
092: * <li>{@link SwingConstants#NORTH_EAST}
093: * <li>{@link SwingConstants#NORTH_WEST}
094: * <li>{@link SwingConstants#SOUTH_EAST}
095: * <li>{@link SwingConstants#SOUTH_WEST}
096: * </ul>
097: *
098: * @param location the overlay component location.
099: */
100: void setOverlayLocation(JComponent component, int location);
101:
102: /**
103: * Gets the overlay component location. If -1, it means the component doesn't exit.
104: *
105: * @return the overlay component location.
106: */
107: int getOverlayLocation(JComponent component);
108:
109: /**
110: * Gets the insets of the overlay component relative to the border of the component.
111: * This will affect the actual location of the overlay component except CENTER. If an edge of the insets
112: * is greater than 0, it will move the overlay component outwards on that edge. On the opposite,
113: * if the value is negative, it will move inward.
114: *
115: * @return the insets of the overlay component relative to the border of the component.
116: */
117: Insets getOverlayLocationInsets();
118:
119: /**
120: * Sets the insets of the overlay component relative to the border of the component.
121: *
122: * @param insets the insets of the overlay component relative to the border of the component.
123: */
124: void setOverlayLocationInsets(Insets insets);
125:
126: /**
127: * Sets all the overlay components visible or invisible. If you want to set one overlay component visible/invisible,
128: * you just need to call setVisible of that component.
129: *
130: * @param visible true to set it visible. False to invisible.
131: */
132: void setOverlayVisible(boolean visible);
133: }
|