jdk/src/share/classes/javax/swing/plaf/LayerUI.java
author alexp
Mon, 24 Aug 2009 19:22:38 +0400
changeset 3737 83fb4621a129
parent 3733 af63479b67b8
child 3748 b88af44d77a8
permissions -rw-r--r--
6824395: Several Swing core components prevent using them in wrapper classes Reviewed-by: peterz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3508
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
     1
/*
3733
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     4
 *
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    10
 *
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    15
 * accompanied this code).
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    16
 *
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    20
 *
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
    23
 * have any questions.
3508
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    24
 */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    25
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    26
package javax.swing.plaf;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    27
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    28
import javax.accessibility.Accessible;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    29
import javax.swing.*;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    30
import javax.swing.plaf.ComponentUI;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    31
import java.awt.*;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    32
import java.awt.event.*;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    33
import java.beans.PropertyChangeEvent;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    34
import java.beans.PropertyChangeSupport;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    35
import java.beans.PropertyChangeListener;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    36
import java.io.Serializable;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    37
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    38
/**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    39
 * The base class for all {@link javax.swing.JLayer}'s UI delegates.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    40
 * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    41
 * {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performes the
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    42
 * painting of the {@code JLayer}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    43
 * and {@link #eventDispatched(AWTEvent, JLayer)} method is notified
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    44
 * about any {@code AWTEvent}s which have been generated by a {@code JLayer}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    45
 * or any of its subcomponents.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    46
 * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    47
 * The {@code LayerUI} differs from the UI delegates of the other components,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    48
 * because it is LookAndFeel independent and is not updated by default when
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    49
 * the system LookAndFeel is changed.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    50
 * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    51
 * The subclasses of {@code LayerUI} can either be stateless and shareable
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    52
 * by multiple {@code JLayer}s or not shareable.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    53
 *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    54
 * @param <V> one of the super types of {@code JLayer}'s view component
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    55
 *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    56
 * @see JLayer#setUI(LayerUI)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    57
 * @see JLayer#setView(Component)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    58
 * @see JLayer#getView()
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    59
 * @since 1.7
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    60
 *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    61
 * @author Alexander Potochkin
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    62
 */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    63
public class LayerUI<V extends Component>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    64
        extends ComponentUI implements Serializable {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    65
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    66
    private final PropertyChangeSupport propertyChangeSupport =
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    67
            new PropertyChangeSupport(this);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    68
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    69
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    70
     * Paints the specified component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    71
     * Subclasses should override this method and use
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    72
     * the specified {@code Graphics} object to
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    73
     * render the content of the component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    74
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    75
     * @param g the {@code Graphics} context in which to paint;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    76
     * @param c the component being painted;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    77
     * it can be safely cast to the {@code JLayer<V>}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    78
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    79
    @Override
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    80
    public void paint(Graphics g, JComponent c) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    81
        c.paint(g);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    82
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    83
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    84
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    85
     * Dispatches {@code AWTEvent}s for {@code JLayer}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    86
     * and <b>all it subcomponents</b> to this {@code LayerUI} instance.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    87
     * <p>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    88
     * To enable the {@code AWTEvent} of the particular type,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    89
     * you call {@link javax.swing.JLayer#setLayerEventMask}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    90
     * in {@link #installUI(javax.swing.JComponent)}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    91
     * and set the layer event mask to {@code 0}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    92
     * in {@link #uninstallUI(javax.swing.JComponent)} after that
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    93
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    94
     * @param e the event to be dispatched
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    95
     * @param l the layer this LayerUI is set to
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    96
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    97
     * @see JLayer#setLayerEventMask(long)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    98
     * @see javax.swing.JLayer#getLayerEventMask()
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
    99
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   100
    public void eventDispatched(AWTEvent e, JLayer<? extends V> l){
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   101
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   102
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   103
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   104
     * Invoked when {@link javax.swing.JLayer#updateUI()} is called
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   105
     * by the {@code JLayer} this {@code LayerUI} is set to.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   106
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   107
     * @param l the {@code JLayer} which UI is updated
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   108
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   109
    public void updateUI(JLayer<? extends V> l){
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   110
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   111
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   112
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   113
     * Configures the {@code JLayer} this {@code LayerUI} is set to.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   114
     * The default implementation registers the {@code LayerUI}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   115
     * as a property change listener for the passed {@code JLayer} component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   116
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   117
     * @param c the {@code JLayer} component where this UI delegate is being installed
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   118
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   119
    public void installUI(JComponent c) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   120
        addPropertyChangeListener((JLayer) c);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   121
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   122
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   123
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   124
     * Reverses the configuration which was previously set
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   125
     * in the {@link #installUI(JComponent)} method.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   126
     * The default implementation unregisters the property change listener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   127
     * for the passed JLayer component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   128
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   129
     * @param c the component from which this UI delegate is being removed.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   130
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   131
    public void uninstallUI(JComponent c) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   132
        removePropertyChangeListener((JLayer) c);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   133
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   134
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   135
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   136
     * Adds a PropertyChangeListener to the listener list. The listener is
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   137
     * registered for all bound properties of this class.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   138
     * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   139
     * If {@code listener} is {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   140
     * no exception is thrown and no action is performed.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   141
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   142
     * @param listener the property change listener to be added
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   143
     * @see #removePropertyChangeListener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   144
     * @see #getPropertyChangeListeners
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   145
     * @see #addPropertyChangeListener(String, java.beans.PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   146
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   147
    public void addPropertyChangeListener(PropertyChangeListener listener) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   148
        propertyChangeSupport.addPropertyChangeListener(listener);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   149
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   150
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   151
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   152
     * Removes a PropertyChangeListener from the listener list. This method
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   153
     * should be used to remove PropertyChangeListeners that were registered
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   154
     * for all bound properties of this class.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   155
     * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   156
     * If {@code listener} is {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   157
     * no exception is thrown and no action is performed.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   158
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   159
     * @param listener the PropertyChangeListener to be removed
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   160
     * @see #addPropertyChangeListener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   161
     * @see #getPropertyChangeListeners
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   162
     * @see #removePropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   163
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   164
    public void removePropertyChangeListener(PropertyChangeListener listener) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   165
        propertyChangeSupport.removePropertyChangeListener(listener);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   166
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   167
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   168
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   169
     * Returns an array of all the property change listeners
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   170
     * registered on this component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   171
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   172
     * @return all of this ui's {@code PropertyChangeListener}s
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   173
     *         or an empty array if no property change
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   174
     *         listeners are currently registered
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   175
     * @see #addPropertyChangeListener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   176
     * @see #removePropertyChangeListener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   177
     * @see #getPropertyChangeListeners(String)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   178
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   179
    public PropertyChangeListener[] getPropertyChangeListeners() {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   180
        return propertyChangeSupport.getPropertyChangeListeners();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   181
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   182
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   183
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   184
     * Adds a PropertyChangeListener to the listener list for a specific
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   185
     * property.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   186
     * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   187
     * If {@code propertyName} or {@code listener} is {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   188
     * no exception is thrown and no action is taken.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   189
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   190
     * @param propertyName one of the property names listed above
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   191
     * @param listener     the property change listener to be added
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   192
     * @see #removePropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   193
     * @see #getPropertyChangeListeners(String)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   194
     * @see #addPropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   195
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   196
    public void addPropertyChangeListener(String propertyName,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   197
                                          PropertyChangeListener listener) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   198
        propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   199
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   200
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   201
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   202
     * Removes a {@code PropertyChangeListener} from the listener
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   203
     * list for a specific property. This method should be used to remove
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   204
     * {@code PropertyChangeListener}s
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   205
     * that were registered for a specific bound property.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   206
     * <p/>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   207
     * If {@code propertyName} or {@code listener} is {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   208
     * no exception is thrown and no action is taken.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   209
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   210
     * @param propertyName a valid property name
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   211
     * @param listener     the PropertyChangeListener to be removed
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   212
     * @see #addPropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   213
     * @see #getPropertyChangeListeners(String)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   214
     * @see #removePropertyChangeListener(PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   215
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   216
    public void removePropertyChangeListener(String propertyName,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   217
                                             PropertyChangeListener listener) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   218
        propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   219
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   220
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   221
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   222
     * Returns an array of all the listeners which have been associated
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   223
     * with the named property.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   224
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   225
     * @return all of the {@code PropertyChangeListener}s associated with
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   226
     *         the named property; if no such listeners have been added or
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   227
     *         if {@code propertyName} is {@code null}, an empty
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   228
     *         array is returned
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   229
     * @see #addPropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   230
     * @see #removePropertyChangeListener(String, PropertyChangeListener)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   231
     * @see #getPropertyChangeListeners
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   232
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   233
    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   234
        return propertyChangeSupport.getPropertyChangeListeners(propertyName);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   235
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   236
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   237
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   238
     * Support for reporting bound property changes for Object properties.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   239
     * This method can be called when a bound property has changed and it will
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   240
     * send the appropriate PropertyChangeEvent to any registered
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   241
     * PropertyChangeListeners.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   242
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   243
     * @param propertyName the property whose value has changed
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   244
     * @param oldValue     the property's previous value
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   245
     * @param newValue     the property's new value
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   246
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   247
    protected void firePropertyChange(String propertyName,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   248
                                      Object oldValue, Object newValue) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   249
        propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   250
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   251
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   252
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   253
     * Notifies the {@code LayerUI} when any of its property are changed
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   254
     * and enables updating every {@code JLayer} this {@code LayerUI} instance is set to.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   255
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   256
     * @param evt the PropertyChangeEvent generated by this {@code LayerUI}
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   257
     * @param l the {@code JLayer} this LayerUI is set to
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   258
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   259
    public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   260
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   261
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   262
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   263
     * Returns the preferred size of the viewport for a view component.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   264
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   265
     * @return the preferred size of the viewport for a view component
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   266
     * @see Scrollable#getPreferredScrollableViewportSize()
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   267
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   268
    public Dimension getPreferredScrollableViewportSize(JLayer<? extends V> l) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   269
        if (l.getView() instanceof Scrollable) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   270
            return ((Scrollable)l.getView()).getPreferredScrollableViewportSize();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   271
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   272
        return l.getPreferredSize();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   273
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   274
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   275
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   276
     * Returns a scroll increment, which is required for components
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   277
     * that display logical rows or columns in order to completely expose
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   278
     * one block of rows or columns, depending on the value of orientation.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   279
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   280
     * @return the "block" increment for scrolling in the specified direction
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   281
     * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   282
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   283
     public int getScrollableBlockIncrement(JLayer<? extends V> l,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   284
                                           Rectangle visibleRect,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   285
                                           int orientation, int direction) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   286
        if (l.getView() instanceof Scrollable) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   287
            return ((Scrollable)l.getView()).getScrollableBlockIncrement(
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   288
                    visibleRect,orientation, direction);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   289
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   290
        return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   291
            visibleRect.width;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   292
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   293
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   294
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   295
     * Returns {@code false} to indicate that the height of the viewport does not
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   296
     * determine the height of the layer, unless the preferred height
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   297
     * of the layer is smaller than the height of the viewport.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   298
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   299
     * @return whether the layer should track the height of the viewport
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   300
     * @see Scrollable#getScrollableTracksViewportHeight()
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   301
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   302
    public boolean getScrollableTracksViewportHeight(JLayer<? extends V> l) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   303
        if (l.getView() instanceof Scrollable) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   304
            return ((Scrollable)l.getView()).getScrollableTracksViewportHeight();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   305
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   306
        return false;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   307
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   308
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   309
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   310
     * Returns {@code false} to indicate that the width of the viewport does not
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   311
     * determine the width of the layer, unless the preferred width
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   312
     * of the layer is smaller than the width of the viewport.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   313
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   314
     * @return whether the layer should track the width of the viewport
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   315
     * @see Scrollable
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   316
     * @see LayerUI#getScrollableTracksViewportWidth(JLayer)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   317
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   318
    public boolean getScrollableTracksViewportWidth(JLayer<? extends V> l) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   319
        if (l.getView() instanceof Scrollable) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   320
            return ((Scrollable)l.getView()).getScrollableTracksViewportWidth();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   321
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   322
        return false;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   323
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   324
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   325
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   326
     * Returns a scroll increment, which is required for components
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   327
     * that display logical rows or columns in order to completely expose
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   328
     * one new row or column, depending on the value of orientation.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   329
     * Ideally, components should handle a partially exposed row or column
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   330
     * by returning the distance required to completely expose the item.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   331
     * <p>
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   332
     * Scrolling containers, like JScrollPane, will use this method
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   333
     * each time the user requests a unit scroll.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   334
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   335
     * @return The "unit" increment for scrolling in the specified direction.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   336
     *         This value should always be positive.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   337
     * @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   338
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   339
    public int getScrollableUnitIncrement(JLayer<? extends V> l,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   340
                                          Rectangle visibleRect,
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   341
                                          int orientation, int direction) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   342
        if (l.getView() instanceof Scrollable) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   343
            return ((Scrollable)l.getView()).getScrollableUnitIncrement(
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   344
                    visibleRect, orientation, direction);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   345
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   346
        return 1;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   347
    }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   348
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   349
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   350
     * If the {@code JLayer}'s view component is not {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   351
     * this calls the view's {@code getBaseline()} method.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   352
     * Otherwise, the default implementation is called.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   353
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   354
     * @param c {@code JLayer} to return baseline resize behavior for
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   355
     * @param width the width to get the baseline for
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   356
     * @param height the height to get the baseline for
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   357
     * @return baseline or a value &lt; 0 indicating there is no reasonable
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   358
     *                  baseline
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   359
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   360
    public int getBaseline(JComponent c, int width, int height) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   361
        JLayer l = (JLayer) c;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   362
        if (l.getView() != null) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   363
            return l.getView().getBaseline(width, height);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   364
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   365
        return super.getBaseline(c, width, height);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   366
     }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   367
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   368
    /**
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   369
     * If the {@code JLayer}'s view component is not {@code null},
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   370
     * this calls the view's {@code getBaselineResizeBehavior()} method.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   371
     * Otherwise, the default implementation is called.
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   372
     *
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   373
     * @param c {@code JLayer} to return baseline resize behavior for
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   374
     * @return an enum indicating how the baseline changes as the component
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   375
     *         size changes
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   376
     */
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   377
    public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   378
        JLayer l = (JLayer) c;
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   379
        if (l.getView() != null) {
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   380
            return l.getView().getBaselineResizeBehavior();
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   381
        }
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   382
        return super.getBaselineResizeBehavior(c);
defe8eec9251 6822696: Integrating JXLayer component to Swing library
alexp
parents:
diff changeset
   383
    }
3733
af63479b67b8 6872492: JLayer sources contain wrong header
alexp
parents: 3508
diff changeset
   384
}