poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1691677 - in /poi/trunk/src/java/org/apache/poi/ss/usermodel: ConditionalFormattingThreshold.java IconMultiStateFormatting.java
Date Sat, 18 Jul 2015 04:52:45 GMT
Author: nick
Date: Sat Jul 18 04:52:45 2015
New Revision: 1691677

URL: http://svn.apache.org/r1691677
Log:
#58130 Improve enum lookup by name, and work around a docs ordering bug

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java?rev=1691677&r1=1691676&r2=1691677&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java Sat
Jul 18 04:52:45 2015
@@ -54,6 +54,12 @@ public interface ConditionalFormattingTh
         public static RangeType byId(int id) {
             return values()[id-1]; // 1-based IDs
         }
+        public static RangeType byName(String name) {
+            for (RangeType t : values()) {
+                if (t.name.equals(name)) return t;
+            }
+            return null;
+        }
         
         private RangeType(int id, String name) {
             this.id = id; this.name = name;

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java?rev=1691677&r1=1691676&r2=1691677&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java Sat Jul 18
04:52:45 2015
@@ -31,12 +31,14 @@ public interface IconMultiStateFormattin
         GREY_3_ARROWS(1, 3, "3ArrowsGray"),
         /** Green / Yellow / Red flags */
         GYR_3_FLAGS(2, 3, "3Flags"),
-        /** Green / Yellow / Red traffic lights (no background) */
-        GYR_3_TRAFFIC_LIGHTS(3, 3, null),
-        /** Green Circle / Yellow Triangle / Red Diamond */ 
-        GYR_3_SHAPES(4, 3, "3Signs"),
-        /** Green / Yellow / Red traffic lights on a black square background */
-        GYR_3_TRAFFIC_LIGHTS_BOX(5, 3, "3TrafficLights2"),
+        /** Green / Yellow / Red traffic lights (no background). Default */
+        GYR_3_TRAFFIC_LIGHTS(3, 3, "3TrafficLights1"),
+        /** Green / Yellow / Red traffic lights on a black square background. 
+         * Note, MS-XLS docs v20141018 say this is id=5 but seems to be id=4 */
+        GYR_3_TRAFFIC_LIGHTS_BOX(4, 3, "3TrafficLights2"),
+        /** Green Circle / Yellow Triangle / Red Diamond.
+         * Note, MS-XLS docs v20141018 say this is id=4 but seems to be id=5 */ 
+        GYR_3_SHAPES(5, 3, "3Signs"),
         /** Green Tick / Yellow ! / Red Cross on a circle background */
         GYR_3_SYMBOLS_CIRCLE(6, 3, "3Symbols"),
         /** Green Tick / Yellow ! / Red Cross (no background) */
@@ -55,6 +57,8 @@ public interface IconMultiStateFormattin
         RATINGS_5(0xF, 5, "5Rating"),
         QUARTERS_5(0x10, 5, "5Quarters");
         
+        protected static final IconSet DEFAULT_ICONSET = IconSet.GYR_3_TRAFFIC_LIGHTS;
+        
         /** Numeric ID of the icon set */
         public int id;
         /** How many icons in the set */
@@ -63,15 +67,18 @@ public interface IconMultiStateFormattin
         public final String name;
         
         public String toString() {
-            return id + " - " + getName();
-        }
-        private String getName() {
-            return (name==null?"default":name);
+            return id + " - " + name;
         }
         
         public static IconSet byId(int id) {
             return values()[id];
         }
+        public static IconSet byName(String name) {
+            for (IconSet set : values()) {
+                if (set.name.equals(name)) return set;
+            }
+            return null;
+        }
         
         private IconSet(int id, int num, String name) {
             this.id = id; this.num = num; this.name = name;
@@ -113,4 +120,8 @@ public interface IconMultiStateFormattin
      *  {@link IconSet#num} for the current {@link #getIconSet()}
      */
     void setThresholds(ConditionalFormattingThreshold[] thresholds);
+    /**
+     * Creates a new, empty Threshold
+     */
+    ConditionalFormattingThreshold createThreshold();
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message