You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2012/05/26 23:19:22 UTC
svn commit: r1342971 [17/20] - in /commons/proper/imaging/trunk/src:
main/java/org/apache/commons/imaging/formats/bmp/
main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/
main/java/org/apache/commons/imaging/formats/bmp/writers/ main/java/or...
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/UnicodeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/UnicodeUtils.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/UnicodeUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/UnicodeUtils.java Sat May 26 21:19:03 2012
@@ -21,19 +21,15 @@ import java.io.UnsupportedEncodingExcept
import org.apache.commons.imaging.common.BinaryConstants;
-public abstract class UnicodeUtils implements BinaryConstants
-{
+public abstract class UnicodeUtils implements BinaryConstants {
/**
* This class should never be instantiated.
*/
- private UnicodeUtils()
- {
+ private UnicodeUtils() {
}
- public static class UnicodeException extends Exception
- {
- public UnicodeException(String message)
- {
+ public static class UnicodeException extends Exception {
+ public UnicodeException(String message) {
super(message);
}
}
@@ -159,15 +155,12 @@ public abstract class UnicodeUtils imple
//
// }
- public static final boolean isValidISO_8859_1(String s)
- {
- try
- {
+ public static final boolean isValidISO_8859_1(String s) {
+ try {
String roundtrip = new String(s.getBytes("ISO-8859-1"),
"ISO-8859-1");
return s.equals(roundtrip);
- } catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
// should never be thrown.
throw new RuntimeException("Error parsing string.", e);
}
@@ -177,10 +170,8 @@ public abstract class UnicodeUtils imple
* Return the index of the first utf-16 terminator (ie. two even-aligned
* nulls). If not found, return -1.
*/
- private static int findFirstDoubleByteTerminator(byte bytes[], int index)
- {
- for (int i = index; i < bytes.length - 1; i += 2)
- {
+ private static int findFirstDoubleByteTerminator(byte bytes[], int index) {
+ for (int i = index; i < bytes.length - 1; i += 2) {
int c1 = 0xff & bytes[index];
int c2 = 0xff & bytes[index + 1];
if (c1 == 0 && c2 == 0)
@@ -190,14 +181,12 @@ public abstract class UnicodeUtils imple
}
public final int findEndWithTerminator(byte bytes[], int index)
- throws UnicodeException
- {
+ throws UnicodeException {
return findEnd(bytes, index, true);
}
public final int findEndWithoutTerminator(byte bytes[], int index)
- throws UnicodeException
- {
+ throws UnicodeException {
return findEnd(bytes, index, false);
}
@@ -205,10 +194,8 @@ public abstract class UnicodeUtils imple
boolean includeTerminator) throws UnicodeException;
public static UnicodeUtils getInstance(int charEncodingCode)
- throws UnicodeException
- {
- switch (charEncodingCode)
- {
+ throws UnicodeException {
+ switch (charEncodingCode) {
case CHAR_ENCODING_CODE_ISO_8859_1:
return new UnicodeMetricsASCII();
case CHAR_ENCODING_CODE_UTF_8:
@@ -228,14 +215,11 @@ public abstract class UnicodeUtils imple
}
}
- private static class UnicodeMetricsASCII extends UnicodeUtils
- {
+ private static class UnicodeMetricsASCII extends UnicodeUtils {
@Override
public int findEnd(byte bytes[], int index, boolean includeTerminator)
- throws UnicodeException
- {
- for (int i = index; i < bytes.length; i++)
- {
+ throws UnicodeException {
+ for (int i = index; i < bytes.length; i++) {
if (bytes[i] == 0)
return includeTerminator ? i + 1 : i;
}
@@ -259,17 +243,14 @@ public abstract class UnicodeUtils imple
// }
// }
- private static class UnicodeMetricsUTF8 extends UnicodeUtils
- {
+ private static class UnicodeMetricsUTF8 extends UnicodeUtils {
@Override
public int findEnd(byte bytes[], int index, boolean includeTerminator)
- throws UnicodeException
- {
+ throws UnicodeException {
// http://en.wikipedia.org/wiki/UTF-8
- while (true)
- {
+ while (true) {
if (index == bytes.length)
return bytes.length;
if (index > bytes.length)
@@ -280,16 +261,14 @@ public abstract class UnicodeUtils imple
return includeTerminator ? index : index - 1;
else if (c1 <= 0x7f)
continue;
- else if (c1 <= 0xDF)
- {
+ else if (c1 <= 0xDF) {
if (index >= bytes.length)
throw new UnicodeException("Invalid unicode.");
int c2 = 0xff & bytes[index++];
if (c2 < 0x80 || c2 > 0xBF)
throw new UnicodeException("Invalid code point.");
- } else if (c1 <= 0xEF)
- {
+ } else if (c1 <= 0xEF) {
if (index >= bytes.length - 1)
throw new UnicodeException("Invalid unicode.");
@@ -299,8 +278,7 @@ public abstract class UnicodeUtils imple
int c3 = 0xff & bytes[index++];
if (c3 < 0x80 || c3 > 0xBF)
throw new UnicodeException("Invalid code point.");
- } else if (c1 <= 0xF4)
- {
+ } else if (c1 <= 0xF4) {
if (index >= bytes.length - 2)
throw new UnicodeException("Invalid unicode.");
@@ -319,30 +297,24 @@ public abstract class UnicodeUtils imple
}
}
- private abstract static class UnicodeMetricsUTF16 extends UnicodeUtils
- {
+ private abstract static class UnicodeMetricsUTF16 extends UnicodeUtils {
protected int byteOrder = BYTE_ORDER_BIG_ENDIAN;
- public UnicodeMetricsUTF16(int byteOrder)
- {
+ public UnicodeMetricsUTF16(int byteOrder) {
this.byteOrder = byteOrder;
}
public boolean isValid(byte bytes[], int index,
- boolean mayHaveTerminator, boolean mustHaveTerminator)
- {
+ boolean mayHaveTerminator, boolean mustHaveTerminator) {
// http://en.wikipedia.org/wiki/UTF-16/UCS-2
- while (true)
- {
- if (index == bytes.length)
- {
+ while (true) {
+ if (index == bytes.length) {
// end of buffer, no terminator found.
return !mustHaveTerminator;
}
- if (index >= bytes.length - 1)
- {
+ if (index >= bytes.length - 1) {
// end of odd-length buffer, no terminator found.
return false;
}
@@ -351,24 +323,20 @@ public abstract class UnicodeUtils imple
int c2 = 0xff & bytes[index++];
int msb1 = byteOrder == BYTE_ORDER_BIG_ENDIAN ? c1 : c2;
- if (c1 == 0 && c2 == 0)
- {
+ if (c1 == 0 && c2 == 0) {
// terminator found.
return mayHaveTerminator;
}
- if (msb1 >= 0xD8)
- {
+ if (msb1 >= 0xD8) {
// Surrogate pair found.
- if (msb1 >= 0xDC)
- {
+ if (msb1 >= 0xDC) {
// invalid first surrogate.
return false;
}
- if (index >= bytes.length - 1)
- {
+ if (index >= bytes.length - 1) {
// missing second surrogate.
return false;
}
@@ -377,8 +345,7 @@ public abstract class UnicodeUtils imple
int c3 = 0xff & bytes[index++];
int c4 = 0xff & bytes[index++];
int msb2 = byteOrder == BYTE_ORDER_BIG_ENDIAN ? c3 : c4;
- if (msb2 < 0xDC)
- {
+ if (msb2 < 0xDC) {
// invalid second surrogate.
return false;
}
@@ -388,12 +355,10 @@ public abstract class UnicodeUtils imple
@Override
public int findEnd(byte bytes[], int index, boolean includeTerminator)
- throws UnicodeException
- {
+ throws UnicodeException {
// http://en.wikipedia.org/wiki/UTF-16/UCS-2
- while (true)
- {
+ while (true) {
if (index == bytes.length)
return bytes.length;
if (index > bytes.length - 1)
@@ -403,11 +368,9 @@ public abstract class UnicodeUtils imple
int c2 = 0xff & bytes[index++];
int msb1 = byteOrder == BYTE_ORDER_BIG_ENDIAN ? c1 : c2;
- if (c1 == 0 && c2 == 0)
- {
+ if (c1 == 0 && c2 == 0) {
return includeTerminator ? index : index - 2;
- } else if (msb1 >= 0xD8)
- {
+ } else if (msb1 >= 0xD8) {
if (index > bytes.length - 1)
throw new UnicodeException("Terminator not found.");
@@ -422,28 +385,23 @@ public abstract class UnicodeUtils imple
}
}
- private static class UnicodeMetricsUTF16NoBOM extends UnicodeMetricsUTF16
- {
+ private static class UnicodeMetricsUTF16NoBOM extends UnicodeMetricsUTF16 {
- public UnicodeMetricsUTF16NoBOM(final int byteOrder)
- {
+ public UnicodeMetricsUTF16NoBOM(final int byteOrder) {
super(byteOrder);
}
}
- private static class UnicodeMetricsUTF16WithBOM extends UnicodeMetricsUTF16
- {
+ private static class UnicodeMetricsUTF16WithBOM extends UnicodeMetricsUTF16 {
- public UnicodeMetricsUTF16WithBOM()
- {
+ public UnicodeMetricsUTF16WithBOM() {
super(BYTE_ORDER_BIG_ENDIAN);
}
@Override
public int findEnd(byte bytes[], int index, boolean includeTerminator)
- throws UnicodeException
- {
+ throws UnicodeException {
// http://en.wikipedia.org/wiki/UTF-16/UCS-2
if (index >= bytes.length - 1)
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java Sat May 26 21:19:03 2012
@@ -37,8 +37,7 @@ public class ImagingGuessFormatTest exte
public static final String PPM_IMAGE_FILE = "pbm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ppm";
public static final String TGA_IMAGE_FILE = "tga\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tga";
- public void testGuess_all() throws Exception
- {
+ public void testGuess_all() throws Exception {
testGuess(ImageFormat.IMAGE_FORMAT_PNG, PNG_IMAGE_FILE);
testGuess(ImageFormat.IMAGE_FORMAT_GIF, GIF_IMAGE_FILE);
testGuess(ImageFormat.IMAGE_FORMAT_ICNS, ICNS_IMAGE_FILE);
@@ -64,8 +63,8 @@ public class ImagingGuessFormatTest exte
testGuess(ImageFormat.IMAGE_FORMAT_UNKNOWN, UNKNOWN_IMAGE_FILE);
}
- public void testGuess(ImageFormat expectedFormat, String imagePath) throws Exception
- {
+ public void testGuess(ImageFormat expectedFormat, String imagePath)
+ throws Exception {
imagePath = FilenameUtils.separatorsToSystem(imagePath);
File imageFile = new File(TEST_IMAGE_FOLDER, imagePath);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTest.java Sat May 26 21:19:03 2012
@@ -81,7 +81,8 @@ public abstract class ImagingTest extend
protected File getTestImageByName(final String filename)
throws IOException, ImageReadException {
return getTestImage(new ImageFilter() {
- public boolean accept(File file) throws IOException, ImageReadException {
+ public boolean accept(File file) throws IOException,
+ ImageReadException {
return file.getName().equals(filename);
}
});
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTestConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTestConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTestConstants.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/ImagingTestConstants.java Sat May 26 21:19:03 2012
@@ -23,7 +23,8 @@ import org.apache.commons.io.FilenameUti
public interface ImagingTestConstants {
static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File(
- FilenameUtils.separatorsToSystem("src\\test\\data\\images\\exif\\philHarvey\\"));
+ FilenameUtils
+ .separatorsToSystem("src\\test\\data\\images\\exif\\philHarvey\\"));
static final File SOURCE_FOLDER = new File("src");
static final File TEST_SOURCE_FOLDER = new File(SOURCE_FOLDER, "test");
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java Sat May 26 21:19:03 2012
@@ -20,25 +20,13 @@ import org.apache.commons.imaging.util.D
import junit.framework.TestCase;
-public class ColorConversionsTest extends TestCase
-{
- private static final int SAMPLE_RGBS[] = {
- 0xffffffff,
- 0xff000000,
- 0xffff0000,
- 0xff00ff00,
- 0xff0000ff,
- 0xffff00ff,
- 0xfff0ff00,
- 0xff00ffff,
- 0x00000000,
- 0xff7f7f7f,
- };
-
- public void testRGBtoCMYK() throws Exception
- {
- for (int i = 0; i < SAMPLE_RGBS.length; i++)
- {
+public class ColorConversionsTest extends TestCase {
+ private static final int SAMPLE_RGBS[] = { 0xffffffff, 0xff000000,
+ 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffff00ff, 0xfff0ff00,
+ 0xff00ffff, 0x00000000, 0xff7f7f7f, };
+
+ public void testRGBtoCMYK() throws Exception {
+ for (int i = 0; i < SAMPLE_RGBS.length; i++) {
int rgb = SAMPLE_RGBS[i];
ColorCmy cmy = ColorConversions.convertRGBtoCMY(rgb);
@@ -49,48 +37,46 @@ public class ColorConversionsTest extend
Debug.debug("cmy", cmy);
Debug.debug("cmyk", cmyk);
Debug.debug("cmyk_cmy", cmyk_cmy);
- Debug.debug("cmyk_cmy_rgb", cmyk_cmy_rgb + " (" + Integer.toHexString(cmyk_cmy_rgb) + ")");
-
+ Debug.debug("cmyk_cmy_rgb",
+ cmyk_cmy_rgb + " (" + Integer.toHexString(cmyk_cmy_rgb)
+ + ")");
+
assertEquals((0xffffff & cmyk_cmy_rgb), (0xffffff & rgb));
}
}
- public void testRGBtoHSL() throws Exception
- {
- for (int i = 0; i < SAMPLE_RGBS.length; i++)
- {
+ public void testRGBtoHSL() throws Exception {
+ for (int i = 0; i < SAMPLE_RGBS.length; i++) {
int rgb = SAMPLE_RGBS[i];
ColorHsl hsl = ColorConversions.convertRGBtoHSL(rgb);
int hsl_rgb = ColorConversions.convertHSLtoRGB(hsl);
Debug.debug("hsl", hsl);
- Debug.debug("hsl_rgb", hsl_rgb + " (" + Integer.toHexString(hsl_rgb) + ")");
-
+ Debug.debug("hsl_rgb",
+ hsl_rgb + " (" + Integer.toHexString(hsl_rgb) + ")");
+
assertEquals((0xffffff & hsl_rgb), (0xffffff & rgb));
}
}
- public void testRGBtoHSV() throws Exception
- {
- for (int i = 0; i < SAMPLE_RGBS.length; i++)
- {
+ public void testRGBtoHSV() throws Exception {
+ for (int i = 0; i < SAMPLE_RGBS.length; i++) {
int rgb = SAMPLE_RGBS[i];
ColorHsv hsv = ColorConversions.convertRGBtoHSV(rgb);
int hsv_rgb = ColorConversions.convertHSVtoRGB(hsv);
Debug.debug("hsv", hsv);
- Debug.debug("hsv_rgb", hsv_rgb + " (" + Integer.toHexString(hsv_rgb) + ")");
-
+ Debug.debug("hsv_rgb",
+ hsv_rgb + " (" + Integer.toHexString(hsv_rgb) + ")");
+
assertEquals((0xffffff & hsv_rgb), (0xffffff & rgb));
}
}
- public void testXYZ() throws Exception
- {
- for (int i = 0; i < SAMPLE_RGBS.length; i++)
- {
+ public void testXYZ() throws Exception {
+ for (int i = 0; i < SAMPLE_RGBS.length; i++) {
int rgb = SAMPLE_RGBS[i];
ColorXyz xyz = ColorConversions.convertRGBtoXYZ(rgb);
@@ -99,35 +85,42 @@ public class ColorConversionsTest extend
Debug.debug();
Debug.debug("rgb", rgb + " (" + Integer.toHexString(rgb) + ")");
Debug.debug("xyz", xyz);
- Debug.debug("xyz_rgb", xyz_rgb + " (" + Integer.toHexString(xyz_rgb) + ")");
-
+ Debug.debug("xyz_rgb",
+ xyz_rgb + " (" + Integer.toHexString(xyz_rgb) + ")");
+
assertEquals((0xffffff & xyz_rgb), (0xffffff & rgb));
-
ColorCieLab cielab = ColorConversions.convertXYZtoCIELab(xyz);
ColorXyz cielab_xyz = ColorConversions.convertCIELabtoXYZ(cielab);
int cielab_xyz_rgb = ColorConversions.convertXYZtoRGB(cielab_xyz);
Debug.debug("cielab", cielab);
Debug.debug("cielab_xyz", cielab_xyz);
- Debug.debug("cielab_xyz_rgb", cielab_xyz_rgb + " (" + Integer.toHexString(cielab_xyz_rgb) + ")");
-
- assertEquals((0xffffff & cielab_xyz_rgb), (0xffffff & rgb));
+ Debug.debug("cielab_xyz_rgb",
+ cielab_xyz_rgb + " (" + Integer.toHexString(cielab_xyz_rgb)
+ + ")");
+ assertEquals((0xffffff & cielab_xyz_rgb), (0xffffff & rgb));
- ColorHunterLab hunterlab = ColorConversions.convertXYZtoHunterLab(xyz);
- ColorXyz hunterlab_xyz = ColorConversions.convertHunterLabtoXYZ(hunterlab);
- int hunterlab_xyz_rgb = ColorConversions.convertXYZtoRGB(hunterlab_xyz);
+ ColorHunterLab hunterlab = ColorConversions
+ .convertXYZtoHunterLab(xyz);
+ ColorXyz hunterlab_xyz = ColorConversions
+ .convertHunterLabtoXYZ(hunterlab);
+ int hunterlab_xyz_rgb = ColorConversions
+ .convertXYZtoRGB(hunterlab_xyz);
Debug.debug("hunterlab", hunterlab);
Debug.debug("hunterlab_xyz", hunterlab_xyz);
- Debug.debug("hunterlab_xyz_rgb", hunterlab_xyz_rgb + " (" + Integer.toHexString(hunterlab_xyz_rgb) + ")");
-
+ Debug.debug(
+ "hunterlab_xyz_rgb",
+ hunterlab_xyz_rgb + " ("
+ + Integer.toHexString(hunterlab_xyz_rgb) + ")");
+
assertEquals((0xffffff & hunterlab_xyz_rgb), (0xffffff & rgb));
-
ColorCieLch cielch = ColorConversions.convertCIELabtoCIELCH(cielab);
- ColorCieLab cielch_cielab = ColorConversions.convertCIELCHtoCIELab(cielch);
+ ColorCieLab cielch_cielab = ColorConversions
+ .convertCIELCHtoCIELab(cielch);
Debug.debug("cielch", cielch);
Debug.debug("cielch_cielab", cielch_cielab);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java Sat May 26 21:19:03 2012
@@ -22,25 +22,34 @@ public class BinaryFileFunctionsTest ext
// Work around that pesky "protected"...
private static class Extender extends BinaryFileFunctions {
public void testFloatToByteConversion() {
- byte[] bytesLE = convertFloatToByteArray(1.0f, BYTE_ORDER_LITTLE_ENDIAN);
- assertEquals(convertByteArrayToFloat("bytes", bytesLE, BYTE_ORDER_LITTLE_ENDIAN),
- 1.0f, 0f);
-
- byte[] bytesBE = convertFloatToByteArray(1.0f, BYTE_ORDER_BIG_ENDIAN);
- assertEquals(convertByteArrayToFloat("bytes", bytesBE, BYTE_ORDER_BIG_ENDIAN),
- 1.0f, 0f);
+ byte[] bytesLE = convertFloatToByteArray(1.0f,
+ BYTE_ORDER_LITTLE_ENDIAN);
+ assertEquals(
+ convertByteArrayToFloat("bytes", bytesLE,
+ BYTE_ORDER_LITTLE_ENDIAN), 1.0f, 0f);
+
+ byte[] bytesBE = convertFloatToByteArray(1.0f,
+ BYTE_ORDER_BIG_ENDIAN);
+ assertEquals(
+ convertByteArrayToFloat("bytes", bytesBE,
+ BYTE_ORDER_BIG_ENDIAN), 1.0f, 0f);
}
public void testDoubleToByteConversion() {
- byte[] bytesLE = convertDoubleToByteArray(1.0, BYTE_ORDER_LITTLE_ENDIAN);
- assertEquals(convertByteArrayToDouble("bytes", bytesLE, BYTE_ORDER_LITTLE_ENDIAN),
- 1.0, 0);
-
- byte[] bytesBE = convertDoubleToByteArray(1.0, BYTE_ORDER_BIG_ENDIAN);
- assertEquals(convertByteArrayToDouble("bytes", bytesBE, BYTE_ORDER_BIG_ENDIAN),
- 1.0, 0);
+ byte[] bytesLE = convertDoubleToByteArray(1.0,
+ BYTE_ORDER_LITTLE_ENDIAN);
+ assertEquals(
+ convertByteArrayToDouble("bytes", bytesLE,
+ BYTE_ORDER_LITTLE_ENDIAN), 1.0, 0);
+
+ byte[] bytesBE = convertDoubleToByteArray(1.0,
+ BYTE_ORDER_BIG_ENDIAN);
+ assertEquals(
+ convertByteArrayToDouble("bytes", bytesBE,
+ BYTE_ORDER_BIG_ENDIAN), 1.0, 0);
}
}
+
private Extender extender = new Extender();
public void testFloatToByteConversion() {
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java Sat May 26 21:19:03 2012
@@ -25,15 +25,13 @@ import org.apache.commons.imaging.common
import org.apache.commons.imaging.common.RationalNumberUtilities;
import org.apache.commons.imaging.util.Debug;
-public class RationalNumberTest extends ImagingTest
-{
+public class RationalNumberTest extends ImagingTest {
// public RationalNumberTest()
// {
// super("Rational Number Test");
// }
- public void test()
- {
+ public void test() {
double testValues[] = {
0, //
0.1, //
@@ -107,8 +105,7 @@ public class RationalNumberTest extends
-(Long.MAX_VALUE - 0.1), //
};
- for (int i = 0; i < testValues.length; i++)
- {
+ for (int i = 0; i < testValues.length; i++) {
double value = testValues[i];
RationalNumber rational = RationalNumberUtilities
.getRationalNumber(value);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java Sat May 26 21:19:03 2012
@@ -28,18 +28,14 @@ import org.apache.commons.imaging.common
import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream;
import org.apache.commons.imaging.util.IoUtils;
-public class ByteSourceDataTest extends ByteSourceTest
-{
+public class ByteSourceDataTest extends ByteSourceTest {
- private interface ByteSourceFactory
- {
+ private interface ByteSourceFactory {
public ByteSource getByteSource(byte src[]) throws IOException;
}
- private class ByteSourceFileFactory implements ByteSourceFactory
- {
- public ByteSource getByteSource(byte src[]) throws IOException
- {
+ private class ByteSourceFileFactory implements ByteSourceFactory {
+ public ByteSource getByteSource(byte src[]) throws IOException {
File file = createTempFile(src);
// test that all bytes written to file.
@@ -50,10 +46,8 @@ public class ByteSourceDataTest extends
}
}
- private class ByteSourceInputStreamFileFactory implements ByteSourceFactory
- {
- public ByteSource getByteSource(byte src[]) throws IOException
- {
+ private class ByteSourceInputStreamFileFactory implements ByteSourceFactory {
+ public ByteSource getByteSource(byte src[]) throws IOException {
File file = createTempFile(src);
FileInputStream is = new FileInputStream(file);
@@ -63,10 +57,8 @@ public class ByteSourceDataTest extends
}
}
- private class ByteSourceInputStreamRawFactory implements ByteSourceFactory
- {
- public ByteSource getByteSource(byte src[]) throws IOException
- {
+ private class ByteSourceInputStreamRawFactory implements ByteSourceFactory {
+ public ByteSource getByteSource(byte src[]) throws IOException {
ByteArrayInputStream is = new ByteArrayInputStream(src);
ByteSource byteSource = new ByteSourceInputStream(is, null);
@@ -76,18 +68,18 @@ public class ByteSourceDataTest extends
}
protected void writeAndReadBytes(ByteSourceFactory byteSourceFactory,
- byte src[]) throws IOException
- {
+ byte src[]) throws IOException {
ByteSource byteSource = byteSourceFactory.getByteSource(src);
- // test cache during interrupted read cache by reading only first N bytes.
+ // test cache during interrupted read cache by reading only first N
+ // bytes.
{
InputStream is = null;
try {
is = byteSource.getInputStream();
byte prefix[] = new byte[256];
int read = is.read(prefix);
-
+
assertTrue(read <= src.length);
for (int i = 0; i < read; i++)
assertTrue(src[i] == prefix[i]);
@@ -102,8 +94,7 @@ public class ByteSourceDataTest extends
}
// test cache by completely reading InputStream N times.
- for (int j = 0; j < 5; j++)
- {
+ for (int j = 0; j < 5; j++) {
InputStream is = byteSource.getInputStream();
byte dst[] = IoUtils.getInputStreamBytes(is);
@@ -116,8 +107,7 @@ public class ByteSourceDataTest extends
compareByteArrays(src, all);
}
- if (src.length > 2)
- {
+ if (src.length > 2) {
// test optional start param to getInputStream()
int start = src.length / 2;
@@ -142,22 +132,18 @@ public class ByteSourceDataTest extends
}
- public void test() throws Exception
- {
+ public void test() throws Exception {
ByteSourceFactory byteSourceFactories[] = {
new ByteSourceFileFactory(),
new ByteSourceInputStreamFileFactory(),
- new ByteSourceInputStreamRawFactory(),
- };
+ new ByteSourceInputStreamRawFactory(), };
byte testByteArrays[][] = getTestByteArrays();
- for (int i = 0; i < testByteArrays.length; i++)
- {
+ for (int i = 0; i < testByteArrays.length; i++) {
byte testByteArray[] = testByteArrays[i];
- for (int j = 0; j < byteSourceFactories.length; j++)
- {
+ for (int j = 0; j < byteSourceFactories.length; j++) {
ByteSourceFactory byteSourceFactory = byteSourceFactories[j];
writeAndReadBytes(byteSourceFactory, testByteArray);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java Sat May 26 21:19:03 2012
@@ -35,14 +35,11 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.util.Debug;
import org.apache.commons.imaging.util.IoUtils;
-public class ByteSourceImageTest extends ByteSourceTest
-{
+public class ByteSourceImageTest extends ByteSourceTest {
- public void test() throws Exception
- {
+ public void test() throws Exception {
List imageFiles = getTestImages();
- for (int i = 0; i < imageFiles.size(); i++)
- {
+ for (int i = 0; i < imageFiles.size(); i++) {
if (i % 1 == 0)
Debug.purgeMemory();
@@ -62,8 +59,7 @@ public class ByteSourceImageTest extends
|| imageFile.getName().toLowerCase().endsWith(".psd")
|| imageFile.getName().toLowerCase().endsWith(".wbmp")
|| imageFile.getName().toLowerCase().endsWith(".xbm")
- || imageFile.getName().toLowerCase().endsWith(".xpm"))
- {
+ || imageFile.getName().toLowerCase().endsWith(".xpm")) {
// these formats can't be parsed without a filename hint.
// they have ambiguous "magic number" signatures.
continue;
@@ -72,30 +68,28 @@ public class ByteSourceImageTest extends
checkGuessFormat(imageFile, imageFileBytes);
if (imageFile.getName().toLowerCase().endsWith(".png")
- && imageFile.getParentFile().getName().equalsIgnoreCase(
- "pngsuite")
+ && imageFile.getParentFile().getName()
+ .equalsIgnoreCase("pngsuite")
&& imageFile.getName().toLowerCase().startsWith("x"))
continue;
checkGetICCProfileBytes(imageFile, imageFileBytes);
- if (!imageFile.getParentFile().getName().toLowerCase().equals(
- "@broken"))
+ if (!imageFile.getParentFile().getName().toLowerCase()
+ .equals("@broken"))
checkGetImageInfo(imageFile, imageFileBytes);
checkGetImageSize(imageFile, imageFileBytes);
ImageFormat imageFormat = Imaging.guessFormat(imageFile);
if (ImageFormat.IMAGE_FORMAT_JPEG != imageFormat
- && ImageFormat.IMAGE_FORMAT_UNKNOWN != imageFormat)
- {
+ && ImageFormat.IMAGE_FORMAT_UNKNOWN != imageFormat) {
checkGetBufferedImage(imageFile, imageFileBytes);
}
}
}
- public void checkGetBufferedImage(File file, byte[] bytes) throws Exception
- {
+ public void checkGetBufferedImage(File file, byte[] bytes) throws Exception {
BufferedImage imageFile = Imaging.getBufferedImage(file);
assertNotNull(imageFile);
assertTrue(imageFile.getWidth() > 0);
@@ -110,8 +104,8 @@ public class ByteSourceImageTest extends
assertTrue(imageFileHeight == imageBytes.getHeight());
}
- public void checkGetImageSize(File imageFile, byte[] imageFileBytes) throws Exception
- {
+ public void checkGetImageSize(File imageFile, byte[] imageFileBytes)
+ throws Exception {
Dimension imageSizeFile = Imaging.getImageSize(imageFile);
assertNotNull(imageSizeFile);
assertTrue(imageSizeFile.width > 0);
@@ -123,8 +117,8 @@ public class ByteSourceImageTest extends
assertTrue(imageSizeFile.height == imageSizeBytes.height);
}
- public void checkGuessFormat(File imageFile, byte[] imageFileBytes) throws Exception
- {
+ public void checkGuessFormat(File imageFile, byte[] imageFileBytes)
+ throws Exception {
// check guessFormat()
ImageFormat imageFormatFile = Imaging.guessFormat(imageFile);
assertNotNull(imageFormatFile);
@@ -139,8 +133,8 @@ public class ByteSourceImageTest extends
assertTrue(imageFormatBytes == imageFormatFile);
}
- public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes) throws Exception
- {
+ public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes)
+ throws Exception {
// check guessFormat()
byte iccBytesFile[] = Imaging.getICCProfileBytes(imageFile);
@@ -156,28 +150,23 @@ public class ByteSourceImageTest extends
public void checkGetImageInfo(File imageFile, byte[] imageFileBytes)
throws IOException, ImageReadException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException
- {
+ IllegalArgumentException, InvocationTargetException {
Map params = new HashMap();
boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
ImageFormat imageFormat = Imaging.guessFormat(imageFile);
if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_TIFF)
|| imageFormat.equals(ImageFormat.IMAGE_FORMAT_JPEG))
- params
- .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
- !ignoreImageData));
+ params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(!ignoreImageData));
ImageInfo imageInfoFile = Imaging.getImageInfo(imageFile, params);
- ImageInfo imageInfoBytes = Imaging
- .getImageInfo(imageFileBytes, params);
+ ImageInfo imageInfoBytes = Imaging.getImageInfo(imageFileBytes, params);
assertNotNull(imageInfoFile);
assertNotNull(imageInfoBytes);
Method methods[] = ImageInfo.class.getMethods();
- for (int i = 0; i < methods.length; i++)
- {
+ for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
method.getModifiers();
if (!Modifier.isPublic(method.getModifiers()))
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java Sat May 26 21:19:03 2012
@@ -26,10 +26,8 @@ import java.io.OutputStream;
import org.apache.commons.imaging.ImagingTest;
-public abstract class ByteSourceTest extends ImagingTest
-{
- protected File createTempFile(byte src[]) throws IOException
- {
+public abstract class ByteSourceTest extends ImagingTest {
+ protected File createTempFile(byte src[]) throws IOException {
File file = createTempFile("raw_", ".bin");
// write test bytes to file.
@@ -44,8 +42,7 @@ public abstract class ByteSourceTest ext
return file;
}
- protected byte[][] getTestByteArrays()
- {
+ protected byte[][] getTestByteArrays() {
byte emptyArray[] = (new byte[0]);
byte single[] = new byte[1];
@@ -61,8 +58,7 @@ public abstract class ByteSourceTest ext
zeroes[i] = 0;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (int i = 0; i < 256 * 256; i++)
- {
+ for (int i = 0; i < 256 * 256; i++) {
baos.write(0xff & i);
baos.write(0xff & (i >> 8));
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java Sat May 26 21:19:03 2012
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
/****************************************************************
* Explanation of Use and Rationale For Procedures
*
@@ -166,62 +165,62 @@ import org.apache.commons.imaging.common
import org.apache.commons.imaging.formats.tiff.TiffImageParser;
/**
- * A "test stand" for evaluating the speed an memory use
- * of different Apache Imaging operations
+ * A "test stand" for evaluating the speed an memory use of different Apache
+ * Imaging operations
*/
-public class ApacheImagingSpeedAndMemoryTest
-{
+public class ApacheImagingSpeedAndMemoryTest {
/**
- * Create an instance of the speed and memory test class
- * and execute a test loop for the specified file.
- * @param args the path to the file to be processed
+ * Create an instance of the speed and memory test class and execute a test
+ * loop for the specified file.
+ *
+ * @param args
+ * the path to the file to be processed
*/
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
String name = args[0];
-
- ApacheImagingSpeedAndMemoryTest testStand =
- new ApacheImagingSpeedAndMemoryTest();
+
+ ApacheImagingSpeedAndMemoryTest testStand = new ApacheImagingSpeedAndMemoryTest();
testStand.performTest(name);
}
/**
- * Loads the input file multiple times, measuring the
- * time and memory use for each iteration.
- * @param name the path for the input image file to be tested
+ * Loads the input file multiple times, measuring the time and memory use
+ * for each iteration.
+ *
+ * @param name
+ * the path for the input image file to be tested
*/
- private void performTest(String name)
- {
+ private void performTest(String name) {
File target = new File(name);
Formatter fmt = new Formatter(System.out);
-
+
double sumTime = 0;
int n = 1;
for (int i = 0; i < 10; i++) {
try {
ByteSourceFile byteSource = new ByteSourceFile(target);
- // This test code allows you to test cases where the
- // input is processed using Apache Imaging's
- // ByteSourceInputStream rather than the ByteSourceFile.
- // You might also want to experiment with ByteSourceArray.
- // FileInputStream fins = new FileInputStream(target);
- // BufferedInputStream bins = new BufferedInputStream(fins);
- // ByteSourceInputStream byteSource =
- // new ByteSourceInputStream(bins, target.getName());
-
+ // This test code allows you to test cases where the
+ // input is processed using Apache Imaging's
+ // ByteSourceInputStream rather than the ByteSourceFile.
+ // You might also want to experiment with ByteSourceArray.
+ // FileInputStream fins = new FileInputStream(target);
+ // BufferedInputStream bins = new BufferedInputStream(fins);
+ // ByteSourceInputStream byteSource =
+ // new ByteSourceInputStream(bins, target.getName());
+
// ready the parser (you may modify this code block
// to use your parser of choice)
HashMap params = new HashMap();
TiffImageParser tiffImageParser = new TiffImageParser();
-
+
// load the file and record time needed to do so
long time0 = System.nanoTime();
- BufferedImage bImage =
- tiffImageParser.getBufferedImage(byteSource, params);
+ BufferedImage bImage = tiffImageParser.getBufferedImage(
+ byteSource, params);
long time1 = System.nanoTime();
-
+
// tabulate results
double testTime = (time1 - time0) / 1000000.0;
if (i > 1) {
@@ -230,12 +229,12 @@ public class ApacheImagingSpeedAndMemory
}
double avgTime = sumTime / n;
- // tabulate the memory results. Note that the
+ // tabulate the memory results. Note that the
// buffered image, the byte source, and the parser
- // are all still in scope. This approach is taken
+ // are all still in scope. This approach is taken
// to get some sense of peak memory use, but Java
// may have already started collecting garbage,
- // so there are limits to the reliability of these
+ // so there are limits to the reliability of these
// statistics
Runtime r = Runtime.getRuntime();
long freeMemory = r.freeMemory();
@@ -246,19 +245,14 @@ public class ApacheImagingSpeedAndMemory
// print header info
fmt.format("\n");
fmt.format("Processing file: %s\n", target.getName());
- fmt.format(" image size: %d by %d\n\n",
- bImage.getWidth(),
- bImage.getHeight());
- fmt.format(
- " time to load image -- memory\n");
- fmt.format(
- " time ms avg ms -- used mb total mb\n");
+ fmt.format(" image size: %d by %d\n\n", bImage.getWidth(),
+ bImage.getHeight());
+ fmt.format(" time to load image -- memory\n");
+ fmt.format(" time ms avg ms -- used mb total mb\n");
}
- fmt.format("%9.3f %9.3f -- %9.3f %9.3f \n",
- testTime,
- avgTime,
- usedMemory / (1024.0 * 1024.0),
- totalMemory / (1024.0 * 1024.0));
+ fmt.format("%9.3f %9.3f -- %9.3f %9.3f \n", testTime,
+ avgTime, usedMemory / (1024.0 * 1024.0), totalMemory
+ / (1024.0 * 1024.0));
bImage = null;
byteSource = null;
params = null;
@@ -273,9 +267,9 @@ public class ApacheImagingSpeedAndMemory
try {
// sleep between loop iterations allows time
- // for the JVM to clean up memory. The Netbeans IDE
+ // for the JVM to clean up memory. The Netbeans IDE
// doesn't "get" the fact that we're doing this operation
- // deliberately and is apt offer hints
+ // deliberately and is apt offer hints
// suggesting that the code should be modified
Runtime.getRuntime().gc();
Thread.sleep(1000);
@@ -287,4 +281,3 @@ public class ApacheImagingSpeedAndMemory
}
}
}
-
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageReadExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageReadExample.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageReadExample.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageReadExample.java Sat May 26 21:19:03 2012
@@ -31,18 +31,16 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.ImagingConstants;
import org.apache.commons.imaging.common.IBufferedImageFactory;
-public class ImageReadExample
-{
+public class ImageReadExample {
public static BufferedImage imageReadExample(File file)
- throws ImageReadException, IOException
- {
+ throws ImageReadException, IOException {
Map params = new HashMap();
// set optional parameters if you like
params.put(ImagingConstants.BUFFERED_IMAGE_FACTORY,
new ManagedImageBufferedImageFactory());
- // params.put(SanselanConstants.PARAM_KEY_VERBOSE, Boolean.TRUE);
+ // params.put(SanselanConstants.PARAM_KEY_VERBOSE, Boolean.TRUE);
// read image
BufferedImage image = Imaging.getBufferedImage(file, params);
@@ -50,14 +48,11 @@ public class ImageReadExample
return image;
}
- public static class ManagedImageBufferedImageFactory
- implements
- IBufferedImageFactory
- {
+ public static class ManagedImageBufferedImageFactory implements
+ IBufferedImageFactory {
public BufferedImage getColorBufferedImage(int width, int height,
- boolean hasAlpha)
- {
+ boolean hasAlpha) {
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
@@ -67,8 +62,7 @@ public class ImageReadExample
}
public BufferedImage getGrayscaleBufferedImage(int width, int height,
- boolean hasAlpha)
- {
+ boolean hasAlpha) {
return getColorBufferedImage(width, height, hasAlpha);
}
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageWriteExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageWriteExample.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageWriteExample.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ImageWriteExample.java Sat May 26 21:19:03 2012
@@ -29,11 +29,9 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.ImagingConstants;
import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
-public class ImageWriteExample
-{
+public class ImageWriteExample {
public static byte[] imageWriteExample(File file)
- throws ImageReadException, ImageWriteException, IOException
- {
+ throws ImageReadException, ImageWriteException, IOException {
// read image
BufferedImage image = Imaging.getBufferedImage(file);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/MetadataExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/MetadataExample.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/MetadataExample.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/MetadataExample.java Sat May 26 21:19:03 2012
@@ -32,19 +32,16 @@ import org.apache.commons.imaging.format
import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
-public class MetadataExample
-{
+public class MetadataExample {
public static void metadataExample(File file) throws ImageReadException,
- IOException
- {
- // get all metadata stored in EXIF format (ie. from JPEG or TIFF).
- // org.w3c.dom.Node node = Sanselan.getMetadataObsolete(imageBytes);
+ IOException {
+ // get all metadata stored in EXIF format (ie. from JPEG or TIFF).
+ // org.w3c.dom.Node node = Sanselan.getMetadataObsolete(imageBytes);
IImageMetadata metadata = Imaging.getMetadata(file);
- //System.out.println(metadata);
+ // System.out.println(metadata);
- if (metadata instanceof JpegImageMetadata)
- {
+ if (metadata instanceof JpegImageMetadata) {
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
// Jpeg EXIF metadata is stored in a TIFF-based directory structure
@@ -65,29 +62,34 @@ public class MetadataExample
printTagValue(jpegMetadata, ExifTagConstants.EXIF_TAG_ISO);
printTagValue(jpegMetadata,
ExifTagConstants.EXIF_TAG_SHUTTER_SPEED_VALUE);
- printTagValue(jpegMetadata, ExifTagConstants.EXIF_TAG_APERTURE_VALUE);
- printTagValue(jpegMetadata, ExifTagConstants.EXIF_TAG_BRIGHTNESS_VALUE);
- printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
+ printTagValue(jpegMetadata,
+ ExifTagConstants.EXIF_TAG_APERTURE_VALUE);
+ printTagValue(jpegMetadata,
+ ExifTagConstants.EXIF_TAG_BRIGHTNESS_VALUE);
+ printTagValue(jpegMetadata,
+ GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE);
- printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
+ printTagValue(jpegMetadata,
+ GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
System.out.println();
// simple interface to GPS data
TiffImageMetadata exifMetadata = jpegMetadata.getExif();
- if (null != exifMetadata)
- {
+ if (null != exifMetadata) {
TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
- if (null != gpsInfo)
- {
+ if (null != gpsInfo) {
String gpsDescription = gpsInfo.toString();
double longitude = gpsInfo.getLongitudeAsDegreesEast();
double latitude = gpsInfo.getLatitudeAsDegreesNorth();
- System.out.println(" " + "GPS Description: " + gpsDescription);
- System.out.println(" " + "GPS Longitude (Degrees East): " + longitude);
- System.out.println(" " + "GPS Latitude (Degrees North): " + latitude);
+ System.out.println(" " + "GPS Description: "
+ + gpsDescription);
+ System.out.println(" "
+ + "GPS Longitude (Degrees East): " + longitude);
+ System.out.println(" "
+ + "GPS Latitude (Degrees North): " + latitude);
}
}
@@ -102,8 +104,7 @@ public class MetadataExample
.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
if (gpsLatitudeRefField != null && gpsLatitudeField != null
&& gpsLongitudeRefField != null
- && gpsLongitudeField != null)
- {
+ && gpsLongitudeField != null) {
// all of these values are strings.
String gpsLatitudeRef = (String) gpsLatitudeRefField.getValue();
RationalNumber gpsLatitude[] = (RationalNumber[]) (gpsLatitudeField
@@ -142,8 +143,7 @@ public class MetadataExample
System.out.println();
List items = jpegMetadata.getItems();
- for (int i = 0; i < items.size(); i++)
- {
+ for (int i = 0; i < items.size(); i++) {
Object item = items.get(i);
System.out.println(" " + "item: " + item);
}
@@ -153,8 +153,7 @@ public class MetadataExample
}
private static void printTagValue(JpegImageMetadata jpegMetadata,
- TagInfo tagInfo)
- {
+ TagInfo tagInfo) {
TiffField field = jpegMetadata.findEXIFValueWithExactMatch(tagInfo);
if (field == null)
System.out.println(tagInfo.name + ": " + "Not Found.");
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/SampleUsage.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/SampleUsage.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/SampleUsage.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/SampleUsage.java Sat May 26 21:19:03 2012
@@ -31,29 +31,30 @@ import org.apache.commons.imaging.ImageI
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.common.IImageMetadata;
-public class SampleUsage
-{
+public class SampleUsage {
- public SampleUsage()
- {
+ public SampleUsage() {
- try
- {
- // <b>Code won't work unless these variables are properly initialized.
- // Sanselan works equally well with File, byte array or InputStream inputs.</b>
+ try {
+ // <b>Code won't work unless these variables are properly
+ // initialized.
+ // Sanselan works equally well with File, byte array or InputStream
+ // inputs.</b>
BufferedImage someImage = null;
byte someBytes[] = null;
File someFile = null;
InputStream someInputStream = null;
OutputStream someOutputStream = null;
- // <b>The Sanselan class provides a simple interface to the library. </b>
+ // <b>The Sanselan class provides a simple interface to the library.
+ // </b>
// <b>how to read an image: </b>
byte imageBytes[] = someBytes;
BufferedImage image_1 = Imaging.getBufferedImage(imageBytes);
- // <b>methods of Sanselan usually accept files, byte arrays, or inputstreams as arguments. </b>
+ // <b>methods of Sanselan usually accept files, byte arrays, or
+ // inputstreams as arguments. </b>
BufferedImage image_2 = Imaging.getBufferedImage(imageBytes);
File file = someFile;
BufferedImage image_3 = Imaging.getBufferedImage(file);
@@ -78,7 +79,8 @@ public class SampleUsage
// <b>get the image's width and height. </b>
Dimension d = Imaging.getImageSize(imageBytes);
- // <b>get all of the image's info (ie. bits per pixel, size, transparency, etc.) </b>
+ // <b>get all of the image's info (ie. bits per pixel, size,
+ // transparency, etc.) </b>
ImageInfo imageInfo = Imaging.getImageInfo(imageBytes);
if (imageInfo.getColorType() == ImageInfo.COLOR_TYPE_GRAYSCALE)
@@ -90,8 +92,10 @@ public class SampleUsage
ImageFormat image_format = Imaging.guessFormat(imageBytes);
image_format.equals(ImageFormat.IMAGE_FORMAT_PNG);
- // <b>get all metadata stored in EXIF format (ie. from JPEG or TIFF). </b>
- // <b>org.w3c.dom.Node node = Sanselan.getMetadataObsolete(imageBytes); </b>
+ // <b>get all metadata stored in EXIF format (ie. from JPEG or
+ // TIFF). </b>
+ // <b>org.w3c.dom.Node node =
+ // Sanselan.getMetadataObsolete(imageBytes); </b>
IImageMetadata metdata = Imaging.getMetadata(imageBytes);
// <b>print a dump of information about an image to stdout. </b>
@@ -101,9 +105,7 @@ public class SampleUsage
FormatCompliance formatCompliance = Imaging
.getFormatCompliance(imageBytes);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
}
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java Sat May 26 21:19:03 2012
@@ -35,26 +35,20 @@ import org.apache.commons.imaging.format
import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
import org.apache.commons.imaging.util.IoUtils;
-public class WriteExifMetadataExample
-{
+public class WriteExifMetadataExample {
public void removeExifMetadata(File jpegImageFile, File dst)
- throws IOException, ImageReadException, ImageWriteException
- {
+ throws IOException, ImageReadException, ImageWriteException {
OutputStream os = null;
- try
- {
+ try {
os = new FileOutputStream(dst);
os = new BufferedOutputStream(os);
new ExifRewriter().removeExifMetadata(jpegImageFile, os);
- } finally
- {
+ } finally {
if (os != null)
- try
- {
+ try {
os.close();
- } catch (IOException e)
- {
+ } catch (IOException e) {
}
}
@@ -62,7 +56,7 @@ public class WriteExifMetadataExample
/**
* This example illustrates how to add/update EXIF metadata in a JPEG file.
- *
+ *
* @param jpegImageFile
* A source image file.
* @param dst
@@ -72,23 +66,19 @@ public class WriteExifMetadataExample
* @throws ImageWriteException
*/
public void changeExifMetadata(File jpegImageFile, File dst)
- throws IOException, ImageReadException, ImageWriteException
- {
+ throws IOException, ImageReadException, ImageWriteException {
OutputStream os = null;
- try
- {
+ try {
TiffOutputSet outputSet = null;
// note that metadata might be null if no metadata is found.
IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
- if (null != jpegMetadata)
- {
+ if (null != jpegMetadata) {
// note that exif might be null if no Exif metadata is found.
TiffImageMetadata exif = jpegMetadata.getExif();
- if (null != exif)
- {
+ if (null != exif) {
// TiffImageMetadata class is immutable (read-only).
// TiffOutputSet class represents the Exif data to write.
//
@@ -130,7 +120,8 @@ public class WriteExifMetadataExample
// not fail if the tag does not exist).
exifDirectory
.removeField(ExifTagConstants.EXIF_TAG_APERTURE_VALUE);
- exifDirectory.add(ExifTagConstants.EXIF_TAG_APERTURE_VALUE, RationalNumber.factoryMethod(3, 10));
+ exifDirectory.add(ExifTagConstants.EXIF_TAG_APERTURE_VALUE,
+ RationalNumber.factoryMethod(3, 10));
}
{
@@ -154,14 +145,11 @@ public class WriteExifMetadataExample
os.close();
os = null;
- } finally
- {
+ } finally {
if (os != null)
- try
- {
+ try {
os.close();
- } catch (IOException e)
- {
+ } catch (IOException e) {
}
}
@@ -170,10 +158,10 @@ public class WriteExifMetadataExample
/**
* This example illustrates how to remove a tag (if present) from EXIF
* metadata in a JPEG file.
- *
+ *
* In this case, we remove the "aperture" tag from the EXIF metadata if
* present.
- *
+ *
* @param jpegImageFile
* A source image file.
* @param dst
@@ -183,23 +171,19 @@ public class WriteExifMetadataExample
* @throws ImageWriteException
*/
public void removeExifTag(File jpegImageFile, File dst) throws IOException,
- ImageReadException, ImageWriteException
- {
+ ImageReadException, ImageWriteException {
OutputStream os = null;
- try
- {
+ try {
TiffOutputSet outputSet = null;
// note that metadata might be null if no metadata is found.
IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
- if (null != jpegMetadata)
- {
+ if (null != jpegMetadata) {
// note that exif might be null if no Exif metadata is found.
TiffImageMetadata exif = jpegMetadata.getExif();
- if (null != exif)
- {
+ if (null != exif) {
// TiffImageMetadata class is immutable (read-only).
// TiffOutputSet class represents the Exif data to write.
//
@@ -212,8 +196,7 @@ public class WriteExifMetadataExample
}
}
- if (null == outputSet)
- {
+ if (null == outputSet) {
// file does not contain any exif metadata. We don't need to
// update the file; just copy it.
IoUtils.copyFileNio(jpegImageFile, dst);
@@ -253,14 +236,11 @@ public class WriteExifMetadataExample
os.close();
os = null;
- } finally
- {
+ } finally {
if (os != null)
- try
- {
+ try {
os.close();
- } catch (IOException e)
- {
+ } catch (IOException e) {
}
}
@@ -268,7 +248,7 @@ public class WriteExifMetadataExample
/**
* This example illustrates how to set the GPS values in JPEG EXIF metadata.
- *
+ *
* @param jpegImageFile
* A source image file.
* @param dst
@@ -278,23 +258,19 @@ public class WriteExifMetadataExample
* @throws ImageWriteException
*/
public void setExifGPSTag(File jpegImageFile, File dst) throws IOException,
- ImageReadException, ImageWriteException
- {
+ ImageReadException, ImageWriteException {
OutputStream os = null;
- try
- {
+ try {
TiffOutputSet outputSet = null;
// note that metadata might be null if no metadata is found.
IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
- if (null != jpegMetadata)
- {
+ if (null != jpegMetadata) {
// note that exif might be null if no Exif metadata is found.
TiffImageMetadata exif = jpegMetadata.getExif();
- if (null != exif)
- {
+ if (null != exif) {
// TiffImageMetadata class is immutable (read-only).
// TiffOutputSet class represents the Exif data to write.
//
@@ -332,14 +308,11 @@ public class WriteExifMetadataExample
os.close();
os = null;
- } finally
- {
+ } finally {
if (os != null)
- try
- {
+ try {
os.close();
- } catch (IOException e)
- {
+ } catch (IOException e) {
}
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java Sat May 26 21:19:03 2012
@@ -26,27 +26,22 @@ import org.apache.commons.imaging.ImageR
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImagingTest;
-public abstract class BmpBaseTest extends ImagingTest
-{
+public abstract class BmpBaseTest extends ImagingTest {
private static boolean isBmp(File file) throws IOException,
- ImageReadException
- {
+ ImageReadException {
ImageFormat format = Imaging.guessFormat(file);
return format == ImageFormat.IMAGE_FORMAT_BMP;
}
private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
- public boolean accept(File file) throws IOException, ImageReadException
- {
+ public boolean accept(File file) throws IOException, ImageReadException {
return isBmp(file);
}
};
- protected List getBmpImages() throws IOException, ImageReadException
- {
+ protected List getBmpImages() throws IOException, ImageReadException {
return getTestImages(IMAGE_FILTER);
}
-
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java Sat May 26 21:19:03 2012
@@ -28,16 +28,13 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.common.IImageMetadata;
import org.apache.commons.imaging.util.Debug;
-public class BmpReadTest extends BmpBaseTest
-{
+public class BmpReadTest extends BmpBaseTest {
- public void test() throws Exception
- {
+ public void test() throws Exception {
Debug.debug("start");
List images = getBmpImages();
- for (int i = 0; i < images.size(); i++)
- {
+ for (int i = 0; i < images.size(); i++) {
if (i % 10 == 0)
Debug.purgeMemory();
@@ -48,7 +45,7 @@ public class BmpReadTest extends BmpBase
// assertNotNull(metadata);
Map params = new HashMap();
-// params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
+ // params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
assertNotNull(imageInfo);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpRoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpRoundtripTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpRoundtripTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/bmp/BmpRoundtripTest.java Sat May 26 21:19:03 2012
@@ -31,11 +31,9 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.util.Debug;
import org.apache.commons.imaging.util.IoUtils;
-public class BmpRoundtripTest extends BmpBaseTest
-{
+public class BmpRoundtripTest extends BmpBaseTest {
- private int[][] getSimpleRawData(int width, int height, int value)
- {
+ private int[][] getSimpleRawData(int width, int height, int value) {
int[][] result = new int[height][width];
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
@@ -43,12 +41,10 @@ public class BmpRoundtripTest extends Bm
return result;
}
- private int[][] getAscendingRawData(int width, int height)
- {
+ private int[][] getAscendingRawData(int width, int height) {
int[][] result = new int[height][width];
for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
+ for (int x = 0; x < width; x++) {
int alpha = (x + y) % 256;
int value = (x + y) % 256;
int argb = (0xff & alpha) << 24 | (0xff & value) << 16
@@ -59,87 +55,73 @@ public class BmpRoundtripTest extends Bm
return result;
}
- private int[][] randomRawData(int width, int height)
- {
+ private int[][] randomRawData(int width, int height) {
Random random = new Random();
int[][] result = new int[height][width];
for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
+ for (int x = 0; x < width; x++) {
int argb = random.nextInt();
result[y][x] = argb;
}
return result;
}
- public void testSmallBlackPixels() throws Exception
- {
- int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
- writeAndReadImageData(smallBlackPixels);
- }
+ public void testSmallBlackPixels() throws Exception {
+ int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
+ writeAndReadImageData(smallBlackPixels);
+ }
- public void testSingleBlackPixel() throws Exception
- {
+ public void testSingleBlackPixel() throws Exception {
int[][] singleBlackPixel = getSimpleRawData(1, 1, 0);
writeAndReadImageData(singleBlackPixel);
}
+ public void testSmallRedPixels() throws Exception {
+ int[][] smallRedPixels = getSimpleRawData(256, 256, 0xffff0000);
+ writeAndReadImageData(smallRedPixels);
+ }
- public void testSmallRedPixels() throws Exception
- {
- int[][] smallRedPixels = getSimpleRawData(256, 256, 0xffff0000);
- writeAndReadImageData(smallRedPixels);
- }
-
- public void testSingleRedPixel() throws Exception
- {
- int[][] singleRedPixel = getSimpleRawData(1, 1, 0xffff0000);
- writeAndReadImageData(singleRedPixel);
- }
-
- public void testSmallAscendingPixels() throws Exception
- {
- int[][] smallAscendingPixels = getAscendingRawData(256, 256);
- writeAndReadImageData(smallAscendingPixels);
- }
-
- public void testSmallRandomPixels() throws Exception
- {
- int[][] smallRandomPixels = randomRawData(256, 256);
- writeAndReadImageData(smallRandomPixels);
- }
+ public void testSingleRedPixel() throws Exception {
+ int[][] singleRedPixel = getSimpleRawData(1, 1, 0xffff0000);
+ writeAndReadImageData(singleRedPixel);
+ }
- private BufferedImage imageDataToBufferedImage(int[][] rawData)
- {
+ public void testSmallAscendingPixels() throws Exception {
+ int[][] smallAscendingPixels = getAscendingRawData(256, 256);
+ writeAndReadImageData(smallAscendingPixels);
+ }
+
+ public void testSmallRandomPixels() throws Exception {
+ int[][] smallRandomPixels = randomRawData(256, 256);
+ writeAndReadImageData(smallRandomPixels);
+ }
+
+ private BufferedImage imageDataToBufferedImage(int[][] rawData) {
int width = rawData[0].length;
int height = rawData.length;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
+ for (int x = 0; x < width; x++) {
image.setRGB(x, y, rawData[y][x]);
}
return image;
}
- private int[][] bufferedImageToImageData(BufferedImage image)
- {
+ private int[][] bufferedImageToImageData(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
int[][] result = new int[height][width];
for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
+ for (int x = 0; x < width; x++) {
result[y][x] = image.getRGB(x, y);
}
return result;
}
private void writeAndReadImageData(int[][] rawData) throws IOException,
- ImageReadException, ImageWriteException
- {
+ ImageReadException, ImageWriteException {
BufferedImage srcImage = imageDataToBufferedImage(rawData);
Map writeParams = new HashMap();
@@ -166,25 +148,21 @@ public class BmpRoundtripTest extends Bm
compare(rawData, dstData);
}
- private void compare(int[][] a, int[][] b)
- {
+ private void compare(int[][] a, int[][] b) {
assertNotNull(a);
assertNotNull(b);
assertTrue(a.length == b.length);
- for (int y = 0; y < a.length; y++)
- {
+ for (int y = 0; y < a.length; y++) {
assertTrue(a[y].length == b[y].length);
// make sure row lengths consistent.
assertTrue(a[0].length == b[y].length);
- for (int x = 0; x < a[y].length; x++)
- {
+ for (int x = 0; x < a[y].length; x++) {
// ignore alpha channel - BMP has no transparency.
int rgbA = 0xffffff & a[y][x];
int rgbB = 0xffffff & b[y][x];
- if (rgbA != rgbB)
- {
+ if (rgbA != rgbB) {
Debug.debug("x: " + x + ", y: " + y + ", rgbA: " + rgbA
+ " (0x" + Integer.toHexString(rgbA) + ")"
+ ", rgbB: " + rgbB + " (0x"
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java Sat May 26 21:19:03 2012
@@ -26,24 +26,21 @@ import org.apache.commons.imaging.ImageR
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImagingTest;
-public abstract class DcxBaseTest extends ImagingTest
-{
+public abstract class DcxBaseTest extends ImagingTest {
- private static boolean isDcx(File file) throws IOException, ImageReadException
- {
+ private static boolean isDcx(File file) throws IOException,
+ ImageReadException {
ImageFormat format = Imaging.guessFormat(file);
return format == ImageFormat.IMAGE_FORMAT_DCX;
}
private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
- public boolean accept(File file) throws IOException, ImageReadException
- {
+ public boolean accept(File file) throws IOException, ImageReadException {
return isDcx(file);
}
};
- protected List getDcxImages() throws IOException, ImageReadException
- {
+ protected List getDcxImages() throws IOException, ImageReadException {
return getTestImages(IMAGE_FILTER);
}
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java Sat May 26 21:19:03 2012
@@ -28,16 +28,13 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.common.IImageMetadata;
import org.apache.commons.imaging.util.Debug;
-public class DcxReadTest extends DcxBaseTest
-{
+public class DcxReadTest extends DcxBaseTest {
- public void test() throws Exception
- {
+ public void test() throws Exception {
Debug.debug("start");
List images = getDcxImages();
- for (int i = 0; i < images.size(); i++)
- {
+ for (int i = 0; i < images.size(); i++) {
if (i % 10 == 0)
Debug.purgeMemory();
@@ -49,7 +46,7 @@ public class DcxReadTest extends DcxBase
Map params = new HashMap();
ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
- //assertNotNull(imageInfo);
+ // assertNotNull(imageInfo);
BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java Sat May 26 21:19:03 2012
@@ -26,25 +26,21 @@ import org.apache.commons.imaging.ImageR
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImagingTest;
-public abstract class GifBaseTest extends ImagingTest
-{
+public abstract class GifBaseTest extends ImagingTest {
private static boolean isGif(File file) throws IOException,
- ImageReadException
- {
+ ImageReadException {
ImageFormat format = Imaging.guessFormat(file);
return format == ImageFormat.IMAGE_FORMAT_GIF;
}
private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
- public boolean accept(File file) throws IOException, ImageReadException
- {
+ public boolean accept(File file) throws IOException, ImageReadException {
return isGif(file);
}
};
- protected List getGifImages() throws IOException, ImageReadException
- {
+ protected List getGifImages() throws IOException, ImageReadException {
return getTestImages(IMAGE_FILTER);
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java Sat May 26 21:19:03 2012
@@ -26,16 +26,13 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.common.IImageMetadata;
import org.apache.commons.imaging.util.Debug;
-public class GifReadTest extends GifBaseTest
-{
+public class GifReadTest extends GifBaseTest {
- public void test() throws Exception
- {
+ public void test() throws Exception {
Debug.debug("start");
List images = getGifImages();
- for (int i = 0; i < images.size(); i++)
- {
+ for (int i = 0; i < images.size(); i++) {
if (i % 10 == 0)
Debug.purgeMemory();
@@ -43,7 +40,7 @@ public class GifReadTest extends GifBase
Debug.debug("imageFile", imageFile);
IImageMetadata metadata = Imaging.getMetadata(imageFile);
-// assertNotNull(metadata);
+ // assertNotNull(metadata);
ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
assertNotNull(imageInfo);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java Sat May 26 21:19:03 2012
@@ -26,24 +26,21 @@ import org.apache.commons.imaging.ImageR
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImagingTest;
-public abstract class IcnsBaseTest extends ImagingTest
-{
+public abstract class IcnsBaseTest extends ImagingTest {
- private static boolean isIcns(File file) throws IOException, ImageReadException
- {
+ private static boolean isIcns(File file) throws IOException,
+ ImageReadException {
ImageFormat format = Imaging.guessFormat(file);
return format == ImageFormat.IMAGE_FORMAT_ICNS;
}
private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
- public boolean accept(File file) throws IOException, ImageReadException
- {
+ public boolean accept(File file) throws IOException, ImageReadException {
return isIcns(file);
}
};
- protected List getIcnsImages() throws IOException, ImageReadException
- {
+ protected List getIcnsImages() throws IOException, ImageReadException {
return getTestImages(IMAGE_FILTER);
}
}
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java Sat May 26 21:19:03 2012
@@ -28,16 +28,13 @@ import org.apache.commons.imaging.Imagin
import org.apache.commons.imaging.common.IImageMetadata;
import org.apache.commons.imaging.util.Debug;
-public class IcnsReadTest extends IcnsBaseTest
-{
+public class IcnsReadTest extends IcnsBaseTest {
- public void test() throws Exception
- {
+ public void test() throws Exception {
Debug.debug("start");
List images = getIcnsImages();
- for (int i = 0; i < images.size(); i++)
- {
+ for (int i = 0; i < images.size(); i++) {
if (i % 10 == 0)
Debug.purgeMemory();