harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r530759 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/synth/ test/api/java/common/javax/swing/plaf/synth/
Date Fri, 20 Apr 2007 12:14:36 GMT
Author: apetrenko
Date: Fri Apr 20 05:14:35 2007
New Revision: 530759

URL: http://svn.apache.org/viewvc?view=rev&rev=530759
Log:
Patch for HARMONY-3448 "[classlib][swing] Synth public classes are not implemented"

Added:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/ColorType.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthPainter.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyleFactory.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/ColorTypeTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/RegionTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthContextTest.java   (with props)
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthLookAndFeelTest.java   (with props)

Added: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/ColorType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/ColorType.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/ColorType.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/ColorType.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,101 @@
+/*
+ *  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 org.apache.harmony.x.swing.internal.nls.Messages;
+
+/**
+ * The class used to mark the states in coloring JComponents
+ */
+public class ColorType {
+
+    public static final ColorType FOCUS = new ColorType("focus"); //$NON-NLS-1$
+
+    public static final ColorType BACKGROUND = new ColorType("background"); //$NON-NLS-1$
+
+    public static final ColorType FOREGROUND = new ColorType("foreground"); //$NON-NLS-1$
+
+    public static final ColorType TEXT_BACKGROUND = new ColorType(
+            "text_background"); //$NON-NLS-1$
+
+    public static final ColorType TEXT_FOREGROUND = new ColorType(
+            "text_foreground"); //$NON-NLS-1$
+
+    /**
+     * The maximum number of created color types. This field exist for
+     * compatibility with RI only
+     */
+    public static final int MAX_COUNT = 5;
+
+    /**
+     * The field is used for ID calculation
+     */
+    private static int count = 0;
+
+    /**
+     * Textual description for ColorType
+     */
+    private String description;
+
+    private int id;
+
+    protected ColorType(String description) {
+        this.description = description;
+        this.id = count;
+        count++;
+    }
+
+    /** @return The unique number id of the current ColorType */
+    public final int getID() {
+        return id;
+    }
+
+    /** @return String describes ColorType */
+    @Override
+    public String toString() {
+        return this.description;
+    }
+
+    /**
+     * The method works for predefined (static fields) ColorTypes
+     * 
+     * @param key
+     *            The ColorType name (description)
+     * @return corresponding to name ColorType.
+     */
+    static ColorType calculateColorType(String key) {
+
+        key = key.toUpperCase().intern();
+
+        if (key == "BACKGROUND") { //$NON-NLS-1$
+            return BACKGROUND;
+        } else if (key == "FOREGROUND") { //$NON-NLS-1$
+            return FOREGROUND;
+        } else if (key == "TEXT_BACKGROUND") { //$NON-NLS-1$
+            return TEXT_BACKGROUND;
+        } else if (key == "TEXT_FOREGROUND") { //$NON-NLS-1$
+            return TEXT_FOREGROUND;
+        } else if (key == "FOCUS") { //$NON-NLS-1$
+            return FOCUS;
+        }
+
+        throw new IllegalStateException(Messages.getString("swing.err.1C") //$NON-NLS-1$
+                + key);
+    }
+
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/Region.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,241 @@
+/*
+ *  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.util.HashMap;
+
+/**
+ * Region used to markup the type of JComponent to be painted
+ */
+@SuppressWarnings("nls")
+public class Region {
+
+    /**
+     * All regions depository
+     */
+    static final HashMap<String, Region> regionsMap = new HashMap<String, Region>();
+
+    public static final Region ARROW_BUTTON = new Region("ArrowButton",
+            "ArrowButtonUI", true);
+
+    public static final Region BUTTON = new Region("Button", "ButtonUI", false);
+
+    public static final Region CHECK_BOX = new Region("CheckBox", "CheckBoxUI",
+            false);
+
+    public static final Region CHECK_BOX_MENU_ITEM = new Region(
+            "CheckBoxMenuItem", "CheckBoxMenuItemUI", false);
+
+    public static final Region COLOR_CHOOSER = new Region("ColorChooser",
+            "ColorChooserUI", false);
+
+    public static final Region COMBO_BOX = new Region("ComboBox", "ComboBoxUI",
+            false);
+
+    public static final Region DESKTOP_ICON = new Region("DesktopIcon",
+            "DesktopIconUI", false);
+
+    public static final Region DESKTOP_PANE = new Region("DesktopPane",
+            "DesktopPaneUI", false);
+
+    public static final Region EDITOR_PANE = new Region("EditorPane",
+            "EditorPaneUI", false);
+
+    public static final Region FILE_CHOOSER = new Region("FileChooser",
+            "FileChooserUI", false);
+
+    public static final Region FORMATTED_TEXT_FIELD = new Region(
+            "FormattedTextField", "FormattedTextFieldUI", false);
+
+    public static final Region INTERNAL_FRAME = new Region("InternalFrame",
+            null, false);
+
+    public static final Region INTERNAL_FRAME_TITLE_PANE = new Region(
+            "InternalFrameTitlePane", "InternalFrameUI", false);
+
+    public static final Region LABEL = new Region("Label", "LabelUI", false);
+
+    public static final Region LIST = new Region("List", "ListUI", false);
+
+    public static final Region MENU = new Region("Menu", "MenuUI", false);
+
+    public static final Region MENU_BAR = new Region("MenuBar", "MenuBarUI",
+            false);
+
+    public static final Region MENU_ITEM = new Region("MenuItem", "MenuItemUI",
+            false);
+
+    public static final Region MENU_ITEM_ACCELERATOR = new Region(
+            "MenuItemAccelerator", "MenuItemAcceleratorUI", false);
+
+    public static final Region OPTION_PANE = new Region("OptionPane",
+            "OptionPaneUI", false);
+
+    public static final Region PANEL = new Region("Panel", "PanelUI", false);
+
+    public static final Region PASSWORD_FIELD = new Region("PasswordField",
+            "PasswordFieldUI", false);
+
+    public static final Region POPUP_MENU = new Region("PopupMenu",
+            "PopupMenuUI", false);
+
+    public static final Region POPUP_MENU_SEPARATOR = new Region(
+            "PopupMenuSeparator", "PopupMenuSeparatorUI", false);
+
+    public static final Region PROGRESS_BAR = new Region("ProgressBar",
+            "ProgressBarUI", false);
+
+    public static final Region RADIO_BUTTON = new Region("RadioButton",
+            "RadioButtonUI", false);
+
+    public static final Region RADIO_BUTTON_MENU_ITEM = new Region(
+            "RadioButtonMenuItem", "RadioButtonMenuItemUI", false);
+
+    public static final Region ROOT_PANE = new Region("RootPane", "RootPaneUI",
+            false);
+
+    public static final Region SCROLL_BAR = new Region("ScrollBar",
+            "ScrollBarUI", false);
+
+    public static final Region SCROLL_BAR_THUMB = new Region("ScrollBarThumb",
+            null, true);
+
+    public static final Region SCROLL_BAR_TRACK = new Region("ScrollBarTrack",
+            null, true);
+
+    public static final Region SCROLL_PANE = new Region("ScrollPane",
+            "ScrollPaneUI", false);
+
+    public static final Region SEPARATOR = new Region("Separator",
+            "SeparatorUI", false);
+
+    public static final Region SLIDER = new Region("Slider", "SliderUI", false);
+
+    public static final Region SLIDER_THUMB = new Region("SliderThumb", null,
+            true);
+
+    public static final Region SLIDER_TRACK = new Region("SliderTrack", null,
+            true);
+
+    public static final Region SPINNER = new Region("Spinner", "SpinnerUI",
+            false);
+
+    public static final Region SPLIT_PANE = new Region("SplitPane",
+            "SplitPaneUI", false);
+
+    public static final Region SPLIT_PANE_DIVIDER = new Region(
+            "SplitPaneDivider", null, true);
+
+    public static final Region TABBED_PANE = new Region("TabbedPane",
+            "TabbedPaneUI", false);
+
+    public static final Region TABBED_PANE_CONTENT = new Region(
+            "TabbedPaneContent", null, true);
+
+    public static final Region TABBED_PANE_TAB = new Region("TabbedPaneTab",
+            null, true);
+
+    public static final Region TABBED_PANE_TAB_AREA = new Region(
+            "TabbedPaneTabArea", null, true);
+
+    public static final Region TABLE = new Region("Table", "TableUI", false);
+
+    public static final Region TABLE_HEADER = new Region("TableHeader",
+            "TableHeaderUI", false);
+
+    public static final Region TEXT_AREA = new Region("TextArea", "TextAreaUI",
+            false);
+
+    public static final Region TEXT_FIELD = new Region("TextField",
+            "TextFieldUI", false);
+
+    public static final Region TEXT_PANE = new Region("TextPane", "TextPaneUI",
+            false);
+
+    public static final Region TOGGLE_BUTTON = new Region("ToggleButton",
+            "ToggleButtonUI", false);
+
+    public static final Region TOOL_BAR = new Region("ToolBar", "ToolBarUI",
+            false);
+
+    public static final Region TOOL_BAR_CONTENT = new Region("ToolBarContent",
+            null, true);
+
+    public static final Region TOOL_BAR_DRAG_WINDOW = new Region(
+            "ToolBarDragWindow", "ToolBarDragWindowUI", false);
+
+    public static final Region TOOL_BAR_SEPARATOR = new Region(
+            "ToolBarSeparator", "ToolBarSeparatorUI", false);
+
+    public static final Region TOOL_TIP = new Region("ToolTip", "ToolTipUI",
+            false);
+
+    public static final Region TREE = new Region("Tree", "TreeUI", false);
+
+    public static final Region TREE_CELL = new Region("TreeCell", null, true);
+
+    public static final Region VIEWPORT = new Region("Viewport", "ViewportUI",
+            false);
+
+    private String name;
+
+    private String ui;
+
+    private boolean isSub;
+
+    protected Region(String name, String ui, boolean subregion) {
+        this.name = name;
+        this.isSub = subregion;
+        this.ui = ui;
+        regionsMap.put(name, this);
+    }
+
+    /**
+     * @return the region corresponds given UI String
+     */
+    static Region getRegionFromUIID(String ui) {
+
+        // 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
+        return regionsMap.get(ui.substring(0, (ui.length() - 2)));
+    }
+
+    public String getName() {
+
+        return this.name;
+    }
+
+    public boolean isSubregion() {
+
+        return this.isSub;
+    }
+
+    @Override
+    public String toString() {
+
+        return this.ui;
+    }
+
+    /**
+     * @return the region corresponds given name String
+     */
+    static Region getRegionFromName(String reference) {
+        return regionsMap.get(reference);
+    }
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthConstants.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,48 @@
+/*
+ *  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;
+
+/**
+ * The SynthConstants contains possible states for the Component. The states
+ * divided into 2 groups: primary (at least one of the states should be present)
+ * and additional (component state may also contain this states)
+ */
+public interface SynthConstants {
+
+    /** The component (usual a button) is marked as default (additional) */
+    static int DEFAULT = 1024;
+
+    /** The component is disabled (primary) */
+    static int DISABLED = 8;
+
+    /** The component is enabled (primary) */
+    static int ENABLED = 1;
+
+    /** The component is focused (additional) */
+    static int FOCUSED = 256;
+
+    /** The mouse arrow is over the component (primary) */
+    static int MOUSE_OVER = 2;
+
+    /** The component is in pressed state (primary) */
+    static int PRESSED = 4;
+
+    /** The component is selected (additional) */
+    static int SELECTED = 512;
+
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthContext.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,128 @@
+/*
+ *  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 javax.swing.JComponent;
+
+public class SynthContext {
+
+    private JComponent component;
+
+    private SynthStyle style;
+
+    private int state;
+
+    private Region region;
+
+    /**
+     * Constructs SynthContext with given parameters
+     */
+    public SynthContext(JComponent component, Region region, SynthStyle style,
+            int state) {
+        this.component = component;
+        this.style = style;
+        this.state = state;
+        this.region = region;
+    }
+
+    /**
+     * For the most of UIs context needed to represent style and state
+     */
+    SynthContext(SynthStyle style, int state) {
+        this.style = style;
+        this.state = state;
+    }
+
+    /**
+     * Sometimes context just represents currentState
+     */
+    SynthContext(int state) {
+        this.state = state;
+    }
+
+    /**
+     * @return The component uses this context
+     */
+    public JComponent getComponent() {
+        return component;
+    }
+
+    /**
+     * @return The state for the component uses this context
+     */
+    public int getComponentState() {
+        return state;
+    }
+
+    /** @return parent style */
+    public SynthStyle getStyle() {
+        return style;
+    }
+
+    /** @return the region of the context */
+    public Region getRegion() {
+        return region;
+    }
+
+    void setState(int state) {
+        this.state = state;
+    }
+
+    /**
+     * Removes proposed state from current if it exists
+     */
+    void lossState(int proposed) {
+
+        this.state &= ~proposed;
+    }
+
+    /**
+     * Adds additional state to current if it doesn't exist
+     */
+    void gainState(int proposed) {
+        this.state |= proposed;
+    }
+
+    static boolean isEnabled(int verifiedState) {
+        return (verifiedState & SynthConstants.ENABLED) != 0;
+    }
+
+    static boolean isDisabled(int verifiedState) {
+        return (verifiedState & SynthConstants.DISABLED) != 0;
+    }
+
+    static boolean isFocused(int verifiedState) {
+        return (verifiedState & SynthConstants.FOCUSED) != 0;
+    }
+
+    static boolean isDefault(int verifiedState) {
+        return (verifiedState & SynthConstants.DEFAULT) != 0;
+    }
+
+    static boolean isMouseOver(int verifiedState) {
+        return (verifiedState & SynthConstants.MOUSE_OVER) != 0;
+    }
+
+    static boolean isPressed(int verifiedState) {
+        return (verifiedState & SynthConstants.PRESSED) != 0;
+    }
+
+    static boolean isSelected(int verifiedState) {
+        return (verifiedState & SynthConstants.SELECTED) != 0;
+    }
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthGraphicsUtils.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,268 @@
+/*
+ *  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.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.Rectangle2D;
+
+import javax.swing.Icon;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+
+import org.apache.harmony.x.swing.ButtonCommons;
+import org.apache.harmony.x.swing.Utilities;
+
+public class SynthGraphicsUtils {
+
+    /**
+     * Calculate string width with given parameters
+     * 
+     * @param context
+     *            SynthContext to specify component
+     * @param font
+     *            Font used to draw the string (if null font calculates from the
+     *            SynthContext)
+     * @param metrics
+     *            FontMetrics used to draw the string (if null metrics
+     *            calculates from the SynthContext)
+     * @param text
+     *            String to draw
+     */
+    public int computeStringWidth(SynthContext context, Font font,
+            FontMetrics metrics, String text) {
+        metrics = computeFontMetrics(context, font, metrics);
+
+        return metrics.stringWidth(text);
+    }
+
+    /**
+     * Calculate string height from Context
+     * 
+     * @param context
+     *            SynthContext to specify component
+     */
+    public int getMaximumCharHeight(SynthContext context) {
+        Rectangle2D maxBounds = context.getStyle().getFont(context)
+                .getMaxCharBounds(new FontRenderContext(null, true, true));
+
+        return (int) Math.ceil(maxBounds.getHeight());
+    }
+
+    /**
+     * Draws a line
+     */
+    @SuppressWarnings("unused")
+    public void drawLine(SynthContext context, Object paintKey, Graphics g,
+            int x1, int y1, int x2, int y2) {
+        g.setColor(context.getStyle().getColor(context, ColorType.FOREGROUND));
+        g.drawLine(x1, y1, x2, y2);
+    }
+
+    /**
+     * Calculates the maximum size for the component with given parameters
+     */
+    @SuppressWarnings("unused")
+    public Dimension getMaximumSize(SynthContext ss, Font font, String text,
+            Icon icon, int hAlign, int vAlign, int hTextPosition,
+            int vTextPosition, int iconTextGap, int mnemonicIndex) {
+
+        final FontMetrics fm = computeFontMetrics(ss, font, null);
+
+        Dimension size = getCompoundLabelSize(fm, text, icon, vTextPosition,
+                hTextPosition, iconTextGap);
+
+        return Utilities.addInsets(size, ss.getStyle().getInsets(ss, null));
+    }
+
+    /**
+     * Calculates the minimum size for the component with given parameters
+     */
+    public Dimension getMinimumSize(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,
+                hTextPosition, vTextPosition, iconTextGap, mnemonicIndex);
+    }
+
+    /**
+     * Calculates the preferred size for the component with given parameters
+     */
+    public Dimension getPreferredSize(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,
+                hTextPosition, vTextPosition, iconTextGap, mnemonicIndex);
+    }
+
+    /**
+     * Layouts text and Icon in the complex JComponent
+     */
+    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) {
+
+        fm = computeFontMetrics(ss, fm);
+
+        SwingUtilities.layoutCompoundLabel(fm, text, icon, vAlign, hAlign,
+                vTextPosition, hTextPosition, viewR, iconR, textR, iconTextGap);
+
+        return text;
+    }
+
+    public void paintText(SynthContext ss, Graphics g, String text, Icon icon,
+            int hAlign, int vAlign, int hTextPosition, int vTextPosition,
+            int iconTextGap, int mnemonicIndex, int textOffset) {
+
+        FontMetrics metrics = computeFontMetrics(ss, null);
+
+        Color color = ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND);
+
+        Rectangle textR = getTextRect(text, metrics);
+        Rectangle iconR = getIconRect(icon);
+
+        Insets insets = ss.getStyle().getInsets(ss, null);
+        Rectangle viewR = Utilities.subtractInsets(g.getClipBounds(), insets);
+
+        layoutText(ss, metrics, text, icon, hAlign, vAlign, hTextPosition,
+                vTextPosition, viewR, iconR, textR, iconTextGap);
+
+        textR.x += textOffset;
+        textR.y += textOffset;
+
+        ButtonCommons.paintText(g, metrics, text, mnemonicIndex, textR, text,
+                color);
+    }
+
+    public void paintText(SynthContext ss, Graphics g, String text, int x,
+            int y, int mnemonicIndex) {
+
+        Color color = ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND);
+        FontMetrics metrics = computeFontMetrics(ss, null);
+        Rectangle textR = getTextRect(text, metrics);
+        textR.x = x;
+        textR.y = y;
+        ButtonCommons.paintText(g, metrics, text, mnemonicIndex, textR, text,
+                color);
+    }
+
+    public void paintText(SynthContext ss, Graphics g, String text,
+            Rectangle bounds, int mnemonicIndex) {
+
+        Color color = ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND);
+        FontMetrics metrics = computeFontMetrics(ss, null);
+        ButtonCommons.paintText(g, metrics, text, mnemonicIndex, bounds, text,
+                color);
+    }
+
+    /**
+     * This method calculates Font metrics from context
+     */
+    private FontMetrics computeFontMetrics(SynthContext context, Font font,
+            FontMetrics metrics) {
+
+        if (metrics == null) {
+
+            if (font == null) {
+                font = context.getStyle().getFont(context);
+            }
+
+            metrics = context.getComponent().getFontMetrics(font);
+        }
+
+        return metrics;
+    }
+
+    /**
+     * This method calculates Font metrics from context
+     */
+    private FontMetrics computeFontMetrics(SynthContext context,
+            FontMetrics metrics) {
+
+        if (metrics == null) {
+
+            metrics = context.getComponent().getFontMetrics(
+                    context.getStyle().getFont(context));
+        }
+
+        return metrics;
+    }
+
+    /**
+     * @param text
+     *            text to be outlined
+     * @param fm
+     *            the FontMetrics of the text
+     * @return outline Rectangle
+     */
+    private Rectangle getTextRect(String text, FontMetrics fm) {
+
+        if (!Utilities.isEmptyString(text)) {
+            Dimension stringDim = Utilities.getStringSize(text, fm);
+            Dimension size = new Dimension(stringDim.width, Utilities.getTextY(
+                    fm, new Rectangle(stringDim)));
+
+            return new Rectangle(size);
+        }
+
+        return new Rectangle();
+    }
+
+    private Dimension getCompoundLabelSize(FontMetrics fm, final String text,
+            final Icon icon, final int verticalTextPosition,
+            final int horizontalTextPosition, final int iconTextGap) {
+
+        final Dimension result = new Dimension();
+        Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
+        Rectangle iconR = new Rectangle();
+        Rectangle textR = new Rectangle();
+
+        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);
+
+        return result;
+    }
+
+    /**
+     * @param icon
+     *            Icon to be outlined
+     * @return outline Rectangle
+     */
+    private Rectangle getIconRect(Icon icon) {
+
+        if (icon != null) {
+            return new Rectangle(icon.getIconWidth(), icon.getIconHeight());
+        }
+
+        return new Rectangle();
+    }
+
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthLookAndFeel.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,208 @@
+/*
+ *  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.Component;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.text.ParseException;
+
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+import org.apache.harmony.luni.util.NotImplementedException;
+import org.apache.harmony.x.swing.internal.nls.Messages;
+
+public class SynthLookAndFeel extends BasicLookAndFeel implements Serializable {
+
+    private final static String packageName = SynthLookAndFeel.class
+            .getPackage().getName();
+
+    private static SynthStyleFactory currentFactory;
+
+    private UIDefaults uiDefaults;
+
+    public static SynthStyle getStyle(JComponent c, Region r) {
+
+        return currentFactory.getStyle(c, r);
+    }
+
+    public static SynthStyleFactory getStyleFactory() {
+
+        return currentFactory;
+    }
+
+    public static void setStyleFactory(SynthStyleFactory proposed) {
+        currentFactory = proposed;
+    }
+
+    /**
+     * Creates the Synth UI object corresponds JComponent given
+     */
+    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$
+
+        } catch (Exception e) {
+
+            return null;
+        }
+    }
+
+    /**
+     * Renew the synth styles for the JComponent. This method isn't fully
+     * correct, but does what needs
+     */
+    public static void updateStyles(Component c) {
+
+        if (c instanceof JComponent) {
+            ((JComponent) c).revalidate();
+        }
+    }
+
+    /**
+     * Calculates the region corresponds JComponent given
+     */
+    public static Region getRegion(JComponent c) {
+
+        return Region.getRegionFromUIID(c.getUIClassID());
+    }
+
+    @Override
+    public String getName() {
+
+        return "Synth Look and Feel"; //$NON-NLS-1$
+    }
+
+    @Override
+    public String getID() {
+
+        return "Synth"; //$NON-NLS-1$
+    }
+
+    @Override
+    public String getDescription() {
+
+        return Messages.getString("swing.B4"); //$NON-NLS-1$
+    }
+
+    @Override
+    public boolean isNativeLookAndFeel() {
+
+        return false;
+    }
+
+    @Override
+    public boolean isSupportedLookAndFeel() {
+
+        return true;
+    }
+
+    @Override
+    public UIDefaults getDefaults() {
+
+        if (uiDefaults == null) {
+            uiDefaults = new UIDefaults();
+            initClassDefaults(uiDefaults);
+            initComponentDefaults(uiDefaults);
+        }
+
+        return uiDefaults;
+    }
+
+    @Override
+    public void initialize() {
+        // Do nothing
+    }
+
+    @Override
+    public void uninitialize() {
+        // Do nothing
+    }
+
+    @SuppressWarnings("unused")
+    public void load(InputStream input, Class<?> resourceBase)
+            throws NotImplementedException, ParseException,
+            IllegalArgumentException {
+        /*
+         * This class will be implemented with XMLSynthParser
+         */
+    }
+
+    /** The default implementation returns false */
+    public boolean shouldUpdateStyleOnAncestorChanged() {
+
+        return false;
+    }
+
+    @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" };
+        defaults.putDefaults(initDefaults);
+    }
+
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthPainter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthPainter.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthPainter.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthPainter.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,593 @@
+/*
+ *  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;
+
+/**
+ * SynthPainter class provides the methods for painting all the JComponents. All
+ * the paint methods are internally blank.
+ */
+@SuppressWarnings("unused")
+public abstract class SynthPainter {
+
+    public void paintArrowButtonBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintArrowButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintArrowButtonForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int direction) {
+        // Blank
+    }
+
+    public void paintButtonBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintCheckBoxBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintCheckBoxBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintCheckBoxMenuItemBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintCheckBoxMenuItemBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintColorChooserBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintColorChooserBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintComboBoxBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintComboBoxBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintDesktopIconBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintDesktopIconBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintDesktopPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintDesktopPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintEditorPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintEditorPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintFileChooserBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintFileChooserBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintFormattedTextFieldBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintFormattedTextFieldBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintInternalFrameBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintInternalFrameBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintInternalFrameTitlePaneBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintInternalFrameTitlePaneBorder(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintLabelBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintLabelBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintListBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintListBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuBarBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuItemBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintMenuItemBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintOptionPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintOptionPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPanelBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPanelBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPasswordFieldBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPasswordFieldBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPopupMenuBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintPopupMenuBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintProgressBarBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintProgressBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintProgressBarForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintRadioButtonBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintRadioButtonBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintRadioButtonMenuItemBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintRadioButtonMenuItemBorder(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintRootPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintRootPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollBarBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollBarThumbBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintScrollBarThumbBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintScrollBarTrackBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollBarTrackBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintScrollPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSeparatorBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSeparatorBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSeparatorForeground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintSliderBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSliderBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSliderThumbBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintSliderThumbBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintSliderTrackBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSliderTrackBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSpinnerBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSpinnerBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSplitPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSplitPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSplitPaneDividerBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintSplitPaneDividerForeground(SynthContext context,
+            Graphics g, int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintSplitPaneDragDivider(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int orientation) {
+        // Blank
+    }
+
+    public void paintTabbedPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneContentBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneContentBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneTabAreaBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneTabAreaBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTabbedPaneTabBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int tabIndex) {
+        // Blank
+    }
+
+    public void paintTabbedPaneTabBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h, int tabIndex) {
+        // Blank
+    }
+
+    public void paintTableBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTableBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTableHeaderBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTableHeaderBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextAreaBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextAreaBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextFieldBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextFieldBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextPaneBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTextPaneBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToggleButtonBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToggleButtonBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarContentBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarContentBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarDragWindowBackground(SynthContext context,
+            Graphics g, int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolBarDragWindowBorder(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolTipBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintToolTipBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTreeBackground(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTreeBorder(SynthContext context, Graphics g, int x, int y,
+            int w, int h) {
+        // Blank
+    }
+
+    public void paintTreeCellBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTreeCellBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintTreeCellFocus(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintViewportBackground(SynthContext context, Graphics g,
+            int x, int y, int w, int h) {
+        // Blank
+    }
+
+    public void paintViewportBorder(SynthContext context, Graphics g, int x,
+            int y, int w, int h) {
+        // Blank
+    }
+}

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

Added: 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=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyle.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,192 @@
+/*
+ *  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.Color;
+import java.awt.Font;
+import java.awt.Insets;
+
+import javax.swing.Icon;
+import javax.swing.JComponent;
+
+/**
+ * SynthStyle contains all the information about component drawing
+ */
+public abstract class SynthStyle {
+
+    /**
+     * The default isOpaque value
+     */
+    private boolean isOpaque = true;
+
+    /**
+     * The default graphics utils
+     */
+    private static final SynthGraphicsUtils gUtils = new SynthGraphicsUtils();
+
+    /**
+     * The default Insets
+     */
+    private static final Insets insets = new Insets(0, 0, 0, 0);
+
+    static int getCommonComponentState(JComponent c) {
+        int result = c.isEnabled() ? SynthConstants.ENABLED
+                : SynthConstants.DISABLED;
+        if (c.isFocusOwner()) {
+            result |= SynthConstants.FOCUSED;
+        }
+        return result;
+    }
+
+    /**
+     * The default implementation returns null
+     */
+    @SuppressWarnings("unused")
+    public Object get(SynthContext context, Object key) {
+        return null;
+    }
+
+    /**
+     * Returns boolean value from the properties table or the default value
+     */
+    public boolean getBoolean(SynthContext context, Object key,
+            boolean defaultValue) {
+
+        Object result = get(context, key);
+        return (result instanceof Boolean) ? ((Boolean) result).booleanValue()
+                : defaultValue;
+    }
+
+    /**
+     * Verifies the colors defined in component than calls getColorForState
+     */
+    public Color getColor(SynthContext context, ColorType type) {
+        JComponent c = context.getComponent();
+        if (c.isEnabled()) {
+
+            if (type == ColorType.BACKGROUND) {
+
+                if (c.getBackground() != null) {
+                    return c.getBackground();
+                }
+
+            } else if (type == ColorType.FOREGROUND) {
+
+                if (c.getForeground() != null) {
+                    return c.getForeground();
+                }
+            }
+        }
+
+        return getColorForState(context, type);
+    }
+
+    public Font getFont(SynthContext context) {
+
+        Font result = context.getComponent().getFont();
+
+        if (result == null) {
+            return getFontForState(context);
+        }
+
+        return result;
+    }
+
+    protected abstract Font getFontForState(SynthContext context);
+
+    /**
+     * The default implementation just casts Object returned by get(Object, key
+     * method)
+     */
+    public Icon getIcon(SynthContext context, Object key) {
+
+        try {
+
+            return (Icon) get(context, key);
+
+        } catch (ClassCastException e) {
+
+            return null;
+
+        }
+
+    }
+
+    @SuppressWarnings("unused")
+    public Insets getInsets(SynthContext context, Insets modified) {
+
+        if (modified == null) {
+            return (Insets) insets.clone();
+        }
+
+        modified.set(insets.top, insets.left, insets.bottom, insets.right);
+
+        return modified;
+    }
+
+    public int getInt(SynthContext context, Object key, int defaultValue) {
+
+        Object value = get(context, key);
+
+        return (value instanceof Integer) ? ((Integer) value).intValue()
+                : defaultValue;
+    }
+
+    /**
+     * @return The default implementation returns null
+     */
+    public SynthPainter getPainter(@SuppressWarnings("unused")
+    SynthContext context) {
+        return null;
+    }
+
+    public String getString(SynthContext context, Object key,
+            String defaultValue) {
+        Object value = get(context, key);
+        return (value instanceof String) ? (String) value : defaultValue;
+    }
+
+    /** The default implementation is empty */
+    @SuppressWarnings("unused")
+    public void installDefaults(SynthContext context) {
+        // Empty
+    }
+
+    @SuppressWarnings("unused")
+    public boolean isOpaque(SynthContext context) {
+        return isOpaque;
+    }
+
+    /** The default implementation is empty */
+    @SuppressWarnings("unused")
+    public void uninstallDefaults(SynthContext context) {
+        // Empty
+    }
+
+    protected abstract Color getColorForState(SynthContext context,
+            ColorType type);
+
+    /**
+     * @return GraphicsUtils used for specified context. The default
+     *         implementation returns default GraphicsUtils for any context.
+     */
+    public SynthGraphicsUtils getGraphicsUtils(@SuppressWarnings("unused")
+    SynthContext context) {
+        return gUtils;
+    }
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyleFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyleFactory.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyleFactory.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/synth/SynthStyleFactory.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,26 @@
+/*
+ *  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 javax.swing.JComponent;
+
+public abstract class SynthStyleFactory {
+    
+    public abstract SynthStyle getStyle(JComponent c, Region id);
+    
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/ColorTypeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/ColorTypeTest.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/ColorTypeTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/ColorTypeTest.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,55 @@
+/*
+ *  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 junit.framework.TestCase;
+
+public class ColorTypeTest extends TestCase {
+
+    private final static String NAME_1 = "test1"; //$NON-NLS-1$
+
+    private final static String NAME_2 = "test2"; //$NON-NLS-1$
+
+    public static void testColorTypes() {
+        assertEquals(ColorType.MAX_COUNT, 5);
+        assertNotSame(ColorType.BACKGROUND, ColorType.FOREGROUND);
+
+        ColorType testCT = new ColorType(NAME_1) {
+            // Empty class - all is inherited
+        };
+
+        ColorType testCT2 = new ColorType(NAME_2) {
+            // Empty class - all is inherited
+        };
+        assertEquals(NAME_1, testCT.toString());
+        assertEquals(NAME_2, testCT2.toString());
+        assertFalse(ColorType.BACKGROUND.getID() == testCT.getID());
+        assertFalse(testCT2.getID() == testCT.getID());
+        assertTrue(testCT.getID() == testCT.getID());
+        assertSame(ColorType.calculateColorType("BACKGROUND"), //$NON-NLS-1$
+                ColorType.BACKGROUND);
+        assertSame(ColorType.calculateColorType("FOREGROUND"), //$NON-NLS-1$
+                ColorType.FOREGROUND);
+        assertSame(ColorType.calculateColorType("FOCUS"), ColorType.FOCUS); //$NON-NLS-1$
+        assertSame(ColorType.calculateColorType("TEXT_BACKGROUND"), //$NON-NLS-1$
+                ColorType.TEXT_BACKGROUND);
+        assertSame(ColorType.calculateColorType("TEXT_FOREGROUND"), //$NON-NLS-1$
+                ColorType.TEXT_FOREGROUND);
+        assertEquals(ColorType.MAX_COUNT, 5);
+    }
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/RegionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/RegionTest.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/RegionTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/RegionTest.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,39 @@
+/*
+ *  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 junit.framework.TestCase;
+
+public class RegionTest extends TestCase {
+
+    private static final String NAME = "test"; //$NON-NLS-1$
+
+    private static final String UI = "testUI"; //$NON-NLS-1$
+
+    private static final Region r = new Region(NAME, UI, false);
+
+    public static void testFields() {
+        assertEquals(NAME, r.getName());
+        assertFalse(r.isSubregion());
+    }
+
+    public static void testRegionLookupMethods() {
+        assertSame(r, Region.getRegionFromName(NAME));
+        assertSame(r, Region.getRegionFromUIID(UI));
+    }
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthContextTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthContextTest.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthContextTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthContextTest.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,85 @@
+/*
+ *  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.Color;
+import java.awt.Font;
+
+import javax.swing.JButton;
+
+import junit.framework.TestCase;
+
+public class SynthContextTest extends TestCase {
+
+    private static final SynthStyle ss = new SynthStyle() {
+        @Override
+        @SuppressWarnings("unused")//$NON-NLS-1$
+        protected Font getFontForState(SynthContext context) {
+            return null;
+        }
+
+        @Override
+        @SuppressWarnings("unused")//$NON-NLS-1$
+        protected Color getColorForState(SynthContext context, ColorType type) {
+            return Color.RED;
+        }
+    };
+
+    private static final String BUTTON_NAME = "testJButton"; //$NON-NLS-1$
+
+    private static final JButton testButton = new JButton(BUTTON_NAME);
+
+    private static final SynthContext sc = new SynthContext(testButton,
+            Region.BUTTON, ss, SynthConstants.ENABLED);
+
+    public static void testFields() {
+        assertSame(Region.BUTTON, sc.getRegion());
+        assertSame(ss, sc.getStyle());
+        assertSame(Color.RED, sc.getStyle().getColorForState(sc, null));
+        assertTrue(sc.getComponentState() == SynthConstants.ENABLED);
+        assertSame(testButton, sc.getComponent());
+    }
+
+    public static void testStates() {
+
+        assertTrue(SynthContext.isEnabled(sc.getComponentState()));
+        sc.setState(SynthConstants.DISABLED);
+        assertFalse(SynthConstants.ENABLED == sc.getComponentState());
+        assertFalse(SynthContext.isEnabled(sc.getComponentState()));
+        assertTrue(SynthContext.isDisabled(sc.getComponentState()));
+
+        sc.gainState(SynthConstants.DISABLED);
+        assertTrue(SynthConstants.DISABLED == sc.getComponentState());
+
+        sc.gainState(SynthConstants.FOCUSED);
+        assertTrue(SynthContext.isDisabled(sc.getComponentState()));
+        assertTrue(SynthContext.isFocused(sc.getComponentState()));
+
+        assertFalse(SynthContext.isMouseOver(sc.getComponentState()));
+        sc.lossState(SynthConstants.MOUSE_OVER);
+        assertFalse(SynthContext.isMouseOver(sc.getComponentState()));
+
+        sc.lossState(SynthConstants.FOCUSED);
+        assertFalse(SynthContext.isFocused(sc.getComponentState()));
+
+        sc.setState(SynthConstants.ENABLED);
+        assertTrue(SynthContext.isEnabled(sc.getComponentState()));
+
+    }
+
+}

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

Added: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthLookAndFeelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthLookAndFeelTest.java?view=auto&rev=530759
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthLookAndFeelTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/synth/SynthLookAndFeelTest.java Fri Apr 20 05:14:35 2007
@@ -0,0 +1,114 @@
+/*
+ *  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 javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.plaf.ComponentUI;
+
+import junit.framework.TestCase;
+
+public class SynthLookAndFeelTest extends TestCase {
+
+    SynthLookAndFeel laf = new SynthLookAndFeel();
+
+    JLabel l = new JLabel();
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.isNativeLookAndFeel()'
+     */
+    public void testIsNativeLookAndFeel() {
+        assertFalse(laf.isNativeLookAndFeel());
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.isSupportedLookAndFeel()'
+     */
+    public void testIsSupportedLookAndFeel() {
+        assertTrue(laf.isSupportedLookAndFeel());
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.getStyleFactory()'
+     */
+    public void testGetStyleFactory() {
+        SynthStyleFactory sf = new SynthStyleFactory() {
+            @Override
+            @SuppressWarnings("unused")
+            public SynthStyle getStyle(JComponent c, Region id) {
+                return null;
+            }
+        };
+        SynthLookAndFeel.setStyleFactory(sf);
+        assertSame(sf, SynthLookAndFeel.getStyleFactory());
+    }
+
+//    /*
+//     * Test method for
+//     * 'javax.swing.plaf.synth.SynthLookAndFeel.createUI(JComponent)'
+//     */
+//    public void testCreateUI() {
+//        l.setEnabled(false);
+//        ComponentUI labelUI = SynthLookAndFeel.createUI(l);
+//        assertTrue(labelUI instanceof SynthUI);
+//        assertTrue(labelUI instanceof SynthLabelUI);
+//        assertTrue(((SynthLabelUI) labelUI).getLabelState(l) == SynthConstants.DISABLED);
+//    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.updateStyles(Component)'
+     */
+    public void testUpdateStyles() {
+        // TODO:
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.getRegion(JComponent)'
+     */
+    public void testGetRegion() {
+        assertSame(Region.LABEL, SynthLookAndFeel.getRegion(l));
+    }
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthLookAndFeel.getName()'
+     */
+    public void testGetName() {
+        assertEquals("Synth Look and Feel", laf.getName()); //$NON-NLS-1$
+    }
+
+    /*
+     * Test method for 'javax.swing.plaf.synth.SynthLookAndFeel.getID()'
+     */
+    public void testGetID() {
+        assertEquals("Synth", laf.getID()); //$NON-NLS-1$
+    }
+
+    /*
+     * Test method for
+     * 'javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnAncestorChanged()'
+     */
+    public void testShouldUpdateStyleOnAncestorChanged() {
+        assertFalse(laf.shouldUpdateStyleOnAncestorChanged());
+    }
+
+}

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



Mime
View raw message