harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r556513 [2/2] - in /harmony/enhanced/classlib/branches/java6: make/ modules/awt/make/ modules/awt/src/main/java/common/java/awt/ modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/ modules/awt/src/test/api/java/common/java/awt/...
Date Mon, 16 Jul 2007 06:12:27 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java
Sun Jul 15 23:12:24 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/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java
Sun Jul 15 23:12:24 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/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java
Sun Jul 15 23:12:24 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/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java
Sun Jul 15 23:12:24 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();
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/parser/ParserDelegator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/parser/ParserDelegator.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/parser/ParserDelegator.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/parser/ParserDelegator.java
Sun Jul 15 23:12:24 2007
@@ -109,10 +109,9 @@
             String oldName = dtd.name;
             // gets the location of the harcoded file that is located in the
             // classpath ...
-            URL bdtdURL = ParserDelegator.class.getResource(name + ".bdtd");
             // fills the DTD ...
             dtd.read(new DataInputStream(
-                    new FileInputStream(new File(bdtdURL.toURI()))));
+                    ParserDelegator.class.getResourceAsStream(name + ".bdtd")));
             dtd.name = oldName;
             DTD.putDTDHash(name, dtd);
         } catch (Exception e) {

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
Sun Jul 15 23:12:24 2007
@@ -224,3 +224,10 @@
 swing.err.1A=Lexical error at line {0}, column {1}. Encountered: 
 swing.err.1B=after : \
 swing.err.1C=Cannot calculate ColorType. Key is:
+swing.err.1D=Please specify InputStream and resourceBase for SynthLookAndFeel
+swing.err.1E=Please, specify font name
+swing.err.1F=Property type is incorrect: {0}
+swing.err.20=Direction description for imagePainter is incorrect
+swing.err.21=State value is incorrect: {0}
+swing.err.22=Bind type={0} is incorrect for styleID={1}
+swing.err.23=Please specify imagePath and sourceInsets for imagePainter

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/synth/SynthStyleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/synth/SynthStyleTest.java?view=diff&rev=556513&r1=556512&r2=556513
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/synth/SynthStyleTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/synth/SynthStyleTest.java
Sun Jul 15 23:12:24 2007
@@ -30,156 +30,169 @@
 
 public class SynthStyleTest extends TestCase {
 
-	static final String ICON_KEY = "TestIcon"; //$NON-NLS-1$
+    static final String ICON_KEY = "TestIcon"; //$NON-NLS-1$
 
-	static final String STRING_KEY = "TestString"; //$NON-NLS-1$
+    static final String STRING_KEY = "TestString"; //$NON-NLS-1$
 
-	static final String INT_KEY = "TestInteger"; //$NON-NLS-1$
+    static final String INT_KEY = "TestInteger"; //$NON-NLS-1$
 
-	static final String BOOLEAN_KEY = "TestBoolean"; //$NON-NLS-1$
+    static final String BOOLEAN_KEY = "TestBoolean"; //$NON-NLS-1$
 
-	static final Icon ICON_VALUE = new ImageIcon("test"); //$NON-NLS-1$
-
-	static final String STRING_VALUE = "test"; //$NON-NLS-1$
-
-	@SuppressWarnings("boxing")
-	static final Integer INT_VALUE = Integer.MAX_VALUE; //$NON-NLS-1$
-
-	@SuppressWarnings("boxing")
-	static final Boolean BOOLEAN_VALUE = true; //$NON-NLS-1$
-
-	static final Color COLOR_VALUE = Color.GREEN;
-
-	static final Font FONT_VALUE = new Font("Times", Font.BOLD, 15); //$NON-NLS-1$
-
-	private static JLabel currentComponent = new JLabel("Test_component"); //$NON-NLS-1$
-
-	private static SynthStyle currentStyle = new SynthStyleForTest();
-
-	private static SynthContext currentContext = new SynthContext(
-			currentComponent, Region.LABEL, currentStyle,
-			SynthConstants.ENABLED);
-
-	/*
-	 * Test method for 'javax.swing.plaf.synth.SynthStyle.get(SynthContext,
-	 * Object)'
-	 */
-	public void testGet() {
-		assertEquals(currentStyle.get(currentContext, ICON_KEY), ICON_VALUE);
-		assertEquals(currentStyle.get(currentContext, INT_KEY), INT_VALUE);
-		assertEquals(currentStyle.get(currentContext, STRING_KEY), STRING_VALUE);
-		assertEquals(currentStyle.get(currentContext, BOOLEAN_KEY),
-				BOOLEAN_VALUE);
-	}
-
-	/*
-	 * Test method for
-	 * 'javax.swing.plaf.synth.SynthStyle.getBoolean(SynthContext, Object,
-	 * boolean)'
-	 */
-	public void testGetBoolean() {
-		assertTrue(currentStyle.getBoolean(currentContext, BOOLEAN_KEY, true));
-		assertTrue(currentStyle.getBoolean(currentContext, BOOLEAN_KEY, false));
-		assertTrue(currentStyle.getBoolean(currentContext,
-				"Not_found_boolean", true)); //$NON-NLS-1$
-		assertFalse(currentStyle.getBoolean(currentContext,
-				"Not_found_boolean", false)); //$NON-NLS-1$
-	}
-
-	/*
-	 * Test method for 'javax.swing.plaf.synth.SynthStyle.getColor(SynthContext,
-	 * ColorType)'
-	 */
-	public void testGetColor() {
-		currentComponent.setBackground(Color.RED);
-		assertEquals(currentStyle
-				.getColor(currentContext, ColorType.BACKGROUND), Color.RED);
-	}
-
-	/*
-	 * Test method for 'javax.swing.plaf.synth.SynthStyle.getFont(SynthContext)'
-	 */
-	public void testGetFont() {
-		Font newFont = new Font("Dialog", Font.BOLD, 15); //$NON-NLS-1$
-		currentComponent.setFont(newFont);
-		assertEquals(currentStyle.getFont(currentContext), newFont);
-	}
-
-	/*
-	 * Test method for
-	 * 'javax.swing.plaf.synth.SynthStyle.getInsets(SynthContext, Insets)'
-	 */
-	public void testGetInsets() {
-		Insets insets = new Insets(1, 2, 3, 4);
-		currentStyle.getInsets(currentContext, insets);
-		assertTrue((insets.top == 0) && (insets.left == 0)
-				&& (insets.right == 0) && (insets.bottom == 0));
-	}
-
-	/*
-	 * Test method for 'javax.swing.plaf.synth.SynthStyle.getInt(SynthContext,
-	 * Object, int)'
-	 */
-	@SuppressWarnings("boxing")
-	public void testGetInt() {
-		assertTrue(currentStyle.getInt(currentContext, INT_KEY, INT_VALUE - 1) == INT_VALUE);
-		assertTrue(currentStyle.getInt(currentContext,
-				"KEY_NOT_FOUND", INT_VALUE - 1) == INT_VALUE - 1); //$NON-NLS-1$
-	}
-
-	/*
-	 * Test method for
-	 * 'javax.swing.plaf.synth.SynthStyle.getString(SynthContext, Object,
-	 * String)'
-	 */
-	public void testGetString() {
-		String anotherString = "KEY_NOT_FOUND"; //$NON-NLS-1$
-		assertEquals(currentStyle.getString(currentContext, STRING_KEY,
-				anotherString), STRING_VALUE);
-		assertEquals(currentStyle.getString(currentContext, anotherString,
-				anotherString), anotherString);
-	}
-
-	/*
-	 * Test method for
-	 * 'javax.swing.plaf.synth.SynthStyle.isOpaque(SynthContext)'
-	 */
-	public void testIsOpaque() {
-		assertTrue(currentStyle.isOpaque(currentContext));
-	}
-
-	private static class SynthStyleForTest extends SynthStyle {
-
-		private final Hashtable<Object, Object> internalMap = new Hashtable<Object, Object>();
-
-		SynthStyleForTest() {
-			addProperty(ICON_KEY, ICON_VALUE);
-			addProperty(STRING_KEY, STRING_VALUE);
-			addProperty(INT_KEY, INT_VALUE);
-			addProperty(BOOLEAN_KEY, BOOLEAN_VALUE);
-		}
-
-		@Override
-		@SuppressWarnings("unused")
-		protected Font getFontForState(SynthContext context) {
-			return FONT_VALUE;
-		}
-
-		@Override
-		@SuppressWarnings("unused")
-		protected Color getColorForState(SynthContext context, ColorType type) {
-			return COLOR_VALUE;
-		}
-
-		@Override
-		@SuppressWarnings("unused")
-		public Object get(SynthContext context, Object key) {
-			return internalMap.get(key);
-		}
-
-		public void addProperty(Object key, Object value) {
-			internalMap.put(key, value);
-		}
-	}
+    static final Icon ICON_VALUE = new ImageIcon("test"); //$NON-NLS-1$
+
+    static final String STRING_VALUE = "test"; //$NON-NLS-1$
+
+    @SuppressWarnings("boxing")
+    static final Integer INT_VALUE = Integer.MAX_VALUE; //$NON-NLS-1$
+
+    @SuppressWarnings("boxing")
+    static final Boolean BOOLEAN_VALUE = true; //$NON-NLS-1$
+
+    static final Color COLOR_VALUE = Color.GREEN;
+
+    static final Font FONT_VALUE = new Font("Times", Font.BOLD, 15); //$NON-NLS-1$
+
+    private static JLabel currentComponent = new JLabel("Test_component"); //$NON-NLS-1$
+
+    private static SynthStyle currentStyle = new SynthStyleForTest();
+
+    private static SynthContext currentContext = new SynthContext(
+            currentComponent, Region.LABEL, currentStyle,
+            SynthConstants.ENABLED);
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthStyle.get(SynthContext,
+     * Object)'
+     */
+    public void testGet() {
+        assertEquals(currentStyle.get(currentContext, ICON_KEY), ICON_VALUE);
+        assertEquals(currentStyle.get(currentContext, INT_KEY), INT_VALUE);
+        assertEquals(currentStyle.get(currentContext, STRING_KEY), STRING_VALUE);
+        assertEquals(currentStyle.get(currentContext, BOOLEAN_KEY),
+                BOOLEAN_VALUE);
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthStyle.getBoolean(SynthContext, Object,
+     * boolean)'
+     */
+    public void testGetBoolean() {
+        assertTrue(currentStyle.getBoolean(currentContext, BOOLEAN_KEY, true));
+        assertTrue(currentStyle.getBoolean(currentContext, BOOLEAN_KEY, false));
+        assertTrue(currentStyle.getBoolean(currentContext,
+                "Not_found_boolean", true)); //$NON-NLS-1$
+        assertFalse(currentStyle.getBoolean(currentContext,
+                "Not_found_boolean", false)); //$NON-NLS-1$
+    }
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthStyle.getColor(SynthContext,
+     * ColorType)'
+     */
+    public void testGetColor() {
+        currentComponent.setBackground(Color.RED);
+        assertEquals(currentStyle
+                .getColor(currentContext, ColorType.BACKGROUND), Color.RED);
+        assertEquals(currentStyle
+                .getColor(currentContext, ColorType.FOREGROUND),
+                currentComponent.getForeground());
+        assertEquals(currentStyle.getColor(currentContext, ColorType.FOCUS),
+                COLOR_VALUE);
+
+    }
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthStyle.getFont(SynthContext)'
+     */
+    public void testGetFont() {
+        Font newFont = new Font("Dialog", Font.BOLD, 15); //$NON-NLS-1$
+        currentComponent.setFont(newFont);
+        assertEquals(currentStyle.getFont(currentContext), newFont);
+        currentContext.setState(SynthConstants.DISABLED);
+        assertEquals(currentStyle.getFont(currentContext), FONT_VALUE);
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthStyle.getInsets(SynthContext, Insets)'
+     */
+    public void testGetInsets() {
+        Insets insets = new Insets(1, 2, 3, 4);
+        currentStyle.getInsets(currentContext, insets);
+        assertTrue((insets.top == 0) && (insets.left == 0)
+                && (insets.right == 0) && (insets.bottom == 0));
+    }
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthStyle.getInt(SynthContext,
+     * Object, int)'
+     */
+    @SuppressWarnings("boxing")
+    public void testGetInt() {
+        assertTrue(currentStyle.getInt(currentContext, INT_KEY, INT_VALUE - 1) == INT_VALUE);
+        assertTrue(currentStyle.getInt(currentContext,
+                "KEY_NOT_FOUND", INT_VALUE - 1) == INT_VALUE - 1); //$NON-NLS-1$
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthStyle.getString(SynthContext, Object,
+     * String)'
+     */
+    public void testGetString() {
+        String anotherString = "KEY_NOT_FOUND"; //$NON-NLS-1$
+        assertEquals(currentStyle.getString(currentContext, STRING_KEY,
+                anotherString), STRING_VALUE);
+        assertEquals(currentStyle.getString(currentContext, anotherString,
+                anotherString), anotherString);
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthStyle.isOpaque(SynthContext)'
+     */
+    public void testIsOpaque() {
+        assertTrue(currentStyle.isOpaque(currentContext));
+    }
+
+    private static class SynthStyleForTest extends SynthStyle {
+
+        Hashtable propertiesMap = new Hashtable();
+
+        SynthStyleForTest() {
+            addProperty(ICON_KEY, ICON_VALUE);
+            addProperty(STRING_KEY, STRING_VALUE);
+            addProperty(INT_KEY, INT_VALUE);
+            addProperty(BOOLEAN_KEY, BOOLEAN_VALUE);
+        }
+
+        @Override
+        public Object get(SynthContext context, Object key) {
+            return propertiesMap.get(key);
+        }
+
+        @Override
+        @SuppressWarnings("unused")
+        protected Font getFontForState(SynthContext context) {
+            if (context.getComponentState() == SynthConstants.DISABLED) {
+                return FONT_VALUE;
+            }
+            return null;
+        }
+
+        @Override
+        @SuppressWarnings("unused")
+        protected Color getColorForState(SynthContext context, ColorType type) {
+            if (type == ColorType.FOCUS) {
+                return COLOR_VALUE;
+            }
+            return null;
+        }
+
+        public void addProperty(String key, Object value) {
+            propertiesMap.put(key, value);
+        }
+    }
 
 }



Mime
View raw message