You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/11 19:30:33 UTC
svn commit: r1432215 - in
/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging:
common/ formats/tiff/ formats/tiff/datareaders/ palette/
Author: ggregory
Date: Fri Jan 11 18:30:33 2013
New Revision: 1432215
URL: http://svn.apache.org/viewvc?rev=1432215&view=rev
Log:
Add final modifier to local variables.
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroupCut.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Dithering.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java Fri Jan 11 18:30:33 2013
@@ -173,10 +173,10 @@ public class ImageBuilder {
// Transcribe the data to an output image array
- int[] argb = new int[w * h];
+ final int[] argb = new int[w * h];
int k = 0;
for (int iRow = 0; iRow < h; iRow++) {
- int dIndex = (iRow + y) * width + x;
+ final int dIndex = (iRow + y) * width + x;
System.arraycopy(this.data, dIndex, argb, k, w);
k += w;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java Fri Jan 11 18:30:33 2013
@@ -514,7 +514,7 @@ public class TiffImageParser extends Ima
return null;
}
- Object obj = params.get(key);
+ final Object obj = params.get(key);
if(obj instanceof Integer){
return (Integer)obj;
@@ -540,7 +540,7 @@ public class TiffImageParser extends Ima
return null;
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
if (ix0 == null) {
sb.append(" x0,");
}
@@ -560,10 +560,10 @@ public class TiffImageParser extends Ima
+ sb.toString());
}
- int x0 = ix0.intValue();
- int y0 = iy0.intValue();
- int width = iwidth.intValue();
- int height = iheight.intValue();
+ final int x0 = ix0.intValue();
+ final int y0 = iy0.intValue();
+ final int width = iwidth.intValue();
+ final int height = iheight.intValue();
return new Rectangle(x0, y0, width, height);
}
@@ -676,8 +676,8 @@ public class TiffImageParser extends Ima
if (subImage != null) {
result = dataReader.readImageData(subImage);
} else {
- boolean hasAlpha = false;
- ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
+ final boolean hasAlpha = false;
+ final ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
dataReader.readImageData(imageBuilder);
result = imageBuilder.getBufferedImage();
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java Fri Jan 11 18:30:33 2013
@@ -240,9 +240,9 @@ public final class DataReaderStrips exte
// strip0 and strip1 give the indices of the strips containing
// the first and last rows of pixels in the subimage
- int strip0 = subImage.y / rowsPerStrip;
- int strip1 = (subImage.y + subImage.height - 1) / rowsPerStrip;
- int workingHeight = (strip1 - strip0 + 1) * rowsPerStrip;
+ final int strip0 = subImage.y / rowsPerStrip;
+ final int strip1 = (subImage.y + subImage.height - 1) / rowsPerStrip;
+ final int workingHeight = (strip1 - strip0 + 1) * rowsPerStrip;
// the legacy code uses a member element "y" to keep track
@@ -251,26 +251,26 @@ public final class DataReaderStrips exte
// call to interpretStrip. y0 will be the index of the first row
// in the full image (the source image) that will be processed.
- int y0 = strip0 * rowsPerStrip;
- int yLimit = subImage.y-y0+subImage.height;
+ final int y0 = strip0 * rowsPerStrip;
+ final int yLimit = subImage.y-y0+subImage.height;
// TO DO: we can probably save some processing by using yLimit instead
// or working
- ImageBuilder workingBuilder =
+ final ImageBuilder workingBuilder =
new ImageBuilder(width, workingHeight, false);
for (int strip = strip0; strip <= strip1; strip++) {
- long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
- long rowsRemaining = height - (strip * rowsPerStripLong);
- long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong);
- long bytesPerRow = (bitsPerPixel * width + 7) / 8;
- long bytesPerStrip = rowsInThisStrip * bytesPerRow;
- long pixelsPerStrip = rowsInThisStrip * width;
+ final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
+ final long rowsRemaining = height - (strip * rowsPerStripLong);
+ final long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong);
+ final long bytesPerRow = (bitsPerPixel * width + 7) / 8;
+ final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
+ final long pixelsPerStrip = rowsInThisStrip * width;
- byte compressed[] = imageData.strips[strip].getData();
+ final byte compressed[] = imageData.strips[strip].getData();
- byte decompressed[] = decompress(compressed, compression,
+ final byte decompressed[] = decompress(compressed, compression,
(int) bytesPerStrip, width, (int) rowsInThisStrip);
interpretStrip(
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java Fri Jan 11 18:30:33 2013
@@ -191,36 +191,36 @@ public final class DataReaderTiled exten
public BufferedImage readImageData(final Rectangle subImage)
throws ImageReadException, IOException
{
- int bitsPerRow = tileWidth * bitsPerPixel;
- int bytesPerRow = (bitsPerRow + 7) / 8;
- int bytesPerTile = bytesPerRow * tileLength;
+ final int bitsPerRow = tileWidth * bitsPerPixel;
+ final int bytesPerRow = (bitsPerRow + 7) / 8;
+ final int bytesPerTile = bytesPerRow * tileLength;
int x = 0, y = 0;
// tileWidth is the width of the tile
// tileLength is the height of the tile
- int col0 = subImage.x / tileWidth;
- int col1 = (subImage.x + subImage.width - 1) / tileWidth;
- int row0 = subImage.y / tileLength;
- int row1 = (subImage.y + subImage.height - 1) / tileLength;
+ final int col0 = subImage.x / tileWidth;
+ final int col1 = (subImage.x + subImage.width - 1) / tileWidth;
+ final int row0 = subImage.y / tileLength;
+ final int row1 = (subImage.y + subImage.height - 1) / tileLength;
- int nCol = col1 - col0 + 1;
- int nRow = row1 - row0 + 1;
- int workingWidth = nCol * tileWidth;
- int workingHeight = nRow * tileLength;
+ final int nCol = col1 - col0 + 1;
+ final int nRow = row1 - row0 + 1;
+ final int workingWidth = nCol * tileWidth;
+ final int workingHeight = nRow * tileLength;
- int nColumnsOfTiles = (width + tileWidth - 1) / tileWidth;
+ final int nColumnsOfTiles = (width + tileWidth - 1) / tileWidth;
- int x0 = col0*tileWidth;
- int y0 = row0*tileLength;
+ final int x0 = col0*tileWidth;
+ final int y0 = row0*tileLength;
- ImageBuilder workingBuilder =
+ final ImageBuilder workingBuilder =
new ImageBuilder(workingWidth, workingHeight, false);
for (int iRow = row0; iRow <= row1; iRow++) {
for (int iCol = col0; iCol <= col1; iCol++) {
- int tile = iRow * nColumnsOfTiles+iCol;
- byte compressed[] = imageData.tiles[tile].getData();
- byte decompressed[] = decompress(compressed, compression,
+ final int tile = iRow * nColumnsOfTiles+iCol;
+ final byte compressed[] = imageData.tiles[tile].getData();
+ final byte decompressed[] = decompress(compressed, compression,
bytesPerTile, tileWidth, tileLength);
x = iCol * tileWidth - x0;
y = iRow * tileLength - y0;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroupCut.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroupCut.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroupCut.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroupCut.java Fri Jan 11 18:30:33 2013
@@ -30,7 +30,7 @@ class ColorGroupCut {
}
public ColorGroup getColorGroup(final int argb) {
- int value = mode.argbComponent(argb);
+ final int value = mode.argbComponent(argb);
if (value <= limit) {
return less;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Dithering.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Dithering.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Dithering.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Dithering.java Fri Jan 11 18:30:33 2013
@@ -24,25 +24,25 @@ public class Dithering {
public static void applyFloydSteinbergDithering(final BufferedImage image, final Palette palette) throws ImageWriteException {
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
- int argb = image.getRGB(x, y);
- int index = palette.getPaletteIndex(argb);
- int nextArgb = palette.getEntry(index);
+ final int argb = image.getRGB(x, y);
+ final int index = palette.getPaletteIndex(argb);
+ final int nextArgb = palette.getEntry(index);
image.setRGB(x, y, nextArgb);
- int a = (argb >> 24) & 0xff;
- int r = (argb >> 16) & 0xff;
- int g = (argb >> 8) & 0xff;
- int b = argb & 0xff;
+ final int a = (argb >> 24) & 0xff;
+ final int r = (argb >> 16) & 0xff;
+ final int g = (argb >> 8) & 0xff;
+ final int b = argb & 0xff;
- int na = (nextArgb >> 24) & 0xff;
- int nr = (nextArgb >> 16) & 0xff;
- int ng = (nextArgb >> 8) & 0xff;
- int nb = nextArgb & 0xff;
+ final int na = (nextArgb >> 24) & 0xff;
+ final int nr = (nextArgb >> 16) & 0xff;
+ final int ng = (nextArgb >> 8) & 0xff;
+ final int nb = nextArgb & 0xff;
- int errA = a - na;
- int errR = r - nr;
- int errG = g - ng;
- int errB = b - nb;
+ final int errA = a - na;
+ final int errR = r - nr;
+ final int errG = g - ng;
+ final int errB = b - nb;
if (x + 1 < image.getWidth()) {
int update = adjustPixel(image.getRGB(x + 1, y), errA, errR, errG, errB, 7);
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java?rev=1432215&r1=1432214&r2=1432215&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java Fri Jan 11 18:30:33 2013
@@ -31,7 +31,7 @@ public class MedianCutMostPopulatedBoxes
ColorGroup colorGroup = null;
for (int i = 0; i < colorGroups.size(); i++) {
if (colorGroups.get(i).max_diff > 0) {
- ColorGroup c = colorGroups.get(i);
+ final ColorGroup c = colorGroups.get(i);
if (c.totalPoints > maxPoints) {
colorGroup = c;
maxPoints = c.totalPoints;
@@ -47,7 +47,7 @@ public class MedianCutMostPopulatedBoxes
double bestScore = Double.MAX_VALUE;
ColorComponent bestColorComponent = null;
int bestMedianIndex = -1;
- for (ColorComponent colorComponent : ColorComponent.values()) {
+ for (final ColorComponent colorComponent : ColorComponent.values()) {
if (ignoreAlpha && colorComponent == ColorComponent.ALPHA) {
continue;
}
@@ -84,10 +84,10 @@ public class MedianCutMostPopulatedBoxes
if (lowerColors.size() == 0 || upperColors.size() == 0) {
continue;
}
- ColorGroup lowerGroup = new ColorGroup(lowerColors, ignoreAlpha);
- ColorGroup upperGroup = new ColorGroup(upperColors, ignoreAlpha);
- int diff = Math.abs(lowerGroup.totalPoints - upperGroup.totalPoints);
- double score = diff / (double)Math.max(lowerGroup.totalPoints, upperGroup.totalPoints);
+ final ColorGroup lowerGroup = new ColorGroup(lowerColors, ignoreAlpha);
+ final ColorGroup upperGroup = new ColorGroup(upperColors, ignoreAlpha);
+ final int diff = Math.abs(lowerGroup.totalPoints - upperGroup.totalPoints);
+ final double score = diff / (double)Math.max(lowerGroup.totalPoints, upperGroup.totalPoints);
if (score < bestScore) {
bestScore = score;
bestColorComponent = colorComponent;
@@ -105,8 +105,8 @@ public class MedianCutMostPopulatedBoxes
final List<ColorCount> upperColors = new ArrayList<ColorCount>(
colorGroup.color_counts.subList(bestMedianIndex + 1,
colorGroup.color_counts.size()));
- ColorGroup lowerGroup = new ColorGroup(lowerColors, ignoreAlpha);
- ColorGroup upperGroup = new ColorGroup(upperColors, ignoreAlpha);
+ final ColorGroup lowerGroup = new ColorGroup(lowerColors, ignoreAlpha);
+ final ColorGroup upperGroup = new ColorGroup(upperColors, ignoreAlpha);
colorGroups.remove(colorGroup);
colorGroups.add(lowerGroup);
colorGroups.add(upperGroup);