harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r555606 [2/3] - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/synth/ main/java/common/org/apache/harmony/x/swing/internal/nls/ test/api/java.injected/javax/swing/plaf/synth/
Date Thu, 12 Jul 2007 12:07:18 GMT
Added: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/PaintersManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/PaintersManager.java?view=auto&rev=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/PaintersManager.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/PaintersManager.java Thu Jul 12 05:07:16 2007
@@ -0,0 +1,1041 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.swing.plaf.synth;
+
+import java.awt.Graphics;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * PaintersManager is a SynthPainter used to combine all the painters described
+ * in XML file. This class is similar to ColorInfo and FontInfo (inner classes
+ * in XMLSynthStyle) but placed separately because contains a lot of methods and
+ * the functionality is differs from just "info" functionality
+ */
+@SuppressWarnings("nls")
+class PaintersManager extends SynthPainter {
+
+    public static final int NO_DIRECTION = -1;
+
+    /**
+     * PainterInfo for the search.
+     */
+    private static class SynthPainterInfo {
+
+        private final String method;
+
+        private final int direction;
+
+        private final int state;
+
+        private final SynthPainter painter;
+
+        SynthPainterInfo(String method, int direction, int state,
+                SynthPainter painter) {
+            this.method = method;
+            this.direction = direction;
+            this.state = state;
+            this.painter = painter;
+        }
+
+        String getMethod() {
+            return method;
+        }
+
+        int getDirection() {
+            return direction;
+        }
+
+        int getState() {
+            return state;
+        }
+
+        SynthPainter getPainter() {
+            return painter;
+        }
+
+        boolean betterThan(SynthPainterInfo candidate, int refState,
+                String refMethod, int refDirection) {
+
+            if (this.method.equalsIgnoreCase(refMethod)
+                    || this.method.equals("default")) {
+
+                if (stateBetterThan(candidate.getState(), refState)) {
+                    if ((this.direction == refDirection)
+                            || (this.direction == -1)) {
+                        return true;
+                    }
+
+                }
+
+            }
+
+            return false;
+        }
+
+        boolean stateBetterThan(int candidateState, int refState) {
+            if (((~refState) & (this.state)) == 0) {
+                if (((~refState) & (candidateState)) == 0) {
+                    return refState >= candidateState;
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+
+    private final List<SynthPainterInfo> painters = new LinkedList<SynthPainterInfo>();
+
+    private final SynthPainterInfo firstCandidate = new SynthPainterInfo(
+            "default", -1, 0, new ColorPainter()); //$NON-NLS-1$
+
+    public SynthPainter findPainter(int state, String method, int direction) {
+        SynthPainterInfo bestCandidate = firstCandidate;
+        for (SynthPainterInfo candidate : painters) {
+            if (candidate.betterThan(bestCandidate, state, method, direction)) {
+                bestCandidate = candidate;
+            }
+        }
+        return bestCandidate.getPainter();
+    }
+
+    public void setPainter(SynthPainter painter, int state, String method,
+            int direction) {
+        painters.add(new SynthPainterInfo(method, direction, state, painter));
+    }
+
+    @Override
+    public void paintArrowButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ArrowButtonBorder", -1)
+                .paintArrowButtonBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintArrowButtonForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int direction) {
+
+        findPainter(context.getComponentState(), "ArrowButtonForeground",
+                direction).paintArrowButtonForeground(context, g, x, y, w, h,
+                direction);
+
+    }
+
+    @Override
+    public void paintButtonBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ButtonBackground", -1)
+                .paintButtonBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ButtonBorder", -1)
+                .paintButtonBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintCheckBoxBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "CheckBoxBackground", -1)
+                .paintCheckBoxBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintCheckBoxBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "CheckBoxBorder", -1)
+                .paintCheckBoxBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintCheckBoxMenuItemBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "CheckBoxMenuItemBackground",
+                -1).paintCheckBoxMenuItemBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintCheckBoxMenuItemBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "CheckBoxMenuItemBorder", -1)
+                .paintCheckBoxMenuItemBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintColorChooserBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ColorChooserBackground", -1)
+                .paintColorChooserBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintColorChooserBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ColorChooserBorder", -1)
+                .paintColorChooserBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintComboBoxBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ComboBoxBackground", -1)
+                .paintComboBoxBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintComboBoxBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ComboBoxBorder", -1)
+                .paintComboBoxBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintDesktopIconBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "DesktopIconBackground", -1)
+                .paintDesktopIconBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintDesktopIconBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "DesktopIconBorder", -1)
+                .paintDesktopIconBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintDesktopPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "DesktopPaneBackground", -1)
+                .paintDesktopPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintDesktopPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "DesktopPaneBorder", -1)
+                .paintDesktopPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintEditorPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "EditorPaneBackground", -1)
+                .paintEditorPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintEditorPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "EditorPaneBorder", -1)
+                .paintEditorPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintFileChooserBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "FileChooserBackground", -1)
+                .paintFileChooserBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintFileChooserBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "FileChooserBorder", -1)
+                .paintFileChooserBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintFormattedTextFieldBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(),
+                "FormattedTextFieldBackground", -1)
+                .paintFormattedTextFieldBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintFormattedTextFieldBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "FormattedTextFieldBorder", -1)
+                .paintFormattedTextFieldBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintInternalFrameBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "InternalFrameBackground", -1)
+                .paintInternalFrameBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintInternalFrameBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "InternalFrameBorder", -1)
+                .paintInternalFrameBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintInternalFrameTitlePaneBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(),
+                "InternalFrameTitlePaneBackground", -1)
+                .paintInternalFrameTitlePaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintInternalFrameTitlePaneBorder(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(),
+                "InternalFrameTitlePaneBorder", -1)
+                .paintInternalFrameTitlePaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintLabelBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "LabelBackground", -1)
+                .paintLabelBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintLabelBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "LabelBorder", -1)
+                .paintLabelBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintListBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ListBackground", -1)
+                .paintListBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintListBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+
+        findPainter(context.getComponentState(), "ListBorder", -1)
+                .paintListBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuBackground", -1)
+                .paintMenuBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuBarBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuBarBackground", -1)
+                .paintMenuBarBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuBarBorder", -1)
+                .paintMenuBarBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuBorder", -1)
+                .paintMenuBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuItemBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuItemBackground", -1)
+                .paintMenuItemBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintMenuItemBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "MenuItemBorder", -1)
+                .paintMenuItemBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintOptionPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "OptionPaneBackground", -1)
+                .paintOptionPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintOptionPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "OptionPaneBorder", -1)
+                .paintOptionPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPanelBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PanelBackground", -1)
+                .paintPanelBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPanelBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PanelBorder", -1)
+                .paintPanelBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPasswordFieldBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PasswordFieldBackground", -1)
+                .paintPasswordFieldBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPasswordFieldBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PasswordFieldBorder", -1)
+                .paintPasswordFieldBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPopupMenuBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PopupMenuBackground", -1)
+                .paintPopupMenuBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintPopupMenuBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "PopupMenuBorder", -1)
+                .paintPopupMenuBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintProgressBarBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ProgressBarBackground", -1)
+                .paintProgressBarBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintProgressBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ProgressBarBorder", -1)
+                .paintProgressBarBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintProgressBarForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(),
+                "ProgressBarForegroundPainter", orientation)
+                .paintProgressBarForeground(context, g, x, y, w, h, orientation);
+
+    }
+
+    @Override
+    public void paintRadioButtonBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "RadioButtonBackground", -1)
+                .paintRadioButtonBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintRadioButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "RadioButtonBorder", -1)
+                .paintRadioButtonBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintRadioButtonMenuItemBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(),
+                "RadioButtonMenuItemBackground", -1)
+                .paintRadioButtonMenuItemBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintRadioButtonMenuItemBorder(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "RadioButtonMenuItemBorder",
+                -1).paintRadioButtonMenuItemBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintRootPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "RootPaneBackground", -1)
+                .paintRootPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintRootPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "RootPaneBorder", -1)
+                .paintRootPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollBarBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollBarBackground", -1)
+                .paintScrollBarBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollBarBorder", -1)
+                .paintScrollBarBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollBarThumbBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(),
+                "ScrollBarThumbBackgroundPainter", orientation)
+                .paintScrollBarThumbBackground(context, g, x, y, w, h,
+                        orientation);
+
+    }
+
+    @Override
+    public void paintScrollBarThumbBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(), "ScrollBarThumbBorderPainter",
+                orientation).paintScrollBarThumbBorder(context, g, x, y, w, h,
+                orientation);
+
+    }
+
+    @Override
+    public void paintScrollBarTrackBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollBarTrackBackground", -1)
+                .paintScrollBarTrackBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollBarTrackBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollBarTrackBorder", -1)
+                .paintScrollBarTrackBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollPaneBackground", -1)
+                .paintScrollPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintScrollPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ScrollPaneBorder", -1)
+                .paintScrollPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSeparatorBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SeparatorBackground", -1)
+                .paintSeparatorBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSeparatorBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SeparatorBorder", -1)
+                .paintSeparatorBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSeparatorForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        findPainter(context.getComponentState(), "SeparatorForegroundPainter",
+                orientation).paintSeparatorForeground(context, g, x, y, w, h,
+                orientation);
+
+    }
+
+    @Override
+    public void paintSliderBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SliderBackground", -1)
+                .paintSliderBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSliderBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SliderBorder", -1)
+                .paintSliderBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSliderThumbBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(),
+                "SliderThumbBackgroundPainter", orientation)
+                .paintSliderThumbBackground(context, g, x, y, w, h, orientation);
+
+    }
+
+    @Override
+    public void paintSliderThumbBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(), "SliderThumbBorderPainter",
+                orientation).paintSliderThumbBorder(context, g, x, y, w, h,
+                orientation);
+
+    }
+
+    @Override
+    public void paintSliderTrackBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SliderTrackBackground", -1)
+                .paintSliderTrackBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSliderTrackBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SliderTrackBorder", -1)
+                .paintSliderTrackBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSpinnerBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SpinnerBackground", -1)
+                .paintSpinnerBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSpinnerBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SpinnerBorder", -1)
+                .paintSpinnerBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSplitPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SplitPaneBackground", -1)
+                .paintSplitPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSplitPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SplitPaneBorder", -1)
+                .paintSplitPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSplitPaneDividerBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "SplitPaneDividerBackground",
+                -1).paintSplitPaneDividerBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintSplitPaneDividerForeground(SynthContext context,
+            Graphics g, int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(),
+                "SplitPaneDividerForegroundPainter", orientation)
+                .paintSplitPaneDividerForeground(context, g, x, y, w, h,
+                        orientation);
+
+    }
+
+    @Override
+    public void paintSplitPaneDragDivider(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+
+        findPainter(context.getComponentState(), "SplitPaneDragDividerPainter",
+                orientation).paintSplitPaneDragDivider(context, g, x, y, w, h,
+                orientation);
+
+    }
+
+    @Override
+    public void paintTabbedPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneBackground", -1)
+                .paintTabbedPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneBorder", -1)
+                .paintTabbedPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneContentBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneContentBackground",
+                -1).paintTabbedPaneContentBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneContentBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneContentBorder", -1)
+                .paintTabbedPaneContentBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneTabAreaBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneTabBackground", -1)
+                .paintTabbedPaneTabAreaBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneTabAreaBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TabbedPaneTabAreaBorder", -1)
+                .paintTabbedPaneTabAreaBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTabbedPaneTabBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int tabIndex) {
+
+        findPainter(context.getComponentState(), "TabbedPaneTabBackground", -1)
+                .paintTabbedPaneTabBackground(context, g, x, y, w, h, tabIndex);
+    }
+
+    @Override
+    public void paintTabbedPaneTabBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int tabIndex) {
+
+        findPainter(context.getComponentState(), "TabbedPaneTabBorder", -1)
+                .paintTabbedPaneTabBorder(context, g, x, y, w, h, tabIndex);
+    }
+
+    @Override
+    public void paintTableBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TableBackground", -1)
+                .paintTableBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTableBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TableBorder", -1)
+                .paintTableBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTableHeaderBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TableHeaderBackground", -1)
+                .paintTableHeaderBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTableHeaderBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TableHeaderBorder", -1)
+                .paintTableHeaderBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextAreaBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextAreaBackground", -1)
+                .paintTextAreaBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextAreaBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextAreaBorder", -1)
+                .paintTextAreaBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextFieldBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextFieldBackground", -1)
+                .paintTextFieldBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextFieldBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextFieldBorder", -1)
+                .paintTextFieldBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextPaneBackground", -1)
+                .paintTextPaneBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTextPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TextPaneBorder", -1)
+                .paintTextPaneBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToggleButtonBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToggleButtonBackground", -1)
+                .paintToggleButtonBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToggleButtonBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToggleButtonBorder", -1)
+                .paintToggleButtonBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarBackground", -1)
+                .paintToolBarBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarBorder", -1)
+                .paintToolBarBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarContentBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarContentBackground", -1)
+                .paintToolBarContentBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarContentBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarContentBorder", -1)
+                .paintToolBarContentBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarDragWindowBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarDragWindowBackground",
+                -1).paintToolBarDragWindowBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolBarDragWindowBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolBarDragWindowBorder", -1)
+                .paintToolBarDragWindowBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolTipBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolTipBackground", -1)
+                .paintToolTipBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintToolTipBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ToolTipBorder", -1)
+                .paintToolTipBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTreeBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TreeBackground", -1)
+                .paintTreeBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTreeBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+
+        findPainter(context.getComponentState(), "TreeBorder", -1)
+                .paintTreeBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTreeCellBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TreeCellBackground", -1)
+                .paintTreeCellBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTreeCellBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TreeCellBorder", -1)
+                .paintTreeCellBorder(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintTreeCellFocus(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "TreeCellFocus", -1)
+                .paintTreeCellFocus(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintViewportBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ViewportBackground", -1)
+                .paintViewportBackground(context, g, x, y, w, h);
+    }
+
+    @Override
+    public void paintViewportBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+
+        findPainter(context.getComponentState(), "ViewportBorder", -1)
+                .paintViewportBorder(context, g, x, y, w, h);
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/PaintersManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java Thu Jul 12 05:07:16 2007
@@ -210,9 +210,10 @@
      */
     static Region getRegionFromUIID(String ui) {
 
+        // Possible improvement:
         // This method creates additional object(substring) but possibly faster
         // way is the creating two HashMaps that contains the same values but
-        // the different keys: ui and name
+        // the different keys: UI and name
         return regionsMap.get(ui.substring(0, (ui.length() - 2)));
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java Thu Jul 12 05:07:16 2007
@@ -24,7 +24,7 @@
  */
 public interface SynthConstants {
 
-    /** The component (usual a button) is marked as default (additional) */
+    /** The component (a JButton) is marked as default (additional) */
     static int DEFAULT = 1024;
 
     /** The component is disabled (primary) */

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java Thu Jul 12 05:07:16 2007
@@ -125,4 +125,16 @@
     static boolean isSelected(int verifiedState) {
         return (verifiedState & SynthConstants.SELECTED) != 0;
     }
+    
+    /**
+     * Used in UI's. Created to reduce code doubling
+     * */
+    static int getCommonComponentState(JComponent c) {
+        int result = c.isEnabled() ? SynthConstants.ENABLED
+                : SynthConstants.DISABLED;
+        if (c.isFocusOwner()) {
+            result |= SynthConstants.FOCUSED;
+        }
+        return result;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java Thu Jul 12 05:07:16 2007
@@ -76,17 +76,15 @@
     @SuppressWarnings("unused")
     public void drawLine(SynthContext context, Object paintKey, Graphics g,
             int x1, int y1, int x2, int y2) {
-        Color oldColor = g.getColor();
         g.setColor(context.getStyle().getColor(context, ColorType.FOREGROUND));
         g.drawLine(x1, y1, x2, y2);
-        g.setColor(oldColor);
     }
 
     /**
      * Calculates the maximum size for the component with given parameters
      */
     @SuppressWarnings("unused")
-    public Dimension getMaximumSize(SynthContext ss, Font font, String text,
+    public Dimension getPreferredSize(SynthContext ss, Font font, String text,
             Icon icon, int hAlign, int vAlign, int hTextPosition,
             int vTextPosition, int iconTextGap, int mnemonicIndex) {
 
@@ -105,18 +103,18 @@
             Icon icon, int hAlign, int vAlign, int hTextPosition,
             int vTextPosition, int iconTextGap, int mnemonicIndex) {
 
-        return getMaximumSize(ss, font, text, icon, hAlign, vAlign,
+        return getPreferredSize(ss, font, text, icon, hAlign, vAlign,
                 hTextPosition, vTextPosition, iconTextGap, mnemonicIndex);
     }
 
     /**
      * Calculates the preferred size for the component with given parameters
      */
-    public Dimension getPreferredSize(SynthContext ss, Font font, String text,
+    public Dimension getMaximumSize(SynthContext ss, Font font, String text,
             Icon icon, int hAlign, int vAlign, int hTextPosition,
             int vTextPosition, int iconTextGap, int mnemonicIndex) {
 
-        return getMaximumSize(ss, font, text, icon, hAlign, vAlign,
+        return getPreferredSize(ss, font, text, icon, hAlign, vAlign,
                 hTextPosition, vTextPosition, iconTextGap, mnemonicIndex);
     }
 
@@ -126,7 +124,7 @@
     public String layoutText(SynthContext ss, FontMetrics fm, String text,
             Icon icon, int hAlign, int vAlign, int hTextPosition,
             int vTextPosition, Rectangle viewR, Rectangle iconR,
-            final Rectangle textR, int iconTextGap) {
+            Rectangle textR, int iconTextGap) {
 
         fm = computeFontMetrics(ss, fm);
 
@@ -153,11 +151,11 @@
         layoutText(ss, metrics, text, icon, hAlign, vAlign, hTextPosition,
                 vTextPosition, viewR, iconR, textR, iconTextGap);
 
-        textR.x += textOffset;
-        textR.y += textOffset;
+        textR.translate(textOffset, textOffset);
 
         ButtonCommons.paintText(g, metrics, text, mnemonicIndex, textR, text,
                 color);
+
     }
 
     public void paintText(SynthContext ss, Graphics g, String text, int x,
@@ -225,7 +223,10 @@
 
         if (!Utilities.isEmptyString(text)) {
             Dimension stringDim = Utilities.getStringSize(text, fm);
-            return new Rectangle(stringDim.width, Utilities.getTextY(fm, new Rectangle(stringDim)));
+            Dimension size = new Dimension(stringDim.width, Utilities.getTextY(
+                    fm, new Rectangle(stringDim)));
+
+            return new Rectangle(size);
         }
 
         return new Rectangle();
@@ -243,6 +244,7 @@
         SwingUtilities.layoutCompoundLabel(fm, text, icon, SwingConstants.TOP,
                 SwingConstants.LEFT, verticalTextPosition,
                 horizontalTextPosition, viewR, iconR, textR, iconTextGap);
+
         result.width = Math.max(iconR.x + iconR.width, textR.x + textR.width);
         result.height = Math
                 .max(iconR.y + iconR.height, textR.y + textR.height);

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java Thu Jul 12 05:07:16 2007
@@ -18,6 +18,7 @@
 package javax.swing.plaf.synth;
 
 import java.awt.Component;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.text.ParseException;
@@ -26,13 +27,19 @@
 import javax.swing.UIDefaults;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicLookAndFeel;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 
-import org.apache.harmony.luni.util.NotImplementedException;
 import org.apache.harmony.x.swing.internal.nls.Messages;
+import org.xml.sax.SAXException;
+
+import org.apache.harmony.luni.util.NotImplementedException;
 
 public class SynthLookAndFeel extends BasicLookAndFeel implements Serializable {
 
-    private final static String packageName = "javax.swing.plaf.synth";
+    /** Path used in UIDefaults */
+    private final static String pathToSynthLaf = "javax.swing.plaf.synth.SynthLookAndFeel"; //$NON-NLS-1$
 
     private static SynthStyleFactory currentFactory;
 
@@ -53,31 +60,116 @@
     }
 
     /**
-     * Creates the Synth UI object corresponds JComponent given
+     * Creates the Synth UI object corresponds JComponent given. (This method
+     * used by UIManager because all the UIs classes are package-protected
+     * according to spec, so reference in defaults table points to
+     * SynthLookAndFeel)
+     * 
+     * @see SynthLookAndFeel#initClassDefaults(UIDefaults)
      */
-    public static ComponentUI createUI(JComponent c) {
-
-        try {
-
-            return (ComponentUI) Class.forName(packageName + c.getUIClassID(),
-                    true, Thread.currentThread().getContextClassLoader())
-                    .getMethod("createUI", JComponent.class).invoke(null, c); //$NON-NLS-1$
+    @SuppressWarnings("nls")
+    public static ComponentUI createUI(JComponent c)
+            throws NotImplementedException {
 
-        } catch (Exception e) {
+        // Commented because UI's patch is not ready for now
 
-            return null;
-        }
+        // String uiClassID = c.getUIClassID().intern();
+        //
+        // if (uiClassID == "InternalFrameUI") {
+        // return SynthInternalFrameUI.createUI(c);
+        // } else if (uiClassID == "ViewportUI") {
+        // return SynthViewportUI.createUI(c);
+        // } else if (uiClassID == "ScrollBarUI") {
+        // SynthScrollBarUI.createUI(c);
+        // } else if (uiClassID == "ToolTipUI") {
+        // return SynthToolTipUI.createUI(c);
+        // } else if (uiClassID == "MenuItemUI") {
+        // return SynthMenuItemUI.createUI(c);
+        // } else if (uiClassID == "MenuUI") {
+        // return SynthMenuUI.createUI(c);
+        // } else if (uiClassID == "TextAreaUI") {
+        // return SynthTextAreaUI.createUI(c);
+        // } else if (uiClassID == "PopupMenuUI") {
+        // return SynthPopupMenuUI.createUI(c);
+        // } else if (uiClassID == "ScrollPaneUI") {
+        // return SynthScrollPaneUI.createUI(c);
+        // } else if (uiClassID == "SliderUI") {
+        // return SynthSliderUI.createUI(c);
+        // } else if (uiClassID == "ComboBoxUI") {
+        // return SynthComboBoxUI.createUI(c);
+        // } else if (uiClassID == "RadioButtonUI") {
+        // return SynthRadioButtonUI.createUI(c);
+        // } else if (uiClassID == "FormattedTextFieldUI") {
+        // return SynthFormattedTextFieldUI.createUI(c);
+        // } else if (uiClassID == "TreeUI") {
+        // return SynthTreeUI.createUI(c);
+        // } else if (uiClassID == "MenuBarUI") {
+        // return SynthMenuBarUI.createUI(c);
+        // } else if (uiClassID == "RadioButtonMenuItemUI") {
+        // return SynthRadioButtonMenuItemUI.createUI(c);
+        // } else if (uiClassID == "ProgressBarUI") {
+        // return SynthProgressBarUI.createUI(c);
+        // } else if (uiClassID == "ToolBarUI") {
+        // return SynthToolBarUI.createUI(c);
+        // } else if (uiClassID == "ColorChooserUI") {
+        // return SynthColorChooserUI.createUI(c);
+        // } else if (uiClassID == "ToolBarSeparatorUI") {
+        // return SynthToolBarSeparatorUI.createUI(c);
+        // } else if (uiClassID == "TabbedPaneUI") {
+        // return SynthTabbedPaneUI.createUI(c);
+        // } else if (uiClassID == "DesktopPaneUI") {
+        // return SynthDesktopPaneUI.createUI(c);
+        // } else if (uiClassID == "TableUI") {
+        // return SynthTableUI.createUI(c);
+        // } else if (uiClassID == "PanelUI") {
+        // return SynthPanelUI.createUI(c);
+        // } else if (uiClassID == "CheckBoxMenuItemUI") {
+        // return SynthCheckBoxMenuItemUI.createUI(c);
+        // } else if (uiClassID == "PasswordFieldUI") {
+        // return SynthPasswordFieldUI.createUI(c);
+        // } else if (uiClassID == "CheckBoxUI") {
+        // return SynthCheckBoxUI.createUI(c);
+        // } else if (uiClassID == "TableHeaderUI") {
+        // return SynthTableHeaderUI.createUI(c);
+        // } else if (uiClassID == "SplitPaneUI") {
+        // return SynthSplitPaneUI.createUI(c);
+        // } else if (uiClassID == "EditorPaneUI") {
+        // return SynthEditorPaneUI.createUI(c);
+        // } else if (uiClassID == "ListUI") {
+        // return SynthListUI.createUI(c);
+        // } else if (uiClassID == "SpinnerUI") {
+        // return SynthSpinnerUI.createUI(c);
+        // } else if (uiClassID == "DesktopIconUI") {
+        // return SynthDesktopIconUI.createUI(c);
+        // } else if (uiClassID == "TextFieldUI") {
+        // return SynthTextFieldUI.createUI(c);
+        // } else if (uiClassID == "TextPaneUI") {
+        // return SynthTextPaneUI.createUI(c);
+        // } else if (uiClassID == "ButtonUI") {
+        // return SynthButtonUI.createUI(c);
+        // } else if (uiClassID == "LabelUI") {
+        // return SynthLabelUI.createUI(c);
+        // } else if (uiClassID == "ToggleButtonUI") {
+        // SynthToggleButtonUI.createUI(c);
+        // } else if (uiClassID == "OptionPaneUI") {
+        // return SynthOptionPaneUI.createUI(c);
+        // } else if (uiClassID == "PopupMenuSeparatorUI") {
+        // return SynthPopupMenuSeparatorUI.createUI(c);
+        // } else if (uiClassID == "RootPaneUI") {
+        // return SynthRootPaneUI.createUI(c);
+        // } else if (uiClassID == "SeparatorUI") {
+        // return SynthSeparatorUI.createUI(c);
+        // }
+        // compatible with RI
+        return null;
     }
 
     /**
      * Renew the synth styles for the JComponent. This method isn't fully
-     * correct, but does what needs
+     * correct, but does what needs (The method is unused in package)
      */
     public static void updateStyles(Component c) {
-
-        if (c instanceof JComponent) {
-            ((JComponent) c).revalidate();
-        }
+        c.setName(c.getName() + " "); //$NON-NLS-1$
     }
 
     /**
@@ -142,11 +234,26 @@
 
     @SuppressWarnings("unused")
     public void load(InputStream input, Class<?> resourceBase)
-            throws NotImplementedException, ParseException,
-            IllegalArgumentException {
-        /*
-         * This class will be implemented with XMLSynthParser
-         */
+            throws ParseException, IllegalArgumentException {
+
+        if (input == null || resourceBase == null) {
+            throw new IllegalArgumentException(Messages
+                    .getString("swing.err.1D")); //$NON-NLS-1$
+        }
+
+        try {
+
+            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser.parse(input, new XMLSynthParser(resourceBase));
+
+        } catch (ParserConfigurationException e) {
+            throw new ParseException(e.getMessage(), 0);
+        } catch (SAXException e) {
+            e.printStackTrace();
+            throw new ParseException(e.getMessage(), 0);
+        } catch (IOException e) {
+            throw new ParseException(e.getMessage(), 0);
+        }
     }
 
     /** The default implementation returns false */
@@ -158,49 +265,30 @@
     @SuppressWarnings("nls")
     @Override
     protected void initClassDefaults(UIDefaults defaults) {
-        Object[] initDefaults = { "InternalFrameUI",
-                packageName + "SynthInternalFrameUI", "ViewportUI",
-                packageName + "SynthViewportUI", "ScrollBarUI",
-                packageName + "SynthScrollBarUI", "ToolTipUI",
-                packageName + "SynthToolTipUI", "MenuItemUI",
-                packageName + "SynthMenuItemUI", "MenuUI",
-                packageName + "SynthMenuUI", "TextAreaUI",
-                packageName + "SynthTextAreaUI", "PopupMenuUI",
-                packageName + "SynthPopupMenuUI", "ScrollPaneUI",
-                packageName + "SynthScrollPaneUI", "SliderUI",
-                packageName + "SynthSliderUI", "ComboBoxUI",
-                packageName + "SynthComboBoxUI", "RadioButtonUI",
-                packageName + "SynthRadioButtonUI", "FormattedTextFieldUI",
-                packageName + "SynthFormattedTextFieldUI", "TreeUI",
-                packageName + "SynthTreeUI", "MenuBarUI",
-                packageName + "SynthMenuBarUI", "RadioButtonMenuItemUI",
-                packageName + "SynthRadioButtonMenuItemUI", "ProgressBarUI",
-                packageName + "SynthProgressBarUI", "ToolBarUI",
-                packageName + "SynthToolBarUI", "ColorChooserUI",
-                packageName + "SynthColorChooserUI", "ToolBarSeparatorUI",
-                packageName + "SynthToolBarSeparatorUI", "TabbedPaneUI",
-                packageName + "SynthTabbedPaneUI", "DesktopPaneUI",
-                packageName + "SynthDesktopPaneUI", "TableUI",
-                packageName + "SynthTableUI", "PanelUI",
-                packageName + "SynthPanelUI", "CheckBoxMenuItemUI",
-                packageName + "SynthCheckBoxMenuItemUI", "PasswordFieldUI",
-                packageName + "SynthPasswordFieldUI", "CheckBoxUI",
-                packageName + "SynthCheckBoxUI", "TableHeaderUI",
-                packageName + "SynthTableHeaderUI", "SplitPaneUI",
-                packageName + "SynthSplitPaneUI", "EditorPaneUI",
-                packageName + "SynthEditorPaneUI", "ListUI",
-                packageName + "SynthListUI", "SpinnerUI",
-                packageName + "SynthSpinnerUI", "DesktopIconUI",
-                packageName + "SynthDesktopIconUI", "TextFieldUI",
-                packageName + "SynthTextFieldUI", "TextPaneUI",
-                packageName + "SynthTextPaneUI", "LabelUI",
-                packageName + "SynthLabelUI", "ButtonUI",
-                packageName + "SynthButtonUI", "ToggleButtonUI",
-                packageName + "SynthToggleButtonUI", "OptionPaneUI",
-                packageName + "SynthOptionPaneUI", "PopupMenuSeparatorUI",
-                packageName + "SynthPopupMenuSeparatorUI", "RootPaneUI",
-                packageName + "SynthRootPaneUI", "SeparatorUI",
-                packageName + "SynthSeparatorUI" };
+        Object[] initDefaults = { "InternalFrameUI", pathToSynthLaf,
+                "ViewportUI", pathToSynthLaf, "ScrollBarUI", pathToSynthLaf,
+                "ToolTipUI", pathToSynthLaf, "MenuItemUI", pathToSynthLaf,
+                "MenuUI", pathToSynthLaf, "TextAreaUI", pathToSynthLaf,
+                "PopupMenuUI", pathToSynthLaf, "ScrollPaneUI", pathToSynthLaf,
+                "SliderUI", pathToSynthLaf, "ComboBoxUI", pathToSynthLaf,
+                "RadioButtonUI", pathToSynthLaf, "FormattedTextFieldUI",
+                pathToSynthLaf, "TreeUI", pathToSynthLaf, "MenuBarUI",
+                pathToSynthLaf, "RadioButtonMenuItemUI", pathToSynthLaf,
+                "ProgressBarUI", pathToSynthLaf, "ToolBarUI", pathToSynthLaf,
+                "ColorChooserUI", pathToSynthLaf, "ToolBarSeparatorUI",
+                pathToSynthLaf, "TabbedPaneUI", pathToSynthLaf,
+                "DesktopPaneUI", pathToSynthLaf, "TableUI", pathToSynthLaf,
+                "PanelUI", pathToSynthLaf, "CheckBoxMenuItemUI",
+                pathToSynthLaf, "PasswordFieldUI", pathToSynthLaf,
+                "CheckBoxUI", pathToSynthLaf, "TableHeaderUI", pathToSynthLaf,
+                "SplitPaneUI", pathToSynthLaf, "EditorPaneUI", pathToSynthLaf,
+                "ListUI", pathToSynthLaf, "SpinnerUI", pathToSynthLaf,
+                "DesktopIconUI", pathToSynthLaf, "TextFieldUI", pathToSynthLaf,
+                "TextPaneUI", pathToSynthLaf, "ButtonUI", pathToSynthLaf,
+                "LabelUI", pathToSynthLaf, "ToggleButtonUI", pathToSynthLaf,
+                "OptionPaneUI", pathToSynthLaf, "PopupMenuSeparatorUI",
+                pathToSynthLaf, "RootPaneUI", pathToSynthLaf, "SeparatorUI",
+                pathToSynthLaf };
         defaults.putDefaults(initDefaults);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java?view=diff&rev=555606&r1=555605&r2=555606
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java Thu Jul 12 05:07:16 2007
@@ -30,28 +30,32 @@
 public abstract class SynthStyle {
 
     /**
-     * The default isOpaque value
+     * Null style used by StyleFactory to represent styles that not found
      */
-    private boolean isOpaque = true;
+    static final SynthStyle NULL_STYLE = new SynthStyle() {
 
-    /**
-     * The default graphics utils
-     */
-    private static final SynthGraphicsUtils gUtils = new SynthGraphicsUtils();
+        @Override
+        public SynthPainter getPainter(SynthContext context) {
+            return new SynthPainter() {
+                // Empty: Null painter nothing paints
+            };
+        }
 
-    /**
-     * The default Insets
-     */
-    private static final Insets insets = new Insets(0, 0, 0, 0);
+        @Override
+        protected Color getColorForState(SynthContext context, ColorType type) {
+            return null;
+        }
 
-    static int getCommonComponentState(JComponent c) {
-        int result = c.isEnabled() ? SynthConstants.ENABLED
-                : SynthConstants.DISABLED;
-        if (c.isFocusOwner()) {
-            result |= SynthConstants.FOCUSED;
+        @Override
+        protected Font getFontForState(SynthContext context) {
+            return null;
         }
-        return result;
-    }
+    };
+
+    /**
+     * The default isOpaque value
+     */
+    private boolean isOpaque = true;
 
     /**
      * The default implementation returns null
@@ -72,39 +76,36 @@
                 : defaultValue;
     }
 
-    /**
-     * Verifies the colors defined in component than calls getColorForState
-     */
     public Color getColor(SynthContext context, ColorType type) {
-        JComponent c = context.getComponent();
-        if (c.isEnabled()) {
+
+        Color result = getColorForState(context, type);
+
+        if (result == null) {
+
+            JComponent c = context.getComponent();
 
             if (type == ColorType.BACKGROUND) {
 
                 if (c.getBackground() != null) {
-                    return c.getBackground();
+                    result = c.getBackground();
                 }
 
             } else if (type == ColorType.FOREGROUND) {
 
                 if (c.getForeground() != null) {
-                    return c.getForeground();
+                    result = c.getForeground();
                 }
             }
         }
 
-        return getColorForState(context, type);
+        return result;
     }
 
     public Font getFont(SynthContext context) {
 
-        Font result = context.getComponent().getFont();
-
-        if (result == null) {
-            return getFontForState(context);
-        }
+        Font result = getFontForState(context);
 
-        return result;
+        return (result == null) ? context.getComponent().getFont() : result;
     }
 
     protected abstract Font getFontForState(SynthContext context);
@@ -127,14 +128,17 @@
 
     }
 
+    /**
+     * The default implementation returns empty insets
+     */
     @SuppressWarnings("unused")
     public Insets getInsets(SynthContext context, Insets modified) {
 
         if (modified == null) {
-            return (Insets) insets.clone();
+            return new Insets(0, 0, 0, 0);
         }
 
-        modified.set(insets.top, insets.left, insets.bottom, insets.right);
+        modified.set(0, 0, 0, 0);
 
         return modified;
     }
@@ -150,8 +154,8 @@
     /**
      * @return The default implementation returns null
      */
-    public SynthPainter getPainter(@SuppressWarnings("unused")
-    SynthContext context) {
+    @SuppressWarnings("unused")
+    public SynthPainter getPainter(SynthContext context) {
         return null;
     }
 
@@ -187,6 +191,7 @@
      */
     public SynthGraphicsUtils getGraphicsUtils(@SuppressWarnings("unused")
     SynthContext context) {
-        return gUtils;
+        return new SynthGraphicsUtils();
     }
+
 }



Mime
View raw message