commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1545255 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorComponent.java
Date Mon, 25 Nov 2013 13:15:17 GMT
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;
+    }
 }



Mime
View raw message