LayerUI.java revision 1561
1561N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 1561N/A * The base class for all {@link javax.swing.JLayer}'s UI delegates. 1561N/A * {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performes the 1561N/A * painting of the {@code JLayer} 1561N/A * and {@link #eventDispatched(AWTEvent, JLayer)} method is notified 1561N/A * about any {@code AWTEvent}s which have been generated by a {@code JLayer} 1561N/A * or any of its subcomponents. 1561N/A * The {@code LayerUI} differs from the UI delegates of the other components, 1561N/A * because it is LookAndFeel independent and is not updated by default when 1561N/A * the system LookAndFeel is changed. 1561N/A * The subclasses of {@code LayerUI} can either be stateless and shareable 1561N/A * by multiple {@code JLayer}s or not shareable. 1561N/A * @param <V> one of the super types of {@code JLayer}'s view component 1561N/A * @see JLayer#setUI(LayerUI) 1561N/A * @see JLayer#setView(Component) 1561N/A * @author Alexander Potochkin 1561N/A * Paints the specified component. 1561N/A * Subclasses should override this method and use 1561N/A * the specified {@code Graphics} object to 1561N/A * render the content of the component. 1561N/A * @param g the {@code Graphics} context in which to paint; 1561N/A * @param c the component being painted; 1561N/A * it can be safely cast to the {@code JLayer<V>} 1561N/A * Dispatches {@code AWTEvent}s for {@code JLayer} 1561N/A * and <b>all it subcomponents</b> to this {@code LayerUI} instance. 1561N/A * To enable the {@code AWTEvent} of the particular type, 1561N/A * you call {@link javax.swing.JLayer#setLayerEventMask} 1561N/A * in {@link #installUI(javax.swing.JComponent)} 1561N/A * and set the layer event mask to {@code 0} 1561N/A * in {@link #uninstallUI(javax.swing.JComponent)} after that 1561N/A * @param e the event to be dispatched 1561N/A * @param l the layer this LayerUI is set to 1561N/A * @see JLayer#setLayerEventMask(long) 1561N/A * @see javax.swing.JLayer#getLayerEventMask() 1561N/A * Invoked when {@link javax.swing.JLayer#updateUI()} is called 1561N/A * by the {@code JLayer} this {@code LayerUI} is set to. 1561N/A * @param l the {@code JLayer} which UI is updated 1561N/A * Configures the {@code JLayer} this {@code LayerUI} is set to. 1561N/A * The default implementation registers the {@code LayerUI} 1561N/A * as a property change listener for the passed {@code JLayer} component. 1561N/A * @param c the {@code JLayer} component where this UI delegate is being installed 1561N/A * Reverses the configuration which was previously set 1561N/A * in the {@link #installUI(JComponent)} method. 1561N/A * The default implementation unregisters the property change listener 1561N/A * for the passed JLayer component. 1561N/A * @param c the component from which this UI delegate is being removed. 1561N/A * Adds a PropertyChangeListener to the listener list. The listener is 1561N/A * registered for all bound properties of this class. 1561N/A * If {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is performed. 1561N/A * @param listener the property change listener to be added 1561N/A * @see #removePropertyChangeListener 1561N/A * @see #getPropertyChangeListeners 1561N/A * @see #addPropertyChangeListener(String, java.beans.PropertyChangeListener) 1561N/A * Removes a PropertyChangeListener from the listener list. This method 1561N/A * should be used to remove PropertyChangeListeners that were registered 1561N/A * for all bound properties of this class. 1561N/A * If {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is performed. 1561N/A * @param listener the PropertyChangeListener to be removed 1561N/A * @see #addPropertyChangeListener 1561N/A * @see #getPropertyChangeListeners 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * Returns an array of all the property change listeners 1561N/A * registered on this component. 1561N/A * @return all of this ui's {@code PropertyChangeListener}s 1561N/A * or an empty array if no property change 1561N/A * listeners are currently registered 1561N/A * @see #addPropertyChangeListener 1561N/A * @see #removePropertyChangeListener 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * Adds a PropertyChangeListener to the listener list for a specific 1561N/A * If {@code propertyName} or {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is taken. 1561N/A * @param propertyName one of the property names listed above 1561N/A * @param listener the property change listener to be added 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * Removes a {@code PropertyChangeListener} from the listener 1561N/A * list for a specific property. This method should be used to remove 1561N/A * {@code PropertyChangeListener}s 1561N/A * that were registered for a specific bound property. 1561N/A * If {@code propertyName} or {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is taken. 1561N/A * @param propertyName a valid property name 1561N/A * @param listener the PropertyChangeListener to be removed 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * @see #removePropertyChangeListener(PropertyChangeListener) 1561N/A * Returns an array of all the listeners which have been associated 1561N/A * @return all of the {@code PropertyChangeListener}s associated with 1561N/A * the named property; if no such listeners have been added or 1561N/A * if {@code propertyName} is {@code null}, an empty 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners 1561N/A * Support for reporting bound property changes for Object properties. 1561N/A * This method can be called when a bound property has changed and it will 1561N/A * send the appropriate PropertyChangeEvent to any registered 1561N/A * @param propertyName the property whose value has changed 1561N/A * @param oldValue the property's previous value 1561N/A * @param newValue the property's new value 1561N/A * Notifies the {@code LayerUI} when any of its property are changed 1561N/A * and enables updating every {@code JLayer} this {@code LayerUI} instance is set to. 1561N/A * @param evt the PropertyChangeEvent generated by this {@code LayerUI} 1561N/A * @param l the {@code JLayer} this LayerUI is set to 1561N/A * Returns the preferred size of the viewport for a view component. 1561N/A * @return the preferred size of the viewport for a view component 1561N/A * @see Scrollable#getPreferredScrollableViewportSize() 1561N/A * Returns a scroll increment, which is required for components 1561N/A * that display logical rows or columns in order to completely expose 1561N/A * one block of rows or columns, depending on the value of orientation. 1561N/A * @return the "block" increment for scrolling in the specified direction 1561N/A * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int) 1561N/A * Returns {@code false} to indicate that the height of the viewport does not 1561N/A * determine the height of the layer, unless the preferred height 1561N/A * of the layer is smaller than the height of the viewport. 1561N/A * @return whether the layer should track the height of the viewport 1561N/A * @see Scrollable#getScrollableTracksViewportHeight() 1561N/A * Returns {@code false} to indicate that the width of the viewport does not 1561N/A * determine the width of the layer, unless the preferred width 1561N/A * of the layer is smaller than the width of the viewport. 1561N/A * @return whether the layer should track the width of the viewport 1561N/A * @see LayerUI#getScrollableTracksViewportWidth(JLayer) 1561N/A * Returns a scroll increment, which is required for components 1561N/A * that display logical rows or columns in order to completely expose 1561N/A * one new row or column, depending on the value of orientation. 1561N/A * Ideally, components should handle a partially exposed row or column 1561N/A * by returning the distance required to completely expose the item. 1561N/A * Scrolling containers, like JScrollPane, will use this method 1561N/A * each time the user requests a unit scroll. 1561N/A * @return The "unit" increment for scrolling in the specified direction. 1561N/A * This value should always be positive. 1561N/A * @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int) 1561N/A * If the {@code JLayer}'s view component is not {@code null}, 1561N/A * this calls the view's {@code getBaseline()} method. 1561N/A * Otherwise, the default implementation is called. 1561N/A * @param c {@code JLayer} to return baseline resize behavior for 1561N/A * @param width the width to get the baseline for 1561N/A * @param height the height to get the baseline for 1561N/A * @return baseline or a value < 0 indicating there is no reasonable 1561N/A * If the {@code JLayer}'s view component is not {@code null}, 1561N/A * this calls the view's {@code getBaselineResizeBehavior()} method. 1561N/A * Otherwise, the default implementation is called. 1561N/A * @param c {@code JLayer} to return baseline resize behavior for 1561N/A * @return an enum indicating how the baseline changes as the component