From 556d92b63555a085b25e32b1cd55afce24edd07a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Jul 2014 16:21:36 +0200 Subject: 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 --- .../jogamp/opengl/util/pngj/FilterType.java | 6 +- .../opengl/util/pngj/FilterWriteStrategy.java | 16 +-- .../classes/jogamp/opengl/util/pngj/ImageInfo.java | 8 +- .../classes/jogamp/opengl/util/pngj/ImageLine.java | 18 ++-- .../jogamp/opengl/util/pngj/ImageLineHelper.java | 94 ++++++++--------- .../jogamp/opengl/util/pngj/ImageLines.java | 14 +-- .../jogamp/opengl/util/pngj/PngDeinterlacer.java | 28 ++--- .../jogamp/opengl/util/pngj/PngHelperInternal.java | 108 +++++++++---------- .../opengl/util/pngj/PngIDatChunkInputStream.java | 22 ++-- .../opengl/util/pngj/PngIDatChunkOutputStream.java | 8 +- .../classes/jogamp/opengl/util/pngj/PngReader.java | 114 ++++++++++----------- .../classes/jogamp/opengl/util/pngj/PngWriter.java | 102 +++++++++--------- .../opengl/util/pngj/PngjBadCrcException.java | 6 +- .../jogamp/opengl/util/pngj/PngjException.java | 6 +- .../opengl/util/pngj/PngjExceptionInternal.java | 6 +- .../opengl/util/pngj/PngjInputException.java | 6 +- .../opengl/util/pngj/PngjOutputException.java | 6 +- .../opengl/util/pngj/PngjUnsupportedException.java | 6 +- .../opengl/util/pngj/ProgressiveOutputStream.java | 12 +-- .../opengl/util/pngj/chunks/ChunkHelper.java | 64 ++++++------ .../jogamp/opengl/util/pngj/chunks/ChunkRaw.java | 10 +- .../jogamp/opengl/util/pngj/chunks/ChunksList.java | 20 ++-- .../util/pngj/chunks/ChunksListForWrite.java | 24 ++--- .../jogamp/opengl/util/pngj/chunks/PngChunk.java | 36 +++---- .../opengl/util/pngj/chunks/PngChunkBKGD.java | 16 +-- .../opengl/util/pngj/chunks/PngChunkCHRM.java | 12 +-- .../opengl/util/pngj/chunks/PngChunkGAMA.java | 16 +-- .../opengl/util/pngj/chunks/PngChunkHIST.java | 12 +-- .../opengl/util/pngj/chunks/PngChunkICCP.java | 20 ++-- .../opengl/util/pngj/chunks/PngChunkIDAT.java | 6 +- .../opengl/util/pngj/chunks/PngChunkIEND.java | 8 +- .../opengl/util/pngj/chunks/PngChunkIHDR.java | 26 ++--- .../opengl/util/pngj/chunks/PngChunkITXT.java | 26 ++--- .../opengl/util/pngj/chunks/PngChunkMultiple.java | 2 +- .../opengl/util/pngj/chunks/PngChunkOFFS.java | 16 +-- .../opengl/util/pngj/chunks/PngChunkPHYS.java | 24 ++--- .../opengl/util/pngj/chunks/PngChunkPLTE.java | 28 ++--- .../opengl/util/pngj/chunks/PngChunkSBIT.java | 14 +-- .../opengl/util/pngj/chunks/PngChunkSPLT.java | 26 ++--- .../opengl/util/pngj/chunks/PngChunkSRGB.java | 10 +- .../opengl/util/pngj/chunks/PngChunkSTER.java | 14 +-- .../opengl/util/pngj/chunks/PngChunkSingle.java | 6 +- .../opengl/util/pngj/chunks/PngChunkSkipped.java | 6 +- .../opengl/util/pngj/chunks/PngChunkTEXT.java | 12 +-- .../opengl/util/pngj/chunks/PngChunkTIME.java | 16 +-- .../opengl/util/pngj/chunks/PngChunkTRNS.java | 20 ++-- .../opengl/util/pngj/chunks/PngChunkTextVar.java | 4 +- .../opengl/util/pngj/chunks/PngChunkUNKNOWN.java | 14 +-- .../opengl/util/pngj/chunks/PngChunkZTXT.java | 22 ++-- .../opengl/util/pngj/chunks/PngMetadata.java | 45 ++++---- 50 files changed, 581 insertions(+), 580 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util/pngj') diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java index 5e177b8c3..c577c4fd5 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java @@ -53,7 +53,7 @@ public enum FilterType { FILTER_UNKNOWN(-100), ; public final int val; - private FilterType(int val) { + private FilterType(final int val) { this.val = val; } @@ -61,12 +61,12 @@ public enum FilterType { static { byVal = new HashMap(); - for (FilterType ft : values()) { + for (final FilterType ft : values()) { byVal.put(ft.val, ft); } } - public static FilterType getByVal(int i) { + public static FilterType getByVal(final int i) { return byVal.get(i); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java index 79eed8f85..63f456347 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java @@ -11,15 +11,15 @@ class FilterWriteStrategy { private FilterType currentType; // 0-4 private int lastRowTested = -1000000; // performance of each filter (less is better) (can be negative) - private double[] lastSums = new double[5]; + private final double[] lastSums = new double[5]; // performance of each filter (less is better) (can be negative) - private double[] lastEntropies = new double[5]; + private final double[] lastEntropies = new double[5]; // a priori preference (NONE SUB UP AVERAGE PAETH) private double[] preference = new double[] { 1.1, 1.1, 1.1, 1.1, 1.2 }; private int discoverEachLines = -1; - private double[] histogram1 = new double[256]; + private final double[] histogram1 = new double[256]; - FilterWriteStrategy(ImageInfo imgInfo, FilterType configuredType) { + FilterWriteStrategy(final ImageInfo imgInfo, final FilterType configuredType) { this.imgInfo = imgInfo; this.configuredType = configuredType; if (configuredType.val < 0) { // first guess @@ -36,7 +36,7 @@ class FilterWriteStrategy { discoverEachLines = 1; } - boolean shouldTestAll(int rown) { + boolean shouldTestAll(final int rown) { if (discoverEachLines > 0 && lastRowTested + discoverEachLines <= rown) { currentType = null; return true; @@ -44,7 +44,7 @@ class FilterWriteStrategy { return false; } - public void setPreference(double none, double sub, double up, double ave, double paeth) { + public void setPreference(final double none, final double sub, final double up, final double ave, final double paeth) { preference = new double[] { none, sub, up, ave, paeth }; } @@ -52,7 +52,7 @@ class FilterWriteStrategy { return (discoverEachLines > 0); } - void fillResultsForFilter(int rown, FilterType type, double sum, int[] histo, boolean tentative) { + void fillResultsForFilter(final int rown, final FilterType type, final double sum, final int[] histo, final boolean tentative) { lastRowTested = rown; lastSums[type.val] = sum; if (histo != null) { @@ -72,7 +72,7 @@ class FilterWriteStrategy { } } - FilterType gimmeFilterType(int rown, boolean useEntropy) { + FilterType gimmeFilterType(final int rown, final boolean useEntropy) { if (currentType == null) { // get better if (rown == 0) currentType = FilterType.FILTER_SUB; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java index ac7b858e1..cdd17a291 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java @@ -92,7 +92,7 @@ public class ImageInfo { /** * Short constructor: assumes truecolor (RGB/RGBA) */ - public ImageInfo(int cols, int rows, int bitdepth, boolean alpha) { + public ImageInfo(final int cols, final int rows, final int bitdepth, final boolean alpha) { this(cols, rows, bitdepth, alpha, false, false); } @@ -113,7 +113,7 @@ public class ImageInfo { * @param indexed * Flag: has palette */ - public ImageInfo(int cols, int rows, int bitdepth, boolean alpha, boolean grayscale, boolean indexed) { + public ImageInfo(final int cols, final int rows, final int bitdepth, final boolean alpha, final boolean grayscale, final boolean indexed) { this.cols = cols; this.rows = rows; this.alpha = alpha; @@ -176,14 +176,14 @@ public class ImageInfo { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - ImageInfo other = (ImageInfo) obj; + final ImageInfo other = (ImageInfo) obj; if (alpha != other.alpha) return false; if (bitDepth != other.bitDepth) diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java index e6afd8694..5ad2e4409 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java @@ -69,7 +69,7 @@ public class ImageLine { /** * default mode: INT packed */ - public ImageLine(ImageInfo imgInfo) { + public ImageLine(final ImageInfo imgInfo) { this(imgInfo, SampleType.INT, false); } @@ -86,14 +86,14 @@ public class ImageLine { * images * */ - public ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode) { + public ImageLine(final ImageInfo imgInfo, final SampleType stype, final boolean unpackedMode) { this(imgInfo, stype, unpackedMode, null, null); } /** * If a preallocated array is passed, the copy is shallow */ - ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode, int[] sci, byte[] scb) { + ImageLine(final ImageInfo imgInfo, final SampleType stype, final boolean unpackedMode, final int[] sci, final byte[] scb) { this.imgInfo = imgInfo; channels = imgInfo.channels; bitDepth = imgInfo.bitDepth; @@ -118,7 +118,7 @@ public class ImageLine { } /** Sets row number (0 : Rows-1) */ - public void setRown(int n) { + public void setRown(final int n) { this.rown = n; } @@ -274,7 +274,7 @@ public class ImageLine { * The caller must be sure that the original was really packed */ public ImageLine unpackToNewImageLine() { - ImageLine newline = new ImageLine(imgInfo, sampleType, true); + final ImageLine newline = new ImageLine(imgInfo, sampleType, true); if (sampleType == SampleType.INT) unpackInplaceInt(imgInfo, scanline, newline.scanline, false); else @@ -288,7 +288,7 @@ public class ImageLine { * The caller must be sure that the original was really unpacked */ public ImageLine packToNewImageLine() { - ImageLine newline = new ImageLine(imgInfo, sampleType, false); + final ImageLine newline = new ImageLine(imgInfo, sampleType, false); if (sampleType == SampleType.INT) packInplaceInt(imgInfo, scanline, newline.scanline, false); else @@ -300,7 +300,7 @@ public class ImageLine { return filterUsed; } - public void setFilterUsed(FilterType ft) { + public void setFilterUsed(final FilterType ft) { filterUsed = ft; } @@ -323,9 +323,9 @@ public class ImageLine { /** * Prints some statistics - just for debugging */ - public static void showLineInfo(ImageLine line) { + public static void showLineInfo(final ImageLine line) { System.out.println(line); - ImageLineStats stats = new ImageLineHelper.ImageLineStats(line); + final ImageLineStats stats = new ImageLineHelper.ImageLineStats(line); System.out.println(stats); System.out.println(ImageLineHelper.infoFirstLastPixels(line)); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java index 4636c3955..616ccd560 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java @@ -33,28 +33,28 @@ public class ImageLineHelper { * @return R G B (A), one sample 0-255 per array element. Ready for * pngw.writeRowInt() */ - public static int[] palette2rgb(ImageLine line, PngChunkPLTE pal, PngChunkTRNS trns, int[] buf) { - boolean isalpha = trns != null; - int channels = isalpha ? 4 : 3; - int nsamples = line.imgInfo.cols * channels; + public static int[] palette2rgb(ImageLine line, final PngChunkPLTE pal, final PngChunkTRNS trns, int[] buf) { + final boolean isalpha = trns != null; + final int channels = isalpha ? 4 : 3; + final int nsamples = line.imgInfo.cols * channels; if (buf == null || buf.length < nsamples) buf = new int[nsamples]; if (!line.samplesUnpacked) line = line.unpackToNewImageLine(); - boolean isbyte = line.sampleType == SampleType.BYTE; - int nindexesWithAlpha = trns != null ? trns.getPalletteAlpha().length : 0; + final boolean isbyte = line.sampleType == SampleType.BYTE; + final int nindexesWithAlpha = trns != null ? trns.getPalletteAlpha().length : 0; for (int c = 0; c < line.imgInfo.cols; c++) { - int index = isbyte ? (line.scanlineb[c] & 0xFF) : line.scanline[c]; + final int index = isbyte ? (line.scanlineb[c] & 0xFF) : line.scanline[c]; pal.getEntryRgb(index, buf, c * channels); if (isalpha) { - int alpha = index < nindexesWithAlpha ? trns.getPalletteAlpha()[index] : 255; + final int alpha = index < nindexesWithAlpha ? trns.getPalletteAlpha()[index] : 255; buf[c * channels + 3] = alpha; } } return buf; } - public static int[] palette2rgb(ImageLine line, PngChunkPLTE pal, int[] buf) { + public static int[] palette2rgb(final ImageLine line, final PngChunkPLTE pal, final int[] buf) { return palette2rgb(line, pal, null, buf); } @@ -65,7 +65,7 @@ public class ImageLineHelper { * Just for basic info or debugging. Shows values for first and last pixel. * Does not include alpha */ - public static String infoFirstLastPixels(ImageLine line) { + public static String infoFirstLastPixels(final ImageLine line) { return line.imgInfo.channels == 1 ? String.format("first=(%d) last=(%d)", line.scanline[0], line.scanline[line.scanline.length - 1]) : String.format("first=(%d %d %d) last=(%d %d %d)", line.scanline[0], line.scanline[1], line.scanline[2], line.scanline[line.scanline.length @@ -73,8 +73,8 @@ public class ImageLineHelper { line.scanline[line.scanline.length - line.imgInfo.channels + 2]); } - public static String infoFull(ImageLine line) { - ImageLineStats stats = new ImageLineStats(line); + public static String infoFull(final ImageLine line) { + final ImageLineStats stats = new ImageLineStats(line); return "row=" + line.getRown() + " " + stats.toString() + "\n " + infoFirstLastPixels(line); } @@ -104,7 +104,7 @@ public class ImageLineHelper { + String.format(" maxdif=(%.1f %.1f %.1f %.1f)", maxdif[0], maxdif[1], maxdif[2], maxdif[3]); } - public ImageLineStats(ImageLine line) { + public ImageLineStats(final ImageLine line) { this.channels = line.channels; if (line.channels < 3) throw new PngjException("ImageLineStats only works for RGB - RGBA"); @@ -146,18 +146,18 @@ public class ImageLineHelper { * integer packed R G B only for bitdepth=8! (does not check!) * **/ - public static int getPixelRGB8(ImageLine line, int column) { - int offset = column * line.channels; + public static int getPixelRGB8(final ImageLine line, final int column) { + final int offset = column * line.channels; return (line.scanline[offset] << 16) + (line.scanline[offset + 1] << 8) + (line.scanline[offset + 2]); } - public static int getPixelARGB8(ImageLine line, int column) { - int offset = column * line.channels; + public static int getPixelARGB8(final ImageLine line, final int column) { + final int offset = column * line.channels; return (line.scanline[offset + 3] << 24) + (line.scanline[offset] << 16) + (line.scanline[offset + 1] << 8) + (line.scanline[offset + 2]); } - public static void setPixelsRGB8(ImageLine line, int[] rgb) { + public static void setPixelsRGB8(final ImageLine line, final int[] rgb) { for (int i = 0, j = 0; i < line.imgInfo.cols; i++) { line.scanline[j++] = ((rgb[i] >> 16) & 0xFF); line.scanline[j++] = ((rgb[i] >> 8) & 0xFF); @@ -165,18 +165,18 @@ public class ImageLineHelper { } } - public static void setPixelRGB8(ImageLine line, int col, int r, int g, int b) { + public static void setPixelRGB8(final ImageLine line, int col, final int r, final int g, final int b) { col *= line.channels; line.scanline[col++] = r; line.scanline[col++] = g; line.scanline[col] = b; } - public static void setPixelRGB8(ImageLine line, int col, int rgb) { + public static void setPixelRGB8(final ImageLine line, final int col, final int rgb) { setPixelRGB8(line, col, (rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF); } - public static void setPixelsRGBA8(ImageLine line, int[] rgb) { + public static void setPixelsRGBA8(final ImageLine line, final int[] rgb) { for (int i = 0, j = 0; i < line.imgInfo.cols; i++) { line.scanline[j++] = ((rgb[i] >> 16) & 0xFF); line.scanline[j++] = ((rgb[i] >> 8) & 0xFF); @@ -185,7 +185,7 @@ public class ImageLineHelper { } } - public static void setPixelRGBA8(ImageLine line, int col, int r, int g, int b, int a) { + public static void setPixelRGBA8(final ImageLine line, int col, final int r, final int g, final int b, final int a) { col *= line.channels; line.scanline[col++] = r; line.scanline[col++] = g; @@ -193,53 +193,53 @@ public class ImageLineHelper { line.scanline[col] = a; } - public static void setPixelRGBA8(ImageLine line, int col, int rgb) { + public static void setPixelRGBA8(final ImageLine line, final int col, final int rgb) { setPixelRGBA8(line, col, (rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF, (rgb >> 24) & 0xFF); } - public static void setValD(ImageLine line, int i, double d) { + public static void setValD(final ImageLine line, final int i, final double d) { line.scanline[i] = double2int(line, d); } - public static int interpol(int a, int b, int c, int d, double dx, double dy) { + public static int interpol(final int a, final int b, final int c, final int d, final double dx, final double dy) { // a b -> x (0-1) // c d // - double e = a * (1.0 - dx) + b * dx; - double f = c * (1.0 - dx) + d * dx; + final double e = a * (1.0 - dx) + b * dx; + final double f = c * (1.0 - dx) + d * dx; return (int) (e * (1 - dy) + f * dy + 0.5); } - public static double int2double(ImageLine line, int p) { + public static double int2double(final ImageLine line, final int p) { return line.bitDepth == 16 ? p / 65535.0 : p / 255.0; // TODO: replace my multiplication? check for other bitdepths } - public static double int2doubleClamped(ImageLine line, int p) { + public static double int2doubleClamped(final ImageLine line, final int p) { // TODO: replace my multiplication? - double d = line.bitDepth == 16 ? p / 65535.0 : p / 255.0; + final double d = line.bitDepth == 16 ? p / 65535.0 : p / 255.0; return d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); } - public static int double2int(ImageLine line, double d) { + public static int double2int(final ImageLine line, double d) { d = d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); return line.bitDepth == 16 ? (int) (d * 65535.0 + 0.5) : (int) (d * 255.0 + 0.5); // } - public static int double2intClamped(ImageLine line, double d) { + public static int double2intClamped(final ImageLine line, double d) { d = d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); return line.bitDepth == 16 ? (int) (d * 65535.0 + 0.5) : (int) (d * 255.0 + 0.5); // } - public static int clampTo_0_255(int i) { + public static int clampTo_0_255(final int i) { return i > 255 ? 255 : (i < 0 ? 0 : i); } - public static int clampTo_0_65535(int i) { + public static int clampTo_0_65535(final int i) { return i > 65535 ? 65535 : (i < 0 ? 0 : i); } - public static int clampTo_128_127(int x) { + public static int clampTo_128_127(final int x) { return x > 127 ? 127 : (x < -128 ? -128 : x); } @@ -255,9 +255,9 @@ public class ImageLineHelper { * You probably should use {@link ImageLine#unpackToNewImageLine()} * */ - public static int[] unpack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { - int len1 = imgInfo.samplesPerRow; - int len0 = imgInfo.samplesPerRowPacked; + public static int[] unpack(final ImageInfo imgInfo, final int[] src, int[] dst, final boolean scale) { + final int len1 = imgInfo.samplesPerRow; + final int len0 = imgInfo.samplesPerRowPacked; if (dst == null || dst.length < len1) dst = new int[len1]; if (imgInfo.packed) @@ -267,9 +267,9 @@ public class ImageLineHelper { return dst; } - public static byte[] unpack(ImageInfo imgInfo, byte[] src, byte[] dst, boolean scale) { - int len1 = imgInfo.samplesPerRow; - int len0 = imgInfo.samplesPerRowPacked; + public static byte[] unpack(final ImageInfo imgInfo, final byte[] src, byte[] dst, final boolean scale) { + final int len1 = imgInfo.samplesPerRow; + final int len0 = imgInfo.samplesPerRowPacked; if (dst == null || dst.length < len1) dst = new byte[len1]; if (imgInfo.packed) @@ -286,8 +286,8 @@ public class ImageLineHelper { * * You probably should use {@link ImageLine#packToNewImageLine()} */ - public static int[] pack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { - int len0 = imgInfo.samplesPerRowPacked; + public static int[] pack(final ImageInfo imgInfo, final int[] src, int[] dst, final boolean scale) { + final int len0 = imgInfo.samplesPerRowPacked; if (dst == null || dst.length < len0) dst = new int[len0]; if (imgInfo.packed) @@ -297,8 +297,8 @@ public class ImageLineHelper { return dst; } - public static byte[] pack(ImageInfo imgInfo, byte[] src, byte[] dst, boolean scale) { - int len0 = imgInfo.samplesPerRowPacked; + public static byte[] pack(final ImageInfo imgInfo, final byte[] src, byte[] dst, final boolean scale) { + final int len0 = imgInfo.samplesPerRowPacked; if (dst == null || dst.length < len0) dst = new byte[len0]; if (imgInfo.packed) @@ -308,7 +308,7 @@ public class ImageLineHelper { return dst; } - static int getMaskForPackedFormats(int bitDepth) { // Utility function for pack/unpack + static int getMaskForPackedFormats(final int bitDepth) { // Utility function for pack/unpack if (bitDepth == 4) return 0xf0; else if (bitDepth == 2) @@ -317,7 +317,7 @@ public class ImageLineHelper { return 0x80; // bitDepth == 1 } - static int getMaskForPackedFormatsLs(int bitDepth) { // Utility function for pack/unpack + static int getMaskForPackedFormatsLs(final int bitDepth) { // Utility function for pack/unpack if (bitDepth == 4) return 0x0f; else if (bitDepth == 2) diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java index fb2cf5910..8f6216ab2 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java @@ -36,7 +36,7 @@ public class ImageLines { * @param nRows * @param rowStep */ - public ImageLines(ImageInfo imgInfo, SampleType stype, boolean unpackedMode, int rowOffset, int nRows, int rowStep) { + public ImageLines(final ImageInfo imgInfo, final SampleType stype, final boolean unpackedMode, final int rowOffset, final int nRows, final int rowStep) { this.imgInfo = imgInfo; channels = imgInfo.channels; bitDepth = imgInfo.bitDepth; @@ -61,8 +61,8 @@ public class ImageLines { * and rounding down) Eg: rowOffset=4,rowStep=2 imageRowToMatrixRow(17) * returns 6 , imageRowToMatrixRow(1) returns 0 */ - public int imageRowToMatrixRow(int imrow) { - int r = (imrow - rowOffset) / rowStep; + public int imageRowToMatrixRow(final int imrow) { + final int r = (imrow - rowOffset) / rowStep; return r < 0 ? 0 : (r < nRows ? r : nRows - 1); } @@ -71,7 +71,7 @@ public class ImageLines { */ public int imageRowToMatrixRowStrict(int imrow) { imrow -= rowOffset; - int mrow = imrow >= 0 && imrow % rowStep == 0 ? imrow / rowStep : -1; + final int mrow = imrow >= 0 && imrow % rowStep == 0 ? imrow / rowStep : -1; return mrow < nRows ? mrow : -1; } @@ -82,7 +82,7 @@ public class ImageLines { * Matrix row number * @return Image row number. Invalid only if mrow is invalid */ - public int matrixRowToImageRow(int mrow) { + public int matrixRowToImageRow(final int mrow) { return mrow * rowStep + rowOffset; } @@ -96,10 +96,10 @@ public class ImageLines { * @return A new ImageLine, backed by the matrix, with the correct ('real') * rownumber */ - public ImageLine getImageLineAtMatrixRow(int mrow) { + public ImageLine getImageLineAtMatrixRow(final int mrow) { if (mrow < 0 || mrow > nRows) throw new PngjException("Bad row " + mrow + ". Should be positive and less than " + nRows); - ImageLine imline = sampleType == SampleType.INT ? new ImageLine(imgInfo, sampleType, samplesUnpacked, + final ImageLine imline = sampleType == SampleType.INT ? new ImageLine(imgInfo, sampleType, samplesUnpacked, scanlines[mrow], null) : new ImageLine(imgInfo, sampleType, samplesUnpacked, null, scanlinesb[mrow]); imline.setRown(matrixRowToImageRow(mrow)); return imline; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java index e099c4f6a..436821cf7 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java @@ -20,7 +20,7 @@ class PngDeinterlacer { private short[][] imageShort; private byte[][] imageByte; - PngDeinterlacer(ImageInfo iminfo) { + PngDeinterlacer(final ImageInfo iminfo) { this.imi = iminfo; pass = 0; if (imi.packed) { @@ -40,14 +40,14 @@ class PngDeinterlacer { } /** this refers to the row currRowSubimg */ - void setRow(int n) { + void setRow(final int n) { currRowSubimg = n; currRowReal = n * dY + oY; if (currRowReal < 0 || currRowReal >= imi.rows) throw new PngjExceptionInternal("bad row - this should not happen"); } - void setPass(int p) { + void setPass(final int p) { if (this.pass == p) return; pass = p; @@ -105,7 +105,7 @@ class PngDeinterlacer { } // notice that this is a "partial" deinterlace, it will be called several times for the same row! - void deinterlaceInt(int[] src, int[] dst, boolean readInPackedFormat) { + void deinterlaceInt(final int[] src, final int[] dst, final boolean readInPackedFormat) { if (!(imi.packed && readInPackedFormat)) for (int i = 0, j = oXsamples; i < cols * imi.channels; i += imi.channels, j += dXsamples) for (int k = 0; k < imi.channels; k++) @@ -115,7 +115,7 @@ class PngDeinterlacer { } // interlaced+packed = monster; this is very clumsy! - private void deinterlaceIntPacked(int[] src, int[] dst) { + private void deinterlaceIntPacked(final int[] src, final int[] dst) { int spos, smod, smask; // source byte position, bits to shift to left (01,2,3,4 int tpos, tmod, p, d; spos = 0; @@ -143,7 +143,7 @@ class PngDeinterlacer { } // yes, duplication of code is evil, normally - void deinterlaceByte(byte[] src, byte[] dst, boolean readInPackedFormat) { + void deinterlaceByte(final byte[] src, final byte[] dst, final boolean readInPackedFormat) { if (!(imi.packed && readInPackedFormat)) for (int i = 0, j = oXsamples; i < cols * imi.channels; i += imi.channels, j += dXsamples) for (int k = 0; k < imi.channels; k++) @@ -152,7 +152,7 @@ class PngDeinterlacer { deinterlacePackedByte(src, dst); } - private void deinterlacePackedByte(byte[] src, byte[] dst) { + private void deinterlacePackedByte(final byte[] src, final byte[] dst) { int spos, smod, smask; // source byte position, bits to shift to left (01,2,3,4 int tpos, tmod, p, d; // what the heck are you reading here? I told you would not enjoy this. Try Dostoyevsky or Simone Weil instead @@ -230,7 +230,7 @@ class PngDeinterlacer { return imageInt; } - void setImageInt(int[][] imageInt) { + void setImageInt(final int[][] imageInt) { this.imageInt = imageInt; } @@ -238,7 +238,7 @@ class PngDeinterlacer { return imageShort; } - void setImageShort(short[][] imageShort) { + void setImageShort(final short[][] imageShort) { this.imageShort = imageShort; } @@ -246,20 +246,20 @@ class PngDeinterlacer { return imageByte; } - void setImageByte(byte[][] imageByte) { + void setImageByte(final byte[][] imageByte) { this.imageByte = imageByte; } static void test() { - Random rand = new Random(); - PngDeinterlacer ih = new PngDeinterlacer(new ImageInfo(rand.nextInt(35) + 1, rand.nextInt(52) + 1, 8, true)); + final Random rand = new Random(); + final PngDeinterlacer ih = new PngDeinterlacer(new ImageInfo(rand.nextInt(35) + 1, rand.nextInt(52) + 1, 8, true)); int np = ih.imi.cols * ih.imi.rows; System.out.println(ih.imi); for (int p = 1; p <= 7; p++) { ih.setPass(p); for (int row = 0; row < ih.getRows(); row++) { ih.setRow(row); - int b = ih.getCols(); + final int b = ih.getCols(); np -= b; System.out.printf("Read %d pixels. Pass:%d Realline:%d cols=%d dX=%d oX=%d last:%b\n", b, ih.pass, ih.currRowReal, ih.cols, ih.dX, ih.oX, ih.isAtLastRow()); @@ -270,7 +270,7 @@ class PngDeinterlacer { throw new PngjExceptionInternal("wtf??" + ih.imi); } - public static void main(String[] args) { + public static void main(final String[] args) { test(); } 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(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java index cdad09809..cde4b517e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java @@ -18,7 +18,7 @@ class PngIDatChunkInputStream extends InputStream { private final CRC32 crcEngine; private boolean checkCrc = true; private int lenLastChunk; - private byte[] idLastChunk = new byte[4]; + private final byte[] idLastChunk = new byte[4]; private int toReadThisChunk = 0; private boolean ended = false; private long offset; // offset inside whole inputstream (counting bytes before IDAT) @@ -28,7 +28,7 @@ class PngIDatChunkInputStream extends InputStream { public final int len; public final long offset; - private IdatChunkInfo(int len, long offset) { + private IdatChunkInfo(final int len, final long offset) { this.len = len; this.offset = offset; } @@ -40,7 +40,7 @@ class PngIDatChunkInputStream extends InputStream { * Constructor must be called just after reading length and id of first IDAT * chunk **/ - PngIDatChunkInputStream(InputStream iStream, int lenFirstChunk, long offset) { + PngIDatChunkInputStream(final InputStream iStream, final int lenFirstChunk, final long offset) { this.offset = offset; inputStream = iStream; this.lenLastChunk = lenFirstChunk; @@ -70,10 +70,10 @@ class PngIDatChunkInputStream extends InputStream { // Those values are left in idLastChunk / lenLastChunk // Skips empty IDATS do { - int crc = PngHelperInternal.readInt4(inputStream); // + final int crc = PngHelperInternal.readInt4(inputStream); // offset += 4; if (checkCrc) { - int crccalc = (int) crcEngine.getValue(); + final int crccalc = (int) crcEngine.getValue(); if (lenLastChunk > 0 && crc != crccalc) throw new PngjBadCrcException("error reading idat; offset: " + offset); crcEngine.reset(); @@ -101,7 +101,7 @@ class PngIDatChunkInputStream extends InputStream { */ void forceChunkEnd() { if (!ended) { - byte[] dummy = new byte[toReadThisChunk]; + final byte[] dummy = new byte[toReadThisChunk]; PngHelperInternal.readBytes(inputStream, dummy, 0, toReadThisChunk); if (checkCrc) crcEngine.update(dummy, 0, toReadThisChunk); @@ -114,12 +114,12 @@ class PngIDatChunkInputStream extends InputStream { * ended prematurely. That is our error. */ @Override - public int read(byte[] b, int off, int len) throws IOException { + public int read(final byte[] b, final int off, final int len) throws IOException { if (ended) return -1; // can happen only when raw reading, see Pngreader.readAndSkipsAllRows() if (toReadThisChunk == 0) throw new PngjExceptionInternal("this should not happen"); - int n = inputStream.read(b, off, len >= toReadThisChunk ? toReadThisChunk : len); + final int n = inputStream.read(b, off, len >= toReadThisChunk ? toReadThisChunk : len); if (n > 0) { if (checkCrc) crcEngine.update(b, off, n); @@ -133,7 +133,7 @@ class PngIDatChunkInputStream extends InputStream { } @Override - public int read(byte[] b) throws IOException { + public int read(final byte[] b) throws IOException { return this.read(b, 0, b.length); } @@ -141,8 +141,8 @@ class PngIDatChunkInputStream extends InputStream { public int read() throws IOException { // PngHelper.logdebug("read() should go here"); // inneficient - but this should be used rarely - byte[] b1 = new byte[1]; - int r = this.read(b1, 0, 1); + final byte[] b1 = new byte[1]; + final int r = this.read(b1, 0, 1); return r < 0 ? -1 : (int) b1[0]; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java index 411d18819..38b500cd3 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java @@ -13,18 +13,18 @@ class PngIDatChunkOutputStream extends ProgressiveOutputStream { private static final int SIZE_DEFAULT = 32768; // 32k private final OutputStream outputStream; - PngIDatChunkOutputStream(OutputStream outputStream) { + PngIDatChunkOutputStream(final OutputStream outputStream) { this(outputStream, 0); } - PngIDatChunkOutputStream(OutputStream outputStream, int size) { + PngIDatChunkOutputStream(final OutputStream outputStream, final int size) { super(size > 0 ? size : SIZE_DEFAULT); this.outputStream = outputStream; } @Override - protected final void flushBuffer(byte[] b, int len) { - ChunkRaw c = new ChunkRaw(len, ChunkHelper.b_IDAT, false); + protected final void flushBuffer(final byte[] b, final int len) { + final ChunkRaw c = new ChunkRaw(len, ChunkHelper.b_IDAT, false); c.data = b; c.writeChunk(outputStream); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java index 0412beb8c..f77d4f4e0 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java @@ -100,32 +100,32 @@ public class PngReader { * error/debug messages * */ - public PngReader(InputStream inputStream, String filenameOrDescription) { + public PngReader(final InputStream inputStream, final String filenameOrDescription) { this.filename = filenameOrDescription == null ? "" : filenameOrDescription; this.inputStream = inputStream; this.chunksList = new ChunksList(null); this.metadata = new PngMetadata(chunksList); // starts reading: signature - byte[] pngid = new byte[8]; + final byte[] pngid = new byte[8]; PngHelperInternal.readBytes(inputStream, pngid, 0, pngid.length); offset += pngid.length; if (!Arrays.equals(pngid, PngHelperInternal.getPngIdSignature())) throw new PngjInputException("Bad PNG signature"); // reads first chunk currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; - int clen = PngHelperInternal.readInt4(inputStream); + final int clen = PngHelperInternal.readInt4(inputStream); offset += 4; if (clen != 13) throw new PngjInputException("IDHR chunk len != 13 ?? " + clen); - byte[] chunkid = new byte[4]; + final byte[] chunkid = new byte[4]; PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); if (!Arrays.equals(chunkid, ChunkHelper.b_IHDR)) throw new PngjInputException("IHDR not found as first chunk??? [" + ChunkHelper.toString(chunkid) + "]"); offset += 4; - PngChunkIHDR ihdr = (PngChunkIHDR) readChunk(chunkid, clen, false); - boolean alpha = (ihdr.getColormodel() & 0x04) != 0; - boolean palette = (ihdr.getColormodel() & 0x01) != 0; - boolean grayscale = (ihdr.getColormodel() == 0 || ihdr.getColormodel() == 4); + final PngChunkIHDR ihdr = (PngChunkIHDR) readChunk(chunkid, clen, false); + final boolean alpha = (ihdr.getColormodel() & 0x04) != 0; + final boolean palette = (ihdr.getColormodel() & 0x01) != 0; + final boolean grayscale = (ihdr.getColormodel() == 0 || ihdr.getColormodel() == 4); // creates ImgInfo and imgLine, and allocates buffers imgInfo = new ImageInfo(ihdr.getCols(), ihdr.getRows(), ihdr.getBitspc(), alpha, grayscale, palette); interlaced = ihdr.getInterlaced() == 1; @@ -163,7 +163,7 @@ public class PngReader { if (currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) { try { idatIstream.close(); - } catch (Exception e) { + } catch (final Exception e) { } readLastChunks(); } @@ -174,23 +174,23 @@ public class PngReader { if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) { // this could only happen if forced close try { idatIstream.close(); - } catch (Exception e) { + } catch (final Exception e) { } currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; } if (shouldCloseStream) { try { inputStream.close(); - } catch (Exception e) { + } catch (final Exception e) { throw new PngjInputException("error closing input stream!", e); } } } // nbytes: NOT including the filter byte. leaves result in rowb - private void unfilterRow(int nbytes) { - int ftn = rowbfilter[0]; - FilterType ft = FilterType.getByVal(ftn); + private void unfilterRow(final int nbytes) { + final int ftn = rowbfilter[0]; + final FilterType ft = FilterType.getByVal(ftn); if (ft == null) throw new PngjInputException("Filter type " + ftn + " invalid"); switch (ft) { @@ -226,7 +226,7 @@ public class PngReader { private void unfilterRowNone(final int nbytes) { for (int i = 1; i <= nbytes; i++) { - rowb[i] = (byte) (rowbfilter[i]); + rowb[i] = (rowbfilter[i]); } } @@ -242,7 +242,7 @@ public class PngReader { private void unfilterRowSub(final int nbytes) { int i, j; for (i = 1; i <= imgInfo.bytesPixel; i++) { - rowb[i] = (byte) (rowbfilter[i]); + rowb[i] = (rowbfilter[i]); } for (j = 1, i = imgInfo.bytesPixel + 1; i <= nbytes; i++, j++) { rowb[i] = (byte) (rowbfilter[i] + rowb[j]); @@ -276,7 +276,7 @@ public class PngReader { return; int clen = 0; boolean found = false; - byte[] chunkid = new byte[4]; // it's important to reallocate in each iteration + final byte[] chunkid = new byte[4]; // it's important to reallocate in each iteration currentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; while (!found) { clen = PngHelperInternal.readInt4(inputStream); @@ -300,7 +300,7 @@ public class PngReader { if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) currentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; } - int idatLen = found ? clen : -1; + final int idatLen = found ? clen : -1; if (idatLen < 0) throw new PngjInputException("first idat chunk not found!"); iIdatCstream = new PngIDatChunkInputStream(inputStream, idatLen, offset); @@ -323,7 +323,7 @@ public class PngReader { if (!iIdatCstream.isEnded()) iIdatCstream.forceChunkEnd(); int clen = iIdatCstream.getLenLastChunk(); - byte[] chunkid = iIdatCstream.getIdLastChunk(); + final byte[] chunkid = iIdatCstream.getIdLastChunk(); boolean endfound = false; boolean first = true; boolean skip = false; @@ -355,14 +355,14 @@ public class PngReader { * Reads chunkd from input stream, adds to ChunksList, and returns it. If * it's skipped, a PngChunkSkipped object is created */ - private PngChunk readChunk(byte[] chunkid, int clen, boolean skipforced) { + private PngChunk readChunk(final byte[] chunkid, final int clen, final boolean skipforced) { if (clen < 0) throw new PngjInputException("invalid chunk lenght: " + clen); // skipChunksByIdSet is created lazyly, if fist IHDR has already been read if (skipChunkIdsSet == null && currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR) skipChunkIdsSet = new HashSet(Arrays.asList(skipChunkIds)); - String chunkidstr = ChunkHelper.toString(chunkid); - boolean critical = ChunkHelper.isCritical(chunkidstr); + final String chunkidstr = ChunkHelper.toString(chunkid); + final boolean critical = ChunkHelper.isCritical(chunkidstr); PngChunk pngChunk = null; boolean skip = skipforced; if (maxTotalBytesRead > 0 && clen + offset > maxTotalBytesRead) @@ -379,7 +379,7 @@ public class PngReader { // clen + 4) for risk of overflow pngChunk = new PngChunkSkipped(chunkidstr, imgInfo, clen); } else { - ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); + final ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); chunk.readChunkData(inputStream, crcEnabled || critical); pngChunk = PngChunk.factory(chunk, imgInfo); if (!pngChunk.crit) @@ -398,7 +398,7 @@ public class PngReader { *

* This happens rarely - most errors are fatal. */ - protected void logWarn(String warn) { + protected void logWarn(final String warn) { System.err.println(warn); } @@ -415,7 +415,7 @@ public class PngReader { * @param chunkLoadBehaviour * {@link ChunkLoadBehaviour} */ - public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) { + public void setChunkLoadBehaviour(final ChunkLoadBehaviour chunkLoadBehaviour) { this.chunkLoadBehaviour = chunkLoadBehaviour; } @@ -459,7 +459,7 @@ public class PngReader { * * @see #readRowInt(int) {@link #readRowByte(int)} */ - public ImageLine readRow(int nrow) { + public ImageLine readRow(final int nrow) { if (imgLine == null) imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); return imgLine.sampleType != SampleType.BYTE ? readRowInt(nrow) : readRowByte(nrow); @@ -476,7 +476,7 @@ public class PngReader { * @return ImageLine object, also available as field. Data is in * {@link ImageLine#scanline} (int) field. */ - public ImageLine readRowInt(int nrow) { + public ImageLine readRowInt(final int nrow) { if (imgLine == null) imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); if (imgLine.getRown() == nrow) // already read @@ -499,7 +499,7 @@ public class PngReader { * @return ImageLine object, also available as field. Data is in * {@link ImageLine#scanlineb} (byte) field. */ - public ImageLine readRowByte(int nrow) { + public ImageLine readRowByte(final int nrow) { if (imgLine == null) imgLine = new ImageLine(imgInfo, SampleType.BYTE, unpackedMode); if (imgLine.getRown() == nrow) // already read @@ -513,7 +513,7 @@ public class PngReader { /** * @see #readRowInt(int[], int) */ - public final int[] readRow(int[] buffer, final int nrow) { + public final int[] readRow(final int[] buffer, final int nrow) { return readRowInt(buffer, nrow); } @@ -596,11 +596,11 @@ public class PngReader { * @deprecated Now {@link #readRow(int)} implements the same funcion. This * method will be removed in future releases */ - public ImageLine getRow(int nrow) { + public ImageLine getRow(final int nrow) { return readRow(nrow); } - private void decodeLastReadRowToInt(int[] buffer, int bytesRead) { + private void decodeLastReadRowToInt(final int[] buffer, final int bytesRead) { if (imgInfo.bitDepth <= 8) for (int i = 0, j = 1; i < bytesRead; i++) buffer[i] = (rowb[j++] & 0xFF); // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html @@ -611,7 +611,7 @@ public class PngReader { ImageLine.unpackInplaceInt(imgInfo, buffer, buffer, false); } - private void decodeLastReadRowToByte(byte[] buffer, int bytesRead) { + private void decodeLastReadRowToByte(final byte[] buffer, final int bytesRead) { if (imgInfo.bitDepth <= 8) System.arraycopy(rowb, 1, buffer, 0, bytesRead); else @@ -644,27 +644,27 @@ public class PngReader { * even/odd lines, etc * @return Set of lines as a ImageLines, which wraps a matrix */ - public ImageLines readRowsInt(int rowOffset, int nRows, int rowStep) { + public ImageLines readRowsInt(final int rowOffset, int nRows, final int rowStep) { if (nRows < 0) nRows = (imgInfo.rows - rowOffset) / rowStep; if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) throw new PngjInputException("bad args"); - ImageLines imlines = new ImageLines(imgInfo, SampleType.INT, unpackedMode, rowOffset, nRows, rowStep); + final ImageLines imlines = new ImageLines(imgInfo, SampleType.INT, unpackedMode, rowOffset, nRows, rowStep); if (!interlaced) { for (int j = 0; j < imgInfo.rows; j++) { - int bytesread = readRowRaw(j); // read and perhaps discards - int mrow = imlines.imageRowToMatrixRowStrict(j); + final int bytesread = readRowRaw(j); // read and perhaps discards + final int mrow = imlines.imageRowToMatrixRowStrict(j); if (mrow >= 0) decodeLastReadRowToInt(imlines.scanlines[mrow], bytesread); } } else { // and now, for something completely different (interlaced) - int[] buf = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + final int[] buf = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; for (int p = 1; p <= 7; p++) { deinterlacer.setPass(p); for (int i = 0; i < deinterlacer.getRows(); i++) { - int bytesread = readRowRaw(i); - int j = deinterlacer.getCurrRowReal(); - int mrow = imlines.imageRowToMatrixRowStrict(j); + final int bytesread = readRowRaw(i); + final int j = deinterlacer.getCurrRowReal(); + final int mrow = imlines.imageRowToMatrixRowStrict(j); if (mrow >= 0) { decodeLastReadRowToInt(buf, bytesread); deinterlacer.deinterlaceInt(buf, imlines.scanlines[mrow], !unpackedMode); @@ -709,27 +709,27 @@ public class PngReader { * even/odd lines, etc * @return Set of lines as a matrix */ - public ImageLines readRowsByte(int rowOffset, int nRows, int rowStep) { + public ImageLines readRowsByte(final int rowOffset, int nRows, final int rowStep) { if (nRows < 0) nRows = (imgInfo.rows - rowOffset) / rowStep; if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) throw new PngjInputException("bad args"); - ImageLines imlines = new ImageLines(imgInfo, SampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep); + final ImageLines imlines = new ImageLines(imgInfo, SampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep); if (!interlaced) { for (int j = 0; j < imgInfo.rows; j++) { - int bytesread = readRowRaw(j); // read and perhaps discards - int mrow = imlines.imageRowToMatrixRowStrict(j); + final int bytesread = readRowRaw(j); // read and perhaps discards + final int mrow = imlines.imageRowToMatrixRowStrict(j); if (mrow >= 0) decodeLastReadRowToByte(imlines.scanlinesb[mrow], bytesread); } } else { // and now, for something completely different (interlaced) - byte[] buf = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + final byte[] buf = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; for (int p = 1; p <= 7; p++) { deinterlacer.setPass(p); for (int i = 0; i < deinterlacer.getRows(); i++) { - int bytesread = readRowRaw(i); - int j = deinterlacer.getCurrRowReal(); - int mrow = imlines.imageRowToMatrixRowStrict(j); + final int bytesread = readRowRaw(i); + final int j = deinterlacer.getCurrRowReal(); + final int mrow = imlines.imageRowToMatrixRowStrict(j); if (mrow >= 0) { decodeLastReadRowToByte(buf, bytesread); deinterlacer.deinterlaceByte(buf, imlines.scanlinesb[mrow], !unpackedMode); @@ -784,7 +784,7 @@ public class PngReader { } rowNum = nrow; // swap buffers - byte[] tmp = rowb; + final byte[] tmp = rowb; rowb = rowbprev; rowbprev = tmp; // loads in rowbfilter "raw" bytes, with filter @@ -821,7 +821,7 @@ public class PngReader { do { r = iIdatCstream.read(rowbfilter, 0, buffersLen); } while (r >= 0); - } catch (IOException e) { + } catch (final IOException e) { throw new PngjInputException("error in raw read of IDAT", e); } offset = iIdatCstream.getOffset(); @@ -838,7 +838,7 @@ public class PngReader { * These are the bytes read (not loaded) in the input stream. If exceeded, * an exception will be thrown. */ - public void setMaxTotalBytesRead(long maxTotalBytesToRead) { + public void setMaxTotalBytesRead(final long maxTotalBytesToRead) { this.maxTotalBytesRead = maxTotalBytesToRead; } @@ -854,7 +854,7 @@ public class PngReader { * default: 5Mb).
* If exceeded, some chunks will be skipped */ - public void setMaxBytesMetadata(int maxBytesChunksToLoad) { + public void setMaxBytesMetadata(final int maxBytesChunksToLoad) { this.maxBytesMetadata = maxBytesChunksToLoad; } @@ -872,7 +872,7 @@ public class PngReader { * checked) and the chunk will be saved as a PngChunkSkipped object. See * also setSkipChunkIds */ - public void setSkipChunkMaxSize(int skipChunksBySize) { + public void setSkipChunkMaxSize(final int skipChunksBySize) { this.skipChunkMaxSize = skipChunksBySize; } @@ -888,7 +888,7 @@ public class PngReader { * These chunks will be skipped (the CRC will not be checked) and the chunk * will be saved as a PngChunkSkipped object. See also setSkipChunkMaxSize */ - public void setSkipChunkIds(String[] skipChunksById) { + public void setSkipChunkIds(final String[] skipChunksById) { this.skipChunkIds = skipChunksById == null ? new String[] {} : skipChunksById; } @@ -904,7 +904,7 @@ public class PngReader { *

* default=true */ - public void setShouldCloseStream(boolean shouldCloseStream) { + public void setShouldCloseStream(final boolean shouldCloseStream) { this.shouldCloseStream = shouldCloseStream; } @@ -936,7 +936,7 @@ public class PngReader { * * @param unPackedMode */ - public void setUnpackedMode(boolean unPackedMode) { + public void setUnpackedMode(final boolean unPackedMode) { this.unpackedMode = unPackedMode; } @@ -954,7 +954,7 @@ public class PngReader { * * @param other A PngReader that has already finished reading pixels. Can be null. */ - public void reuseBuffersFrom(PngReader other) { + public void reuseBuffersFrom(final PngReader other) { if(other==null) return; if (other.currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) throw new PngjInputException("PngReader to be reused have not yet ended reading pixels"); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java index 2f475aab1..ed5dd7d69 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java @@ -64,7 +64,7 @@ public class PngWriter { */ private int deflaterStrategy = Deflater.FILTERED; - private int[] histox = new int[256]; // auxiliar buffer, only used by reportResultsForFilter + private final int[] histox = new int[256]; // auxiliar buffer, only used by reportResultsForFilter private int idatMaxSize = 0; // 0=use default (PngIDatChunkOutputStream 32768) @@ -78,7 +78,7 @@ public class PngWriter { // this only influences the 1-2-4 bitdepth format - and if we pass a ImageLine to writeRow, this is ignored private boolean unpackedMode = false; - public PngWriter(OutputStream outputStream, ImageInfo imgInfo) { + public PngWriter(final OutputStream outputStream, final ImageInfo imgInfo) { this(outputStream, imgInfo, "[NO FILENAME AVAILABLE]"); } @@ -96,7 +96,7 @@ public class PngWriter { * @param filenameOrDescription * Optional, just for error/debug messages */ - public PngWriter(OutputStream outputStream, ImageInfo imgInfo, String filenameOrDescription) { + public PngWriter(final OutputStream outputStream, final ImageInfo imgInfo, final String filenameOrDescription) { this.filename = filenameOrDescription == null ? "" : filenameOrDescription; this.os = outputStream; this.imgInfo = imgInfo; @@ -111,29 +111,29 @@ public class PngWriter { private void init() { datStream = new PngIDatChunkOutputStream(this.os, idatMaxSize); - Deflater def = new Deflater(compLevel); + final Deflater def = new Deflater(compLevel); def.setStrategy(deflaterStrategy); datStreamDeflated = new DeflaterOutputStream(datStream, def); writeSignatureAndIHDR(); writeFirstChunks(); } - private void reportResultsForFilter(int rown, FilterType type, boolean tentative) { + private void reportResultsForFilter(final int rown, final FilterType type, final boolean tentative) { Arrays.fill(histox, 0); int s = 0, v; for (int i = 1; i <= imgInfo.bytesPerRow; i++) { v = rowbfilter[i]; if (v < 0) - s -= (int) v; + s -= v; else - s += (int) v; + s += v; histox[v & 0xFF]++; } filterStrat.fillResultsForFilter(rown, type, s, histox, tentative); } private void writeEndChunk() { - PngChunkIEND c = new PngChunkIEND(imgInfo); + final PngChunkIEND c = new PngChunkIEND(imgInfo); c.createRawChunk().writeChunk(os); } @@ -156,7 +156,7 @@ public class PngWriter { currentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; chunksList.writeChunks(os, currentChunkGroup); // should not be unwriten chunks - List pending = chunksList.getQueuedChunks(); + final List pending = chunksList.getQueuedChunks(); if (!pending.isEmpty()) throw new PngjOutputException(pending.size() + " chunks were not written! Eg: " + pending.get(0).toString()); currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; @@ -169,7 +169,7 @@ public class PngWriter { currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; PngHelperInternal.writeBytes(os, PngHelperInternal.getPngIdSignature()); // signature - PngChunkIHDR ihdr = new PngChunkIHDR(imgInfo); + final PngChunkIHDR ihdr = new PngChunkIHDR(imgInfo); // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html ihdr.setCols(imgInfo.cols); ihdr.setRows(imgInfo.rows); @@ -189,16 +189,16 @@ public class PngWriter { } - protected void encodeRowFromByte(byte[] row) { + protected void encodeRowFromByte(final byte[] row) { if (row.length == imgInfo.samplesPerRowPacked) { // some duplication of code - because this case is typical and it works faster this way int j = 1; if (imgInfo.bitDepth <= 8) { - for (byte x : row) { // optimized + for (final byte x : row) { // optimized rowb[j++] = x; } } else { // 16 bitspc - for (byte x : row) { // optimized + for (final byte x : row) { // optimized rowb[j] = x; j += 2; } @@ -221,17 +221,17 @@ public class PngWriter { } } - protected void encodeRowFromInt(int[] row) { + protected void encodeRowFromInt(final int[] row) { // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html if (row.length == imgInfo.samplesPerRowPacked) { // some duplication of code - because this case is typical and it works faster this way int j = 1; if (imgInfo.bitDepth <= 8) { - for (int x : row) { // optimized + for (final int x : row) { // optimized rowb[j++] = (byte) x; } } else { // 16 bitspc - for (int x : row) { // optimized + for (final int x : row) { // optimized rowb[j++] = (byte) (x >> 8); rowb[j++] = (byte) (x); } @@ -253,7 +253,7 @@ public class PngWriter { } } - private void filterRow(int rown) { + private void filterRow(final int rown) { // warning: filters operation rely on: "previos row" (rowbprev) is // initialized to 0 the first time if (filterStrat.shouldTestAll(rown)) { @@ -268,7 +268,7 @@ public class PngWriter { filterRowPaeth(); reportResultsForFilter(rown, FilterType.FILTER_PAETH, true); } - FilterType filterType = filterStrat.gimmeFilterType(rown, true); + final FilterType filterType = filterStrat.gimmeFilterType(rown, true); rowbfilter[0] = (byte) filterType.val; switch (filterType) { case FILTER_NONE: @@ -292,23 +292,23 @@ public class PngWriter { reportResultsForFilter(rown, filterType, false); } - private void prepareEncodeRow(int rown) { + private void prepareEncodeRow(final int rown) { if (datStream == null) init(); rowNum++; if (rown >= 0 && rowNum != rown) throw new PngjOutputException("rows must be written in order: expected:" + rowNum + " passed:" + rown); // swap - byte[] tmp = rowb; + final byte[] tmp = rowb; rowb = rowbprev; rowbprev = tmp; } - private void filterAndSend(int rown) { + private void filterAndSend(final int rown) { filterRow(rown); try { datStreamDeflated.write(rowbfilter, 0, imgInfo.bytesPerRow + 1); - } catch (IOException e) { + } catch (final IOException e) { throw new PngjOutputException(e); } } @@ -323,7 +323,7 @@ public class PngWriter { protected void filterRowNone() { for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - rowbfilter[i] = (byte) rowb[i]; + rowbfilter[i] = rowb[i]; } } @@ -341,7 +341,7 @@ public class PngWriter { protected void filterRowSub() { int i, j; for (i = 1; i <= imgInfo.bytesPixel; i++) - rowbfilter[i] = (byte) rowb[i]; + rowbfilter[i] = rowb[i]; for (j = 1, i = imgInfo.bytesPixel + 1; i <= imgInfo.bytesPerRow; i++, j++) { // !!! rowbfilter[i] = (byte) (rowb[i] - rowb[j]); rowbfilter[i] = (byte) PngHelperInternal.filterRowSub(rowb[i], rowb[j]); @@ -359,9 +359,9 @@ public class PngWriter { int s = 0; for (int i = 1; i <= imgInfo.bytesPerRow; i++) if (rowbfilter[i] < 0) - s -= (int) rowbfilter[i]; + s -= rowbfilter[i]; else - s += (int) rowbfilter[i]; + s += rowbfilter[i]; return s; } @@ -372,12 +372,12 @@ public class PngWriter { *

* TODO: this should be more customizable */ - private void copyChunks(PngReader reader, int copy_mask, boolean onlyAfterIdat) { - boolean idatDone = currentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; + private void copyChunks(final PngReader reader, final int copy_mask, final boolean onlyAfterIdat) { + final boolean idatDone = currentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; if (onlyAfterIdat && reader.getCurrentChunkGroup() < ChunksList.CHUNK_GROUP_6_END) throw new PngjExceptionInternal("tried to copy last chunks but reader has not ended"); - for (PngChunk chunk : reader.getChunksList().getChunks()) { - int group = chunk.getChunkGroup(); + for (final PngChunk chunk : reader.getChunksList().getChunks()) { + final int group = chunk.getChunkGroup(); if (group < ChunksList.CHUNK_GROUP_4_IDAT && idatDone) continue; boolean copy = false; @@ -389,8 +389,8 @@ public class PngWriter { copy = true; } } else { // ancillary - boolean text = (chunk instanceof PngChunkTextVar); - boolean safe = chunk.safe; + final boolean text = (chunk instanceof PngChunkTextVar); + final boolean safe = chunk.safe; // notice that these if are not exclusive if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) copy = true; @@ -429,7 +429,7 @@ public class PngWriter { * : Mask bit (OR), see ChunksToWrite.COPY_XXX * constants */ - public void copyChunksFirst(PngReader reader, int copy_mask) { + public void copyChunksFirst(final PngReader reader, final int copy_mask) { copyChunks(reader, copy_mask, false); } @@ -446,7 +446,7 @@ public class PngWriter { * : Mask bit (OR), see ChunksToWrite.COPY_XXX * constants */ - public void copyChunksLast(PngReader reader, int copy_mask) { + public void copyChunksLast(final PngReader reader, final int copy_mask) { copyChunks(reader, copy_mask, true); } @@ -461,8 +461,8 @@ public class PngWriter { public double computeCompressionRatio() { if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) throw new PngjOutputException("must be called after end()"); - double compressed = (double) datStream.getCountFlushed(); - double raw = (imgInfo.bytesPerRow + 1) * imgInfo.rows; + final double compressed = datStream.getCountFlushed(); + final double raw = (imgInfo.bytesPerRow + 1) * imgInfo.rows; return compressed / raw; } @@ -480,7 +480,7 @@ public class PngWriter { writeEndChunk(); if (shouldCloseStream) os.close(); - } catch (IOException e) { + } catch (final IOException e) { throw new PngjOutputException(e); } } @@ -516,7 +516,7 @@ public class PngWriter { * @param compLevel * between 0 and 9 (default:6 , recommended: 6 or more) */ - public void setCompLevel(int compLevel) { + public void setCompLevel(final int compLevel) { if (compLevel < 0 || compLevel > 9) throw new PngjOutputException("Compression level invalid (" + compLevel + ") Must be 0..9"); this.compLevel = compLevel; @@ -534,7 +534,7 @@ public class PngWriter { * PngFilterType) Recommended values: DEFAULT * (default) or AGGRESIVE */ - public void setFilterType(FilterType filterType) { + public void setFilterType(final FilterType filterType) { filterStrat = new FilterWriteStrategy(imgInfo, filterType); } @@ -546,7 +546,7 @@ public class PngWriter { * @param idatMaxSize * default=0 : use defaultSize (32K) */ - public void setIdatMaxSize(int idatMaxSize) { + public void setIdatMaxSize(final int idatMaxSize) { this.idatMaxSize = idatMaxSize; } @@ -555,7 +555,7 @@ public class PngWriter { *

* default=true */ - public void setShouldCloseStream(boolean shouldCloseStream) { + public void setShouldCloseStream(final boolean shouldCloseStream) { this.shouldCloseStream = shouldCloseStream; } @@ -565,7 +565,7 @@ public class PngWriter { *

* Default: Deflater.FILTERED . This should be changed very rarely. */ - public void setDeflaterStrategy(int deflaterStrategy) { + public void setDeflaterStrategy(final int deflaterStrategy) { this.deflaterStrategy = deflaterStrategy; } @@ -575,7 +575,7 @@ public class PngWriter { * * @deprecated Better use writeRow(ImageLine imgline, int rownumber) */ - public void writeRow(ImageLine imgline) { + public void writeRow(final ImageLine imgline) { writeRow(imgline.scanline, imgline.getRown()); } @@ -586,7 +586,7 @@ public class PngWriter { * * @see #writeRowInt(int[], int) */ - public void writeRow(ImageLine imgline, int rownumber) { + public void writeRow(final ImageLine imgline, final int rownumber) { unpackedMode = imgline.samplesUnpacked; if (imgline.sampleType == SampleType.INT) writeRowInt(imgline.scanline, rownumber); @@ -599,7 +599,7 @@ public class PngWriter { * * @param newrow */ - public void writeRow(int[] newrow) { + public void writeRow(final int[] newrow) { writeRow(newrow, -1); } @@ -608,7 +608,7 @@ public class PngWriter { * * @see #writeRowInt(int[], int) */ - public void writeRow(int[] newrow, int rown) { + public void writeRow(final int[] newrow, final int rown) { writeRowInt(newrow, rown); } @@ -632,7 +632,7 @@ public class PngWriter { * Row number, from 0 (top) to rows-1 (bottom). This is just used * as a check. Pass -1 if you want to autocompute it */ - public void writeRowInt(int[] newrow, int rown) { + public void writeRowInt(final int[] newrow, final int rown) { prepareEncodeRow(rown); encodeRowFromInt(newrow); filterAndSend(rown); @@ -645,7 +645,7 @@ public class PngWriter { * * @see PngWriter#writeRowInt(int[], int) */ - public void writeRowByte(byte[] newrow, int rown) { + public void writeRowByte(final byte[] newrow, final int rown) { prepareEncodeRow(rown); encodeRowFromByte(newrow); filterAndSend(rown); @@ -654,7 +654,7 @@ public class PngWriter { /** * Writes all the pixels, calling writeRowInt() for each image row */ - public void writeRowsInt(int[][] image) { + public void writeRowsInt(final int[][] image) { for (int i = 0; i < imgInfo.rows; i++) writeRowInt(image[i], i); } @@ -662,7 +662,7 @@ public class PngWriter { /** * Writes all the pixels, calling writeRowByte() for each image row */ - public void writeRowsByte(byte[][] image) { + public void writeRowsByte(final byte[][] image) { for (int i = 0; i < imgInfo.rows; i++) writeRowByte(image[i], i); } @@ -682,7 +682,7 @@ public class PngWriter { * packed flag of the ImageLine object overrides (and overwrites!) * this field. */ - public void setUseUnPackedMode(boolean useUnpackedMode) { + public void setUseUnPackedMode(final boolean useUnpackedMode) { this.unpackedMode = useUnpackedMode; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjBadCrcException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjBadCrcException.java index 3b74f862f..032b2ed3a 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjBadCrcException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjBadCrcException.java @@ -6,15 +6,15 @@ package jogamp.opengl.util.pngj; public class PngjBadCrcException extends PngjInputException { private static final long serialVersionUID = 1L; - public PngjBadCrcException(String message, Throwable cause) { + public PngjBadCrcException(final String message, final Throwable cause) { super(message, cause); } - public PngjBadCrcException(String message) { + public PngjBadCrcException(final String message) { super(message); } - public PngjBadCrcException(Throwable cause) { + public PngjBadCrcException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java index 97e24fc73..3d05589b1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java @@ -9,15 +9,15 @@ package jogamp.opengl.util.pngj; public class PngjException extends RuntimeException { private static final long serialVersionUID = 1L; - public PngjException(String message, Throwable cause) { + public PngjException(final String message, final Throwable cause) { super(message, cause); } - public PngjException(String message) { + public PngjException(final String message) { super(message); } - public PngjException(Throwable cause) { + public PngjException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java index 5da70de7b..9484abf5e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java @@ -10,15 +10,15 @@ package jogamp.opengl.util.pngj; public class PngjExceptionInternal extends RuntimeException { private static final long serialVersionUID = 1L; - public PngjExceptionInternal(String message, Throwable cause) { + public PngjExceptionInternal(final String message, final Throwable cause) { super(message, cause); } - public PngjExceptionInternal(String message) { + public PngjExceptionInternal(final String message) { super(message); } - public PngjExceptionInternal(Throwable cause) { + public PngjExceptionInternal(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjInputException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjInputException.java index 5cc36b99a..c92d80b2c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjInputException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjInputException.java @@ -6,15 +6,15 @@ package jogamp.opengl.util.pngj; public class PngjInputException extends PngjException { private static final long serialVersionUID = 1L; - public PngjInputException(String message, Throwable cause) { + public PngjInputException(final String message, final Throwable cause) { super(message, cause); } - public PngjInputException(String message) { + public PngjInputException(final String message) { super(message); } - public PngjInputException(Throwable cause) { + public PngjInputException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjOutputException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjOutputException.java index c8cd36acb..4e9cdc950 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjOutputException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjOutputException.java @@ -6,15 +6,15 @@ package jogamp.opengl.util.pngj; public class PngjOutputException extends PngjException { private static final long serialVersionUID = 1L; - public PngjOutputException(String message, Throwable cause) { + public PngjOutputException(final String message, final Throwable cause) { super(message, cause); } - public PngjOutputException(String message) { + public PngjOutputException(final String message) { super(message); } - public PngjOutputException(Throwable cause) { + public PngjOutputException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java index f68458d19..e68b153ac 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java @@ -11,15 +11,15 @@ public class PngjUnsupportedException extends RuntimeException { super(); } - public PngjUnsupportedException(String message, Throwable cause) { + public PngjUnsupportedException(final String message, final Throwable cause) { super(message, cause); } - public PngjUnsupportedException(String message) { + public PngjUnsupportedException(final String message) { super(message); } - public PngjUnsupportedException(Throwable cause) { + public PngjUnsupportedException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java index 4516a0886..248472298 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java @@ -11,7 +11,7 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { private final int size; private long countFlushed = 0; - public ProgressiveOutputStream(int size) { + public ProgressiveOutputStream(final int size) { this.size = size; } @@ -28,19 +28,19 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { } @Override - public final void write(byte[] b, int off, int len) { + public final void write(final byte[] b, final int off, final int len) { super.write(b, off, len); checkFlushBuffer(false); } @Override - public final void write(byte[] b) throws IOException { + public final void write(final byte[] b) throws IOException { super.write(b); checkFlushBuffer(false); } @Override - public final void write(int arg0) { + public final void write(final int arg0) { super.write(arg0); checkFlushBuffer(false); } @@ -54,7 +54,7 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { * if it's time to flush data (or if forced==true) calls abstract method * flushBuffer() and cleans those bytes from own buffer */ - private final void checkFlushBuffer(boolean forced) { + private final void checkFlushBuffer(final boolean forced) { while (forced || count >= size) { int nb = size; if (nb > count) @@ -63,7 +63,7 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { return; flushBuffer(buf, nb); countFlushed += nb; - int bytesleft = count - nb; + final int bytesleft = count - nb; count = bytesleft; if (bytesleft > 0) System.arraycopy(buf, nb, buf, 0, bytesleft); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java index 4e8bf5635..b8cfd8691 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java @@ -68,63 +68,63 @@ public class ChunkHelper { /** * Converts to bytes using Latin1 (ISO-8859-1) */ - public static byte[] toBytes(String x) { + public static byte[] toBytes(final String x) { return x.getBytes(PngHelperInternal.charsetLatin1); } /** * Converts to String using Latin1 (ISO-8859-1) */ - public static String toString(byte[] x) { + public static String toString(final byte[] x) { return new String(x, PngHelperInternal.charsetLatin1); } /** * Converts to String using Latin1 (ISO-8859-1) */ - public static String toString(byte[] x, int offset, int len) { + public static String toString(final byte[] x, final int offset, final int len) { return new String(x, offset, len, PngHelperInternal.charsetLatin1); } /** * Converts to bytes using UTF-8 */ - public static byte[] toBytesUTF8(String x) { + public static byte[] toBytesUTF8(final String x) { return x.getBytes(PngHelperInternal.charsetUTF8); } /** * Converts to string using UTF-8 */ - public static String toStringUTF8(byte[] x) { + public static String toStringUTF8(final byte[] x) { return new String(x, PngHelperInternal.charsetUTF8); } /** * Converts to string using UTF-8 */ - public static String toStringUTF8(byte[] x, int offset, int len) { + public static String toStringUTF8(final byte[] x, final int offset, final int len) { return new String(x, offset, len, PngHelperInternal.charsetUTF8); } /** * critical chunk : first letter is uppercase */ - public static boolean isCritical(String id) { + public static boolean isCritical(final String id) { return (Character.isUpperCase(id.charAt(0))); } /** * public chunk: second letter is uppercase */ - public static boolean isPublic(String id) { // + public static boolean isPublic(final String id) { // return (Character.isUpperCase(id.charAt(1))); } /** * Safe to copy chunk: fourth letter is lower case */ - public static boolean isSafeToCopy(String id) { + public static boolean isSafeToCopy(final String id) { return (!Character.isUpperCase(id.charAt(3))); } @@ -132,7 +132,7 @@ public class ChunkHelper { * "Unknown" just means that our chunk factory (even when it has been * augmented by client code) did not recognize its id */ - public static boolean isUnknown(PngChunk c) { + public static boolean isUnknown(final PngChunk c) { return c instanceof PngChunkUNKNOWN; } @@ -142,7 +142,7 @@ public class ChunkHelper { * @param b * @return -1 if not found */ - public static int posNullByte(byte[] b) { + public static int posNullByte(final byte[] b) { for (int i = 0; i < b.length; i++) if (b[i] == 0) return i; @@ -156,10 +156,10 @@ public class ChunkHelper { * @param behav * @return true/false */ - public static boolean shouldLoad(String id, ChunkLoadBehaviour behav) { + public static boolean shouldLoad(final String id, final ChunkLoadBehaviour behav) { if (isCritical(id)) return true; - boolean kwown = PngChunk.isKnown(id); + final boolean kwown = PngChunk.isKnown(id); switch (behav) { case LOAD_CHUNK_ALWAYS: return true; @@ -173,21 +173,21 @@ public class ChunkHelper { return false; // should not reach here } - public final static byte[] compressBytes(byte[] ori, boolean compress) { + public final static byte[] compressBytes(final byte[] ori, final boolean compress) { return compressBytes(ori, 0, ori.length, compress); } - public static byte[] compressBytes(byte[] ori, int offset, int len, boolean compress) { + public static byte[] compressBytes(final byte[] ori, final int offset, final int len, final boolean compress) { try { - ByteArrayInputStream inb = new ByteArrayInputStream(ori, offset, len); - InputStream in = compress ? inb : new InflaterInputStream(inb, getInflater()); - ByteArrayOutputStream outb = new ByteArrayOutputStream(); - OutputStream out = compress ? new DeflaterOutputStream(outb) : outb; + final ByteArrayInputStream inb = new ByteArrayInputStream(ori, offset, len); + final InputStream in = compress ? inb : new InflaterInputStream(inb, getInflater()); + final ByteArrayOutputStream outb = new ByteArrayOutputStream(); + final OutputStream out = compress ? new DeflaterOutputStream(outb) : outb; shovelInToOut(in, out); in.close(); out.close(); return outb.toByteArray(); - } catch (Exception e) { + } catch (final Exception e) { throw new PngjException(e); } } @@ -195,7 +195,7 @@ public class ChunkHelper { /** * Shovels all data from an input stream to an output stream. */ - private static void shovelInToOut(InputStream in, OutputStream out) throws IOException { + private static void shovelInToOut(final InputStream in, final OutputStream out) throws IOException { synchronized (tmpbuffer) { int len; while ((len = in.read(tmpbuffer)) > 0) { @@ -204,7 +204,7 @@ public class ChunkHelper { } } - public static boolean maskMatch(int v, int mask) { + public static boolean maskMatch(final int v, final int mask) { return (v & mask) != 0; } @@ -213,9 +213,9 @@ public class ChunkHelper { * * See also trimList() */ - public static List filterList(List target, ChunkPredicate predicateKeep) { - List result = new ArrayList(); - for (PngChunk element : target) { + public static List filterList(final List target, final ChunkPredicate predicateKeep) { + final List result = new ArrayList(); + for (final PngChunk element : target) { if (predicateKeep.match(element)) { result.add(element); } @@ -228,11 +228,11 @@ public class ChunkHelper { * * See also filterList */ - public static int trimList(List target, ChunkPredicate predicateRemove) { - Iterator it = target.iterator(); + public static int trimList(final List target, final ChunkPredicate predicateRemove) { + final Iterator it = target.iterator(); int cont = 0; while (it.hasNext()) { - PngChunk c = it.next(); + final PngChunk c = it.next(); if (predicateRemove.match(c)) { it.remove(); cont++; @@ -252,7 +252,7 @@ public class ChunkHelper { * * @return true if "equivalent" */ - public static final boolean equivalent(PngChunk c1, PngChunk c2) { + public static final boolean equivalent(final PngChunk c1, final PngChunk c2) { if (c1 == c2) return true; if (c1 == null || c2 == null || !c1.id.equals(c2.id)) @@ -272,7 +272,7 @@ public class ChunkHelper { return false; } - public static boolean isText(PngChunk c) { + public static boolean isText(final PngChunk c) { return c instanceof PngChunkTextVar; } @@ -281,7 +281,7 @@ public class ChunkHelper { * individual chunks compression */ public static Inflater getInflater() { - Inflater inflater = inflaterProvider.get(); + final Inflater inflater = inflaterProvider.get(); inflater.reset(); return inflater; } @@ -291,7 +291,7 @@ public class ChunkHelper { * individual chunks decompression */ public static Deflater getDeflater() { - Deflater deflater = deflaterProvider.get(); + final Deflater deflater = deflaterProvider.get(); deflater.reset(); return deflater; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java index dcb1958df..0ac2dc6a0 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java @@ -50,7 +50,7 @@ public class ChunkRaw { * @param alloc * : it true, the data array will be allocced */ - public ChunkRaw(int len, byte[] idbytes, boolean alloc) { + public ChunkRaw(final int len, final byte[] idbytes, final boolean alloc) { this.len = len; System.arraycopy(idbytes, 0, this.idbytes, 0, 4); if (alloc) @@ -66,7 +66,7 @@ public class ChunkRaw { * this is called after setting data, before writing to os */ private int computeCrc() { - CRC32 crcengine = PngHelperInternal.getCRC(); + final CRC32 crcengine = PngHelperInternal.getCRC(); crcengine.reset(); crcengine.update(idbytes, 0, 4); if (len > 0) @@ -78,7 +78,7 @@ public class ChunkRaw { * Computes the CRC and writes to the stream. If error, a * PngjOutputException is thrown */ - public void writeChunk(OutputStream os) { + public void writeChunk(final OutputStream os) { if (idbytes.length != 4) throw new PngjOutputException("bad chunkid [" + ChunkHelper.toString(idbytes) + "]"); crcval = computeCrc(); @@ -93,11 +93,11 @@ public class ChunkRaw { * position before: just after chunk id. positon after: after crc Data * should be already allocated. Checks CRC Return number of byte read. */ - public int readChunkData(InputStream is, boolean checkCrc) { + public int readChunkData(final InputStream is, final boolean checkCrc) { PngHelperInternal.readBytes(is, data, 0, len); crcval = PngHelperInternal.readInt4(is); if (checkCrc) { - int crc = computeCrc(); + final int crc = computeCrc(); if (crc != crcval) throw new PngjBadCrcException("chunk: " + this + " crc calc=" + crc + " read=" + crcval); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java index 75107d761..f5a920e73 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java @@ -31,7 +31,7 @@ public class ChunksList { final ImageInfo imageInfo; // only required for writing - public ChunksList(ImageInfo imfinfo) { + public ChunksList(final ImageInfo imfinfo) { this.imageInfo = imfinfo; } @@ -41,8 +41,8 @@ public class ChunksList { * @return key:chunk id, val: number of occurrences */ public HashMap getChunksKeys() { - HashMap ck = new HashMap(); - for (PngChunk c : chunks) { + final HashMap ck = new HashMap(); + for (final PngChunk c : chunks) { ck.put(c.id, ck.containsKey(c.id) ? ck.get(c.id) + 1 : 1); } return ck; @@ -60,14 +60,14 @@ public class ChunksList { if (innerid == null) return ChunkHelper.filterList(list, new ChunkPredicate() { @Override - public boolean match(PngChunk c) { + public boolean match(final PngChunk c) { return c.id.equals(id); } }); else return ChunkHelper.filterList(list, new ChunkPredicate() { @Override - public boolean match(PngChunk c) { + public boolean match(final PngChunk c) { if (!c.id.equals(id)) return false; if (c instanceof PngChunkTextVar && !((PngChunkTextVar) c).getKey().equals(innerid)) @@ -82,7 +82,7 @@ public class ChunksList { /** * Adds chunk in next position. This is used onyl by the pngReader */ - public void appendReadChunk(PngChunk chunk, int chunkGroup) { + public void appendReadChunk(final PngChunk chunk, final int chunkGroup) { chunk.setChunkGroup(chunkGroup); chunks.add(chunk); } @@ -138,7 +138,7 @@ public class ChunksList { * one is returned (failifMultiple=false) **/ public PngChunk getById1(final String id, final String innerid, final boolean failIfMultiple) { - List list = getById(id, innerid); + final List list = getById(id, innerid); if (list.isEmpty()) return null; if (list.size() > 1 && (failIfMultiple || !list.get(0).allowsMultiple())) @@ -155,7 +155,7 @@ public class ChunksList { public List getEquivalent(final PngChunk c2) { return ChunkHelper.filterList(chunks, new ChunkPredicate() { @Override - public boolean match(PngChunk c) { + public boolean match(final PngChunk c) { return ChunkHelper.equivalent(c, c2); } }); @@ -170,9 +170,9 @@ public class ChunksList { * for debugging */ public String toStringFull() { - StringBuilder sb = new StringBuilder(toString()); + final StringBuilder sb = new StringBuilder(toString()); sb.append("\n Read:\n"); - for (PngChunk chunk : chunks) { + for (final PngChunk chunk : chunks) { sb.append(chunk).append(" G=" + chunk.getChunkGroup() + "\n"); } return sb.toString(); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java index c502e9071..6ad61f8e2 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java @@ -19,9 +19,9 @@ public class ChunksListForWrite extends ChunksList { private final List queuedChunks = new ArrayList(); // redundant, just for eficciency - private HashMap alreadyWrittenKeys = new HashMap(); + private final HashMap alreadyWrittenKeys = new HashMap(); - public ChunksListForWrite(ImageInfo imfinfo) { + public ChunksListForWrite(final ImageInfo imfinfo) { super(imfinfo); } @@ -43,7 +43,7 @@ public class ChunksListForWrite extends ChunksList { * Same as getById1(), but looking in the queued chunks **/ public PngChunk getQueuedById1(final String id, final String innerid, final boolean failIfMultiple) { - List list = getQueuedById(id, innerid); + final List list = getQueuedById(id, innerid); if (list.isEmpty()) return null; if (list.size() > 1 && (failIfMultiple || !list.get(0).allowsMultiple())) @@ -72,7 +72,7 @@ public class ChunksListForWrite extends ChunksList { * straightforward for SingleChunks. For MultipleChunks, it will normally * check for reference equality! */ - public boolean removeChunk(PngChunk c) { + public boolean removeChunk(final PngChunk c) { return queuedChunks.remove(c); } @@ -83,7 +83,7 @@ public class ChunksListForWrite extends ChunksList { * * @param c */ - public boolean queue(PngChunk c) { + public boolean queue(final PngChunk c) { queuedChunks.add(c); return true; } @@ -92,7 +92,7 @@ public class ChunksListForWrite extends ChunksList { * this should be called only for ancillary chunks and PLTE (groups 1 - 3 - * 5) **/ - private static boolean shouldWrite(PngChunk c, int currentGroup) { + private static boolean shouldWrite(final PngChunk c, final int currentGroup) { if (currentGroup == CHUNK_GROUP_2_PLTE) return c.id.equals(ChunkHelper.PLTE); if (currentGroup % 2 == 0) @@ -121,11 +121,11 @@ public class ChunksListForWrite extends ChunksList { return false; } - public int writeChunks(OutputStream os, int currentGroup) { + public int writeChunks(final OutputStream os, final int currentGroup) { int cont = 0; - Iterator it = queuedChunks.iterator(); + final Iterator it = queuedChunks.iterator(); while (it.hasNext()) { - PngChunk c = it.next(); + final PngChunk c = it.next(); if (!shouldWrite(c, currentGroup)) continue; if (ChunkHelper.isCritical(c.id) && !c.id.equals(ChunkHelper.PLTE)) @@ -159,14 +159,14 @@ public class ChunksListForWrite extends ChunksList { */ @Override public String toStringFull() { - StringBuilder sb = new StringBuilder(toString()); + final StringBuilder sb = new StringBuilder(toString()); sb.append("\n Written:\n"); - for (PngChunk chunk : chunks) { + for (final PngChunk chunk : chunks) { sb.append(chunk).append(" G=" + chunk.getChunkGroup() + "\n"); } if (!queuedChunks.isEmpty()) { sb.append(" Queued:\n"); - for (PngChunk chunk : queuedChunks) { + for (final PngChunk chunk : queuedChunks) { sb.append(chunk).append("\n"); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java index 6cd86eb98..eba218fe3 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java @@ -122,7 +122,7 @@ public abstract class PngChunk { * (not implmemented in this library) to the factory, so that the PngReader * knows about it. */ - public static void factoryRegister(String chunkId, Class chunkClass) { + public static void factoryRegister(final String chunkId, final Class chunkClass) { factoryMap.put(chunkId, chunkClass); } @@ -137,11 +137,11 @@ public abstract class PngChunk { *

* Unknown chunks will be parsed as instances of {@link PngChunkUNKNOWN} */ - public static boolean isKnown(String id) { + public static boolean isKnown(final String id) { return factoryMap.containsKey(id); } - protected PngChunk(String id, ImageInfo imgInfo) { + protected PngChunk(final String id, final ImageInfo imgInfo) { this.id = id; this.imgInfo = imgInfo; this.crit = ChunkHelper.isCritical(id); @@ -153,8 +153,8 @@ public abstract class PngChunk { * This factory creates the corresponding chunk and parses the raw chunk. * This is used when reading. */ - public static PngChunk factory(ChunkRaw chunk, ImageInfo info) { - PngChunk c = factoryFromId(ChunkHelper.toString(chunk.idbytes), info); + public static PngChunk factory(final ChunkRaw chunk, final ImageInfo info) { + final PngChunk c = factoryFromId(ChunkHelper.toString(chunk.idbytes), info); c.length = chunk.len; c.parseFromRaw(chunk); return c; @@ -164,15 +164,15 @@ public abstract class PngChunk { * Creates one new blank chunk of the corresponding type, according to * factoryMap (PngChunkUNKNOWN if not known) */ - public static PngChunk factoryFromId(String cid, ImageInfo info) { + public static PngChunk factoryFromId(final String cid, final ImageInfo info) { PngChunk chunk = null; try { - Class cla = factoryMap.get(cid); + final Class cla = factoryMap.get(cid); if (cla != null) { - Constructor constr = cla.getConstructor(ImageInfo.class); + final Constructor constr = cla.getConstructor(ImageInfo.class); chunk = constr.newInstance(info); } - } catch (Exception e) { + } catch (final Exception e) { // this can happen for unkown chunks } if (chunk == null) @@ -180,8 +180,8 @@ public abstract class PngChunk { return chunk; } - protected final ChunkRaw createEmptyChunk(int len, boolean alloc) { - ChunkRaw c = new ChunkRaw(len, ChunkHelper.toBytes(id), alloc); + protected final ChunkRaw createEmptyChunk(final int len, final boolean alloc) { + final ChunkRaw c = new ChunkRaw(len, ChunkHelper.toBytes(id), alloc); return c; } @@ -189,8 +189,8 @@ public abstract class PngChunk { * Makes a clone (deep copy) calling {@link #cloneDataFromRead(PngChunk)} */ @SuppressWarnings("unchecked") - public static T cloneChunk(T chunk, ImageInfo info) { - PngChunk cn = factoryFromId(chunk.id, info); + public static T cloneChunk(final T chunk, final ImageInfo info) { + final PngChunk cn = factoryFromId(chunk.id, info); if (cn.getClass() != chunk.getClass()) throw new PngjExceptionInternal("bad class cloning chunk: " + cn.getClass() + " " + chunk.getClass()); cn.cloneDataFromRead(chunk); @@ -210,7 +210,7 @@ public abstract class PngChunk { /** * @see #getChunkGroup() */ - final public void setChunkGroup(int chunkGroup) { + final public void setChunkGroup(final int chunkGroup) { this.chunkGroup = chunkGroup; } @@ -218,12 +218,12 @@ public abstract class PngChunk { return priority; } - public void setPriority(boolean priority) { + public void setPriority(final boolean priority) { this.priority = priority; } - final void write(OutputStream os) { - ChunkRaw c = createRawChunk(); + final void write(final OutputStream os) { + final ChunkRaw c = createRawChunk(); if (c == null) throw new PngjExceptionInternal("null chunk ! creation failed for " + this); c.writeChunk(os); @@ -241,7 +241,7 @@ public abstract class PngChunk { return offset; } - public void setOffset(long offset) { + public void setOffset(final long offset) { this.offset = offset; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java index ea6235432..191278dbc 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java @@ -18,7 +18,7 @@ public class PngChunkBKGD extends PngChunkSingle { private int red, green, blue; private int paletteIndex; - public PngChunkBKGD(ImageInfo info) { + public PngChunkBKGD(final ImageInfo info) { super(ChunkHelper.bKGD, info); } @@ -46,11 +46,11 @@ public class PngChunkBKGD extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (imgInfo.greyscale) { gray = PngHelperInternal.readInt2fromBytes(c.data, 0); } else if (imgInfo.indexed) { - paletteIndex = (int) (c.data[0] & 0xff); + paletteIndex = c.data[0] & 0xff; } else { red = PngHelperInternal.readInt2fromBytes(c.data, 0); green = PngHelperInternal.readInt2fromBytes(c.data, 2); @@ -59,8 +59,8 @@ public class PngChunkBKGD extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkBKGD otherx = (PngChunkBKGD) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkBKGD otherx = (PngChunkBKGD) other; gray = otherx.gray; red = otherx.red; green = otherx.red; @@ -73,7 +73,7 @@ public class PngChunkBKGD extends PngChunkSingle { * * @param gray */ - public void setGray(int gray) { + public void setGray(final int gray) { if (!imgInfo.greyscale) throw new PngjException("only gray images support this"); this.gray = gray; @@ -89,7 +89,7 @@ public class PngChunkBKGD extends PngChunkSingle { * Set pallette index * */ - public void setPaletteIndex(int i) { + public void setPaletteIndex(final int i) { if (!imgInfo.indexed) throw new PngjException("only indexed (pallete) images support this"); this.paletteIndex = i; @@ -105,7 +105,7 @@ public class PngChunkBKGD extends PngChunkSingle { * Set rgb values * */ - public void setRGB(int r, int g, int b) { + public void setRGB(final int r, final int g, final int b) { if (imgInfo.greyscale || imgInfo.indexed) throw new PngjException("only rgb or rgba images support this"); red = r; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java index 25a4bf2d6..8bdd7b4c0 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java @@ -18,7 +18,7 @@ public class PngChunkCHRM extends PngChunkSingle { private double greenx, greeny; private double bluex, bluey; - public PngChunkCHRM(ImageInfo info) { + public PngChunkCHRM(final ImageInfo info) { super(ID, info); } @@ -43,7 +43,7 @@ public class PngChunkCHRM extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (c.len != 32) throw new PngjException("bad chunk " + c); whitex = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 0)); @@ -57,8 +57,8 @@ public class PngChunkCHRM extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkCHRM otherx = (PngChunkCHRM) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkCHRM otherx = (PngChunkCHRM) other; whitex = otherx.whitex; whitey = otherx.whitex; redx = otherx.redx; @@ -69,8 +69,8 @@ public class PngChunkCHRM extends PngChunkSingle { bluey = otherx.bluey; } - public void setChromaticities(double whitex, double whitey, double redx, double redy, double greenx, double greeny, - double bluex, double bluey) { + public void setChromaticities(final double whitex, final double whitey, final double redx, final double redy, final double greenx, final double greeny, + final double bluex, final double bluey) { this.whitex = whitex; this.redx = redx; this.greenx = greenx; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java index 74640746e..6b627326c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java @@ -15,7 +15,7 @@ public class PngChunkGAMA extends PngChunkSingle { // http://www.w3.org/TR/PNG/#11gAMA private double gamma; - public PngChunkGAMA(ImageInfo info) { + public PngChunkGAMA(final ImageInfo info) { super(ID, info); } @@ -26,22 +26,22 @@ public class PngChunkGAMA extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(4, true); - int g = (int) (gamma * 100000 + 0.5); + final ChunkRaw c = createEmptyChunk(4, true); + final int g = (int) (gamma * 100000 + 0.5); PngHelperInternal.writeInt4tobytes(g, c.data, 0); return c; } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { if (chunk.len != 4) throw new PngjException("bad chunk " + chunk); - int g = PngHelperInternal.readInt4fromBytes(chunk.data, 0); - gamma = ((double) g) / 100000.0; + final int g = PngHelperInternal.readInt4fromBytes(chunk.data, 0); + gamma = (g) / 100000.0; } @Override - public void cloneDataFromRead(PngChunk other) { + public void cloneDataFromRead(final PngChunk other) { gamma = ((PngChunkGAMA) other).gamma; } @@ -49,7 +49,7 @@ public class PngChunkGAMA extends PngChunkSingle { return gamma; } - public void setGamma(double gamma) { + public void setGamma(final double gamma) { this.gamma = gamma; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java index 6dc3fd9ec..4a4832d3b 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java @@ -15,7 +15,7 @@ public class PngChunkHIST extends PngChunkSingle { private int[] hist = new int[0]; // should have same lenght as palette - public PngChunkHIST(ImageInfo info) { + public PngChunkHIST(final ImageInfo info) { super(ID, info); } @@ -25,10 +25,10 @@ public class PngChunkHIST extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (!imgInfo.indexed) throw new PngjException("only indexed images accept a HIST chunk"); - int nentries = c.data.length / 2; + final int nentries = c.data.length / 2; hist = new int[nentries]; for (int i = 0; i < hist.length; i++) { hist[i] = PngHelperInternal.readInt2fromBytes(c.data, i * 2); @@ -48,8 +48,8 @@ public class PngChunkHIST extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkHIST otherx = (PngChunkHIST) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkHIST otherx = (PngChunkHIST) other; hist = new int[otherx.hist.length]; System.arraycopy(otherx.hist, 0, hist, 0, otherx.hist.length); } @@ -58,7 +58,7 @@ public class PngChunkHIST extends PngChunkSingle { return hist; } - public void setHist(int[] hist) { + public void setHist(final int[] hist) { this.hist = hist; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java index 399577d72..17f69861c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java @@ -16,7 +16,7 @@ public class PngChunkICCP extends PngChunkSingle { private String profileName; private byte[] compressedProfile; // copmression/decopmresion is done in getter/setter - public PngChunkICCP(ImageInfo info) { + public PngChunkICCP(final ImageInfo info) { super(ID, info); } @@ -27,7 +27,7 @@ public class PngChunkICCP extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(profileName.length() + compressedProfile.length + 2, true); + final ChunkRaw c = createEmptyChunk(profileName.length() + compressedProfile.length + 2, true); System.arraycopy(ChunkHelper.toBytes(profileName), 0, c.data, 0, profileName.length()); c.data[profileName.length()] = 0; c.data[profileName.length() + 1] = 0; @@ -36,20 +36,20 @@ public class PngChunkICCP extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw chunk) { - int pos0 = ChunkHelper.posNullByte(chunk.data); + public void parseFromRaw(final ChunkRaw chunk) { + final int pos0 = ChunkHelper.posNullByte(chunk.data); profileName = new String(chunk.data, 0, pos0, PngHelperInternal.charsetLatin1); - int comp = (chunk.data[pos0 + 1] & 0xff); + final int comp = (chunk.data[pos0 + 1] & 0xff); if (comp != 0) throw new PngjException("bad compression for ChunkTypeICCP"); - int compdatasize = chunk.data.length - (pos0 + 2); + final int compdatasize = chunk.data.length - (pos0 + 2); compressedProfile = new byte[compdatasize]; System.arraycopy(chunk.data, pos0 + 2, compressedProfile, 0, compdatasize); } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkICCP otherx = (PngChunkICCP) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkICCP otherx = (PngChunkICCP) other; profileName = otherx.profileName; compressedProfile = new byte[otherx.compressedProfile.length]; System.arraycopy(otherx.compressedProfile, 0, compressedProfile, 0, otherx.compressedProfile.length); // deep @@ -59,12 +59,12 @@ public class PngChunkICCP extends PngChunkSingle { /** * The profile should be uncompressed bytes */ - public void setProfileNameAndContent(String name, byte[] profile) { + public void setProfileNameAndContent(final String name, final byte[] profile) { profileName = name; compressedProfile = ChunkHelper.compressBytes(profile, true); } - public void setProfileNameAndContent(String name, String profile) { + public void setProfileNameAndContent(final String name, final String profile) { setProfileNameAndContent(name, profile.getBytes(PngHelperInternal.charsetLatin1)); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java index 911513c0d..f7bee4b11 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java @@ -14,7 +14,7 @@ public class PngChunkIDAT extends PngChunkMultiple { public final static String ID = ChunkHelper.IDAT; // http://www.w3.org/TR/PNG/#11IDAT - public PngChunkIDAT(ImageInfo i, int len, long offset) { + public PngChunkIDAT(final ImageInfo i, final int len, final long offset) { super(ID, i); this.length = len; this.offset = offset; @@ -31,10 +31,10 @@ public class PngChunkIDAT extends PngChunkMultiple { } @Override - public void parseFromRaw(ChunkRaw c) { // does nothing + public void parseFromRaw(final ChunkRaw c) { // does nothing } @Override - public void cloneDataFromRead(PngChunk other) { + public void cloneDataFromRead(final PngChunk other) { } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java index fbec564d8..3f6e47b09 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java @@ -12,7 +12,7 @@ public class PngChunkIEND extends PngChunkSingle { // http://www.w3.org/TR/PNG/#11IEND // this is a dummy placeholder - public PngChunkIEND(ImageInfo info) { + public PngChunkIEND(final ImageInfo info) { super(ID, info); } @@ -23,16 +23,16 @@ public class PngChunkIEND extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = new ChunkRaw(0, ChunkHelper.b_IEND, false); + final ChunkRaw c = new ChunkRaw(0, ChunkHelper.b_IEND, false); return c; } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { // this is not used } @Override - public void cloneDataFromRead(PngChunk other) { + public void cloneDataFromRead(final PngChunk other) { } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java index 94bfedd38..71e0ec90e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java @@ -27,7 +27,7 @@ public class PngChunkIHDR extends PngChunkSingle { // http://www.w3.org/TR/PNG/#11IHDR // - public PngChunkIHDR(ImageInfo info) { + public PngChunkIHDR(final ImageInfo info) { super(ID, info); } @@ -38,7 +38,7 @@ public class PngChunkIHDR extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = new ChunkRaw(13, ChunkHelper.b_IHDR, true); + final ChunkRaw c = new ChunkRaw(13, ChunkHelper.b_IHDR, true); int offset = 0; PngHelperInternal.writeInt4tobytes(cols, c.data, offset); offset += 4; @@ -53,10 +53,10 @@ public class PngChunkIHDR extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (c.len != 13) throw new PngjException("Bad IDHR len " + c.len); - ByteArrayInputStream st = c.getAsByteStream(); + final ByteArrayInputStream st = c.getAsByteStream(); cols = PngHelperInternal.readInt4(st); rows = PngHelperInternal.readInt4(st); // bit depth: number of bits per channel @@ -68,8 +68,8 @@ public class PngChunkIHDR extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkIHDR otherx = (PngChunkIHDR) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkIHDR otherx = (PngChunkIHDR) other; cols = otherx.cols; rows = otherx.rows; bitspc = otherx.bitspc; @@ -83,7 +83,7 @@ public class PngChunkIHDR extends PngChunkSingle { return cols; } - public void setCols(int cols) { + public void setCols(final int cols) { this.cols = cols; } @@ -91,7 +91,7 @@ public class PngChunkIHDR extends PngChunkSingle { return rows; } - public void setRows(int rows) { + public void setRows(final int rows) { this.rows = rows; } @@ -99,7 +99,7 @@ public class PngChunkIHDR extends PngChunkSingle { return bitspc; } - public void setBitspc(int bitspc) { + public void setBitspc(final int bitspc) { this.bitspc = bitspc; } @@ -107,7 +107,7 @@ public class PngChunkIHDR extends PngChunkSingle { return colormodel; } - public void setColormodel(int colormodel) { + public void setColormodel(final int colormodel) { this.colormodel = colormodel; } @@ -115,7 +115,7 @@ public class PngChunkIHDR extends PngChunkSingle { return compmeth; } - public void setCompmeth(int compmeth) { + public void setCompmeth(final int compmeth) { this.compmeth = compmeth; } @@ -123,7 +123,7 @@ public class PngChunkIHDR extends PngChunkSingle { return filmeth; } - public void setFilmeth(int filmeth) { + public void setFilmeth(final int filmeth) { this.filmeth = filmeth; } @@ -131,7 +131,7 @@ public class PngChunkIHDR extends PngChunkSingle { return interlaced; } - public void setInterlaced(int interlaced) { + public void setInterlaced(final int interlaced) { this.interlaced = interlaced; } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java index ab52d7c90..738f92471 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java @@ -21,7 +21,7 @@ public class PngChunkITXT extends PngChunkTextVar { private String translatedTag = ""; // http://www.w3.org/TR/PNG/#11iTXt - public PngChunkITXT(ImageInfo info) { + public PngChunkITXT(final ImageInfo info) { super(ID, info); } @@ -30,7 +30,7 @@ public class PngChunkITXT extends PngChunkTextVar { if (key.isEmpty()) throw new PngjException("Text chunk key must be non empty"); try { - ByteArrayOutputStream ba = new ByteArrayOutputStream(); + final ByteArrayOutputStream ba = new ByteArrayOutputStream(); ba.write(ChunkHelper.toBytes(key)); ba.write(0); // separator ba.write(compressed ? 1 : 0); @@ -44,19 +44,19 @@ public class PngChunkITXT extends PngChunkTextVar { textbytes = ChunkHelper.compressBytes(textbytes, true); } ba.write(textbytes); - byte[] b = ba.toByteArray(); - ChunkRaw chunk = createEmptyChunk(b.length, false); + final byte[] b = ba.toByteArray(); + final ChunkRaw chunk = createEmptyChunk(b.length, false); chunk.data = b; return chunk; - } catch (IOException e) { + } catch (final IOException e) { throw new PngjException(e); } } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { int nullsFound = 0; - int[] nullsIdx = new int[3]; + final int[] nullsIdx = new int[3]; for (int i = 0; i < c.data.length; i++) { if (c.data[i] != 0) continue; @@ -80,7 +80,7 @@ public class PngChunkITXT extends PngChunkTextVar { PngHelperInternal.charsetUTF8); i = nullsIdx[2] + 1; if (compressed) { - byte[] bytes = ChunkHelper.compressBytes(c.data, i, c.data.length - i, false); + final byte[] bytes = ChunkHelper.compressBytes(c.data, i, c.data.length - i, false); val = ChunkHelper.toStringUTF8(bytes); } else { val = ChunkHelper.toStringUTF8(c.data, i, c.data.length - i); @@ -88,8 +88,8 @@ public class PngChunkITXT extends PngChunkTextVar { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkITXT otherx = (PngChunkITXT) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkITXT otherx = (PngChunkITXT) other; key = otherx.key; val = otherx.val; compressed = otherx.compressed; @@ -101,7 +101,7 @@ public class PngChunkITXT extends PngChunkTextVar { return compressed; } - public void setCompressed(boolean compressed) { + public void setCompressed(final boolean compressed) { this.compressed = compressed; } @@ -109,7 +109,7 @@ public class PngChunkITXT extends PngChunkTextVar { return langTag; } - public void setLangtag(String langtag) { + public void setLangtag(final String langtag) { this.langTag = langtag; } @@ -117,7 +117,7 @@ public class PngChunkITXT extends PngChunkTextVar { return translatedTag; } - public void setTranslatedTag(String translatedTag) { + public void setTranslatedTag(final String translatedTag) { this.translatedTag = translatedTag; } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java index 057f6c25e..5a7bee98c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java @@ -7,7 +7,7 @@ import jogamp.opengl.util.pngj.ImageInfo; */ public abstract class PngChunkMultiple extends PngChunk { - protected PngChunkMultiple(String id, ImageInfo imgInfo) { + protected PngChunkMultiple(final String id, final ImageInfo imgInfo) { super(id, imgInfo); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java index a3bab4995..2217a59b4 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java @@ -17,7 +17,7 @@ public class PngChunkOFFS extends PngChunkSingle { private long posY; private int units; // 0: pixel 1:micrometer - public PngChunkOFFS(ImageInfo info) { + public PngChunkOFFS(final ImageInfo info) { super(ID, info); } @@ -28,7 +28,7 @@ public class PngChunkOFFS extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(9, true); + final ChunkRaw c = createEmptyChunk(9, true); PngHelperInternal.writeInt4tobytes((int) posX, c.data, 0); PngHelperInternal.writeInt4tobytes((int) posY, c.data, 4); c.data[8] = (byte) units; @@ -36,7 +36,7 @@ public class PngChunkOFFS extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { if (chunk.len != 9) throw new PngjException("bad chunk length " + chunk); posX = PngHelperInternal.readInt4fromBytes(chunk.data, 0); @@ -49,8 +49,8 @@ public class PngChunkOFFS extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkOFFS otherx = (PngChunkOFFS) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkOFFS otherx = (PngChunkOFFS) other; this.posX = otherx.posX; this.posY = otherx.posY; this.units = otherx.units; @@ -66,7 +66,7 @@ public class PngChunkOFFS extends PngChunkSingle { /** * 0: pixel, 1:micrometer */ - public void setUnits(int units) { + public void setUnits(final int units) { this.units = units; } @@ -74,7 +74,7 @@ public class PngChunkOFFS extends PngChunkSingle { return posX; } - public void setPosX(long posX) { + public void setPosX(final long posX) { this.posX = posX; } @@ -82,7 +82,7 @@ public class PngChunkOFFS extends PngChunkSingle { return posY; } - public void setPosY(long posY) { + public void setPosY(final long posY) { this.posY = posY; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java index b0a1bb898..fc647273e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java @@ -16,7 +16,7 @@ public class PngChunkPHYS extends PngChunkSingle { private long pixelsxUnitY; private int units; // 0: unknown 1:metre - public PngChunkPHYS(ImageInfo info) { + public PngChunkPHYS(final ImageInfo info) { super(ID, info); } @@ -27,7 +27,7 @@ public class PngChunkPHYS extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(9, true); + final ChunkRaw c = createEmptyChunk(9, true); PngHelperInternal.writeInt4tobytes((int) pixelsxUnitX, c.data, 0); PngHelperInternal.writeInt4tobytes((int) pixelsxUnitY, c.data, 4); c.data[8] = (byte) units; @@ -35,7 +35,7 @@ public class PngChunkPHYS extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { if (chunk.len != 9) throw new PngjException("bad chunk length " + chunk); pixelsxUnitX = PngHelperInternal.readInt4fromBytes(chunk.data, 0); @@ -48,8 +48,8 @@ public class PngChunkPHYS extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkPHYS otherx = (PngChunkPHYS) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkPHYS otherx = (PngChunkPHYS) other; this.pixelsxUnitX = otherx.pixelsxUnitX; this.pixelsxUnitY = otherx.pixelsxUnitY; this.units = otherx.units; @@ -59,7 +59,7 @@ public class PngChunkPHYS extends PngChunkSingle { return pixelsxUnitX; } - public void setPixelsxUnitX(long pixelsxUnitX) { + public void setPixelsxUnitX(final long pixelsxUnitX) { this.pixelsxUnitX = pixelsxUnitX; } @@ -67,7 +67,7 @@ public class PngChunkPHYS extends PngChunkSingle { return pixelsxUnitY; } - public void setPixelsxUnitY(long pixelsxUnitY) { + public void setPixelsxUnitY(final long pixelsxUnitY) { this.pixelsxUnitY = pixelsxUnitY; } @@ -75,7 +75,7 @@ public class PngChunkPHYS extends PngChunkSingle { return units; } - public void setUnits(int units) { + public void setUnits(final int units) { this.units = units; } @@ -87,7 +87,7 @@ public class PngChunkPHYS extends PngChunkSingle { public double getAsDpi() { if (units != 1 || pixelsxUnitX != pixelsxUnitY) return -1; - return ((double) pixelsxUnitX) * 0.0254; + return (pixelsxUnitX) * 0.0254; } /** @@ -96,16 +96,16 @@ public class PngChunkPHYS extends PngChunkSingle { public double[] getAsDpi2() { if (units != 1) return new double[] { -1, -1 }; - return new double[] { ((double) pixelsxUnitX) * 0.0254, ((double) pixelsxUnitY) * 0.0254 }; + return new double[] { (pixelsxUnitX) * 0.0254, (pixelsxUnitY) * 0.0254 }; } - public void setAsDpi(double dpi) { + public void setAsDpi(final double dpi) { units = 1; pixelsxUnitX = (long) (dpi / 0.0254 + 0.5); pixelsxUnitY = pixelsxUnitX; } - public void setAsDpi2(double dpix, double dpiy) { + public void setAsDpi2(final double dpix, final double dpiy) { units = 1; pixelsxUnitX = (long) (dpix / 0.0254 + 0.5); pixelsxUnitY = (long) (dpiy / 0.0254 + 0.5); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java index dbf5e53c0..0f135d1ed 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java @@ -20,7 +20,7 @@ public class PngChunkPLTE extends PngChunkSingle { */ private int[] entries; - public PngChunkPLTE(ImageInfo info) { + public PngChunkPLTE(final ImageInfo info) { super(ID, info); } @@ -31,9 +31,9 @@ public class PngChunkPLTE extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - int len = 3 * nentries; - int[] rgb = new int[3]; - ChunkRaw c = createEmptyChunk(len, true); + final int len = 3 * nentries; + final int[] rgb = new int[3]; + final ChunkRaw c = createEmptyChunk(len, true); for (int n = 0, i = 0; n < nentries; n++) { getEntryRgb(n, rgb); c.data[i++] = (byte) rgb[0]; @@ -44,21 +44,21 @@ public class PngChunkPLTE extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { setNentries(chunk.len / 3); for (int n = 0, i = 0; n < nentries; n++) { - setEntry(n, (int) (chunk.data[i++] & 0xff), (int) (chunk.data[i++] & 0xff), (int) (chunk.data[i++] & 0xff)); + setEntry(n, chunk.data[i++] & 0xff, chunk.data[i++] & 0xff, chunk.data[i++] & 0xff); } } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkPLTE otherx = (PngChunkPLTE) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkPLTE otherx = (PngChunkPLTE) other; this.setNentries(otherx.getNentries()); System.arraycopy(otherx.entries, 0, entries, 0, nentries); } - public void setNentries(int n) { + public void setNentries(final int n) { nentries = n; if (nentries < 1 || nentries > 256) throw new PngjException("invalid pallette - nentries=" + nentries); @@ -71,20 +71,20 @@ public class PngChunkPLTE extends PngChunkSingle { return nentries; } - public void setEntry(int n, int r, int g, int b) { + public void setEntry(final int n, final int r, final int g, final int b) { entries[n] = ((r << 16) | (g << 8) | b); } - public int getEntry(int n) { + public int getEntry(final int n) { return entries[n]; } - public void getEntryRgb(int n, int[] rgb) { + public void getEntryRgb(final int n, final int[] rgb) { getEntryRgb(n, rgb, 0); } - public void getEntryRgb(int n, int[] rgb, int offset) { - int v = entries[n]; + public void getEntryRgb(final int n, final int[] rgb, final int offset) { + final int v = entries[n]; rgb[offset + 0] = ((v & 0xff0000) >> 16); rgb[offset + 1] = ((v & 0xff00) >> 8); rgb[offset + 2] = (v & 0xff); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java index 3a490654a..53858da83 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java @@ -19,7 +19,7 @@ public class PngChunkSBIT extends PngChunkSingle { private int graysb, alphasb; private int redsb, greensb, bluesb; - public PngChunkSBIT(ImageInfo info) { + public PngChunkSBIT(final ImageInfo info) { super(ID, info); } @@ -36,7 +36,7 @@ public class PngChunkSBIT extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (c.len != getLen()) throw new PngjException("bad chunk length " + c); if (imgInfo.greyscale) { @@ -71,8 +71,8 @@ public class PngChunkSBIT extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkSBIT otherx = (PngChunkSBIT) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkSBIT otherx = (PngChunkSBIT) other; graysb = otherx.graysb; redsb = otherx.redsb; greensb = otherx.greensb; @@ -80,7 +80,7 @@ public class PngChunkSBIT extends PngChunkSingle { alphasb = otherx.alphasb; } - public void setGraysb(int gray) { + public void setGraysb(final int gray) { if (!imgInfo.greyscale) throw new PngjException("only greyscale images support this"); graysb = gray; @@ -92,7 +92,7 @@ public class PngChunkSBIT extends PngChunkSingle { return graysb; } - public void setAlphasb(int a) { + public void setAlphasb(final int a) { if (!imgInfo.alpha) throw new PngjException("only images with alpha support this"); alphasb = a; @@ -108,7 +108,7 @@ public class PngChunkSBIT extends PngChunkSingle { * Set rgb values * */ - public void setRGB(int r, int g, int b) { + public void setRGB(final int r, final int g, final int b) { if (imgInfo.greyscale || imgInfo.indexed) throw new PngjException("only rgb or rgba images support this"); redsb = r; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java index 2ff65834d..44ff249ac 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java @@ -21,7 +21,7 @@ public class PngChunkSPLT extends PngChunkMultiple { private int sampledepth; // 8/16 private int[] palette; // 5 elements per entry - public PngChunkSPLT(ImageInfo info) { + public PngChunkSPLT(final ImageInfo info) { super(ID, info); } @@ -33,11 +33,11 @@ public class PngChunkSPLT extends PngChunkMultiple { @Override public ChunkRaw createRawChunk() { try { - ByteArrayOutputStream ba = new ByteArrayOutputStream(); + final ByteArrayOutputStream ba = new ByteArrayOutputStream(); ba.write(palName.getBytes(PngHelperInternal.charsetLatin1)); ba.write(0); // separator ba.write((byte) sampledepth); - int nentries = getNentries(); + final int nentries = getNentries(); for (int n = 0; n < nentries; n++) { for (int i = 0; i < 4; i++) { if (sampledepth == 8) @@ -47,17 +47,17 @@ public class PngChunkSPLT extends PngChunkMultiple { } PngHelperInternal.writeInt2(ba, palette[n * 5 + 4]); } - byte[] b = ba.toByteArray(); - ChunkRaw chunk = createEmptyChunk(b.length, false); + final byte[] b = ba.toByteArray(); + final ChunkRaw chunk = createEmptyChunk(b.length, false); chunk.data = b; return chunk; - } catch (IOException e) { + } catch (final IOException e) { throw new PngjException(e); } } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { int t = -1; for (int i = 0; i < c.data.length; i++) { // look for first zero if (c.data[i] == 0) { @@ -70,7 +70,7 @@ public class PngChunkSPLT extends PngChunkMultiple { palName = new String(c.data, 0, t, PngHelperInternal.charsetLatin1); sampledepth = PngHelperInternal.readInt1fromByte(c.data, t + 1); t += 2; - int nentries = (c.data.length - t) / (sampledepth == 8 ? 6 : 10); + final int nentries = (c.data.length - t) / (sampledepth == 8 ? 6 : 10); palette = new int[nentries * 5]; int r, g, b, a, f, ne; ne = 0; @@ -101,8 +101,8 @@ public class PngChunkSPLT extends PngChunkMultiple { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkSPLT otherx = (PngChunkSPLT) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkSPLT otherx = (PngChunkSPLT) other; palName = otherx.palName; sampledepth = otherx.sampledepth; palette = new int[otherx.palette.length]; @@ -117,7 +117,7 @@ public class PngChunkSPLT extends PngChunkMultiple { return palName; } - public void setPalName(String palName) { + public void setPalName(final String palName) { this.palName = palName; } @@ -125,7 +125,7 @@ public class PngChunkSPLT extends PngChunkMultiple { return sampledepth; } - public void setSampledepth(int sampledepth) { + public void setSampledepth(final int sampledepth) { this.sampledepth = sampledepth; } @@ -133,7 +133,7 @@ public class PngChunkSPLT extends PngChunkMultiple { return palette; } - public void setPalette(int[] palette) { + public void setPalette(final int[] palette) { this.palette = palette; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java index e4d77d40a..19504b917 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java @@ -21,7 +21,7 @@ public class PngChunkSRGB extends PngChunkSingle { private int intent; - public PngChunkSRGB(ImageInfo info) { + public PngChunkSRGB(final ImageInfo info) { super(ID, info); } @@ -31,7 +31,7 @@ public class PngChunkSRGB extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (c.len != 1) throw new PngjException("bad chunk length " + c); intent = PngHelperInternal.readInt1fromByte(c.data, 0); @@ -46,8 +46,8 @@ public class PngChunkSRGB extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkSRGB otherx = (PngChunkSRGB) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkSRGB otherx = (PngChunkSRGB) other; intent = otherx.intent; } @@ -55,7 +55,7 @@ public class PngChunkSRGB extends PngChunkSingle { return intent; } - public void setIntent(int intent) { + public void setIntent(final int intent) { this.intent = intent; } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java index 4dc5edec5..52037b396 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java @@ -14,7 +14,7 @@ public class PngChunkSTER extends PngChunkSingle { // http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.sTER private byte mode; // 0: cross-fuse layout 1: diverging-fuse layout - public PngChunkSTER(ImageInfo info) { + public PngChunkSTER(final ImageInfo info) { super(ID, info); } @@ -25,21 +25,21 @@ public class PngChunkSTER extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(1, true); - c.data[0] = (byte) mode; + final ChunkRaw c = createEmptyChunk(1, true); + c.data[0] = mode; return c; } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { if (chunk.len != 1) throw new PngjException("bad chunk length " + chunk); mode = chunk.data[0]; } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkSTER otherx = (PngChunkSTER) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkSTER otherx = (PngChunkSTER) other; this.mode = otherx.mode; } @@ -53,7 +53,7 @@ public class PngChunkSTER extends PngChunkSingle { /** * 0: cross-fuse layout 1: diverging-fuse layout */ - public void setMode(byte mode) { + public void setMode(final byte mode) { this.mode = mode; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java index 7df5ba021..c5e9407b1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java @@ -8,7 +8,7 @@ import jogamp.opengl.util.pngj.ImageInfo; */ public abstract class PngChunkSingle extends PngChunk { - protected PngChunkSingle(String id, ImageInfo imgInfo) { + protected PngChunkSingle(final String id, final ImageInfo imgInfo) { super(id, imgInfo); } @@ -26,14 +26,14 @@ public abstract class PngChunkSingle extends PngChunk { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - PngChunkSingle other = (PngChunkSingle) obj; + final PngChunkSingle other = (PngChunkSingle) obj; if (id == null) { if (other.id != null) return false; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java index f4c77b4e1..02a18816b 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java @@ -8,7 +8,7 @@ import jogamp.opengl.util.pngj.PngjException; */ public class PngChunkSkipped extends PngChunk { - public PngChunkSkipped(String id, ImageInfo info, int clen) { + public PngChunkSkipped(final String id, final ImageInfo info, final int clen) { super(id, info); this.length = clen; } @@ -24,12 +24,12 @@ public class PngChunkSkipped extends PngChunk { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { throw new PngjException("Non supported for a skipped chunk"); } @Override - public void cloneDataFromRead(PngChunk other) { + public void cloneDataFromRead(final PngChunk other) { throw new PngjException("Non supported for a skipped chunk"); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java index d97cd63c5..634d0cd12 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java @@ -12,7 +12,7 @@ import jogamp.opengl.util.pngj.PngjException; public class PngChunkTEXT extends PngChunkTextVar { public final static String ID = ChunkHelper.tEXt; - public PngChunkTEXT(ImageInfo info) { + public PngChunkTEXT(final ImageInfo info) { super(ID, info); } @@ -20,14 +20,14 @@ public class PngChunkTEXT extends PngChunkTextVar { public ChunkRaw createRawChunk() { if (key.isEmpty()) throw new PngjException("Text chunk key must be non empty"); - byte[] b = (key + "\0" + val).getBytes(PngHelperInternal.charsetLatin1); - ChunkRaw chunk = createEmptyChunk(b.length, false); + final byte[] b = (key + "\0" + val).getBytes(PngHelperInternal.charsetLatin1); + final ChunkRaw chunk = createEmptyChunk(b.length, false); chunk.data = b; return chunk; } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { int i; for (i = 0; i < c.data.length; i++) if (c.data[i] == 0) @@ -38,8 +38,8 @@ public class PngChunkTEXT extends PngChunkTextVar { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkTEXT otherx = (PngChunkTEXT) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkTEXT otherx = (PngChunkTEXT) other; key = otherx.key; val = otherx.val; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java index 8f34c78fe..850fb649f 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java @@ -17,7 +17,7 @@ public class PngChunkTIME extends PngChunkSingle { // http://www.w3.org/TR/PNG/#11tIME private int year, mon, day, hour, min, sec; - public PngChunkTIME(ImageInfo info) { + public PngChunkTIME(final ImageInfo info) { super(ID, info); } @@ -28,7 +28,7 @@ public class PngChunkTIME extends PngChunkSingle { @Override public ChunkRaw createRawChunk() { - ChunkRaw c = createEmptyChunk(7, true); + final ChunkRaw c = createEmptyChunk(7, true); PngHelperInternal.writeInt2tobytes(year, c.data, 0); c.data[2] = (byte) mon; c.data[3] = (byte) day; @@ -39,7 +39,7 @@ public class PngChunkTIME extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw chunk) { + public void parseFromRaw(final ChunkRaw chunk) { if (chunk.len != 7) throw new PngjException("bad chunk " + chunk); year = PngHelperInternal.readInt2fromBytes(chunk.data, 0); @@ -51,8 +51,8 @@ public class PngChunkTIME extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkTIME x = (PngChunkTIME) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkTIME x = (PngChunkTIME) other; year = x.year; mon = x.mon; day = x.day; @@ -61,8 +61,8 @@ public class PngChunkTIME extends PngChunkSingle { sec = x.sec; } - public void setNow(int secsAgo) { - Calendar d = Calendar.getInstance(); + public void setNow(final int secsAgo) { + final Calendar d = Calendar.getInstance(); d.setTimeInMillis(System.currentTimeMillis() - 1000 * (long) secsAgo); year = d.get(Calendar.YEAR); mon = d.get(Calendar.MONTH) + 1; @@ -72,7 +72,7 @@ public class PngChunkTIME extends PngChunkSingle { sec = d.get(Calendar.SECOND); } - public void setYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx) { + public void setYMDHMS(final int yearx, final int monx, final int dayx, final int hourx, final int minx, final int secx) { year = yearx; mon = monx; day = dayx; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java index 867e34861..5e10c041b 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java @@ -21,7 +21,7 @@ public class PngChunkTRNS extends PngChunkSingle { private int red, green, blue; private int[] paletteAlpha = new int[] {}; - public PngChunkTRNS(ImageInfo info) { + public PngChunkTRNS(final ImageInfo info) { super(ID, info); } @@ -51,14 +51,14 @@ public class PngChunkTRNS extends PngChunkSingle { } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { if (imgInfo.greyscale) { gray = PngHelperInternal.readInt2fromBytes(c.data, 0); } else if (imgInfo.indexed) { - int nentries = c.data.length; + final int nentries = c.data.length; paletteAlpha = new int[nentries]; for (int n = 0; n < nentries; n++) { - paletteAlpha[n] = (int) (c.data[n] & 0xff); + paletteAlpha[n] = c.data[n] & 0xff; } } else { red = PngHelperInternal.readInt2fromBytes(c.data, 0); @@ -68,8 +68,8 @@ public class PngChunkTRNS extends PngChunkSingle { } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkTRNS otherx = (PngChunkTRNS) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkTRNS otherx = (PngChunkTRNS) other; gray = otherx.gray; red = otherx.red; green = otherx.green; @@ -84,7 +84,7 @@ public class PngChunkTRNS extends PngChunkSingle { * Set rgb values * */ - public void setRGB(int r, int g, int b) { + public void setRGB(final int r, final int g, final int b) { if (imgInfo.greyscale || imgInfo.indexed) throw new PngjException("only rgb or rgba images support this"); red = r; @@ -98,7 +98,7 @@ public class PngChunkTRNS extends PngChunkSingle { return new int[] { red, green, blue }; } - public void setGray(int g) { + public void setGray(final int g) { if (!imgInfo.greyscale) throw new PngjException("only grayscale images support this"); gray = g; @@ -113,7 +113,7 @@ public class PngChunkTRNS extends PngChunkSingle { /** * WARNING: non deep copy */ - public void setPalletteAlpha(int[] palAlpha) { + public void setPalletteAlpha(final int[] palAlpha) { if (!imgInfo.indexed) throw new PngjException("only indexed images support this"); paletteAlpha = palAlpha; @@ -122,7 +122,7 @@ public class PngChunkTRNS extends PngChunkSingle { /** * to use when only one pallete index is set as totally transparent */ - public void setIndexEntryAsTransparent(int palAlphaIndex) { + public void setIndexEntryAsTransparent(final int palAlphaIndex) { if (!imgInfo.indexed) throw new PngjException("only indexed images support this"); paletteAlpha = new int[] { palAlphaIndex + 1 }; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java index ba3ffc30c..d00c29971 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java @@ -21,7 +21,7 @@ public abstract class PngChunkTextVar extends PngChunkMultiple { public final static String KEY_Source = "Source"; // Device used to create the image public final static String KEY_Comment = "Comment"; // Miscellaneous comment - protected PngChunkTextVar(String id, ImageInfo info) { + protected PngChunkTextVar(final String id, final ImageInfo info) { super(id, info); } @@ -51,7 +51,7 @@ public abstract class PngChunkTextVar extends PngChunkMultiple { return val; } - public void setKeyVal(String key, String val) { + public void setKeyVal(final String key, final String val) { this.key = key; this.val = val; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java index 3803428e6..693729e9b 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java @@ -11,11 +11,11 @@ public class PngChunkUNKNOWN extends PngChunkMultiple { // unkown, custom or not private byte[] data; - public PngChunkUNKNOWN(String id, ImageInfo info) { + public PngChunkUNKNOWN(final String id, final ImageInfo info) { super(id, info); } - private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info) { + private PngChunkUNKNOWN(final PngChunkUNKNOWN c, final ImageInfo info) { super(c.id, info); System.arraycopy(c.data, 0, data, 0, c.data.length); } @@ -27,13 +27,13 @@ public class PngChunkUNKNOWN extends PngChunkMultiple { // unkown, custom or not @Override public ChunkRaw createRawChunk() { - ChunkRaw p = createEmptyChunk(data.length, false); + final ChunkRaw p = createEmptyChunk(data.length, false); p.data = this.data; return p; } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { data = c.data; } @@ -43,14 +43,14 @@ public class PngChunkUNKNOWN extends PngChunkMultiple { // unkown, custom or not } /* does not copy! */ - public void setData(byte[] data) { + public void setData(final byte[] data) { this.data = data; } @Override - public void cloneDataFromRead(PngChunk other) { + public void cloneDataFromRead(final PngChunk other) { // THIS SHOULD NOT BE CALLED IF ALREADY CLONED WITH COPY CONSTRUCTOR - PngChunkUNKNOWN c = (PngChunkUNKNOWN) other; + final PngChunkUNKNOWN c = (PngChunkUNKNOWN) other; data = c.data; // not deep copy } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java index 64593eae4..c1dfdeb33 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java @@ -16,7 +16,7 @@ public class PngChunkZTXT extends PngChunkTextVar { public final static String ID = ChunkHelper.zTXt; // http://www.w3.org/TR/PNG/#11zTXt - public PngChunkZTXT(ImageInfo info) { + public PngChunkZTXT(final ImageInfo info) { super(ID, info); } @@ -25,23 +25,23 @@ public class PngChunkZTXT extends PngChunkTextVar { if (key.isEmpty()) throw new PngjException("Text chunk key must be non empty"); try { - ByteArrayOutputStream ba = new ByteArrayOutputStream(); + final ByteArrayOutputStream ba = new ByteArrayOutputStream(); ba.write(key.getBytes(PngHelperInternal.charsetLatin1)); ba.write(0); // separator ba.write(0); // compression method: 0 - byte[] textbytes = ChunkHelper.compressBytes(val.getBytes(PngHelperInternal.charsetLatin1), true); + final byte[] textbytes = ChunkHelper.compressBytes(val.getBytes(PngHelperInternal.charsetLatin1), true); ba.write(textbytes); - byte[] b = ba.toByteArray(); - ChunkRaw chunk = createEmptyChunk(b.length, false); + final byte[] b = ba.toByteArray(); + final ChunkRaw chunk = createEmptyChunk(b.length, false); chunk.data = b; return chunk; - } catch (IOException e) { + } catch (final IOException e) { throw new PngjException(e); } } @Override - public void parseFromRaw(ChunkRaw c) { + public void parseFromRaw(final ChunkRaw c) { int nullsep = -1; for (int i = 0; i < c.data.length; i++) { // look for first zero if (c.data[i] != 0) @@ -52,16 +52,16 @@ public class PngChunkZTXT extends PngChunkTextVar { if (nullsep < 0 || nullsep > c.data.length - 2) throw new PngjException("bad zTXt chunk: no separator found"); key = new String(c.data, 0, nullsep, PngHelperInternal.charsetLatin1); - int compmet = (int) c.data[nullsep + 1]; + final int compmet = c.data[nullsep + 1]; if (compmet != 0) throw new PngjException("bad zTXt chunk: unknown compression method"); - byte[] uncomp = ChunkHelper.compressBytes(c.data, nullsep + 2, c.data.length - nullsep - 2, false); // uncompress + final byte[] uncomp = ChunkHelper.compressBytes(c.data, nullsep + 2, c.data.length - nullsep - 2, false); // uncompress val = new String(uncomp, PngHelperInternal.charsetLatin1); } @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkZTXT otherx = (PngChunkZTXT) other; + public void cloneDataFromRead(final PngChunk other) { + final PngChunkZTXT otherx = (PngChunkZTXT) other; key = otherx.key; val = otherx.val; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java index 139603448..bba2b3e7c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java @@ -19,7 +19,7 @@ public class PngMetadata { private final ChunksList chunkList; private final boolean readonly; - public PngMetadata(ChunksList chunks) { + public PngMetadata(final ChunksList chunks) { this.chunkList = chunks; if (chunks instanceof ChunksListForWrite) { this.readonly = false; @@ -35,14 +35,14 @@ public class PngMetadata { * and if so, overwrites it. However if that not check for already written * chunks. */ - public void queueChunk(final PngChunk c, boolean lazyOverwrite) { - ChunksListForWrite cl = getChunkListW(); + public void queueChunk(final PngChunk c, final boolean lazyOverwrite) { + final ChunksListForWrite cl = getChunkListW(); if (readonly) throw new PngjException("cannot set chunk : readonly metadata"); if (lazyOverwrite) { ChunkHelper.trimList(cl.getQueuedChunks(), new ChunkPredicate() { @Override - public boolean match(PngChunk c2) { + public boolean match(final PngChunk c2) { return ChunkHelper.equivalent(c, c2); } }); @@ -66,19 +66,19 @@ public class PngMetadata { * returns -1 if not found or dimension unknown */ public double[] getDpi() { - PngChunk c = chunkList.getById1(ChunkHelper.pHYs, true); + final PngChunk c = chunkList.getById1(ChunkHelper.pHYs, true); if (c == null) return new double[] { -1, -1 }; else return ((PngChunkPHYS) c).getAsDpi2(); } - public void setDpi(double x) { + public void setDpi(final double x) { setDpi(x, x); } - public void setDpi(double x, double y) { - PngChunkPHYS c = new PngChunkPHYS(chunkList.imageInfo); + public void setDpi(final double x, final double y) { + final PngChunkPHYS c = new PngChunkPHYS(chunkList.imageInfo); c.setAsDpi2(x, y); queueChunk(c); } @@ -92,8 +92,8 @@ public class PngMetadata { * @return Returns the created-queued chunk, just in case you want to * examine or modify it */ - public PngChunkTIME setTimeNow(int secsAgo) { - PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); + public PngChunkTIME setTimeNow(final int secsAgo) { + final PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); c.setNow(secsAgo); queueChunk(c); return c; @@ -110,8 +110,8 @@ public class PngMetadata { * @return Returns the created-queued chunk, just in case you want to * examine or modify it */ - public PngChunkTIME setTimeYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx) { - PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); + public PngChunkTIME setTimeYMDHMS(final int yearx, final int monx, final int dayx, final int hourx, final int minx, final int secx) { + final PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); c.setYMDHMS(yearx, monx, dayx, hourx, minx, secx); queueChunk(c, true); return c; @@ -125,7 +125,7 @@ public class PngMetadata { } public String getTimeAsString() { - PngChunkTIME c = getTime(); + final PngChunkTIME c = getTime(); return c == null ? "" : c.getAsString(); } @@ -144,7 +144,7 @@ public class PngMetadata { * @return Returns the created-queued chunks, just in case you want to * examine, touch it */ - public PngChunkTextVar setText(String k, String val, boolean useLatin1, boolean compress) { + public PngChunkTextVar setText(final String k, final String val, final boolean useLatin1, final boolean compress) { if (compress && !useLatin1) throw new PngjException("cannot compress non latin text"); PngChunkTextVar c; @@ -163,7 +163,7 @@ public class PngMetadata { return c; } - public PngChunkTextVar setText(String k, String val) { + public PngChunkTextVar setText(final String k, final String val) { return setText(k, val, false, false); } @@ -175,8 +175,9 @@ public class PngMetadata { * Warning: this does not check the "lang" key of iTxt */ @SuppressWarnings("unchecked") - public List getTxtsForKey(String k) { + public List getTxtsForKey(final String k) { @SuppressWarnings("rawtypes") + final List c = new ArrayList(); c.addAll(chunkList.getById(ChunkHelper.tEXt, k)); c.addAll(chunkList.getById(ChunkHelper.zTXt, k)); @@ -190,12 +191,12 @@ public class PngMetadata { *

* Use getTxtsForKey() if you don't want this behaviour */ - public String getTxtForKey(String k) { - List li = getTxtsForKey(k); + public String getTxtForKey(final String k) { + final List li = getTxtsForKey(k); if (li.isEmpty()) return ""; - StringBuilder t = new StringBuilder(); - for (PngChunkTextVar c : li) + final StringBuilder t = new StringBuilder(); + for (final PngChunkTextVar c : li) t.append(c.getVal()).append("\n"); return t.toString().trim(); } @@ -214,7 +215,7 @@ public class PngMetadata { * the caller, who should fill its entries */ public PngChunkPLTE createPLTEChunk() { - PngChunkPLTE plte = new PngChunkPLTE(chunkList.imageInfo); + final PngChunkPLTE plte = new PngChunkPLTE(chunkList.imageInfo); queueChunk(plte); return plte; } @@ -233,7 +234,7 @@ public class PngMetadata { * caller, who should fill its entries */ public PngChunkTRNS createTRNSChunk() { - PngChunkTRNS trns = new PngChunkTRNS(chunkList.imageInfo); + final PngChunkTRNS trns = new PngChunkTRNS(chunkList.imageInfo); queueChunk(trns); return trns; } -- cgit v1.2.3