diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
commit | 556d92b63555a085b25e32b1cd55afce24edd07a (patch) | |
tree | 6be2b02c62a77d5aba81ffbe34c46960608be163 /src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java | |
parent | a90f4a51dffec3247278e3c683ed4462b1dd9ab5 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java index 9e64c3eb1..f1bee1957 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java @@ -31,18 +31,18 @@ public class PngHelperInternal { return new byte[] { -119, 80, 78, 71, 13, 10, 26, 10 };
}
- public static int doubleToInt100000(double d) {
+ public static int doubleToInt100000(final double d) {
return (int) (d * 100000.0 + 0.5);
}
- public static double intToDouble100000(int i) {
+ public static double intToDouble100000(final int i) {
return i / 100000.0;
}
- public static int readByte(InputStream is) {
+ public static int readByte(final InputStream is) {
try {
return is.read();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjInputException("error reading byte", e);
}
}
@@ -52,14 +52,14 @@ public class PngHelperInternal { *
* PNG uses "network byte order"
*/
- public static int readInt2(InputStream is) {
+ public static int readInt2(final InputStream is) {
try {
- int b1 = is.read();
- int b2 = is.read();
+ final int b1 = is.read();
+ final int b2 = is.read();
if (b1 == -1 || b2 == -1)
return -1;
return (b1 << 8) + b2;
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjInputException("error reading readInt2", e);
}
}
@@ -67,58 +67,58 @@ public class PngHelperInternal { /**
* -1 if eof
*/
- public static int readInt4(InputStream is) {
+ public static int readInt4(final InputStream is) {
try {
- int b1 = is.read();
- int b2 = is.read();
- int b3 = is.read();
- int b4 = is.read();
+ final int b1 = is.read();
+ final int b2 = is.read();
+ final int b3 = is.read();
+ final int b4 = is.read();
if (b1 == -1 || b2 == -1 || b3 == -1 || b4 == -1)
return -1;
return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjInputException("error reading readInt4", e);
}
}
- public static int readInt1fromByte(byte[] b, int offset) {
+ public static int readInt1fromByte(final byte[] b, final int offset) {
return (b[offset] & 0xff);
}
- public static int readInt2fromBytes(byte[] b, int offset) {
+ public static int readInt2fromBytes(final byte[] b, final int offset) {
return ((b[offset] & 0xff) << 16) | ((b[offset + 1] & 0xff));
}
- public static int readInt4fromBytes(byte[] b, int offset) {
+ public static int readInt4fromBytes(final byte[] b, final int offset) {
return ((b[offset] & 0xff) << 24) | ((b[offset + 1] & 0xff) << 16) | ((b[offset + 2] & 0xff) << 8)
| (b[offset + 3] & 0xff);
}
- public static void writeByte(OutputStream os, byte b) {
+ public static void writeByte(final OutputStream os, final byte b) {
try {
os.write(b);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjOutputException(e);
}
}
- public static void writeInt2(OutputStream os, int n) {
- byte[] temp = { (byte) ((n >> 8) & 0xff), (byte) (n & 0xff) };
+ public static void writeInt2(final OutputStream os, final int n) {
+ final byte[] temp = { (byte) ((n >> 8) & 0xff), (byte) (n & 0xff) };
writeBytes(os, temp);
}
- public static void writeInt4(OutputStream os, int n) {
- byte[] temp = new byte[4];
+ public static void writeInt4(final OutputStream os, final int n) {
+ final byte[] temp = new byte[4];
writeInt4tobytes(n, temp, 0);
writeBytes(os, temp);
}
- public static void writeInt2tobytes(int n, byte[] b, int offset) {
+ public static void writeInt2tobytes(final int n, final byte[] b, final int offset) {
b[offset] = (byte) ((n >> 8) & 0xff);
b[offset + 1] = (byte) (n & 0xff);
}
- public static void writeInt4tobytes(int n, byte[] b, int offset) {
+ public static void writeInt4tobytes(final int n, final byte[] b, final int offset) {
b[offset] = (byte) ((n >> 24) & 0xff);
b[offset + 1] = (byte) ((n >> 16) & 0xff);
b[offset + 2] = (byte) ((n >> 8) & 0xff);
@@ -128,26 +128,26 @@ public class PngHelperInternal { /**
* guaranteed to read exactly len bytes. throws error if it can't
*/
- public static void readBytes(InputStream is, byte[] b, int offset, int len) {
+ public static void readBytes(final InputStream is, final byte[] b, final int offset, final int len) {
if (len == 0)
return;
try {
int read = 0;
while (read < len) {
- int n = is.read(b, offset + read, len - read);
+ final int n = is.read(b, offset + read, len - read);
if (n < 1)
throw new PngjInputException("error reading bytes, " + n + " !=" + len);
read += n;
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjInputException("error reading", e);
}
}
- public static void skipBytes(InputStream is, long len) {
+ public static void skipBytes(final InputStream is, long len) {
try {
while (len > 0) {
- long n1 = is.skip(len);
+ final long n1 = is.skip(len);
if (n1 > 0) {
len -= n1;
} else if (n1 == 0) { // should we retry? lets read one byte
@@ -159,28 +159,28 @@ public class PngHelperInternal { // negative? this should never happen but...
throw new IOException("skip() returned a negative value ???");
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjInputException(e);
}
}
- public static void writeBytes(OutputStream os, byte[] b) {
+ public static void writeBytes(final OutputStream os, final byte[] b) {
try {
os.write(b);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjOutputException(e);
}
}
- public static void writeBytes(OutputStream os, byte[] b, int offset, int n) {
+ public static void writeBytes(final OutputStream os, final byte[] b, final int offset, final int n) {
try {
os.write(b, offset, n);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new PngjOutputException(e);
}
}
- public static void logdebug(String msg) {
+ public static void logdebug(final String msg) {
if (DEBUG)
System.out.println(msg);
}
@@ -198,43 +198,43 @@ public class PngHelperInternal { }
// / filters
- public static int filterRowNone(int r) {
- return (int) (r & 0xFF);
+ public static int filterRowNone(final int r) {
+ return r & 0xFF;
}
- public static int filterRowSub(int r, int left) {
- return ((int) (r - left) & 0xFF);
+ public static int filterRowSub(final int r, final int left) {
+ return (r - left & 0xFF);
}
- public static int filterRowUp(int r, int up) {
- return ((int) (r - up) & 0xFF);
+ public static int filterRowUp(final int r, final int up) {
+ return (r - up & 0xFF);
}
- public static int filterRowAverage(int r, int left, int up) {
+ public static int filterRowAverage(final int r, final int left, final int up) {
return (r - (left + up) / 2) & 0xFF;
}
- public static int filterRowPaeth(int r, int left, int up, int upleft) { // a = left, b = above, c = upper left
+ public static int filterRowPaeth(final int r, final int left, final int up, final int upleft) { // a = left, b = above, c = upper left
return (r - filterPaethPredictor(left, up, upleft)) & 0xFF;
}
- public static int unfilterRowNone(int r) {
- return (int) (r & 0xFF);
+ public static int unfilterRowNone(final int r) {
+ return r & 0xFF;
}
- public static int unfilterRowSub(int r, int left) {
- return ((int) (r + left) & 0xFF);
+ public static int unfilterRowSub(final int r, final int left) {
+ return (r + left & 0xFF);
}
- public static int unfilterRowUp(int r, int up) {
- return ((int) (r + up) & 0xFF);
+ public static int unfilterRowUp(final int r, final int up) {
+ return (r + up & 0xFF);
}
- public static int unfilterRowAverage(int r, int left, int up) {
+ public static int unfilterRowAverage(final int r, final int left, final int up) {
return (r + (left + up) / 2) & 0xFF;
}
- public static int unfilterRowPaeth(int r, int left, int up, int upleft) { // a = left, b = above, c = upper left
+ public static int unfilterRowPaeth(final int r, final int left, final int up, final int upleft) { // a = left, b = above, c = upper left
return (r + filterPaethPredictor(left, up, upleft)) & 0xFF;
}
@@ -259,11 +259,11 @@ public class PngHelperInternal { /*
* we put this methods here so as to not pollute the public interface of PngReader
*/
- public final static void initCrcForTests(PngReader pngr) {
+ public final static void initCrcForTests(final PngReader pngr) {
pngr.initCrctest();
}
- public final static long getCrctestVal(PngReader pngr) {
+ public final static long getCrctestVal(final PngReader pngr) {
return pngr.getCrctestVal();
}
|