[svn:47] Partial success at refactoring - all compiles.

  • From: JonathanGiles@kenai.com
  • To: commits@swing2.kenai.com
  • Subject: [svn:47] Partial success at refactoring - all compiles.
  • Date: Fri, 27 Feb 2009 23:45:48 +0000 (GMT)

Repository: svn
Revision:   47
Author:     JonathanGiles
Date:       2009-02-27 23:45:32 UTC
Link:       http://kenai.com/projects/swing2/sources/svn/revision/47

Log Message:
-----------
Partial success at refactoring - all compiles. Next step may break
compilation, so checking in first.

Modified Paths:
--------------
    Swing 2.0/trunk/src/javax/swing/JColorChooser.java
    Swing 2.0/trunk/src/javax/swing/JComponent.java
    Swing 2.0/trunk/src/javax/swing/JInternalFrame.java
    Swing 2.0/trunk/src/javax/swing/JList.java
    Swing 2.0/trunk/src/javax/swing/JTabbedPane.java
    Swing 2.0/trunk/src/javax/swing/JTable.java
    Swing 2.0/trunk/src/javax/swing/JTree.java
    Swing 2.0/trunk/src/javax/swing/LookAndFeel.java
    Swing 2.0/trunk/src/javax/swing/SwingUtilities.java
    Swing 2.0/trunk/src/javax/swing/SwingWorker.java
    Swing 2.0/trunk/src/javax/swing/ToolTipManager.java
    Swing 2.0/trunk/src/javax/swing/TransferHandler.java
    Swing 2.0/trunk/src/javax/swing/UIManager.java
    Swing 2.0/trunk/src/javax/swing/table/DefaultTableColumnModel.java
    Swing
2.0/trunk/src/sun/swing2/table/DefaultTableCellHeaderRenderer.java
    Swing 2.0/trunk/src_extended/javax/swing/border/TitledBorder.java
    Swing
2.0/trunk/src_extended/javax/swing/colorchooser/DefaultPreviewPanel.jav
a
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicButtonListener.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicButtonUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicColorChooserUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicComboBoxUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicDesktopPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicEditorPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicFileChooserUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicGraphicsUtils.java
    Swing 2.0/trunk/src_extended/javax/swing/plaf/basic/BasicHTML.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicInternalFrameTitlePa
ne.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicInternalFrameUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicLabelUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicListUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicLookAndFeel.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicMenuBarUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicMenuItemUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicMenuUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicOptionPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicPopupMenuUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicProgressBarUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicRadioButtonUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicRootPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicScrollBarUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicScrollPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicSliderUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicSpinnerUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicSplitPaneDivider.jav
a
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicSplitPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTabbedPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTableHeaderUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTableUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTextFieldUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTextUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicToolBarUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicToolTipUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/BasicTreeUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/basic/DefaultMenuLayout.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/DefaultMetalTheme.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalBorders.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalButtonUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalFileChooserUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalIconFactory.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalInternalFrameTitlePa
ne.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalLabelUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalLookAndFeel.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalRadioButtonUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalTitlePane.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalToggleButtonUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/metal/MetalToolTipUI.java
    Swing 2.0/trunk/src_extended/javax/swing/plaf/metal/MetalUtils.java
    Swing 2.0/trunk/src_extended/javax/swing/plaf/metal/OceanTheme.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthDefaultLookup.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthGraphicsUtils.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthInternalFrameTitlePa
ne.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthLookAndFeel.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthMenuItemUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthOptionPaneUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthProgressBarUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthSliderUI.java
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthSplitPaneDivider.jav
a
    Swing
2.0/trunk/src_extended/javax/swing/plaf/synth/SynthTabbedPaneUI.java
    Swing 2.0/trunk/src_extended/javax/swing/text/AbstractDocument.java
    Swing 2.0/trunk/src_extended/javax/swing/text/DefaultCaret.java
    Swing 2.0/trunk/src_extended/javax/swing/text/FieldView.java
    Swing 2.0/trunk/src_extended/javax/swing/text/GlyphView.java
    Swing 2.0/trunk/src_extended/javax/swing/text/JTextComponent.java
    Swing
2.0/trunk/src_extended/sun/swing/plaf/synth/Paint9Painter.java
    Swing
2.0/trunk/src_extended/sun/swing/plaf/synth/SynthFileChooserUIImpl.java

Added Paths:
-----------
    Swing 2.0/trunk/src/sun/swing2
    Swing 2.0/trunk/src/sun/swing2/AccessibleMethod.java
    Swing 2.0/trunk/src/sun/swing2/AccumulativeRunnable.java
    Swing 2.0/trunk/src/sun/swing2/BakedArrayList.java
    Swing 2.0/trunk/src/sun/swing2/CachedPainter.java
    Swing 2.0/trunk/src/sun/swing2/DefaultLayoutStyle.java
    Swing 2.0/trunk/src/sun/swing2/DefaultLookup.java
    Swing 2.0/trunk/src/sun/swing2/FilePane.java
    Swing 2.0/trunk/src/sun/swing2/ImageIconUIResource.java
    Swing 2.0/trunk/src/sun/swing2/MenuItemCheckIconFactory.java
    Swing 2.0/trunk/src/sun/swing2/PrintColorUIResource.java
    Swing 2.0/trunk/src/sun/swing2/PrintingStatus.java
    Swing 2.0/trunk/src/sun/swing2/StringUIClientPropertyKey.java
    Swing 2.0/trunk/src/sun/swing2/SwingLazyValue.java
    Swing 2.0/trunk/src/sun/swing2/SwingUtilities2.java
    Swing 2.0/trunk/src/sun/swing2/UIAction.java
    Swing 2.0/trunk/src/sun/swing2/UIClientPropertyKey.java
    Swing 2.0/trunk/src/sun/swing2/WindowsPlacesBar.java
    Swing 2.0/trunk/src/sun/swing2/table

Removed Paths:
-------------
    Swing 2.0/trunk/src/sun/swing/AccessibleMethod.java
    Swing 2.0/trunk/src/sun/swing/AccumulativeRunnable.java
    Swing 2.0/trunk/src/sun/swing/BakedArrayList.java
    Swing 2.0/trunk/src/sun/swing/CachedPainter.java
    Swing 2.0/trunk/src/sun/swing/DefaultLayoutStyle.java
    Swing 2.0/trunk/src/sun/swing/DefaultLookup.java
    Swing 2.0/trunk/src/sun/swing/FilePane.java
    Swing 2.0/trunk/src/sun/swing/ImageCache.java
    Swing 2.0/trunk/src/sun/swing/ImageIconUIResource.java
    Swing 2.0/trunk/src/sun/swing/MenuItemCheckIconFactory.java
    Swing 2.0/trunk/src/sun/swing/PrintColorUIResource.java
    Swing 2.0/trunk/src/sun/swing/PrintingStatus.java
    Swing 2.0/trunk/src/sun/swing/StringUIClientPropertyKey.java
    Swing 2.0/trunk/src/sun/swing/SwingLazyValue.java
    Swing 2.0/trunk/src/sun/swing/SwingUtilities2.java
    Swing 2.0/trunk/src/sun/swing/UIAction.java
    Swing 2.0/trunk/src/sun/swing/UIClientPropertyKey.java
    Swing 2.0/trunk/src/sun/swing/WindowsPlacesBar.java
    Swing 2.0/trunk/src/sun/swing/table

Diffs:
-----
Index: Swing 2.0/trunk/src/sun/swing/PrintColorUIResource.java
===================================================================
--- Swing 2.0/trunk/src/sun/swing/PrintColorUIResource.java    
(revision 46)
+++ Swing 2.0/trunk/src/sun/swing/PrintColorUIResource.java    
(revision 47)
@@ -1,91 +0,0 @@
-/*
- * Copyright 2004-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify
it
- * under the terms of the GNU General Public License version 2 only,
as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but
WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License
- * version 2 for more details (a copy is included in the LICENSE file
that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
version
- * 2 along with this work; if not, write to the Free Software
Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
Clara,
- * CA 95054 USA or visit www.sun.com if you need additional
information or
- * have any questions.
- */
-
-package sun.swing;
-
-import java.awt.Color;
-import javax.swing.plaf.ColorUIResource;
-
-/**
- * A subclass of ColorUIResource that wraps an alternate color
- * for use during printing. Useful to replace color values that
- * may look poor in printed output.
- *
- * @author Shannon Hickey
- *
- */
-public class PrintColorUIResource extends ColorUIResource {
-
-    /** The color to use during printing */
-    private Color printColor;
-
-    /**
-     * Construct an instance for the given RGB value and
-     * alternate color to use during printing.
-     *
-     * @param rgb the color rgb value
-     * @param printColor the alternate color for printing
-     */
-    public PrintColorUIResource(int rgb, Color printColor) {
-        super(rgb);
-        this.printColor = printColor;
-    }
-
-    /**
-     * Return the color to use during printing. If no alternate
-     * color was specified on construction, this method will
-     * return <code>this</code>.
-     *
-     * @return the color to use during printing
-     */
-    public Color getPrintColor() {
-        return ((printColor != null) ? printColor : this);
-    }
-
-    /**
-     * Replaces this object with a plain {@code ColorUIResource}
during
-     * serialization. Since {@code PrintColorUIResource} resides in
the
-     * sun.swing package, access can be disallowed to it by a security
-     * manager. When access is disallowed, deserialization of any
object
-     * with reference to a {@code PrintColorUIResource} fails.
-     * <p>
-     * Since {@code PrintColorUIResource) is used only by Swing's look
-     * and feels, and we know that UI supplied colors are replaced
after
-     * deserialization when the UI is re-installed, the only important
-     * aspect of the {@code PrintColorUIResource} that needs to be
-     * persisted is the fact that it is a {@code ColorUIResource}. As
-     * such, we can avoid the problem outlined above by replacing
-     * the problematic {@code PrintColorUIResource} with a plain
-     * {@code ColorUIResource}.
-     * <p>
-     * Note: As a result of this method, it is not possible to write
-     * a {@code PrintColorUIResource} to a stream and then read
-     * back a {@code PrintColorUIResource}. This is acceptable since
we
-     * don't have a requirement for that in Swing.
-     */
-    private Object writeReplace() {
-        return new ColorUIResource(this);
-    }
-}
Index: Swing 2.0/trunk/src/sun/swing/ImageIconUIResource.java
===================================================================
--- Swing 2.0/trunk/src/sun/swing/ImageIconUIResource.java     
(revision 46)
+++ Swing 2.0/trunk/src/sun/swing/ImageIconUIResource.java     
(revision 47)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify
it
- * under the terms of the GNU General Public License version 2 only,
as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but
WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License
- * version 2 for more details (a copy is included in the LICENSE file
that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
version
- * 2 along with this work; if not, write to the Free Software
Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
Clara,
- * CA 95054 USA or visit www.sun.com if you need additional
information or
- * have any questions.
- */
-
-package sun.swing;
-
-import javax.swing.ImageIcon;
-import javax.swing.plaf.UIResource;
-import java.awt.Image;
-
-/**
- * A subclass of <code>ImageIcon</code> that implements UIResource.
- *
- * @author Shannon Hickey
- *
- */
-public class ImageIconUIResource extends ImageIcon implements
UIResource {
-
-    /**
-     * Calls the superclass constructor with the same parameter.
-     *
-     * @param imageData an array of pixels
-     * @see javax.swing.ImageIcon#ImageIcon(byte[])
-     */
-    public ImageIconUIResource(byte[] imageData) {
-        super(imageData);
-    }
-
-    /**
-     * Calls the superclass constructor with the same parameter.
-     *
-     * @param image an image
-     * @see javax.swing.ImageIcon#ImageIcon(Image)
-     */
-    public ImageIconUIResource(Image image) {
-        super(image);
-    }
-}
Index: Swing 2.0/trunk/src/sun/swing/BakedArrayList.java
===================================================================
--- Swing 2.0/trunk/src/sun/swing/BakedArrayList.java   (revision 46)
+++ Swing 2.0/trunk/src/sun/swing/BakedArrayList.java   (revision 47)
@@ -1,93 +0,0 @@
-/*
- * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify
it
- * under the terms of the GNU General Public License version 2 only,
as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but
WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License
- * version 2 for more details (a copy is included in the LICENSE file
that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
version
- * 2 along with this work; if not, write to the Free Software
Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
Clara,
- * CA 95054 USA or visit www.sun.com if you need additional
information or
- * have any questions.
- */
-package sun.swing;
-
-import java.util.*;
-
-/**
- * <b>WARNING:</b> This class is an implementation detail and is only
- * public so that it can be used by two packages. You should NOT
consider
- * this public API.
- * <p>
- * <b>WARNING 2:</b> This is not a general purpose List
implementation! It
- * has a specific use and will not work correctly if you use it
outside of
- * its use.
- * <p>
- * A specialized ArrayList that caches its hashCode as well as
overriding
- * equals to avoid creating an Iterator. This class is useful in
scenarios
- * where the list won't change and you want to avoid the overhead of
hashCode
- * iterating through the elements invoking hashCode. This also assumes
you'll
- * only ever compare a BakedArrayList to another BakedArrayList.
- *
- * @author Scott Violet
- */
-public class BakedArrayList extends ArrayList {
-    /**
-     * The cached hashCode.
-     */
-    private int _hashCode;
-
-    public BakedArrayList(int size) {
-        super(size);
-    }
-
-    public BakedArrayList(java.util.List data) {
-        this(data.size());
-        for (int counter = 0, max = data.size(); counter < max;
counter++){
-            add(data.get(counter));
-        }
-        cacheHashCode();
-    }
-
-    /**
-     * Caches the hash code. It is assumed you won't modify the list,
or that
-     * if you do you'll call cacheHashCode again.
-     */
-    public void cacheHashCode() {
-        _hashCode = 1;
-        for (int counter = size() - 1; counter >= 0; counter--) {
-            _hashCode = 31 * _hashCode + get(counter).hashCode();
-        }
-    }
-
-    public int hashCode() {
-        return _hashCode;
-    }
-
-    public boolean equals(Object o) {
-        BakedArrayList list = (BakedArrayList)o;
-        int size = size();
-
-        if (list.size() != size) {
-            return false;
-        }
-        while (size-- > 0) {
-            if (!get(size).equals(list.get(size))) {
-                return false;
-            }
-        }
-        return true;
-    }
-}
Index: Swing 2.0/trunk/src/sun/swing/DefaultLayoutStyle.java
===================================================================
--- Swing 2.0/trunk/src/sun/swing/DefaultLayoutStyle.java      
(revision 46)
+++ Swing 2.0/trunk/src/sun/swing/DefaultLayoutStyle.java      
(revision 47)
@@ -1,258 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify
it
- * under the terms of the GNU General Public License version 2 only,
as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but
WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License
- * version 2 for more details (a copy is included in the LICENSE file
that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
version
- * 2 along with this work; if not, write to the Free Software
Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
Clara,
- * CA 95054 USA or visit www.sun.com if you need additional
information or
- * have any questions.
- */
-package sun.swing;
-
-import java.awt.Container;
-import java.awt.Insets;
-
-import javax.swing.*;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.border.Border;
-import javax.swing.plaf.UIResource;
-
-/**
- * An implementation of <code>LayoutStyle</code> that returns 6 for
related
- * components, otherwise 12.  This class also provides helper methods
for
- * subclasses.
- *
- */
-public class DefaultLayoutStyle extends LayoutStyle {
-    private static final DefaultLayoutStyle INSTANCE =
-            new DefaultLayoutStyle();
-
-    public static LayoutStyle getInstance() {
-        return INSTANCE;
-    }
-
-    @Override
-    public int getPreferredGap(JComponent component1, JComponent
component2,
-            ComponentPlacement type, int position, Container parent) {
-
-        if (component1 == null || component2 == null || type == null)
{
-            throw new NullPointerException();
-        }
-        if (type == ComponentPlacement.INDENT &&
-                (position == SwingConstants.EAST ||
-                 position == SwingConstants.WEST)) {
-            int indent = getIndent(component1, position);
-            if (indent > 0) {
-                return indent;
-            }
-        }
-        return (type == ComponentPlacement.UNRELATED) ? 12 : 6;
-    }
-
-    @Override
-    public int getContainerGap(JComponent component, int position,
-                               Container parent) {
-        if (component == null) {
-            throw new NullPointerException();
-        }
-        checkPosition(position);
-        return 6;
-    }
-
-    /**
-     * Returns true if the classes identify a JLabel and a non-JLabel
-     * along the horizontal axis.
-     */
-    protected boolean isLabelAndNonlabel(JComponent c1, JComponent c2,
-                                         int position) {
-        if (position == SwingConstants.EAST ||
-                position == SwingConstants.WEST) {
-            boolean c1Label = (c1 instanceof JLabel);
-            boolean c2Label = (c2 instanceof JLabel);
-            return ((c1Label || c2Label) && (c1Label != c2Label));
-        }
-        return false;
-    }
-
-    /**
-     * For some look and feels check boxs and radio buttons typically
-     * don't paint the border, yet they have padding for a border. 
Look
-     * and feel guidelines generally don't include this space.  Use
-     * this method to subtract this space from the specified
-     * components.
-     *
-     * @param source First component
-     * @param target Second component
-     * @param position Position doing layout along.
-     * @param offset Ideal offset, not including border/margin
-     * @return offset - border/margin around the component.
-     */
-    protected int getButtonGap(JComponent source, JComponent target,
-                               int position, int offset) {
-        offset -= getButtonGap(source, position);
-        if (offset > 0) {
-            offset -= getButtonGap(target, flipDirection(position));
-        }
-        if (offset < 0) {
-            return 0;
-        }
-        return offset;
-    }
-
-    /**
-     * For some look and feels check boxs and radio buttons typically
-     * don't paint the border, yet they have padding for a border. 
Look
-     * and feel guidelines generally don't include this space.  Use
-     * this method to subtract this space from the specified
-     * components.
-     *
-     * @param source Component
-     * @param position Position doing layout along.
-     * @param offset Ideal offset, not including border/margin
-     * @return offset - border/margin around the component.
-     */
-    protected int getButtonGap(JComponent source, int position, int
offset) {
-        offset -= getButtonGap(source, position);
-        return Math.max(offset, 0);
-    }
-
-    /**
-     * If <code>c</code> is a check box or radio button, and the
border is
-     * not painted this returns the inset along the specified axis.
-     */
-    public int getButtonGap(JComponent c, int position) {
-        String classID = c.getUIClassID();
-        if ((classID == "CheckBoxUI" || classID == "RadioButtonUI") &&
-                !((AbstractButton)c).isBorderPainted()) {
-            Border border = c.getBorder();
-            if (border instanceof UIResource) {
-                return getInset(c, position);
-            }
-        }
-        return 0;
-    }
-
-    private void checkPosition(int position) {
-        if (position != SwingConstants.NORTH &&
-                position != SwingConstants.SOUTH &&
-                position != SwingConstants.WEST &&
-                position != SwingConstants.EAST) {
-            throw new IllegalArgumentException();
-        }
-    }
-
-    protected int flipDirection(int position) {
-        switch(position) {
-        case SwingConstants.NORTH:
-            return SwingConstants.SOUTH;
-        case SwingConstants.SOUTH:
-            return SwingConstants.NORTH;
-        case SwingConstants.EAST:
-            return SwingConstants.WEST;
-        case SwingConstants.WEST:
-            return SwingConstants.EAST;
-        }
-        assert false;
-        return 0;
-    }
-
-    /**
-     * Returns the amount to indent the specified component if it's
-     * a JCheckBox or JRadioButton.  If the component is not a
JCheckBox or
-     * JRadioButton, 0 will be returned.
-     */
-    protected int getIndent(JComponent c, int position) {
-        String classID = c.getUIClassID();
-        if (classID == "CheckBoxUI" || classID == "RadioButtonUI") {
-            AbstractButton button = (AbstractButton)c;
-            Insets insets = c.getInsets();
-            Icon icon = getIcon(button);
-            int gap = button.getIconTextGap();
-            if (isLeftAligned(button, position)) {
-                return insets.left + icon.getIconWidth() + gap;
-            } else if (isRightAligned(button, position)) {
-                return insets.right + icon.getIconWidth() + gap;
-            }
-        }
-        return 0;
-    }
-
-    private Icon getIcon(AbstractButton button) {
-        Icon icon = button.getIcon();
-        if (icon != null) {
-            return icon;
-        }
-        String key = null;
-        if (button instanceof JCheckBox) {
-            key = "CheckBox.icon";
-        } else if (button instanceof JRadioButton) {
-            key = "RadioButton.icon";
-        }
-        if (key != null) {
-            Object oIcon = UIManager.get(key);
-            if (oIcon instanceof Icon) {
-                return (Icon)oIcon;
-            }
-        }
-        return null;
-    }
-
-    private boolean isLeftAligned(AbstractButton button, int position)
{
-        if (position == SwingConstants.WEST) {
-            boolean ltr =
button.getComponentOrientation().isLeftToRight();
-            int hAlign = button.getHorizontalAlignment();
-            return ((ltr && (hAlign == SwingConstants.LEFT ||
-                             hAlign == SwingConstants.LEADING)) ||
-                    (!ltr && (hAlign == SwingConstants.TRAILING)));
-        }
-        return false;
-    }
-
-    private boolean isRightAligned(AbstractButton button, int
position) {
-        if (position == SwingConstants.EAST) {
-            boolean ltr =
button.getComponentOrientation().isLeftToRight();
-            int hAlign = button.getHorizontalAlignment();
-            return ((ltr && (hAlign == SwingConstants.RIGHT ||
-                             hAlign == SwingConstants.TRAILING)) ||
-                    (!ltr && (hAlign == SwingConstants.LEADING)));
-        }
-        return false;
-    }
-
-    private int getInset(JComponent c, int position) {
-        return getInset(c.getInsets(), position);
-    }
-
-    private int getInset(Insets insets, int position) {
-        if (insets == null) {
-            return 0;
-        }
-        switch(position) {
-        case SwingConstants.NORTH:
-            return insets.top;
-        case SwingConstants.SOUTH:
-            return insets.bottom;
-        case SwingConstants.EAST:
-            return insets.right;
-        case SwingConstants.WEST:
-            return insets.left;
-        }
-        assert false;
-        return 0;
-    }
-}
Index: Swing 2.0/trunk/src/sun/swing/SwingUtilities2.java
===================================================================
--- Swing 2.0/trunk/src/sun/swing/SwingUtilities2.java  (revision 46)
+++ Swing 2.0/trunk/src/sun/swing/SwingUtilities2.java  (revision 47)
@@ -1,1859 +0,0 @@
-/*
- * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify
it
- * under the terms of the GNU General Public License version 2 only,
as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but
WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License
- * version 2 for more details (a copy is included in the LICENSE file
that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
version
- * 2 along with this work; if not, write to the Free Software
Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
Clara,
- * CA 95054 USA or visit www.sun.com if you need additional
information or
- * have any questions.
- */
-
-package sun.swing;
-
-import java.security.*;
-import java.lang.reflect.*;
-import java.lang.ref.SoftReference;
-import java.awt.*;
-import static java.awt.RenderingHints.*;
-import java.awt.event.*;
-import java.awt.font.*;
-import java.awt.geom.*;
-import java.awt.print.PrinterGraphics;
-import java.text.Bidi;
-import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
-
-import javax.swing.*;
-import javax.swing.plaf.*;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.text.Highlighter;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.DefaultHighlighter;
-import javax.swing.text.DefaultCaret;
-
-import sun.swing.ImageIconUIResource;
-import sun.swing.PrintColorUIResource;
-import sun.print.ProxyPrintGraphics;
-import sun.awt.*;
-import sun.security.action.GetPropertyAction;
-import sun.security.util.SecurityConstants;
-import java.io.*;
-import java.util.*;
-import sun.font.FontDesignMetrics;
-import sun.font.FontManager;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-
-/**
- * A collection of utility methods for Swing.
- * <p>
- * <b>WARNING:</b> While this class is public, it should not be
treated as
- * public API and its API may change in incompatable ways between dot
dot
- * releases and even patch releases. You should not rely on this class
even
- * existing.
- *
- */
-public class SwingUtilities2 {
-    /**
-     * The <code>AppContext</code> key for our one
<code>LAFState</code>
-     * instance.
-     */
-    public static final Object LAF_STATE_KEY =
-            new StringBuffer("LookAndFeel State");
-
-    // Most of applications use 10 or less fonts simultaneously
-    private static final int STRONG_BEARING_CACHE_SIZE = 10;
-    // Strong cache for the left and right side bearings
-    // for STRONG_BEARING_CACHE_SIZE most recently used fonts.
-    private static BearingCacheEntry[] strongBearingCache =
-            new BearingCacheEntry[STRONG_BEARING_CACHE_SIZE];
-    // Next index to insert an entry into the strong bearing cache
-    private static int strongBearingCacheNextIndex = 0;
-    // Soft cache for the left and right side bearings
-    private static Set<SoftReference<BearingCacheEntry>>
softBearingCache =
-            new HashSet<SoftReference<BearingCacheEntry>>();
-
-    public static final FontRenderContext DEFAULT_FRC =
-        new FontRenderContext(null, false, false);
-
-    /**
-     * A JComponent client property is used to determine text aa
settings.
-     * To avoid having this property persist between look and feels
changes
-     * the value of the property is set to null in JComponent.setUI
-     */
-    public static final Object AA_TEXT_PROPERTY_KEY =
-                          new StringBuffer("AATextInfoPropertyKey");
-
-    /**
-     * Used to tell a text component, being used as an editor for
table
-     * or tree, how many clicks it took to start editing.
-     */
-    private static final StringBuilder SKIP_CLICK_COUNT =
-        new StringBuilder("skipClickCount");
-
-    /* Presently this class assumes default fractional metrics.
-     * This may need to change to emulate future platform L&Fs.
-     */
-    public static class AATextInfo {
-
-        private static AATextInfo getAATextInfoFromMap(Map hints) {
-
-            Object aaHint   = hints.get(KEY_TEXT_ANTIALIASING);
-            Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST);
-
-            if (aaHint == null ||
-                aaHint == VALUE_TEXT_ANTIALIAS_OFF ||
-                aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) {
-                return null;
-            } else {
-                return new AATextInfo(aaHint, (Integer)contHint);
-            }
-        }
-
-        public static AATextInfo getAATextInfo(boolean lafCondition) {
-            SunToolkit.setAAFontSettingsCondition(lafCondition);
-            Toolkit tk = Toolkit.getDefaultToolkit();
-            Object map =
tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
-            if (map instanceof Map) {
-                return getAATextInfoFromMap((Map)map);
-            } else {
-                return null;
-            }
-        }
-
-        Object aaHint;
-        Integer lcdContrastHint;
-        FontRenderContext frc;
-
-        /* These are rarely constructed objects, and only when a
complete
-         * UI is being updated, so the cost of the tests here is
minimal
-         * and saves tests elsewhere.
-         * We test that the values are ones we support/expect.
-         */
-        public AATextInfo(Object aaHint, Integer lcdContrastHint) {
-            if (aaHint == null) {
-                throw new InternalError("null not allowed here");
-            }
-            if (aaHint == VALUE_TEXT_ANTIALIAS_OFF ||
-                aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) {
-                throw new InternalError("AA must be on");
-            }
-            this.aaHint = aaHint;
-            this.lcdContrastHint = lcdContrastHint;
-            this.frc = new FontRenderContext(null, aaHint,
-                                            
VALUE_FRACTIONALMETRICS_DEFAULT);
-        }
-    }
-
-    /**
-     * Key used in client properties used to indicate that the
-     * <code>ComponentUI</code> of the JComponent instance should be
returned.
-     */
-    public static final Object COMPONENT_UI_PROPERTY_KEY =
-                            new
StringBuffer("ComponentUIPropertyKey");
-
-    /** Client Property key for the text maximal offsets for
BasicMenuItemUI */
-    public static final StringUIClientPropertyKey
BASICMENUITEMUI_MAX_TEXT_OFFSET =
-        new StringUIClientPropertyKey ("maxTextOffset");
-
-    // security stuff
-    private static Field inputEvent_CanAccessSystemClipboard_Field =
null;
-    private static final String UntrustedClipboardAccess =
-        "UNTRUSTED_CLIPBOARD_ACCESS_KEY";
-
-    //all access to  charsBuffer is to be synchronized on
charsBufferLock
-    private static final int CHAR_BUFFER_SIZE = 100;
-    private static final Object charsBufferLock = new Object();
-    private static char[] charsBuffer = new char[CHAR_BUFFER_SIZE];
-
-    /**
-     * checks whether TextLayout is required to handle characters.
-     *
-     * @param text characters to be tested
-     * @param start start
-     * @param limit limit
-     * @return <tt>true</tt>  if TextLayout is required
-     *         <tt>false</tt> if TextLayout is not required
-     */
-    public static final boolean isComplexLayout(char[] text, int
start, int limit) {
-        return FontManager.isComplexText(text, start, limit);
-    }
-
-    //
-    // WARNING WARNING WARNING WARNING WARNING WARNING
-    // Many of the following methods are invoked from older API.
-    // As this older API was not passed a Component, a null Component
may
-    // now be passsed in.  For example,
SwingUtilities.computeStringWidth
-    // is implemented to call SwingUtilities2.stringWidth, the
-    // SwingUtilities variant does not take a JComponent, as such
-    // SwingUtilities2.stringWidth can be passed a null Component.
-    // In other words, if you add new functionality to these methods
you
-    // need to gracefully handle null.
-    //
-
-    /**
-     * Returns whether or not text should be drawn antialiased.
-     *
-     * @param c JComponent to test.
-     * @return Whether or not text should be drawn antialiased for the
-     *         specified component.
-     */
-    public static AATextInfo drawTextAntialiased(JComponent c) {
-        if (c != null) {
-            /* a non-null property implies some form of AA requested
*/
-            return
(AATextInfo)c.getClientProperty(AA_TEXT_PROPERTY_KEY);
-        }
-        // No component, assume aa is off
-        return null;
-    }
-
-    /**
-     * Returns the left side bearing of the first character of string.
The
-     * left side bearing is calculated from the passed in FontMetrics.
-     *
-     * @param c JComponent that will display the string
-     * @param fm FontMetrics used to measure the String width
-     * @param string String to get the left side bearing for.
-     */
-    public static int getLeftSideBearing(JComponent c, FontMetrics fm,
-                                         String string) {
-        if ((string == null) || (string.length() == 0)) {
-            return 0;
-        }
-        return getLeftSideBearing(c, fm, string.charAt(0));
-    }
-
-    /**
-     * Returns the left side bearing of the specified character. The
-     * left side bearing is calculated from the passed in FontMetrics.
-     *
-     * @param c JComponent that will display the string
-     * @param fm FontMetrics used to measure the String width
-     * @param firstChar Character to get the left side bearing for.
-     */
-    public static int getLeftSideBearing(JComponent c, FontMetrics fm,
-                                         char firstChar) {
-        return getBearing(c, fm, firstChar, true);
-    }
-
-    /**
-     * Returns the right side bearing of the last character of string.
The
-     * right side bearing is calculated from the passed in
FontMetrics.
-     *
-     * @param c JComponent that will display the string
-     * @param fm FontMetrics used to measure the String width
-     * @param string String to get the right side bearing for.
-     */
-    public static int getRightSideBearing(JComponent c, FontMetrics
fm,
-                                          String string) {
-        if ((string == null) || (string.length() == 0)) {
-            return 0;
-        }
-        return getRightSideBearing(c, fm,
string.charAt(string.length() - 1));
-    }
-
-    /**
-     * Returns the right side bearing of the specified character. The
-     * right side bearing is calculated from the passed in
FontMetrics.
-     *
-     * @param c JComponent that will display the string
-     * @param fm FontMetrics used to measure the String width
-     * @param lastChar Character to get the right side bearing for.
-     */
-    public static int getRightSideBearing(JComponent c, FontMetrics
fm,
-                                         char lastChar) {
-        return getBearing(c, fm, lastChar, false);
-    }
-
-    /* Calculates the left and right side bearing for a character.
-     * Strongly caches bearings for STRONG_BEARING_CACHE_SIZE
-     * most recently used Fonts and softly caches as many as GC
allows.
-     */
-    private static int getBearing(JComponent comp, FontMetrics fm,
char c,
-                                  boolean isLeftBearing) {
-        if (fm == null) {
-            if (comp == null) {
-                return 0;
-            } else {
-                fm = comp.getFontMetrics(comp.getFont());
-            }
-        }
-        synchronized (SwingUtilities2.class) {
-            BearingCacheEntry entry = null;
-            BearingCacheEntry searchKey = new BearingCacheEntry(fm);
-            // See if we already have an entry in the strong cache
-            for (BearingCacheEntry cacheEntry : strongBearingCache) {
-                if (searchKey.equals(cacheEntry)) {
-                    entry = cacheEntry;
-                    break;
-                }
-            }
-            // See if we already have an entry in the soft cache
-            if (entry == null) {
-                Iterator<SoftReference<BearingCacheEntry>> iter =
-                        softBearingCache.iterator();
-                while (iter.hasNext()) {
-                    BearingCacheEntry cacheEntry = iter.next().get();
-                    if (cacheEntry == null) {
-                        // Remove discarded soft reference from the
cache
-                        iter.remove();
-                        continue;
-                    }
-                    if (searchKey.equals(cacheEntry)) {
-                        entry = cacheEntry;
-                        putEntryInStrongCache(entry);
-                        break;
-                    }
-                }
-            }
-            if (entry == null) {
-                // No entry, add it
-                entry = searchKey;
-                cacheEntry(entry);
-            }
-            return (isLeftBearing)
-                    ? entry.getLeftSideBearing(c)
-                    : entry.getRightSideBearing(c);
-        }
-    }
-
-    private synchronized static void cacheEntry(BearingCacheEntry
entry) {
-        // Move the oldest entry from the strong cache into the soft
cache
-        BearingCacheEntry oldestEntry =
-                strongBearingCache[strongBearingCacheNextIndex];
-        if (oldestEntry != null) {
-            softBearingCache.add(new
SoftReference<BearingCacheEntry>(oldestEntry));
-        }
-        // Put entry in the strong cache
-        putEntryInStrongCache(entry);
-    }
-
-    private synchronized static void
putEntryInStrongCache(BearingCacheEntry entry) {
-        strongBearingCache[strongBearingCacheNextIndex] = entry;
-        strongBearingCacheNextIndex = (strongBearingCacheNextIndex +
1)
-                % STRONG_BEARING_CACHE_SIZE;
-    }
-
-    /**
-     * Returns the FontMetrics for the current Font of the passed
-     * in Graphics.  This method is used when a Graphics
-     * is available, typically when painting.  If a Graphics is not
-     * available the JComponent method of the same name should be
used.
-     * <p>
-     * Callers should pass in a non-null JComponent, the exception
-     * to this is if a JComponent is not readily available at the time
of
-     * painting.
-     * <p>
-     * This does not necessarily return the FontMetrics from the
-     * Graphics.
-     *
-     * @param c JComponent requesting FontMetrics, may be null
-     * @param g Graphics Graphics
-     */
-    public static FontMetrics getFontMetrics(JComponent c, Graphics g)
{
-        return getFontMetrics(c, g, g.getFont());
-    }
-
-
-    /**
-     * Returns the FontMetrics for the specified Font.
-     * This method is used when a Graphics is available, typically
when
-     * painting.  If a Graphics is not available the JComponent method
of
-     * the same name should be used.
-     * <p>
-     * Callers should pass in a non-null JComonent, the exception
-     * to this is if a JComponent is not readily available at the time
of
-     * painting.
-     * <p>
-     * This does not necessarily return the FontMetrics from the
-     * Graphics.
-     *
-     * @param c JComponent requesting FontMetrics, may be null
-     * @param c Graphics Graphics
-     * @param font Font to get FontMetrics for
-     */
-    public static FontMetrics getFontMetrics(JComponent c, Graphics g,
-                                             Font font) {
-        if (c != null) {
-            // Note: We assume that we're using the FontMetrics
-            // from the widget to layout out text, otherwise we can
get
-            // mismatches when printing.
-            return c.getFontMetrics(font);
-        }
-        return Toolkit.getDefaultToolkit().getFontMetrics(font);
-    }
-
-
-    /**
-     * Returns the width of the passed in String.
-     * If the passed String is <code>null</code>, returns zero.
-     *
-     * @param c JComponent that will display the string, may be null
-     * @param fm FontMetrics used to measure the String width
-     * @param string String to get the width of
-     */
-    public static int stringWidth(JComponent c, FontMetrics fm, String
string){
-        if (string == null || string.equals("")) {
-            return 0;
-        }
-        return fm.stringWidth(string);
-    }
-
-
-    /**
-     * Clips the passed in String to the space provided.
-     *
-     * @param c JComponent that will display the string, may be null
-     * @param fm FontMetrics used to measure the String width
-     * @param string String to display
-     * @param availTextWidth Amount of space that the string can be
drawn in
-     * @return Clipped string that can fit in the provided space.
-     */
-    public static String clipStringIfNecessary(JComponent c,
FontMetrics fm,
-                                               String string,
-                                               int availTextWidth) {
-        if ((string == null) || (string.equals("")))  {
-            return "";
-        }
-        int textWidth = SwingUtilities2.stringWidth(c, fm, string);
-        if (textWidth > availTextWidth) {
-            return SwingUtilities2.clipString(c, fm, string,
availTextWidth);
-        }
-        return string;
-    }
-
-
-    /**
-     * Clips the passed in String to the space provided.  NOTE: this
assumes
-     * the string does not fit in the available space.
-     *
-     * @param c JComponent that will display the string, may be null
-     * @param fm FontMetrics used to measure the String width
-     * @param string String to display
-     * @param availTextWidth Amount of space that the string can be
drawn in
-     * @return Clipped string that can fit in the provided space.
-     */
-    public static String clipString(JComponent c, FontMetrics fm,
-                                    String string, int availTextWidth)
{
-        // c may be null here.
-        String clipString = "...";
-        int stringLength = string.length();
-        availTextWidth -= SwingUtilities2.stringWidth(c, fm,
clipString);
-        if (availTextWidth <= 0) {
-            //can not fit any characters
-            return clipString;
-        }
-
-        boolean needsTextLayout = false;
-
-        synchronized (charsBufferLock) {
-            if (charsBuffer == null || charsBuffer.length <
stringLength) {
-                charsBuffer  = string.toCharArray();
-            } else {
-                string.getChars(0, stringLength, charsBuffer, 0);
-            }
-            needsTextLayout =
-                isComplexLayout(charsBuffer, 0, stringLength);
-            if (!needsTextLayout) {
[trimmed for length]


[svn:47] Partial success at refactoring - all compiles.

JonathanGiles 02/27/2009
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close