Coverage Report - org.webslinger.ext.image.AbstractSizingTransformerFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractSizingTransformerFactory
0%
0/8
0%
0/1
1.25
AbstractSizingTransformerFactory$1
0%
0/4
N/A
1.25
AbstractSizingTransformerFactory$2
0%
0/4
N/A
1.25
 
 1  
 package org.webslinger.ext.image;
 2  
 
 3  
 import java.awt.Rectangle;
 4  
 import java.io.File;
 5  
 import java.io.IOException;
 6  
 
 7  
 import org.apache.commons.vfs.FileObject;
 8  
 
 9  0
 public abstract class AbstractSizingTransformerFactory implements ImageTransformerFactory {
 10  
     public Rectangle getKey(ImageDescriptor image) throws IOException {
 11  0
         return getSize(image);
 12  
     }
 13  
 
 14  
     public boolean isEnabled(ImageDescriptor image) throws IOException {
 15  0
         return true;
 16  
     }
 17  
 
 18  
     public ImageTransformer getTransformer(final ImageDescriptor image) throws IOException {
 19  0
         final Rectangle size = getSize(image);
 20  0
         if (size == null) {
 21  0
             return new ImageTransformer() {
 22  
                 public boolean isEnabled() throws IOException {
 23  0
                     return false;
 24  
                 }
 25  
 
 26  
                 public Rectangle transform(File file, Rectangle dimensions) throws InterruptedException, IOException {
 27  0
                     throw new InternalError();
 28  
                 }
 29  
 
 30  
                 public String toString() {
 31  0
                     return "";
 32  
                 }
 33  
             };
 34  
         }
 35  0
         return new ImageTransformer() {
 36  
             public boolean isEnabled() throws IOException {
 37  0
                 return true;
 38  
             }
 39  
 
 40  
             public Rectangle transform(File file, Rectangle dimensions) throws InterruptedException, IOException {
 41  0
                 return AbstractSizingTransformerFactory.this.transform(image, file, size, dimensions);
 42  
             }
 43  
 
 44  
             public String toString() {
 45  0
                 return "" + ((int) size.getWidth()) + '-' + ((int) size.getHeight());
 46  
             }
 47  
         };
 48  
     }
 49  
 
 50  
     public Rectangle transform(ImageDescriptor image, File file, Rectangle size, Rectangle dimensions) throws InterruptedException, IOException {
 51  0
         return transform(image, file, (int) size.getWidth(), (int) size.getHeight());
 52  
     }
 53  
 
 54  
     protected abstract Rectangle transform(ImageDescriptor image, File file, int width, int height) throws InterruptedException, IOException;
 55  
     protected abstract Rectangle getSize(ImageDescriptor image) throws IOException;
 56  
 }