New code style. No functional changes.

This commit is contained in:
Harald Kuhr 2011-02-17 21:42:36 +01:00
parent dda46b0ab9
commit f1a4a79003
6 changed files with 74 additions and 74 deletions

View File

@ -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<ImageTypeSpecifier> getImageTypes(final int pIndex) throws IOException {
public Iterator<ImageTypeSpecifier> 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<ImageTypeSpecifier> types = new ArrayList<ImageTypeSpecifier>();
@ -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<PSDThumbnail> getThumbnailResources(final int pIndex) throws IOException {
checkBounds(pIndex);
private List<PSDThumbnail> 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<PSDThumbnail> thumbnails = getThumbnailResources(pIndex);
public int getNumThumbnails(final int imageIndex) throws IOException {
List<PSDThumbnail> thumbnails = getThumbnailResources(imageIndex);
return thumbnails == null ? 0 : thumbnails.size();
}
private PSDThumbnail getThumbnailResource(final int pImageIndex, final int pThumbnailIndex) throws IOException {
List<PSDThumbnail> thumbnails = getThumbnailResources(pImageIndex);
private PSDThumbnail getThumbnailResource(final int imageIndex, final int thumbnailIndex) throws IOException {
List<PSDThumbnail> 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...

View File

@ -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[]{

View File

@ -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();
}
}

View File

@ -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<Entry> pFilter) {
FilterIterator<Entry> pEntries = new FilterIterator<Entry>(pDirectory.iterator(), pFilter);
private void appendTextEntriesFlat(final IIOMetadataNode node, final Directory directory, final FilterIterator.Filter<Entry> filter) {
FilterIterator<Entry> pEntries = new FilterIterator<Entry>(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;
}
<T extends PSDImageResource> Iterator<T> getResources(final Class<T> pResourceType) {
<T extends PSDImageResource> Iterator<T> getResources(final Class<T> resourceType) {
// NOTE: The cast here is wrong, strictly speaking, but it does not matter...
@SuppressWarnings({"unchecked"})
Iterator<T> iterator = (Iterator<T>) imageResources.iterator();
return new FilterIterator<T>(iterator, new FilterIterator.Filter<T>() {
public boolean accept(final T pElement) {
return pResourceType.isInstance(pElement);
return resourceType.isInstance(pElement);
}
});
}
Iterator<PSDImageResource> getResources(final int... pResourceTypes) {
Iterator<PSDImageResource> getResources(final int... resourceTypes) {
Iterator<PSDImageResource> iterator = imageResources.iterator();
return new FilterIterator<PSDImageResource>(iterator, new FilterIterator.Filter<PSDImageResource>() {
public boolean accept(final PSDImageResource pResource) {
for (int type : pResourceTypes) {
for (int type : resourceTypes) {
if (type == pResource.id) {
return true;
}

View File

@ -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
}

View File

@ -21,7 +21,7 @@ import java.io.IOException;
*/
public class PSDImageReaderTestCase extends ImageReaderAbstractTestCase<PSDImageReader> {
static ImageReaderSpi sProvider = new PSDImageReaderSpi();
static ImageReaderSpi provider = new PSDImageReaderSpi();
protected List<TestData> getTestData() {
return Arrays.asList(
@ -49,12 +49,12 @@ public class PSDImageReaderTestCase extends ImageReaderAbstractTestCase<PSDImage
}
protected ImageReaderSpi createProvider() {
return sProvider;
return provider;
}
@Override
protected PSDImageReader createReader() {
return new PSDImageReader(sProvider);
return new PSDImageReader(provider);
}
protected Class<PSDImageReader> getReaderClass() {