Author: rwhitcomb
Date: Thu Jun  8 20:40:00 2017
New Revision: 1798122

URL: http://svn.apache.org/viewvc?rev=1798122&view=rev
Log:
PIVOT-999: Rename the "getIntValue" and etc. new methods in Dictionary
to just "getInt()", "getColor()" and etc. for code brevity.

Also add "getBoolean()" and "setBoolean()" for the same reasons we
added the "Int" methods: to provide a bit of type safety and brevity
of code.

Add some uses of the boolean methods.

Modified:
    pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java
    pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java
    
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/tools/ComponentInspectorSkin.java
    
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorSkin.java
    
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
    
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
    
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Point.java
    
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java

Modified: pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java Thu Jun  
8 20:40:00 2017
@@ -110,7 +110,7 @@ public interface Dictionary<K, V> {
      * value to retrieve (actually any {@link Number} will work).
      * @return The integer value, or 0 if the key is not present.
      */
-    default int getIntValue(K key) {
+    default int getInt(K key) {
         if (containsKey(key)) {
             return ((Number)get(key)).intValue();
         } else {
@@ -127,11 +127,40 @@ public interface Dictionary<K, V> {
      * @return The previous value for this key.
      */
     @SuppressWarnings("unchecked")
-    default V putIntValue(K key, int value) {
+    default V putInt(K key, int value) {
         return put(key, (V)Integer.valueOf(value));
     }
 
     /**
+     * Using the other methods in this interface, retrieve a boolean value
+     * from this dictionary; returning false if the key does not exist.
+     *
+     * @param key The key for the (supposed) <tt>Boolean</tt>
+     * value to retrieve.
+     * @return The boolean value, or false if the key is not present.
+     */
+    default boolean getBoolean(K key) {
+        if (containsKey(key)) {
+            return ((Boolean)get(key)).booleanValue();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Using the other methods in this interface, put a boolean value
+     * into this dictionary.
+     *
+     * @param key The key for the <tt>Boolean</tt> value to save.
+     * @param value The value to be saved.
+     * @return The previous value for this key.
+     */
+    @SuppressWarnings("unchecked")
+    default V putBoolean(K key, boolean value) {
+        return put(key, (V)Boolean.valueOf(value));
+    }
+
+    /**
      * Using the other methods in this interface, retrieve a {@link Color} 
value
      * from this dictionary; returning <tt>null</tt> if the key does not exist.
      *
@@ -139,7 +168,7 @@ public interface Dictionary<K, V> {
      * value to retrieve.
      * @return The color value, or <tt>null</tt> if the key is not present.
      */
-    default Color getColorValue(K key) {
+    default Color getColor(K key) {
         if (containsKey(key)) {
             return (Color)get(key);
         } else {

Modified: 
pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java 
(original)
+++ pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java 
Thu Jun  8 20:40:00 2017
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEqu
 
 import org.junit.Test;
 
+import java.awt.Color;
 import org.apache.pivot.collections.HashMap;
 
 
@@ -27,12 +28,30 @@ public class DictionaryTest {
     @Test
     public void test() {
         HashMap<String, Integer> map = new HashMap<>();
-        map.putIntValue("one", 1);
-        map.putIntValue("two", 2);
-        map.putIntValue("three", 300);
-        assertEquals(map.getIntValue("one"), 1);
-        assertEquals(map.getIntValue("two"), 2);
-        assertEquals(map.getIntValue("three"), 300);
+        map.putInt("one", 1);
+        map.putInt("two", 2);
+        map.putInt("three", 300);
+        assertEquals(map.getInt("one"), 1);
+        assertEquals(map.getInt("two"), 2);
+        assertEquals(map.getInt("three"), 300);
+    }
+
+    @Test
+    public void boolTest() {
+        HashMap<String, Boolean> map = new HashMap<>();
+        map.putBoolean("true", false);
+        map.putBoolean("false", true);
+        map.putBoolean("other", true);
+        assertEquals(map.getBoolean("true"), false);
+        assertEquals(map.getBoolean("false"), true);
+        assertEquals(map.getBoolean("other"), true);
+    }
+
+    @Test
+    public void colorTest() {
+        HashMap<String, Color> map = new HashMap<>();
+        map.put("black", Color.BLACK);
+        assertEquals(map.getColor("black"), Color.BLACK);
     }
 
 }

Modified: 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/tools/ComponentInspectorSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/tools/ComponentInspectorSkin.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/tools/ComponentInspectorSkin.java
 (original)
+++ 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/tools/ComponentInspectorSkin.java
 Thu Jun  8 20:40:00 2017
@@ -247,7 +247,7 @@ abstract class ComponentInspectorSkin ex
 
     private static Component addIntControl(final Dictionary<String, Object> 
dictionary,
         final String key, Form.Section section) {
-        int value = dictionary.getIntValue(key);
+        int value = dictionary.getInt(key);
 
         TextInput textInput = new TextInput();
         textInput.setTextSize(10);
@@ -267,7 +267,7 @@ abstract class ComponentInspectorSkin ex
                         dictionary.put(key, 
Integer.parseInt(textInputLocal.getText()));
                     } catch (Exception exception) {
                         displayErrorMessage(exception, component.getWindow());
-                        int valueLocal = dictionary.getIntValue(key);
+                        int valueLocal = dictionary.getInt(key);
                         textInputLocal.setText(String.valueOf(valueLocal));
                     }
                 }
@@ -281,7 +281,7 @@ abstract class ComponentInspectorSkin ex
         TextInput textInput = (TextInput) controls.get(key);
 
         if (textInput != null) {
-            int value = dictionary.getIntValue(key);
+            int value = dictionary.getInt(key);
             textInput.setText(String.valueOf(value));
         }
     }

Modified: 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorSkin.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorSkin.java
 (original)
+++ 
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorSkin.java
 Thu Jun  8 20:40:00 2017
@@ -247,7 +247,7 @@ abstract class ComponentInspectorSkin ex
 
     private static Component addIntControl(final Dictionary<String, Object> 
dictionary,
         final String key, Form.Section section) {
-        int value = dictionary.getIntValue(key);
+        int value = dictionary.getInt(key);
 
         TextInput textInput = new TextInput();
         textInput.setTextSize(10);
@@ -267,7 +267,7 @@ abstract class ComponentInspectorSkin ex
                         dictionary.put(key, 
Integer.parseInt(textInputLocal.getText()));
                     } catch (Exception exception) {
                         displayErrorMessage(exception, component.getWindow());
-                        int valueLocal = dictionary.getIntValue(key);
+                        int valueLocal = dictionary.getInt(key);
                         textInputLocal.setText(String.valueOf(valueLocal));
                     }
                 }
@@ -281,7 +281,7 @@ abstract class ComponentInspectorSkin ex
         TextInput textInput = (TextInput) controls.get(key);
 
         if (textInput != null) {
-            int value = dictionary.getIntValue(key);
+            int value = dictionary.getInt(key);
             textInput.setText(String.valueOf(value));
         }
     }

Modified: 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
 (original)
+++ 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
 Thu Jun  8 20:40:00 2017
@@ -614,19 +614,19 @@ public class TerraMenuButtonSkin extends
     }
 
     public int getCloseTransitionDuration() {
-        return menuPopup.getStyles().getIntValue("closeTransitionDuration");
+        return menuPopup.getStyles().getInt("closeTransitionDuration");
     }
 
     public void setCloseTransitionDuration(int closeTransitionDuration) {
-        menuPopup.getStyles().putIntValue("closeTransitionDuration", 
closeTransitionDuration);
+        menuPopup.getStyles().putInt("closeTransitionDuration", 
closeTransitionDuration);
     }
 
     public int getCloseTransitionRate() {
-        return menuPopup.getStyles().getIntValue("closeTransitionRate");
+        return menuPopup.getStyles().getInt("closeTransitionRate");
     }
 
     public void setCloseTransitionRate(int closeTransitionRate) {
-        menuPopup.getStyles().putIntValue("closeTransitionRate", 
closeTransitionRate);
+        menuPopup.getStyles().putInt("closeTransitionRate", 
closeTransitionRate);
     }
 
     @Override

Modified: 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
 (original)
+++ 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
 Thu Jun  8 20:40:00 2017
@@ -182,14 +182,14 @@ public class TerraSuggestionPopupSkin ex
     private static final int DEFAULT_CLOSE_TRANSITION_RATE = 30;
 
     public TerraSuggestionPopupSkin() {
-        listView.getStyles().put("variableItemHeight", new Boolean(true));
+        listView.getStyles().putBoolean("variableItemHeight", true);
         
listView.getListViewSelectionListeners().add(listViewSelectionListener);
         listView.getComponentKeyListeners().add(listViewKeyListener);
 
         listViewPanorama = new Panorama(listView);
         listViewPanorama.getStyles().put("buttonBackgroundColor",
-            listView.getStyles().get("backgroundColor"));
-        listViewPanorama.getStyles().put("alwaysShowScrollButtons", new 
Boolean(true));
+            listView.getStyles().getColor("backgroundColor"));
+        listViewPanorama.getStyles().putBoolean("alwaysShowScrollButtons", 
true);
 
         listViewBorder = new Border(listViewPanorama);
     }
@@ -236,7 +236,7 @@ public class TerraSuggestionPopupSkin ex
     }
 
     public Color getColor() {
-        return (Color) listView.getStyles().get("color");
+        return listView.getStyles().getColor("color");
     }
 
     public void setColor(Color color) {
@@ -250,7 +250,7 @@ public class TerraSuggestionPopupSkin ex
     }
 
     public Color getBorderColor() {
-        return (Color) listViewBorder.getStyles().get("color");
+        return listViewBorder.getStyles().getColor("color");
     }
 
     public void setBorderColor(Color borderColor) {

Modified: 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java 
(original)
+++ 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java 
Thu Jun  8 20:40:00 2017
@@ -605,7 +605,7 @@ public class TerraTabPaneSkin extends Ta
         tabButtonBoxPane.getStyles().put("fill", new Boolean(true));
 
         tabButtonPanorama.getStyles().put("buttonBackgroundColor", 
borderColor);
-        tabButtonPanorama.getStyles().putIntValue("buttonPadding", 6);
+        tabButtonPanorama.getStyles().putInt("buttonPadding", 6);
         tabButtonPanorama.setView(tabButtonBoxPane);
 
         tabButtonGroup.getButtonGroupListeners().add(new 
ButtonGroupListener.Adapter() {
@@ -1335,11 +1335,11 @@ public class TerraTabPaneSkin extends Ta
     }
 
     public int getButtonSpacing() {
-        return tabButtonBoxPane.getStyles().getIntValue("spacing");
+        return tabButtonBoxPane.getStyles().getInt("spacing");
     }
 
     public void setButtonSpacing(int buttonSpacing) {
-        tabButtonBoxPane.getStyles().putIntValue("spacing", buttonSpacing);
+        tabButtonBoxPane.getStyles().putInt("spacing", buttonSpacing);
     }
 
     public final void setButtonCornerRadius(int buttonCornerRadius) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java Thu Jun  8 20:40:00 
2017
@@ -98,10 +98,10 @@ public final class Bounds implements Ser
     public Bounds(Dictionary<String, ?> bounds) {
         Utils.checkNull(bounds, "bounds");
 
-        x = bounds.getIntValue(X_KEY);
-        y = bounds.getIntValue(Y_KEY);
-        width = bounds.getIntValue(WIDTH_KEY);
-        height = bounds.getIntValue(HEIGHT_KEY);
+        x = bounds.getInt(X_KEY);
+        y = bounds.getInt(Y_KEY);
+        width = bounds.getInt(WIDTH_KEY);
+        height = bounds.getInt(HEIGHT_KEY);
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java Thu Jun  8 20:40:00 
2017
@@ -72,10 +72,10 @@ public final class Insets implements Ser
     public Insets(Dictionary<String, ?> insets) {
         Utils.checkNull(insets, "padding/margin");
 
-        top = insets.getIntValue(TOP_KEY);
-        left = insets.getIntValue(LEFT_KEY);
-        bottom = insets.getIntValue(BOTTOM_KEY);
-        right = insets.getIntValue(RIGHT_KEY);
+        top = insets.getInt(TOP_KEY);
+        left = insets.getInt(LEFT_KEY);
+        bottom = insets.getInt(BOTTOM_KEY);
+        right = insets.getInt(RIGHT_KEY);
 
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Point.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Point.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Point.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Point.java Thu Jun  8 20:40:00 2017
@@ -53,8 +53,8 @@ public final class Point implements Seri
     public Point(Dictionary<String, ?> point) {
         Utils.checkNull(point, "point");
 
-        this.x = point.getIntValue(X_KEY);
-        this.y = point.getIntValue(Y_KEY);
+        this.x = point.getInt(X_KEY);
+        this.y = point.getInt(Y_KEY);
     }
 
     /**

Modified: 
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java?rev=1798122&r1=1798121&r2=1798122&view=diff
==============================================================================
--- 
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java
 (original)
+++ 
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java
 Thu Jun  8 20:40:00 2017
@@ -67,15 +67,15 @@ public class TableViewTextAreaCellRender
         if (tableView.isEnabled() && !rowDisabled) {
             if (rowSelected) {
                 if (tableView.isFocused()) {
-                    color = tableViewStyles.getColorValue("selectionColor");
+                    color = tableViewStyles.getColor("selectionColor");
                 } else {
-                    color = 
tableViewStyles.getColorValue("inactiveSelectionColor");
+                    color = tableViewStyles.getColor("inactiveSelectionColor");
                 }
             } else {
-                color = tableViewStyles.getColorValue("color");
+                color = tableViewStyles.getColor("color");
             }
         } else {
-            color = tableViewStyles.getColorValue("disabledColor");
+            color = tableViewStyles.getColor("disabledColor");
         }
 
         styles.put("color", color);


Reply via email to