You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2013/11/25 14:15:17 UTC

svn commit: r1545255 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java

Author: ebourg
Date: Mon Nov 25 13:15:17 2013
New Revision: 1545255

URL: http://svn.apache.org/r1545255
Log:
Simplified the ColorComponent enum

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java?rev=1545255&r1=1545254&r2=1545255&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java Mon Nov 25 13:15:17 2013
@@ -17,30 +17,18 @@
 package org.apache.commons.imaging.palette;
 
 enum ColorComponent {
-    ALPHA {
-        @Override
-        public int argbComponent(final int argb) {
-            return (argb >> 24) & 0xff;
-        }
-    },
-    RED {
-        @Override
-        public int argbComponent(final int argb) {
-            return (argb >> 16) & 0xff;
-        }
-    },
-    GREEN {
-        @Override
-        public int argbComponent(final int argb) {
-            return (argb >> 8) & 0xff;
-        }
-    },
-    BLUE {
-        @Override
-        public int argbComponent(final int argb) {
-            return (argb & 0xff);
-        }
-    };
+    ALPHA(24),
+    RED(16),
+    GREEN(8),
+    BLUE(0);
     
-    public abstract int argbComponent(int argb);
+    private final int shift;
+
+    private ColorComponent(int shift) {
+        this.shift = shift;
+    }
+
+    public int argbComponent(int argb) {
+        return (argb >> shift) & 0xff;
+    }
 }