jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
author alexsch
Fri, 15 Apr 2016 19:15:12 +0400
changeset 37698 4d798c873df0
parent 25859 3317bb8137f4
permissions -rw-r--r--
8132791: No access to SynthContext.getContext() Reviewed-by: serb, ssadetsky
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25173
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
     2
 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4848
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4848
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4848
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4848
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4848
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.ComponentUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.plaf.SeparatorUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.plaf.UIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.DimensionUIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
    39
 * Provides the Synth L&F UI delegate for
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    40
 * {@link javax.swing.JSeparator}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author Shannon Hickey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Joshua Outwater
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    44
 * @since 1.7
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 */
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    46
public class SynthSeparatorUI extends SeparatorUI
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    47
                              implements PropertyChangeListener, SynthUI {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private SynthStyle style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    50
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    51
     * Creates a new UI object for the given component.
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    52
     *
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    53
     * @param c component to create UI object for
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    54
     * @return the UI object
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    55
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        return new SynthSeparatorUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    60
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
    61
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    62
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    63
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public void installUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        installDefaults((JSeparator)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        installListeners((JSeparator)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    69
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
    70
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    71
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    72
    @Override
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    73
    public void uninstallUI(JComponent c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        uninstallListeners((JSeparator)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        uninstallDefaults((JSeparator)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    78
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    79
     * Installs default setting. This method is called when a
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    80
     * {@code LookAndFeel} is installed.
25173
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
    81
     *
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
    82
     * @param c specifies the {@code JSeparator} for the installed
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
    83
     * {@code LookAndFeel}.
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    84
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public void installDefaults(JSeparator c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        updateStyle(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private void updateStyle(JSeparator sep) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        SynthContext context = getContext(sep, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        SynthStyle oldStyle = style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        style = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        if (style != oldStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            if (sep instanceof JToolBar.Separator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                Dimension size = ((JToolBar.Separator)sep).getSeparatorSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                if (size == null || size instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    size = (DimensionUIResource)style.get(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                                      context, "ToolBar.separatorSize");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                    if (size == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                        size = new DimensionUIResource(10, 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    ((JToolBar.Separator)sep).setSeparatorSize(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   111
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   112
     * Uninstalls default setting. This method is called when a
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   113
     * {@code LookAndFeel} is uninstalled.
25173
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   114
     *
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   115
     * @param c specifies the {@code JSeparator} for the (un)installed
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   116
     * {@code LookAndFeel}.
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   117
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public void uninstallDefaults(JSeparator c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        SynthContext context = getContext(c, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        style.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        style = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   125
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   126
     * Installs listeners. This method is called when a
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   127
     * {@code LookAndFeel} is installed.
25173
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   128
     *
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   129
     * @param c specifies the {@code JSeparator} for the installed
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   130
     * {@code LookAndFeel}.
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   131
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public void installListeners(JSeparator c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        c.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   136
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   137
     * Uninstalls listeners. This method is called when a
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   138
     * {@code LookAndFeel} is uninstalled.
25173
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   139
     *
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   140
     * @param c specifies the {@code JSeparator} for the (un)installed
4f093fa54fa1 8044276: Fix doclint warnings (missing javadoc tags) in javax.swing.plaf.synth
yan
parents: 25100
diff changeset
   141
     * {@code LookAndFeel}.
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   142
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public void uninstallListeners(JSeparator c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        c.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   147
    /**
4848
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   148
     * Notifies this UI delegate to repaint the specified component.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   149
     * This method paints the component background, then calls
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   150
     * the {@link #paint(SynthContext,Graphics)} method.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   151
     *
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   152
     * <p>In general, this method does not need to be overridden by subclasses.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   153
     * All Look and Feel rendering code should reside in the {@code paint} method.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   154
     *
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   155
     * @param g the {@code Graphics} object used for painting
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   156
     * @param c the component being painted
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   157
     * @see #paint(SynthContext,Graphics)
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   158
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   159
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public void update(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        JSeparator separator = (JSeparator)context.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        SynthLookAndFeel.update(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        context.getPainter().paintSeparatorBackground(context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                          g, 0, 0, c.getWidth(), c.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                          separator.getOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   171
    /**
4848
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   172
     * Paints the specified component according to the Look and Feel.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   173
     * <p>This method is not used by Synth Look and Feel.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   174
     * Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   175
     *
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   176
     * @param g the {@code Graphics} object used for painting
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   177
     * @param c the component being painted
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   178
     * @see #paint(SynthContext,Graphics)
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   179
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   180
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public void paint(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   187
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   188
     * Paints the specified component.
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   189
     *
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   190
     * @param context context for the component being painted
4848
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   191
     * @param g the {@code Graphics} object used for painting
ffcc849b9351 6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents: 4394
diff changeset
   192
     * @see #update(Graphics,JComponent)
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   193
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    protected void paint(SynthContext context, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        JSeparator separator = (JSeparator)context.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        context.getPainter().paintSeparatorForeground(context, g, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                             separator.getWidth(), separator.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                             separator.getOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   201
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
   202
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   203
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   204
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void paintBorder(SynthContext context, Graphics g, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        JSeparator separator = (JSeparator)context.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        context.getPainter().paintSeparatorBorder(context, g, x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                                  separator.getOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   212
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
   213
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   214
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   215
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public Dimension getPreferredSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        int thickness = style.getInt(context, "Separator.thickness", 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        Insets insets = c.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        Dimension size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (((JSeparator)c).getOrientation() == JSeparator.VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            size = new Dimension(insets.left + insets.right + thickness,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                 insets.top + insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            size = new Dimension(insets.left + insets.right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                 insets.top + insets.bottom + thickness);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   233
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
   234
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   235
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   236
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public Dimension getMinimumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return getPreferredSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   241
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
   242
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   243
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   244
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public Dimension getMaximumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   249
    /**
20168
137788883a22 8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents: 7668
diff changeset
   250
     * {@inheritDoc}
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   251
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   252
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public SynthContext getContext(JComponent c) {
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   254
        return getContext(c, SynthLookAndFeel.getComponentState(c));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    private SynthContext getContext(JComponent c, int state) {
25100
d527cc827d7d 8043627: NPE in SynthContext in plugin mode
malenkov
parents: 23010
diff changeset
   258
        return SynthContext.getContext(c, style, state);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            updateStyle((JSeparator)evt.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}