From f1a4a79003acb0b2630effe65379251b37a1b0c8 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Thu, 17 Feb 2011 21:42:36 +0100 Subject: [PATCH] New code style. No functional changes. --- .../imageio/plugins/psd/PSDImageReader.java | 78 +++++++++---------- .../plugins/psd/PSDImageReaderSpi.java | 6 +- .../imageio/plugins/psd/PSDImageResource.java | 20 ++--- .../imageio/plugins/psd/PSDMetadata.java | 36 ++++----- .../plugins/psd/PSDMetadataFormat.java | 2 +- .../plugins/psd/PSDImageReaderTestCase.java | 6 +- 6 files changed, 74 insertions(+), 74 deletions(-) diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java index 22e531d1..d7aa0087 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java @@ -76,8 +76,8 @@ public class PSDImageReader extends ImageReaderBase { private ICC_ColorSpace colorSpace; protected PSDMetadata metadata; - protected PSDImageReader(final ImageReaderSpi pOriginatingProvider) { - super(pOriginatingProvider); + protected PSDImageReader(final ImageReaderSpi originatingProvider) { + super(originatingProvider); } protected void resetMembers() { @@ -86,25 +86,25 @@ public class PSDImageReader extends ImageReaderBase { colorSpace = null; } - public int getWidth(final int pIndex) throws IOException { - checkBounds(pIndex); + public int getWidth(final int imageIndex) throws IOException { + checkBounds(imageIndex); readHeader(); return header.width; } - public int getHeight(final int pIndex) throws IOException { - checkBounds(pIndex); + public int getHeight(final int imageIndex) throws IOException { + checkBounds(imageIndex); readHeader(); return header.height; } @Override - public ImageTypeSpecifier getRawImageType(final int pIndex) throws IOException { - return getRawImageTypeInternal(pIndex); + public ImageTypeSpecifier getRawImageType(final int imageIndex) throws IOException { + return getRawImageTypeInternal(imageIndex); } - private ImageTypeSpecifier getRawImageTypeInternal(final int pIndex) throws IOException { - checkBounds(pIndex); + private ImageTypeSpecifier getRawImageTypeInternal(final int imageIndex) throws IOException { + checkBounds(imageIndex); readHeader(); ColorSpace cs; @@ -203,12 +203,12 @@ public class PSDImageReader extends ImageReaderBase { } } - public Iterator getImageTypes(final int pIndex) throws IOException { + public Iterator getImageTypes(final int imageIndex) throws IOException { // TODO: Check out the custom ImageTypeIterator and ImageTypeProducer used in the Sun provided JPEGImageReader // Could use similar concept to create lazily-created ImageTypeSpecifiers (util candidate, based on FilterIterator?) // Get the raw type. Will fail for unsupported types - ImageTypeSpecifier rawType = getRawImageTypeInternal(pIndex); + ImageTypeSpecifier rawType = getRawImageTypeInternal(imageIndex); ColorSpace cs = rawType.getColorModel().getColorSpace(); List types = new ArrayList(); @@ -295,21 +295,21 @@ public class PSDImageReader extends ImageReaderBase { return colorSpace; } - public BufferedImage read(final int pIndex, final ImageReadParam pParam) throws IOException { - checkBounds(pIndex); + public BufferedImage read(final int imageIndex, final ImageReadParam param) throws IOException { + checkBounds(imageIndex); readHeader(); readImageResources(false); readLayerAndMaskInfo(false); - BufferedImage image = getDestination(pParam, getImageTypes(pIndex), header.width, header.height); - ImageTypeSpecifier rawType = getRawImageType(pIndex); - checkReadParamBandSettings(pParam, rawType.getNumBands(), image.getSampleModel().getNumBands()); + BufferedImage image = getDestination(param, getImageTypes(imageIndex), header.width, header.height); + ImageTypeSpecifier rawType = getRawImageType(imageIndex); + checkReadParamBandSettings(param, rawType.getNumBands(), image.getSampleModel().getNumBands()); final Rectangle source = new Rectangle(); final Rectangle dest = new Rectangle(); - computeRegions(pParam, header.width, header.height, image, source, dest); + computeRegions(param, header.width, header.height, image, source, dest); /* NOTE: It seems safe to just leave this out for now. The only thing we need is to support sub sampling. @@ -329,8 +329,8 @@ public class PSDImageReader extends ImageReaderBase { // TODO: Banding... - ImageTypeSpecifier spec = getRawImageType(pIndex); - BufferedImage temp = spec.createBufferedImage(getWidth(pIndex), 1); + ImageTypeSpecifier spec = getRawImageType(imageIndex); + BufferedImage temp = spec.createBufferedImage(getWidth(imageIndex), 1); temp.getRaster(); if (...) @@ -341,15 +341,15 @@ public class PSDImageReader extends ImageReaderBase { final int xSub; final int ySub; - if (pParam == null) { + if (param == null) { xSub = ySub = 1; } else { - xSub = pParam.getSourceXSubsampling(); - ySub = pParam.getSourceYSubsampling(); + xSub = param.getSourceXSubsampling(); + ySub = param.getSourceYSubsampling(); } - processImageStarted(pIndex); + processImageStarted(imageIndex); int[] byteCounts = null; int compression = imageInput.readShort(); @@ -1028,8 +1028,8 @@ public class PSDImageReader extends ImageReaderBase { return true; } - private List getThumbnailResources(final int pIndex) throws IOException { - checkBounds(pIndex); + private List getThumbnailResources(final int imageIndex) throws IOException { + checkBounds(imageIndex); readHeader(); @@ -1056,40 +1056,40 @@ public class PSDImageReader extends ImageReaderBase { } @Override - public int getNumThumbnails(final int pIndex) throws IOException { - List thumbnails = getThumbnailResources(pIndex); + public int getNumThumbnails(final int imageIndex) throws IOException { + List thumbnails = getThumbnailResources(imageIndex); return thumbnails == null ? 0 : thumbnails.size(); } - private PSDThumbnail getThumbnailResource(final int pImageIndex, final int pThumbnailIndex) throws IOException { - List thumbnails = getThumbnailResources(pImageIndex); + private PSDThumbnail getThumbnailResource(final int imageIndex, final int thumbnailIndex) throws IOException { + List thumbnails = getThumbnailResources(imageIndex); if (thumbnails == null) { - throw new IndexOutOfBoundsException(String.format("thumbnail index %d > 0", pThumbnailIndex)); + throw new IndexOutOfBoundsException(String.format("thumbnail index %d > 0", thumbnailIndex)); } - return thumbnails.get(pThumbnailIndex); + return thumbnails.get(thumbnailIndex); } @Override - public int getThumbnailWidth(final int pImageIndex, final int pThumbnailIndex) throws IOException { - return getThumbnailResource(pImageIndex, pThumbnailIndex).getWidth(); + public int getThumbnailWidth(final int imageIndex, final int thumbnailIndex) throws IOException { + return getThumbnailResource(imageIndex, thumbnailIndex).getWidth(); } @Override - public int getThumbnailHeight(final int pImageIndex, final int pThumbnailIndex) throws IOException { - return getThumbnailResource(pImageIndex, pThumbnailIndex).getHeight(); + public int getThumbnailHeight(final int imageIndex, final int thumbnailIndex) throws IOException { + return getThumbnailResource(imageIndex, thumbnailIndex).getHeight(); } @Override - public BufferedImage readThumbnail(final int pImageIndex, final int pThumbnailIndex) throws IOException { + public BufferedImage readThumbnail(final int imageIndex, final int thumbnailIndex) throws IOException { // TODO: Thumbnail progress listeners... - PSDThumbnail thumbnail = getThumbnailResource(pImageIndex, pThumbnailIndex); + PSDThumbnail thumbnail = getThumbnailResource(imageIndex, thumbnailIndex); // TODO: Defer decoding // TODO: It's possible to attach listeners to the ImageIO reader delegate... But do we really care? - processThumbnailStarted(pImageIndex, pThumbnailIndex); + processThumbnailStarted(imageIndex, thumbnailIndex); processThumbnailComplete(); // TODO: Returning a cached mutable thumbnail is not really safe... diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderSpi.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderSpi.java index 0b63af8d..754b355e 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderSpi.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderSpi.java @@ -53,10 +53,10 @@ public class PSDImageReaderSpi extends ImageReaderSpi { this(IIOUtil.getProviderInfo(PSDImageReaderSpi.class)); } - private PSDImageReaderSpi(final ProviderInfo pProviderInfo) { + private PSDImageReaderSpi(final ProviderInfo providerInfo) { super( - pProviderInfo.getVendorName(), - pProviderInfo.getVersion(), + providerInfo.getVendorName(), + providerInfo.getVersion(), new String[]{"psd", "PSD"}, new String[]{"psd"}, new String[]{ diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java index 554e85c0..3ea653f1 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java @@ -51,30 +51,30 @@ public class PSDImageResource { final String name; final long size; - PSDImageResource(final short pId, final ImageInputStream pInput) throws IOException { - id = pId; + PSDImageResource(final short resourceId, final ImageInputStream input) throws IOException { + id = resourceId; - name = PSDUtil.readPascalString(pInput); + name = PSDUtil.readPascalString(input); // Skip pad int nameSize = name.length() + 1; if (nameSize % 2 != 0) { - pInput.readByte(); + input.readByte(); } - size = pInput.readUnsignedInt(); - long startPos = pInput.getStreamPosition(); + size = input.readUnsignedInt(); + long startPos = input.getStreamPosition(); - readData(new SubImageInputStream(pInput, size)); + readData(new SubImageInputStream(input, size)); // NOTE: This should never happen, however it's safer to keep it here to - if (pInput.getStreamPosition() != startPos + size) { - pInput.seek(startPos + size); + if (input.getStreamPosition() != startPos + size) { + input.seek(startPos + size); } // Data is even-padded (word aligned) if (size % 2 != 0) { - pInput.read(); + input.read(); } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java index 425016c4..5ff0d4c9 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java @@ -304,8 +304,8 @@ public final class PSDMetadata extends AbstractMetadata { return resource; } - private void appendEntries(final IIOMetadataNode pNode, final String pType, final Directory pDirectory) { - for (Entry entry : pDirectory) { + private void appendEntries(final IIOMetadataNode node, final String type, final Directory directory) { + for (Entry entry : directory) { Object tagId = entry.getIdentifier(); IIOMetadataNode tag = new IIOMetadataNode("Entry"); @@ -316,13 +316,13 @@ public final class PSDMetadata extends AbstractMetadata { tag.setAttribute("field", String.format("%s", field)); } else { - if ("IPTC".equals(pType)) { + if ("IPTC".equals(type)) { tag.setAttribute("field", String.format("%s:%s", (Integer) tagId >> 8, (Integer) tagId & 0xff)); } } if (entry.getValue() instanceof Directory) { - appendEntries(tag, pType, (Directory) entry.getValue()); + appendEntries(tag, type, (Directory) entry.getValue()); tag.setAttribute("type", "Directory"); } else { @@ -330,7 +330,7 @@ public final class PSDMetadata extends AbstractMetadata { tag.setAttribute("type", entry.getTypeName()); } - pNode.appendChild(tag); + node.appendChild(tag); } } @@ -426,9 +426,9 @@ public final class PSDMetadata extends AbstractMetadata { return node; } - private String getMultiChannelCS(short pChannels) { - if (pChannels < 16) { - return String.format("%xCLR", pChannels); + private String getMultiChannelCS(short channels) { + if (channels < 16) { + return String.format("%xCLR", channels); } throw new UnsupportedOperationException("Standard meta data format does not support more than 15 channels"); @@ -563,9 +563,9 @@ public final class PSDMetadata extends AbstractMetadata { return dimensionNode; } - private static float asMM(final short pUnit, final float pResolution) { + private static float asMM(final short unit, final float resolution) { // Unit: 1 -> pixels per inch, 2 -> pixels pr cm - return (pUnit == 1 ? 25.4f : 10) / pResolution; + return (unit == 1 ? 25.4f : 10) / resolution; } @Override @@ -670,13 +670,13 @@ public final class PSDMetadata extends AbstractMetadata { return text; } - private void appendTextEntriesFlat(final IIOMetadataNode pNode, final Directory pDirectory, final FilterIterator.Filter pFilter) { - FilterIterator pEntries = new FilterIterator(pDirectory.iterator(), pFilter); + private void appendTextEntriesFlat(final IIOMetadataNode node, final Directory directory, final FilterIterator.Filter filter) { + FilterIterator pEntries = new FilterIterator(directory.iterator(), filter); while (pEntries.hasNext()) { Entry entry = pEntries.next(); if (entry.getValue() instanceof Directory) { - appendTextEntriesFlat(pNode, (Directory) entry.getValue(), pFilter); + appendTextEntriesFlat(node, (Directory) entry.getValue(), filter); } else if (entry.getValue() instanceof String) { IIOMetadataNode tag = new IIOMetadataNode("TextEntry"); @@ -691,7 +691,7 @@ public final class PSDMetadata extends AbstractMetadata { } tag.setAttribute("value", entry.getValueAsString()); - pNode.appendChild(tag); + node.appendChild(tag); } } } @@ -718,24 +718,24 @@ public final class PSDMetadata extends AbstractMetadata { header.mode == PSD.COLOR_MODE_CMYK & header.channels >= 5; } - Iterator getResources(final Class pResourceType) { + Iterator getResources(final Class resourceType) { // NOTE: The cast here is wrong, strictly speaking, but it does not matter... @SuppressWarnings({"unchecked"}) Iterator iterator = (Iterator) imageResources.iterator(); return new FilterIterator(iterator, new FilterIterator.Filter() { public boolean accept(final T pElement) { - return pResourceType.isInstance(pElement); + return resourceType.isInstance(pElement); } }); } - Iterator getResources(final int... pResourceTypes) { + Iterator getResources(final int... resourceTypes) { Iterator iterator = imageResources.iterator(); return new FilterIterator(iterator, new FilterIterator.Filter() { public boolean accept(final PSDImageResource pResource) { - for (int type : pResourceTypes) { + for (int type : resourceTypes) { if (type == pResource.id) { return true; } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadataFormat.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadataFormat.java index b6a78cb6..4d19eec9 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadataFormat.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadataFormat.java @@ -195,7 +195,7 @@ public final class PSDMetadataFormat extends IIOMetadataFormatImpl { @Override - public boolean canNodeAppear(final String pElementName, final ImageTypeSpecifier pImageType) { + public boolean canNodeAppear(final String elementName, final ImageTypeSpecifier imageType) { // TODO: PSDColorData and PaletteEntry only for indexed color model throw new UnsupportedOperationException("Method canNodeAppear not implemented"); // TODO: Implement } diff --git a/imageio/imageio-psd/src/test/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderTestCase.java b/imageio/imageio-psd/src/test/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderTestCase.java index 8d65764a..1fe1c196 100644 --- a/imageio/imageio-psd/src/test/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderTestCase.java +++ b/imageio/imageio-psd/src/test/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReaderTestCase.java @@ -21,7 +21,7 @@ import java.io.IOException; */ public class PSDImageReaderTestCase extends ImageReaderAbstractTestCase { - static ImageReaderSpi sProvider = new PSDImageReaderSpi(); + static ImageReaderSpi provider = new PSDImageReaderSpi(); protected List getTestData() { return Arrays.asList( @@ -49,12 +49,12 @@ public class PSDImageReaderTestCase extends ImageReaderAbstractTestCase getReaderClass() {