Merged java-1.5 branch to default.
1.1 --- a/SConstruct Mon Aug 03 23:22:22 2009 +0200
1.2 +++ b/SConstruct Sat Aug 08 23:06:58 2009 +0200
1.3 @@ -6,7 +6,7 @@
1.4
1.5 # Note that setting the source version does not provide backwards compatibility,
1.6 # that would require -target, -bootclasspath and -extdir parameters.
1.7 -java_source_version = '1.3'
1.8 +java_source_version = '1.5'
1.9 env['JAVAVERSION'] = java_source_version
1.10 env['JAVACFLAGS'] = '-source ' + java_source_version
1.11
1.12 @@ -20,7 +20,7 @@
1.13 if os.environ.has_key('ECLIPSE_HOME'):
1.14 # try to use eclipse java compiler
1.15 java_env = env.Clone(tools=['eclipse_javac'])
1.16 - java_env['JAVACFLAGS'] = '-1.3 -warn:-serial -warn:-unusedPrivate'
1.17 + java_env['JAVACFLAGS'] = '-1.5 -warn:-serial -warn:-unusedPrivate'
1.18 else:
1.19 java_env = env
1.20
1.21 @@ -53,7 +53,7 @@
1.22 versioned_files = versioned_mercurial_files()
1.23
1.24 if versioned_files:
1.25 - VERSION = '0.14.3'
1.26 + VERSION = '0.15.0'
1.27 BUNDLENAME = 'java-imaging-utilities-' + VERSION
1.28 SUFFIXES = ['.zip', '.tar.gz', '.tar.bz2']
1.29
2.1 --- a/net/sourceforge/jiu/apps/ColorIndexer.java Mon Aug 03 23:22:22 2009 +0200
2.2 +++ b/net/sourceforge/jiu/apps/ColorIndexer.java Sat Aug 08 23:06:58 2009 +0200
2.3 @@ -2,6 +2,7 @@
2.4 * ColorIndexer
2.5 *
2.6 * Copyright (c) 2003 Marco Schmidt.
2.7 + * Copyright (c) 2009 Knut Arild Erstad.
2.8 * All rights reserved.
2.9 */
2.10 package net.sourceforge.jiu.apps;
2.11 @@ -16,6 +17,7 @@
2.12 import net.sourceforge.jiu.data.RGB24Image;
2.13 import net.sourceforge.jiu.data.RGBIndex;
2.14 import net.sourceforge.jiu.geometry.Resample;
2.15 +import net.sourceforge.jiu.geometry.Resample.FilterType;
2.16 import net.sourceforge.jiu.gui.awt.ToolkitLoader;
2.17 import net.sourceforge.jiu.ops.BatchProcessorOperation;
2.18 import net.sourceforge.jiu.ops.OperationFailedException;
2.19 @@ -31,16 +33,38 @@
2.20 private int contrastChange = 100;
2.21 private NumberFormat formatter = new DecimalFormat("#.##");
2.22
2.23 - public static final int BLACK = 0;
2.24 - public static final int RED = 4;
2.25 - public static final int GREEN = 2;
2.26 - public static final int BLUE = 1;
2.27 - public static final int YELLOW = 6;
2.28 - public static final int MAGENTA = 5;
2.29 - public static final int CYAN = 3;
2.30 - public static final int WHITE = 7;
2.31 - public static final String[] COLOR_NAMES =
2.32 - {"black", "blue", "green", "cyan", "red", "magenta", "yellow", "white"};
2.33 + /**
2.34 + * Enumerates the countable RGB colors.
2.35 + * The bits of the ordinal of each enum value is significant:
2.36 + * <ul>
2.37 + * <li>Bit 1 (0x1) represents blue.
2.38 + * <li>Bit 2 (0x2) represents green.
2.39 + * <li>Bit 3 (0x4) represents red.
2.40 + * </ul>
2.41 + */
2.42 + public enum Color
2.43 + {
2.44 + BLACK("black"), // 0
2.45 + BLUE("blue"), // 1
2.46 + GREEN("green"), // 2
2.47 + CYAN("cyan"), // 3 (B+G)
2.48 + RED("red"), // 4
2.49 + MAGENTA("magenta"), // 5 (B+R)
2.50 + YELLOW("yellow"), // 6 (G+R)
2.51 + WHITE("white"); // 7 (B+G+R)
2.52 +
2.53 + private String name;
2.54 +
2.55 + private Color(String name)
2.56 + {
2.57 + this.name = name;
2.58 + }
2.59 +
2.60 + public String getName()
2.61 + {
2.62 + return name;
2.63 + }
2.64 + }
2.65
2.66 public static void main(String[] args)
2.67 {
2.68 @@ -124,7 +148,7 @@
2.69 try
2.70 {
2.71 Resample res = new Resample();
2.72 - res.setFilter(Resample.FILTER_TYPE_LANCZOS3);
2.73 + res.setFilter(FilterType.LANCZOS3);
2.74 res.setInputImage(in);
2.75 float thumbRatio = 1.0f;
2.76 float imageRatio = (float)in.getWidth() / (float)in.getHeight();
2.77 @@ -210,7 +234,7 @@
2.78 {
2.79 continue;
2.80 }
2.81 - System.out.print(COLOR_NAMES[i] + " = " + formatter.format(rel) + ";");
2.82 + System.out.print(Color.values()[i].getName() + " = " + formatter.format(rel) + ";");
2.83 }
2.84 System.out.println();
2.85 }
3.1 --- a/net/sourceforge/jiu/apps/EditorState.java Mon Aug 03 23:22:22 2009 +0200
3.2 +++ b/net/sourceforge/jiu/apps/EditorState.java Sat Aug 08 23:06:58 2009 +0200
3.3 @@ -9,7 +9,7 @@
3.4
3.5 import java.io.IOException;
3.6 import java.util.Locale;
3.7 -import java.util.Vector;
3.8 +import java.util.ArrayList;
3.9 import net.sourceforge.jiu.data.PixelImage;
3.10 import net.sourceforge.jiu.ops.Operation;
3.11 import net.sourceforge.jiu.ops.ProgressListener;
3.12 @@ -48,42 +48,51 @@
3.13 public static final int ORIGINAL_SIZE_ZOOM_INDEX = 8;
3.14
3.15 /**
3.16 - * Integer constant for <em>nearest neighbor interpolation</em>.
3.17 - * A fast but ugly method.
3.18 + * Enumerates interpolation methods.
3.19 */
3.20 - public static final int INTERPOLATION_NEAREST_NEIGHBOR = 0;
3.21 + public enum Interpolation
3.22 + {
3.23 + /**
3.24 + * Nearest neighbor interpolation.
3.25 + * A fast but ugly method.
3.26 + */
3.27 + NEAREST_NEIGHBOR,
3.28 + /**
3.29 + * Bilinear neighbor interpolation.
3.30 + * A slow but nice method.
3.31 + */
3.32 + BILINEAR,
3.33 + /**
3.34 + * Bicubic interpolation.
3.35 + * A very slow method, but with the nicest output of the three supported interpolation types.
3.36 + */
3.37 + BICUBIC;
3.38 +
3.39 + /**
3.40 + * Returns the default interpolation type.
3.41 + * @return {@link #NEAREST_NEIGHBOR}
3.42 + */
3.43 + public static Interpolation getDefault()
3.44 + {
3.45 + return NEAREST_NEIGHBOR;
3.46 + }
3.47 + }
3.48
3.49 - /**
3.50 - * Integer constant for <em>bilinear neighbor interpolation</em>.
3.51 - * A slow but nice method.
3.52 - */
3.53 - public static final int INTERPOLATION_BILINEAR = 1;
3.54 -
3.55 - /**
3.56 - * Integer constant for <em>bicubic interpolation</em>.
3.57 - * A very slow method, but with the nicest output of the three supported interpolation types.
3.58 - */
3.59 - public static final int INTERPOLATION_BICUBIC = 2;
3.60 -
3.61 - /**
3.62 - * The default interpolation type, one of the three INTERPOLATION_xyz constants.
3.63 - */
3.64 - public static final int DEFAULT_INTERPOLATION = INTERPOLATION_NEAREST_NEIGHBOR;
3.65 private String currentDirectory;
3.66 private String fileName;
3.67 private PixelImage currentImage;
3.68 - private int interpolation;
3.69 + private Interpolation interpolation;
3.70 private Locale locale;
3.71 private int maxRedoImages;
3.72 private int maxUndoImages;
3.73 private boolean modified;
3.74 - private Vector progressListeners;
3.75 - private Vector redoImages;
3.76 - private Vector redoModified;
3.77 + private ArrayList<ProgressListener> progressListeners;
3.78 + private ArrayList<PixelImage> redoImages;
3.79 + private ArrayList<Boolean> redoModified;
3.80 private String startupImageName;
3.81 private Strings strings;
3.82 - private Vector undoImages;
3.83 - private Vector undoModified;
3.84 + private ArrayList<PixelImage> undoImages;
3.85 + private ArrayList<Boolean> undoModified;
3.86 private int zoomIndex = ORIGINAL_SIZE_ZOOM_INDEX;
3.87 private double zoomFactorX;
3.88 private double zoomFactorY;
3.89 @@ -97,16 +106,17 @@
3.90 {
3.91 locale = Locale.getDefault();
3.92 setStrings(null);
3.93 - progressListeners = new Vector();
3.94 + progressListeners = new ArrayList<ProgressListener>();
3.95 maxRedoImages = DEFAULT_MAX_REDO_IMAGES;
3.96 maxUndoImages = DEFAULT_MAX_UNDO_IMAGES;
3.97 - redoImages = new Vector(maxRedoImages);
3.98 - redoModified = new Vector(maxRedoImages);
3.99 - undoImages = new Vector(maxUndoImages);
3.100 - undoModified = new Vector(maxUndoImages);
3.101 + redoImages = new ArrayList<PixelImage>(maxRedoImages);
3.102 + redoModified = new ArrayList<Boolean>(maxRedoImages);
3.103 + undoImages = new ArrayList<PixelImage>(maxUndoImages);
3.104 + undoModified = new ArrayList<Boolean>(maxUndoImages);
3.105 zoomFactorX = 1.0;
3.106 zoomFactorY = 1.0;
3.107 zoomToFit = false;
3.108 + interpolation = Interpolation.getDefault();
3.109 }
3.110
3.111 private void addImageToRedo(PixelImage image, boolean modifiedState)
3.112 @@ -117,12 +127,12 @@
3.113 }
3.114 if (redoImages.size() == maxRedoImages)
3.115 {
3.116 - redoImages.setElementAt(null, 0);
3.117 - redoImages.removeElementAt(0);
3.118 - redoModified.removeElementAt(0);
3.119 + redoImages.set(0, null);
3.120 + redoImages.remove(0);
3.121 + redoModified.remove(0);
3.122 }
3.123 - redoImages.addElement(image);
3.124 - redoModified.addElement(new Boolean(modifiedState));
3.125 + redoImages.add(image);
3.126 + redoModified.add(modifiedState);
3.127 }
3.128
3.129 private void addImageToUndo(PixelImage image, boolean modifiedState)
3.130 @@ -133,12 +143,12 @@
3.131 }
3.132 if (undoImages.size() == maxUndoImages)
3.133 {
3.134 - undoImages.setElementAt(null, 0);
3.135 - undoImages.removeElementAt(0);
3.136 - undoModified.removeElementAt(0);
3.137 + undoImages.set(0, null);
3.138 + undoImages.remove(0);
3.139 + undoModified.remove(0);
3.140 }
3.141 - undoImages.addElement(image);
3.142 - undoModified.addElement(new Boolean(modifiedState));
3.143 + undoImages.add(image);
3.144 + undoModified.add(modifiedState);
3.145 }
3.146
3.147 /**
3.148 @@ -148,7 +158,7 @@
3.149 */
3.150 public void addProgressListener(ProgressListener pl)
3.151 {
3.152 - progressListeners.addElement(pl);
3.153 + progressListeners.add(pl);
3.154 }
3.155
3.156 /**
3.157 @@ -169,24 +179,14 @@
3.158
3.159 public void clearRedo()
3.160 {
3.161 - int index = 0;
3.162 - while (index < redoImages.size())
3.163 - {
3.164 - redoImages.setElementAt(null, index++);
3.165 - }
3.166 - redoImages.setSize(0);
3.167 - redoModified.setSize(0);
3.168 + redoImages.clear();
3.169 + redoModified.clear();
3.170 }
3.171
3.172 public void clearUndo()
3.173 {
3.174 - int index = 0;
3.175 - while (index < undoImages.size())
3.176 - {
3.177 - undoImages.setElementAt(null, index++);
3.178 - }
3.179 - undoImages.setSize(0);
3.180 - undoModified.setSize(0);
3.181 + undoImages.clear();
3.182 + undoModified.clear();
3.183 }
3.184
3.185 public void ensureStringsAvailable()
3.186 @@ -225,7 +225,7 @@
3.187 /**
3.188 * Returns the current interpolation type, one of the INTERPOLATION_xyz constants.
3.189 */
3.190 - public int getInterpolation()
3.191 + public Interpolation getInterpolation()
3.192 {
3.193 return interpolation;
3.194 }
3.195 @@ -250,7 +250,7 @@
3.196 /**
3.197 * Returns the internal list of progress listeners.
3.198 */
3.199 - public Vector getProgressListeners()
3.200 + public ArrayList<ProgressListener> getProgressListeners()
3.201 {
3.202 return progressListeners;
3.203 }
3.204 @@ -325,11 +325,8 @@
3.205 {
3.206 return;
3.207 }
3.208 - // cannot use Iterator because it's 1.2+
3.209 - int index = 0;
3.210 - while (index < progressListeners.size())
3.211 + for (ProgressListener pl: progressListeners)
3.212 {
3.213 - ProgressListener pl = (ProgressListener)progressListeners.elementAt(index++);
3.214 op.addProgressListener(pl);
3.215 }
3.216 }
3.217 @@ -371,11 +368,10 @@
3.218 }
3.219 addImageToUndo(currentImage, modified);
3.220 int redoIndex = redoImages.size() - 1;
3.221 - currentImage = (PixelImage)redoImages.elementAt(redoIndex);
3.222 - redoImages.setElementAt(null, redoIndex);
3.223 - redoImages.setSize(redoIndex);
3.224 - modified = ((Boolean)redoModified.elementAt(redoIndex)).booleanValue();
3.225 - redoModified.setSize(redoIndex);
3.226 + currentImage = redoImages.get(redoIndex);
3.227 + redoImages.remove(redoIndex);
3.228 + modified = redoModified.get(redoIndex);
3.229 + redoModified.remove(redoIndex);
3.230 }
3.231
3.232 public void resetZoomFactors()
3.233 @@ -428,11 +424,9 @@
3.234 * Sets a new interpolation type to be used for display.
3.235 * @param newInterpolation an int for the interpolation type, must be one of the INTERPOLATION_xyz constants
3.236 */
3.237 - public void setInterpolation(int newInterpolation)
3.238 + public void setInterpolation(Interpolation newInterpolation)
3.239 {
3.240 - if (newInterpolation == INTERPOLATION_NEAREST_NEIGHBOR ||
3.241 - newInterpolation == INTERPOLATION_BILINEAR ||
3.242 - newInterpolation == INTERPOLATION_BICUBIC)
3.243 + if (newInterpolation != null)
3.244 {
3.245 interpolation = newInterpolation;
3.246 }
3.247 @@ -504,11 +498,10 @@
3.248 }
3.249 addImageToRedo(currentImage, modified);
3.250 int undoIndex = undoImages.size() - 1;
3.251 - currentImage = (PixelImage)undoImages.elementAt(undoIndex);
3.252 - undoImages.setElementAt(null, undoIndex);
3.253 - undoImages.setSize(undoIndex);
3.254 - modified = ((Boolean)undoModified.elementAt(undoIndex)).booleanValue();
3.255 - undoModified.setSize(undoIndex);
3.256 + currentImage = undoImages.get(undoIndex);
3.257 + undoImages.remove(undoIndex);
3.258 + modified = undoModified.get(undoIndex);
3.259 + undoModified.remove(undoIndex);
3.260 }
3.261
3.262 /**
4.1 --- a/net/sourceforge/jiu/apps/ImageDescriptionCreator.java Mon Aug 03 23:22:22 2009 +0200
4.2 +++ b/net/sourceforge/jiu/apps/ImageDescriptionCreator.java Sat Aug 08 23:06:58 2009 +0200
4.3 @@ -66,7 +66,7 @@
4.4 */
4.5 public static String getDescription(PixelImage image, Locale locale, Strings strings)
4.6 {
4.7 - StringBuffer result = new StringBuffer();
4.8 + StringBuilder result = new StringBuilder();
4.9 result.append(strings.get(StringIndexConstants.IMAGE_TYPE));
4.10 result.append(": ");
4.11 result.append(strings.get(getImageType(image)));
5.1 --- a/net/sourceforge/jiu/apps/JiuBlur.java Mon Aug 03 23:22:22 2009 +0200
5.2 +++ b/net/sourceforge/jiu/apps/JiuBlur.java Sat Aug 08 23:06:58 2009 +0200
5.3 @@ -12,6 +12,7 @@
5.4 import net.sourceforge.jiu.color.adjustment.Contrast;
5.5 import net.sourceforge.jiu.data.PixelImage;
5.6 import net.sourceforge.jiu.filters.ConvolutionKernelFilter;
5.7 +import net.sourceforge.jiu.filters.ConvolutionKernelFilter.KernelType;
5.8 import net.sourceforge.jiu.gui.awt.ImageCreator;
5.9 import net.sourceforge.jiu.gui.awt.ToolkitLoader;
5.10
5.11 @@ -28,7 +29,7 @@
5.12 {
5.13 PixelImage image = ToolkitLoader.loadAsRgb24Image("resources/images/image1.jpg");
5.14 image = Contrast.adjust(image, 20);
5.15 - image = ConvolutionKernelFilter.filter(image, ConvolutionKernelFilter.TYPE_BLUR);
5.16 + image = ConvolutionKernelFilter.filter(image, KernelType.BLUR);
5.17 BufferedImage awtImage = ImageCreator.convertToAwtBufferedImage(image);
5.18 ImageIO.write(awtImage, "jpg", new File("out-image1.jpg"));
5.19 }
6.1 --- a/net/sourceforge/jiu/apps/JiuInfo.java Mon Aug 03 23:22:22 2009 +0200
6.2 +++ b/net/sourceforge/jiu/apps/JiuInfo.java Sat Aug 08 23:06:58 2009 +0200
6.3 @@ -17,7 +17,7 @@
6.4 /**
6.5 * Three int values for the JIU version, in order (major, minor, patch).
6.6 */
6.7 - int[] JIU_NUMERICAL_VERSION = {0, 14, 3};
6.8 + int[] JIU_NUMERICAL_VERSION = {0, 15, 0};
6.9
6.10 /**
6.11 * Version as String, created from {@link #JIU_NUMERICAL_VERSION}.
7.1 --- a/net/sourceforge/jiu/apps/StringLoader.java Mon Aug 03 23:22:22 2009 +0200
7.2 +++ b/net/sourceforge/jiu/apps/StringLoader.java Sat Aug 08 23:06:58 2009 +0200
7.3 @@ -11,7 +11,7 @@
7.4 import java.io.IOException;
7.5 import java.io.InputStream;
7.6 import java.io.InputStreamReader;
7.7 -import java.util.Vector;
7.8 +import java.util.ArrayList;
7.9
7.10 /**
7.11 * This class loads a {@link Strings} resource from a text file.
7.12 @@ -55,11 +55,11 @@
7.13 {
7.14 return null;
7.15 }
7.16 - Vector list = new Vector();
7.17 + ArrayList<String> list = new ArrayList<String>();
7.18 String line;
7.19 while ((line = in.readLine()) != null)
7.20 {
7.21 - list.addElement(line);
7.22 + list.add(line);
7.23 }
7.24 if (list.size() < 1)
7.25 {
7.26 @@ -68,7 +68,7 @@
7.27 String[] data = new String[list.size()];
7.28 for (int i = 0; i < list.size(); i++)
7.29 {
7.30 - data[i] = (String)list.elementAt(i);
7.31 + data[i] = list.get(i);
7.32 }
7.33 in.close();
7.34 return new Strings(langCode, data);
8.1 --- a/net/sourceforge/jiu/apps/Strings.java Mon Aug 03 23:22:22 2009 +0200
8.2 +++ b/net/sourceforge/jiu/apps/Strings.java Sat Aug 08 23:06:58 2009 +0200
8.3 @@ -7,7 +7,7 @@
8.4
8.5 package net.sourceforge.jiu.apps;
8.6
8.7 -import java.util.Hashtable;
8.8 +import java.util.HashMap;
8.9 import java.util.Locale;
8.10
8.11 /**
8.12 @@ -71,11 +71,11 @@
8.13 * A hashtable that maps from ISO 639 country codes to Integer
8.14 * objects with the corresponding LANG_xyz constant for that language.
8.15 */
8.16 - private static Hashtable isoToConstant;
8.17 + private static HashMap<String, Integer> isoToConstant;
8.18
8.19 static
8.20 {
8.21 - isoToConstant = new Hashtable(ISO_639_LANGUAGE_CODES.length);
8.22 + isoToConstant = new HashMap<String, Integer>(ISO_639_LANGUAGE_CODES.length);
8.23 for (int i = 0; i < ISO_639_LANGUAGE_CODES.length; i++)
8.24 {
8.25 isoToConstant.put(ISO_639_LANGUAGE_CODES[i], LANGUAGE_CONSTANTS[i]);
8.26 @@ -134,7 +134,7 @@
8.27 return null;
8.28 }
8.29 String code = iso639LanguageCode.toLowerCase();
8.30 - return (Integer)isoToConstant.get(code);
8.31 + return isoToConstant.get(code);
8.32 }
8.33
8.34 /**
9.1 --- a/net/sourceforge/jiu/apps/jiuconvert.java Mon Aug 03 23:22:22 2009 +0200
9.2 +++ b/net/sourceforge/jiu/apps/jiuconvert.java Sat Aug 08 23:06:58 2009 +0200
9.3 @@ -9,8 +9,8 @@
9.4
9.5 import java.io.File;
9.6 import java.io.IOException;
9.7 -import java.util.Hashtable;
9.8 -import java.util.Vector;
9.9 +import java.util.HashMap;
9.10 +import java.util.ArrayList;
9.11 import net.sourceforge.jiu.codecs.BMPCodec;
9.12 import net.sourceforge.jiu.codecs.CodecMode;
9.13 import net.sourceforge.jiu.codecs.ImageCodec;
9.14 @@ -33,7 +33,7 @@
9.15 static final int FORMAT_PNM = 1;
9.16 static final int FORMAT_PALM = 2;
9.17
9.18 - Vector inputFileNames = new Vector();
9.19 + ArrayList<String> inputFileNames = new ArrayList<String>();
9.20 File destinationDirectory;
9.21 int fileFormat;
9.22 boolean noAwtLoading;
9.23 @@ -150,7 +150,7 @@
9.24
9.25 class PrintHelpSwitch extends Switch
9.26 {
9.27 - static Vector switches;
9.28 + static ArrayList<Switch> switches;
9.29 String[] getValues() { return new String[] {"-H", "--help"}; }
9.30 String getDescription() { return "print help text to stdout and terminate"; }
9.31 int init(String[] args, int index, JiuConvertSettings settings)
9.32 @@ -159,7 +159,7 @@
9.33 System.out.println("");
9.34 for (int i = 0; i < switches.size(); i++)
9.35 {
9.36 - Switch sw = (Switch)switches.elementAt(i);
9.37 + Switch sw = switches.get(i);
9.38 System.out.print("\t");
9.39 String[] values = sw.getValues();
9.40 int chars = 0;
9.41 @@ -250,21 +250,21 @@
9.42 {
9.43 }
9.44
9.45 - private static Vector createSwitches()
9.46 + private static ArrayList<Switch> createSwitches()
9.47 {
9.48 - Vector switches = new Vector();
9.49 + ArrayList<Switch> switches = new ArrayList<Switch>();
9.50 // note that the order in which the switches are added is the order in which they are displayed
9.51 - switches.addElement(new BMPSwitch());
9.52 - switches.addElement(new PalmSwitch());
9.53 - switches.addElement(new PNMSwitch());
9.54 - switches.addElement(new TestSwitch());
9.55 - switches.addElement(new NoAwtLoadingSwitch());
9.56 - switches.addElement(new OverwriteSwitch());
9.57 - switches.addElement(new DestinationDirectorySwitch());
9.58 - switches.addElement(new QuietSwitch());
9.59 - switches.addElement(new VerbositySwitch());
9.60 - switches.addElement(new PrintHelpSwitch());
9.61 - switches.addElement(new PrintVersionSwitch());
9.62 + switches.add(new BMPSwitch());
9.63 + switches.add(new PalmSwitch());
9.64 + switches.add(new PNMSwitch());
9.65 + switches.add(new TestSwitch());
9.66 + switches.add(new NoAwtLoadingSwitch());
9.67 + switches.add(new OverwriteSwitch());
9.68 + switches.add(new DestinationDirectorySwitch());
9.69 + switches.add(new QuietSwitch());
9.70 + switches.add(new VerbositySwitch());
9.71 + switches.add(new PrintHelpSwitch());
9.72 + switches.add(new PrintVersionSwitch());
9.73 return switches;
9.74 }
9.75
9.76 @@ -278,15 +278,15 @@
9.77 private static JiuConvertSettings initFromArguments(String[] args)
9.78 {
9.79 // create switch objects
9.80 - Vector switches = createSwitches();
9.81 + ArrayList<Switch> switches = createSwitches();
9.82 PrintHelpSwitch.switches = switches;
9.83 // set defaults
9.84 JiuConvertSettings settings = new JiuConvertSettings();
9.85 settings.time1 = System.currentTimeMillis();
9.86 - Hashtable switchHash = new Hashtable();
9.87 + HashMap<String, Switch> switchHash = new HashMap<String, Switch>();
9.88 for (int i = 0; i < switches.size(); i++)
9.89 {
9.90 - Switch sw = (Switch)switches.elementAt(i);
9.91 + Switch sw = switches.get(i);
9.92 sw.setDefaults(settings);
9.93 String[] values = sw.getValues();
9.94 int j = 0;
9.95 @@ -306,7 +306,7 @@
9.96 while (index < args.length)
9.97 {
9.98 String arg = args[index++];
9.99 - Switch sw = (Switch)switchHash.get(arg);
9.100 + Switch sw = switchHash.get(arg);
9.101 if (sw == null)
9.102 {
9.103 // maybe a switch that does not exist?
9.104 @@ -322,7 +322,7 @@
9.105 System.err.println("Error: There is no file \"" + arg + "\".");
9.106 System.exit(1);
9.107 }
9.108 - settings.inputFileNames.addElement(arg);
9.109 + settings.inputFileNames.add(arg);
9.110 }
9.111 else
9.112 {
9.113 @@ -338,7 +338,7 @@
9.114 // now call check() on each switch
9.115 for (int i = 0; i < switches.size(); i++)
9.116 {
9.117 - Switch sw = (Switch)switches.elementAt(i);
9.118 + Switch sw = switches.get(i);
9.119 sw.check(settings);
9.120 }
9.121 // other checks
9.122 @@ -372,7 +372,7 @@
9.123 PixelImage image = null;
9.124 try
9.125 {
9.126 - image = ImageLoader.load(inputFileName, (Vector)null);
9.127 + image = ImageLoader.load(inputFileName, null);
9.128 }
9.129 catch (InvalidImageIndexException iiie)
9.130 {
9.131 @@ -476,7 +476,7 @@
9.132 int index = 0;
9.133 while (index < settings.inputFileNames.size())
9.134 {
9.135 - String fileName = (String)settings.inputFileNames.elementAt(index++);
9.136 + String fileName = settings.inputFileNames.get(index++);
9.137 run(settings, fileName);
9.138 }
9.139 exit(settings, 0);
10.1 --- a/net/sourceforge/jiu/codecs/IFFCodec.java Mon Aug 03 23:22:22 2009 +0200
10.2 +++ b/net/sourceforge/jiu/codecs/IFFCodec.java Sat Aug 08 23:06:58 2009 +0200
10.3 @@ -401,7 +401,7 @@
10.4
10.5 private static String getChunkName(int name)
10.6 {
10.7 - StringBuffer sb = new StringBuffer(4);
10.8 + StringBuilder sb = new StringBuilder(4);
10.9 sb.setLength(4);
10.10 sb.setCharAt(0, (char)((name >> 24) & 0xff));
10.11 sb.setCharAt(1, (char)((name >> 16) & 0xff));
10.12 @@ -515,7 +515,7 @@
10.13 "RLE-compressed image " +
10.14 "file seems to be corrupt (compressed=" + compressed +
10.15 ", x=" + x + ", y=" + y +
10.16 - ", count=" + (compressed ? (-((int)n) + 1) : n) +
10.17 + ", count=" + (compressed ? (-n + 1) : n) +
10.18 ", array length=" + data.length + ").");
10.19 }
10.20 }
11.1 --- a/net/sourceforge/jiu/codecs/ImageCodec.java Mon Aug 03 23:22:22 2009 +0200
11.2 +++ b/net/sourceforge/jiu/codecs/ImageCodec.java Sat Aug 08 23:06:58 2009 +0200
11.3 @@ -20,7 +20,7 @@
11.4 import java.io.IOException;
11.5 import java.io.OutputStream;
11.6 import java.io.RandomAccessFile;
11.7 -import java.util.Vector;
11.8 +import java.util.ArrayList;
11.9 import net.sourceforge.jiu.ops.MissingParameterException;
11.10 import net.sourceforge.jiu.ops.Operation;
11.11 import net.sourceforge.jiu.ops.WrongParameterException;
11.12 @@ -133,7 +133,7 @@
11.13 private boolean boundsAvail;
11.14 private int boundsWidth;
11.15 private int boundsHeight;
11.16 - private Vector comments;
11.17 + private ArrayList<String> comments;
11.18 private int dpiX;
11.19 private int dpiY;
11.20 private DataInput din;
11.21 @@ -152,7 +152,7 @@
11.22 public ImageCodec()
11.23 {
11.24 super();
11.25 - comments = new Vector();
11.26 + comments = new ArrayList<String>();
11.27 removeBounds();
11.28 }
11.29
11.30 @@ -166,7 +166,7 @@
11.31 {
11.32 if (comment != null)
11.33 {
11.34 - comments.addElement(comment);
11.35 + comments.add(comment);
11.36 }
11.37 }
11.38
11.39 @@ -342,7 +342,7 @@
11.40 {
11.41 if (index >= 0 && index < comments.size())
11.42 {
11.43 - return (String)comments.elementAt(index);
11.44 + return comments.get(index);
11.45 }
11.46 else
11.47 {
11.48 @@ -674,7 +674,7 @@
11.49 */
11.50 public void removeAllComments()
11.51 {
11.52 - comments.removeAllElements();
11.53 + comments.clear();
11.54 }
11.55
11.56 /**
12.1 --- a/net/sourceforge/jiu/codecs/ImageLoader.java Mon Aug 03 23:22:22 2009 +0200
12.2 +++ b/net/sourceforge/jiu/codecs/ImageLoader.java Sat Aug 08 23:06:58 2009 +0200
12.3 @@ -15,7 +15,7 @@
12.4 import java.io.FilenameFilter;
12.5 import java.io.IOException;
12.6 import java.io.InputStream;
12.7 -import java.util.Vector;
12.8 +import java.util.ArrayList;
12.9 import net.sourceforge.jiu.codecs.InvalidFileStructureException;
12.10 import net.sourceforge.jiu.codecs.InvalidImageIndexException;
12.11 import net.sourceforge.jiu.codecs.WrongFileFormatException;
12.12 @@ -31,6 +31,7 @@
12.13 import net.sourceforge.jiu.gui.awt.ImageCreator;
12.14 import net.sourceforge.jiu.ops.MissingParameterException;
12.15 import net.sourceforge.jiu.ops.OperationFailedException;
12.16 +import net.sourceforge.jiu.ops.ProgressListener;
12.17
12.18 /**
12.19 * A convenience class with static methods to load images from files using JIU codecs.
12.20 @@ -64,12 +65,12 @@
12.21 public class ImageLoader
12.22 {
12.23 // all elements of class String
12.24 - private static Vector fileExtensions;
12.25 - private static Vector imageCodecClasses;
12.26 + private static ArrayList<String> fileExtensions;
12.27 + private static ArrayList<Class<? extends ImageCodec>> imageCodecClasses;
12.28
12.29 static
12.30 {
12.31 - imageCodecClasses = new Vector();
12.32 + imageCodecClasses = new ArrayList<Class<? extends ImageCodec>>();
12.33 registerCodecClass(new BMPCodec());
12.34 registerCodecClass(new IFFCodec());
12.35 registerCodecClass(new PCDCodec());
12.36 @@ -94,7 +95,7 @@
12.37 ImageCodec result = null;
12.38 if (index >= 0 && index < getNumCodecs())
12.39 {
12.40 - Class c = (Class)imageCodecClasses.elementAt(index);
12.41 + Class<? extends ImageCodec> c = imageCodecClasses.get(index);
12.42 try
12.43 {
12.44 Object obj = c.newInstance();
12.45 @@ -142,7 +143,7 @@
12.46 int index = 0;
12.47 while (index < fileExtensions.size())
12.48 {
12.49 - String ext = (String)fileExtensions.elementAt(index++);
12.50 + String ext = fileExtensions.get(index++);
12.51 if (name.endsWith(ext))
12.52 {
12.53 return true;
12.54 @@ -183,10 +184,10 @@
12.55 * Attempts to load an image from a file, notifying the
12.56 * argument progress listeners.
12.57 * @param file the file to load an image from
12.58 - * @param listeners a Vector of ProgressListener objects to be notified
12.59 + * @param listeners a ArrayList of ProgressListener objects to be notified
12.60 * @return an instance of a class implementing {@link PixelImage}
12.61 */
12.62 - public static PixelImage load(File file, Vector listeners) throws
12.63 + public static PixelImage load(File file, ArrayList<ProgressListener> listeners) throws
12.64 IOException,
12.65 InvalidFileStructureException,
12.66 InvalidImageIndexException,
12.67 @@ -258,7 +259,7 @@
12.68 * @param listeners a list of objects implementing ProgressListener
12.69 * @return the loaded image
12.70 */
12.71 - public static PixelImage load(String fileName, Vector listeners) throws
12.72 + public static PixelImage load(String fileName, ArrayList<ProgressListener> listeners) throws
12.73 IOException,
12.74 InvalidFileStructureException,
12.75 InvalidImageIndexException,
12.76 @@ -338,7 +339,7 @@
12.77 {
12.78 throw new IllegalArgumentException("Codec does not support loading.");
12.79 }
12.80 - imageCodecClasses.addElement(codec.getClass());
12.81 + imageCodecClasses.add(codec.getClass());
12.82 updateFileExtensions();
12.83 }
12.84
12.85 @@ -349,7 +350,7 @@
12.86 */
12.87 public static void removeAllCodecClasses()
12.88 {
12.89 - imageCodecClasses = new Vector();
12.90 + imageCodecClasses = new ArrayList<Class<? extends ImageCodec>>();
12.91 updateFileExtensions();
12.92 }
12.93
12.94 @@ -378,7 +379,7 @@
12.95
12.96 private static void updateFileExtensions()
12.97 {
12.98 - fileExtensions = new Vector();
12.99 + fileExtensions = new ArrayList<String>();
12.100 int index = 0;
12.101 while (index < getNumCodecs())
12.102 {
12.103 @@ -390,7 +391,7 @@
12.104 {
12.105 for (int i = 0; i < extArray.length; i++)
12.106 {
12.107 - fileExtensions.addElement(extArray[i].toLowerCase());
12.108 + fileExtensions.add(extArray[i].toLowerCase());
12.109 }
12.110 }
12.111 }
13.1 --- a/net/sourceforge/jiu/codecs/PCDCodec.java Mon Aug 03 23:22:22 2009 +0200
13.2 +++ b/net/sourceforge/jiu/codecs/PCDCodec.java Sat Aug 08 23:06:58 2009 +0200
13.3 @@ -2,6 +2,7 @@
13.4 * PCDCodec
13.5 *
13.6 * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Marco Schmidt.
13.7 + * Copyright (c) 2009 Knut Arild Erstad.
13.8 * All rights reserved.
13.9 */
13.10
13.11 @@ -9,6 +10,8 @@
13.12
13.13 import java.io.IOException;
13.14 import java.io.RandomAccessFile;
13.15 +import java.util.EnumSet;
13.16 +
13.17 import net.sourceforge.jiu.codecs.ImageCodec;
13.18 import net.sourceforge.jiu.codecs.InvalidFileStructureException;
13.19 import net.sourceforge.jiu.codecs.UnsupportedTypeException;
13.20 @@ -47,60 +50,87 @@
13.21 public class PCDCodec extends ImageCodec implements YCbCrIndex
13.22 {
13.23 /**
13.24 - * Base/16, the minimum pixel resolution, 192 x 128 pixels.
13.25 + * Enumerates the available PCD resolutions.
13.26 */
13.27 - public static final int PCD_RESOLUTION_1 = 0;
13.28 + public enum Resolution
13.29 + {
13.30 + /**
13.31 + * Base/16, the minimum pixel resolution, 192 x 128 pixels.
13.32 + */
13.33 + RESOLUTION_1 (192, 128, 0x2000),
13.34 + /**
13.35 + * Base/4, the second pixel resolution, 384 x 256 pixels.
13.36 + */
13.37 + RESOLUTION_2 (384, 256, 0xb800),
13.38 + /**
13.39 + * Base, the third pixel resolution, 768 x 512 pixels.
13.40 + */
13.41 + RESOLUTION_3 (768, 512, 0x30000),
13.42 + /**
13.43 + * Base*4, the fourth pixel resolution, 1536 x 1024 pixels. <em>Unsupported</em>
13.44 + */
13.45 + RESOLUTION_4 (1536, 1024, -1),
13.46 + /**
13.47 + * Base*16, the fifth pixel resolution, 3072 x 2048 pixels. <em>Unsupported</em>
13.48 + */
13.49 + RESOLUTION_5 (3072, 2048, -1),
13.50 + /**
13.51 + * Base*64, the sixth pixel resolution, 6144 x 4096 pixels. <em>Unsupported</em>
13.52 + */
13.53 + RESOLUTION_6 (6144, 4096, -1);
13.54 +
13.55 + private int dimension1;
13.56 + private int dimension2;
13.57 + private long fileOffset;
13.58 +
13.59 + private Resolution(int dim1, int dim2, long offset)
13.60 + {
13.61 + assert dim1 > dim2;
13.62 + dimension1 = dim1;
13.63 + dimension2 = dim2;
13.64 + fileOffset = offset;
13.65 + }
13.66
13.67 - /**
13.68 - * Base/4, the second pixel resolution, 384 x 256 pixels.
13.69 - */
13.70 - public static final int PCD_RESOLUTION_2 = 1;
13.71 + /**
13.72 + * Returns the larger dimension of this resolution.
13.73 + * This can be the width or the height of the image, depending on the orientation.
13.74 + * @return The larger dimension, in pixels.
13.75 + */
13.76 + public int getDimension1()
13.77 + {
13.78 + return dimension1;
13.79 + }
13.80
13.81 - /**
13.82 - * Base, the third pixel resolution, 768 x 512 pixels.
13.83 - */
13.84 - public static final int PCD_RESOLUTION_3 = 2;
13.85 + /**
13.86 + * Returns the smaller dimension of this resolution.
13.87 + * This can be the width or the height of the image, depending on the orientation.
13.88 + * @return The smaller dimension, in pixels.
13.89 + */
13.90 + public int getDimension2()
13.91 + {
13.92 + return dimension2;
13.93 + }
13.94
13.95 - /**
13.96 - * Base*4, the fourth pixel resolution, 1536 x 1024 pixels. <em>Unsupported</em>
13.97 - */
13.98 - public static final int PCD_RESOLUTION_4 = 3;
13.99 + /**
13.100 + * @return The file offset of the resolution, or -1 for unsupported resolutions.
13.101 + */
13.102 + public long getFileOffset()
13.103 + {
13.104 + return fileOffset;
13.105 + }
13.106 +
13.107 + /**
13.108 + * The default resolution, {@link #RESOLUTION_3}.
13.109 + */
13.110 + public static final Resolution DEFAULT = RESOLUTION_3;
13.111 +
13.112 + /**
13.113 + * A set of supported resolutions.
13.114 + */
13.115 + public static final EnumSet<Resolution> supportedResolutions = EnumSet.of(
13.116 + RESOLUTION_1, RESOLUTION_2, RESOLUTION_3);
13.117 + }
13.118
13.119 - /**
13.120 - * Base*16, the fifth pixel resolution, 3072 x 2048 pixels. <em>Unsupported</em>
13.121 - */
13.122 - public static final int PCD_RESOLUTION_5 = 4;
13.123 -
13.124 - /**
13.125 - * Base*64, the sixth pixel resolution, 6144 x 4096 pixels. <em>Unsupported</em>
13.126 - */
13.127 - public static final int PCD_RESOLUTION_6 = 5;
13.128 -
13.129 - /**
13.130 - * Index for the default resolution , Base ({@link #PCD_RESOLUTION_3}).
13.131 - */
13.132 - public static final int PCD_RESOLUTION_DEFAULT = PCD_RESOLUTION_3;
13.133 -
13.134 - /**
13.135 - * This two-dimensional int array holds all possible pixel resolutions for
13.136 - * a PCD file. Use one of the PCD resolution constants (e.g.
13.137 - * {@link #PCD_RESOLUTION_3} as first index.
13.138 - * The second index must be 0 or 1 and leads to either width or
13.139 - * height.
13.140 - * Example: <code>PCD_RESOLUTION[PCD_RESOLUTION_3][1]</code> will evalute
13.141 - * as 512, which can be width or height, depending on the image being
13.142 - * in landscape or portrait mode.
13.143 - * You may want to use these resolution values in your program
13.144 - * to prompt the user which resolution to load from the file.
13.145 - */
13.146 - public static final int[][] PCD_RESOLUTIONS =
13.147 - {{192, 128}, {384, 256}, {768, 512},
13.148 - {1536, 1024}, {3072, 2048}, {6144, 4096}};
13.149 - // offsets into the file for the three uncompressed resolutions
13.150 - private static final long[] PCD_FILE_OFFSETS =
13.151 - {0x2000, 0xb800, 0x30000};
13.152 - /*private static final long[] PCD_BASE_LENGTH =
13.153 - {0x2000, 0xb800, 0x30000};*/
13.154 // some constants to understand the orientation of an image
13.155 private static final int NO_ROTATION = 0;
13.156 private static final int ROTATE_90_LEFT = 1;
13.157 @@ -114,7 +144,7 @@
13.158 private boolean performColorConversion;
13.159 private boolean monochrome;
13.160 private int numChannels;
13.161 - private int resolutionIndex;
13.162 + private Resolution resolution;
13.163 private RandomAccessFile in;
13.164 private byte[][] data;
13.165
13.166 @@ -132,13 +162,12 @@
13.167 super();
13.168 setColorConversion(true);
13.169 setMonochrome(false);
13.170 - setResolutionIndex(PCD_RESOLUTION_DEFAULT);
13.171 + setResolution(Resolution.DEFAULT);
13.172 }
13.173
13.174 private byte[][] allocateMemory()
13.175 {
13.176 - int numPixels = PCD_RESOLUTIONS[resolutionIndex][0] *
13.177 - PCD_RESOLUTIONS[resolutionIndex][1];
13.178 + int numPixels = resolution.getDimension1() * resolution.getDimension2();
13.179 byte[][] result = new byte[numChannels][];
13.180 for (int i = 0; i < numChannels; i++)
13.181 {
13.182 @@ -298,9 +327,7 @@
13.183 UnsupportedTypeException,
13.184 WrongFileFormatException
13.185 {
13.186 - if (resolutionIndex != PCD_RESOLUTION_1 &&
13.187 - resolutionIndex != PCD_RESOLUTION_2 &&
13.188 - resolutionIndex != PCD_RESOLUTION_3)
13.189 + if (!Resolution.supportedResolutions.contains(resolution))
13.190 {
13.191 throw new UnsupportedTypeException("Error reading PCD input " +
13.192 "stream. Only the three lowest resolutions are supported.");
13.193 @@ -337,8 +364,8 @@
13.194 }
13.195 // get image orientation and resolution
13.196 int rotationAngle = sector[0x602] & 0x03;
13.197 - int width = PCD_RESOLUTIONS[resolutionIndex][0];
13.198 - int height = PCD_RESOLUTIONS[resolutionIndex][1];
13.199 + int width = resolution.getDimension1();
13.200 + int height = resolution.getDimension2();
13.201 int realWidth = width;
13.202 int realHeight = height;
13.203 if (rotationAngle == ROTATE_90_LEFT || rotationAngle == ROTATE_90_RIGHT)
13.204 @@ -351,10 +378,10 @@
13.205 setBounds(0, 0, realWidth - 1, realHeight - 1);
13.206 }
13.207 // determine which uncompressed image will be loaded
13.208 - int uncompressedResolution = resolutionIndex;
13.209 - if (resolutionIndex > PCD_RESOLUTION_3)
13.210 + Resolution uncompressedResolution = resolution;
13.211 + if (!Resolution.supportedResolutions.contains(resolution))
13.212 {
13.213 - uncompressedResolution = PCD_RESOLUTION_3;
13.214 + uncompressedResolution = Resolution.RESOLUTION_3;
13.215 }
13.216 // load uncompressed image
13.217 data = allocateMemory();
13.218 @@ -363,11 +390,11 @@
13.219 if (!monochrome)
13.220 {
13.221 ArrayScaling.scaleUp200Percent(data[INDEX_CB],
13.222 - PCD_RESOLUTIONS[uncompressedResolution][0] / 2,
13.223 - PCD_RESOLUTIONS[uncompressedResolution][1] / 2);
13.224 + uncompressedResolution.getDimension1() / 2,
13.225 + uncompressedResolution.getDimension2() / 2);
13.226 ArrayScaling.scaleUp200Percent(data[INDEX_CR],
13.227 - PCD_RESOLUTIONS[uncompressedResolution][0] / 2,
13.228 - PCD_RESOLUTIONS[uncompressedResolution][1] / 2);
13.229 + uncompressedResolution.getDimension1() / 2,
13.230 + uncompressedResolution.getDimension2() / 2);
13.231 }
13.232 // TODO load higher resolution by decoding differences to uncompressed image
13.233 // ...
13.234 @@ -402,20 +429,18 @@
13.235 * @param resolution one of PCD_RESOLUTION_1, PCD_RESOLUTION_2 or PCD_RESOLUTION_3
13.236 * @throws an IOException if there were any reading errors
13.237 */
13.238 - private void loadUncompressedImage(int resolution)
13.239 + private void loadUncompressedImage(Resolution resolution)
13.240 throws IllegalArgumentException, IOException
13.241 {
13.242 - if (resolution != PCD_RESOLUTION_1 &&
13.243 - resolution != PCD_RESOLUTION_2 &&
13.244 - resolution != PCD_RESOLUTION_3)
13.245 + if (!Resolution.supportedResolutions.contains(resolution))
13.246 {
13.247 throw new IllegalArgumentException("Error loading " +
13.248 "PCD image, only the lowest three resolutions are " +
13.249 "uncompressed.");
13.250 }
13.251 - in.seek(PCD_FILE_OFFSETS[resolution]);
13.252 - int fullWidth = PCD_RESOLUTIONS[resolution][0];
13.253 - int fullHeight = PCD_RESOLUTIONS[resolution][1];
13.254 + in.seek(resolution.getFileOffset());
13.255 + int fullWidth = resolution.getDimension1();
13.256 + int fullHeight = resolution.getDimension2();
13.257 int halfWidth = fullWidth / 2;
13.258 int halfHeight = fullHeight / 2;
13.259 int offset1 = 0;
13.260 @@ -561,8 +586,8 @@
13.261 }
13.262 }
13.263
13.264 - public void setResolutionIndex(int resolutionIndex)
13.265 + public void setResolution(Resolution resolution)
13.266 {
13.267 - this.resolutionIndex = resolutionIndex;
13.268 + this.resolution = resolution;
13.269 }
13.270 }
14.1 --- a/net/sourceforge/jiu/codecs/PNGCodec.java Mon Aug 03 23:22:22 2009 +0200
14.2 +++ b/net/sourceforge/jiu/codecs/PNGCodec.java Sat Aug 08 23:06:58 2009 +0200
14.3 @@ -476,7 +476,7 @@
14.4 */
14.5 private static String getChunkName(int chunk)
14.6 {
14.7 - StringBuffer result = new StringBuffer(4);
14.8 + StringBuilder result = new StringBuilder(4);
14.9 for (int i = 24; i >= 0; i -= 8)
14.10 {
14.11 result.append((char)((chunk >> i) & 0xff));
14.12 @@ -676,7 +676,7 @@
14.13 }
14.14 else
14.15 {
14.16 - StringBuffer text = new StringBuffer((int)chunkSize);
14.17 + StringBuilder text = new StringBuilder((int)chunkSize);
14.18 int i = 0;
14.19 char c;
14.20 do
15.1 --- a/net/sourceforge/jiu/codecs/PNMCodec.java Mon Aug 03 23:22:22 2009 +0200
15.2 +++ b/net/sourceforge/jiu/codecs/PNMCodec.java Sat Aug 08 23:06:58 2009 +0200
15.3 @@ -33,6 +33,7 @@
15.4 import net.sourceforge.jiu.ops.MissingParameterException;
15.5 import net.sourceforge.jiu.ops.OperationFailedException;
15.6 import net.sourceforge.jiu.ops.WrongParameterException;
15.7 +import net.sourceforge.jiu.util.EnumHelper;
15.8
15.9 /**
15.10 * A codec to read and write Portable Anymap (PNM) image files.
15.11 @@ -101,29 +102,45 @@
15.12 public class PNMCodec extends ImageCodec
15.13 {
15.14 /**
15.15 - * Image type constant for images of unknown type.
15.16 + * Enumerates the possible image types.
15.17 + * Note that the ordinal value of each enum value is significant,
15.18 + * since it is currently used when loading and saving files.
15.19 */
15.20 - public static final int IMAGE_TYPE_UNKNOWN = -1;
15.21 + public enum ImageType
15.22 + {
15.23 + /**
15.24 + * For bilevel images, stored in PBM files.
15.25 + */
15.26 + BILEVEL (".pbm"),
15.27 + /**
15.28 + * For grayscale images, stored in PGM files.
15.29 + */
15.30 + GRAY (".pgm"),
15.31 + /**
15.32 + * For RGB truecolor images, stored in PPM files.
15.33 + */
15.34 + COLOR (".ppm");
15.35 +
15.36 + private String fileExtension;
15.37 +
15.38 + private ImageType(String fileExtension)
15.39 + {
15.40 + this.fileExtension = fileExtension;
15.41 + }
15.42 +
15.43 + /**
15.44 + * Get the suggested file extension for the image type.
15.45 + * @return a lower case file extension, including the . (dot) character.
15.46 + */
15.47 + public String getFileExtension()
15.48 + {
15.49 + return fileExtension;
15.50 + }
15.51 + }
15.52
15.53 - /**
15.54 - * Image type constant for bilevel images, stored in PBM files.
15.55 - */
15.56 - public static final int IMAGE_TYPE_BILEVEL = 0;
15.57 -
15.58 - /**
15.59 - * Image type constant for grayscale images, stored in PGM files.
15.60 - */
15.61 - public static final int IMAGE_TYPE_GRAY = 1;
15.62 -
15.63 - /**
15.64 - * Image type constant for RGB truecolor images, stored in PPM files.
15.65 - */
15.66 - public static final int IMAGE_TYPE_COLOR = 2;
15.67 - private static final String[] IMAGE_TYPE_FILE_EXTENSIONS =
15.68 - {".pbm", ".pgm", ".ppm"};
15.69 private Boolean ascii;
15.70 private int columns;
15.71 - private int imageType;
15.72 + private ImageType imageType;
15.73 private PushbackInputStream in;
15.74 private DataOutput out;
15.75 private int height;
15.76 @@ -133,32 +150,32 @@
15.77 /**
15.78 * Attempts to find the appropriate image type by looking at a file's name.
15.79 * Ignores case when comparing.
15.80 - * Returns {@link #IMAGE_TYPE_BILEVEL} for <code>.pbm</code>,
15.81 - * {@link #IMAGE_TYPE_GRAY} for <code>.pgm</code> and
15.82 - * {@link #IMAGE_TYPE_COLOR} for <code>.ppm</code>.
15.83 - * Otherwise, {@link #IMAGE_TYPE_UNKNOWN} is returned.
15.84 + * Returns {@link ImageType#BILEVEL} for <code>.pbm</code>,
15.85 + * {@link ImageType#GRAY} for <code>.pgm</code> and
15.86 + * {@link ImageType#COLOR} for <code>.ppm</code>.
15.87 + * Otherwise, <code>null</code> is returned.
15.88 * To get a file extension given that you have an image type, use
15.89 - * {@link #getTypicalFileExtension}.
15.90 + * {@link ImageType#getFileExtension()}.
15.91 *
15.92 * @param fileName the file name to be examined
15.93 - * @return one of the <code>IMAGE_TYPE_xxx</code> constants of this class
15.94 + * @return an {@link ImageType} enum value, or <code>null</code>
15.95 */
15.96 - public static int determineImageTypeFromFileName(String fileName)
15.97 + public static ImageType determineImageTypeFromFileName(String fileName)
15.98 {
15.99 if (fileName == null || fileName.length() < 4)
15.100 {
15.101 - return IMAGE_TYPE_UNKNOWN;
15.102 + return null;
15.103 }
15.104 String ext = fileName.substring(fileName.length() - 3);
15.105 ext = ext.toLowerCase();
15.106 - for (int i = 0; i < IMAGE_TYPE_FILE_EXTENSIONS.length; i++)
15.107 + for (ImageType type: ImageType.values())
15.108 {
15.109 - if (IMAGE_TYPE_FILE_EXTENSIONS[i].equals(ext))
15.110 + if (type.getFileExtension().equals(ext))
15.111 {
15.112 - return i;
15.113 + return type;
15.114 }
15.115 }
15.116 - return IMAGE_TYPE_UNKNOWN;
15.117 + return null;
15.118 }
15.119
15.120 /**
15.121 @@ -184,28 +201,6 @@
15.122 "image/x-portable-anymap"};
15.123 }
15.124
15.125 - /**
15.126 - * Returns the typical file extension (including leading dot) for an
15.127 - * image type.
15.128 - * Returns <code>null</code> for {@link #IMAGE_TYPE_UNKNOWN}.
15.129 - * To get the image type given that you have a file name, use
15.130 - * {@link #determineImageTypeFromFileName}.
15.131 - *
15.132 - * @param imageType the image type for which the extension is required
15.133 - * @return the file extension or null
15.134 - */
15.135 - public static String getTypicalFileExtension(int imageType)
15.136 - {
15.137 - if (imageType >= 0 && imageType < IMAGE_TYPE_FILE_EXTENSIONS.length)
15.138 - {
15.139 - return IMAGE_TYPE_FILE_EXTENSIONS[imageType];
15.140 - }
15.141 - else
15.142 - {
15.143 - return null;
15.144 - }
15.145 - }
15.146 -
15.147 public boolean isLoadingSupported()
15.148 {
15.149 return true;
15.150 @@ -252,7 +247,7 @@
15.151 String resolutionLine = loadTextLine();
15.152 setResolution(resolutionLine);
15.153 setBoundsIfNecessary(width, height);
15.154 - if (imageType == IMAGE_TYPE_BILEVEL)
15.155 + if (imageType == ImageType.BILEVEL)
15.156 {
15.157 maxSample = 1;
15.158 }
15.159 @@ -269,17 +264,17 @@
15.160 checkImageResolution();
15.161 switch (imageType)
15.162 {
15.163 - case(IMAGE_TYPE_BILEVEL):
15.164 + case BILEVEL:
15.165 {
15.166 loadBilevelImage();
15.167 break;
15.168 }
15.169 - case(IMAGE_TYPE_COLOR):
15.170 + case COLOR:
15.171 {
15.172 loadColorImage();
15.173 break;
15.174 }
15.175 - case(IMAGE_TYPE_GRAY):
15.176 + case GRAY:
15.177 {
15.178 loadGrayImage();
15.179 break;
15.180 @@ -701,12 +696,12 @@
15.181 // 1) a normal text line is found
15.182 // 2) an error occurs
15.183 // any comment lines starting with # are added to the
15.184 - // comments Vector
15.185 + // comments ArrayList
15.186 boolean isComment;
15.187 - StringBuffer sb;
15.188 + StringBuilder sb;
15.189 do
15.190 {
15.191 - sb = new StringBuffer();
15.192 + sb = new StringBuilder();
15.193 int b;
15.194 boolean crOrLf;
15.195 do
15.196 @@ -736,7 +731,7 @@
15.197 {
15.198 //sb.deleteCharAt(0);
15.199 //sb.delete(0, 1);
15.200 - StringBuffer result = new StringBuffer(sb.length() - 1);
15.201 + StringBuilder result = new StringBuilder(sb.length() - 1);
15.202 int i = 1;
15.203 while (i < sb.length())
15.204 {
15.205 @@ -786,7 +781,7 @@
15.206 ascii = new Boolean(v2 < 0x34);
15.207 // determine image type from second byte
15.208 v2 = v2 - 0x30;
15.209 - imageType = (v2 - 1) % 3;
15.210 + imageType = EnumHelper.fromOrdinal(ImageType.values(), (v2 - 1) % 3);
15.211 // skip LF and CR
15.212 int b;
15.213 do
15.214 @@ -849,35 +844,35 @@
15.215 setBoundsIfNecessary(width, height);
15.216 if (image instanceof RGB24Image)
15.217 {
15.218 - imageType = IMAGE_TYPE_COLOR;
15.219 + imageType = ImageType.COLOR;
15.220 maxSample = 255;
15.221 save((RGB24Image)image);
15.222 }
15.223 else
15.224 if (image instanceof RGB48Image)
15.225 {
15.226 - imageType = IMAGE_TYPE_COLOR;
15.227 + imageType = ImageType.COLOR;
15.228 maxSample = 65535;
15.229 save((RGB48Image)image);
15.230 }
15.231 else
15.232 if (image instanceof BilevelImage)
15.233 {
15.234 - imageType = IMAGE_TYPE_BILEVEL;
15.235 + imageType = ImageType.BILEVEL;
15.236 maxSample = 1;
15.237 save((BilevelImage)image);
15.238 }
15.239 else
15.240 if (image instanceof Gray8Image)
15.241 {
15.242 - imageType = IMAGE_TYPE_GRAY;
15.243 + imageType = ImageType.GRAY;
15.244 maxSample = 255;
15.245 save((Gray8Image)image);
15.246 }
15.247 else
15.248 if (image instanceof Gray16Image)
15.249 {
15.250 - imageType = IMAGE_TYPE_GRAY;
15.251 + imageType = ImageType.GRAY;
15.252 maxSample = 65535;
15.253 save((Gray16Image)image);
15.254 }
15.255 @@ -1123,7 +1118,7 @@
15.256 private void saveHeader() throws IOException
15.257 {
15.258 out.write(80); // 'P'
15.259 - int pnmType = 49 + imageType;
15.260 + int pnmType = 49 + imageType.ordinal();
15.261 if (getAscii() == null)
15.262 {
15.263 setAscii(maxSample > 255);
15.264 @@ -1138,7 +1133,7 @@
15.265 out.write(32); // space
15.266 saveAsciiNumber(getBoundsHeight());
15.267 out.write(10); // line feed
15.268 - if (imageType != IMAGE_TYPE_BILEVEL)
15.269 + if (imageType != ImageType.BILEVEL)
15.270 {
15.271 // bilevel max sample is always 1 and MUST NOT be saved
15.272 saveAsciiNumber(maxSample);
15.273 @@ -1238,17 +1233,17 @@
15.274 }
15.275 if (image instanceof BilevelImage)
15.276 {
15.277 - return IMAGE_TYPE_FILE_EXTENSIONS[IMAGE_TYPE_BILEVEL];
15.278 + return ImageType.BILEVEL.getFileExtension();
15.279 }
15.280 else
15.281 if (image instanceof GrayImage)
15.282 {
15.283 - return IMAGE_TYPE_FILE_EXTENSIONS[IMAGE_TYPE_GRAY];
15.284 + return ImageType.GRAY.getFileExtension();
15.285 }
15.286 else
15.287 if (image instanceof RGB24Image)
15.288 {
15.289 - return IMAGE_TYPE_FILE_EXTENSIONS[IMAGE_TYPE_COLOR];
15.290 + return ImageType.COLOR.getFileExtension();
15.291 }
15.292 return null;
15.293 }
16.1 --- a/net/sourceforge/jiu/codecs/jpeg/JPEGData.java Mon Aug 03 23:22:22 2009 +0200
16.2 +++ b/net/sourceforge/jiu/codecs/jpeg/JPEGData.java Sat Aug 08 23:06:58 2009 +0200
16.3 @@ -6,7 +6,7 @@
16.4 */
16.5 package net.sourceforge.jiu.codecs.jpeg;
16.6
16.7 -import java.util.Vector;
16.8 +import java.util.ArrayList;
16.9
16.10 /**
16.11 * Data for decoding or encoding images from or to
16.12 @@ -17,9 +17,9 @@
16.13 public class JPEGData
16.14 {
16.15 private JPEGFrame frame;
16.16 - private Vector huffmanTables = new Vector();
16.17 - private Vector quantTables = new Vector();
16.18 - private Vector scans = new Vector();
16.19 + private ArrayList<JPEGHuffmanTable> huffmanTables = new ArrayList<JPEGHuffmanTable>();
16.20 + private ArrayList<JPEGQuantizationTable> quantTables = new ArrayList<JPEGQuantizationTable>();
16.21 + private ArrayList<JPEGScan> scans = new ArrayList<JPEGScan>();
16.22
16.23 public void addQuantizationTable(JPEGQuantizationTable table)
16.24 {
16.25 @@ -49,11 +49,8 @@
16.26 */
16.27 public JPEGQuantizationTable getQuantizationTable(int id)
16.28 {
16.29 - JPEGQuantizationTable table = null;
16.30 - int index = 0;
16.31 - while (index < quantTables.size())
16.32 + for (JPEGQuantizationTable table: quantTables)
16.33 {
16.34 - table = (JPEGQuantizationTable)quantTables.elementAt(index++);
16.35 if (table.getId() == id)
16.36 {
16.37 return table;
17.1 --- a/net/sourceforge/jiu/codecs/jpeg/JPEGFrame.java Mon Aug 03 23:22:22 2009 +0200
17.2 +++ b/net/sourceforge/jiu/codecs/jpeg/JPEGFrame.java Sat Aug 08 23:06:58 2009 +0200
17.3 @@ -74,7 +74,7 @@
17.4
17.5 public String toString()
17.6 {
17.7 - StringBuffer sb = new StringBuffer();
17.8 + StringBuilder sb = new StringBuilder();
17.9 sb.append("#components=");
17.10 sb.append(numComponents);
17.11 sb.append("/precision=");
18.1 --- a/net/sourceforge/jiu/codecs/jpeg/JPEGFrameComponent.java Mon Aug 03 23:22:22 2009 +0200
18.2 +++ b/net/sourceforge/jiu/codecs/jpeg/JPEGFrameComponent.java Sat Aug 08 23:06:58 2009 +0200
18.3 @@ -61,7 +61,7 @@
18.4
18.5 public String toString()
18.6 {
18.7 - StringBuffer sb = new StringBuffer();
18.8 + StringBuilder sb = new StringBuilder();
18.9 sb.append("component id=");
18.10 sb.append(componentId);
18.11 sb.append(", horiz. sampling=");
19.1 --- a/net/sourceforge/jiu/codecs/jpeg/JPEGHuffmanTable.java Mon Aug 03 23:22:22 2009 +0200
19.2 +++ b/net/sourceforge/jiu/codecs/jpeg/JPEGHuffmanTable.java Sat Aug 08 23:06:58 2009 +0200
19.3 @@ -136,7 +136,7 @@
19.4
19.5 public String toString()
19.6 {
19.7 - StringBuffer sb = new StringBuffer();
19.8 + StringBuilder sb = new StringBuilder();
19.9 sb.append("id=");
19.10 sb.append(id);
19.11 sb.append("/class=");
20.1 --- a/net/sourceforge/jiu/codecs/tiff/TIFFCodec.java Mon Aug 03 23:22:22 2009 +0200
20.2 +++ b/net/sourceforge/jiu/codecs/tiff/TIFFCodec.java Sat Aug 08 23:06:58 2009 +0200
20.3 @@ -9,8 +9,8 @@
20.4
20.5 import java.io.IOException;
20.6 import java.io.RandomAccessFile;
20.7 -import java.util.Hashtable;
20.8 -import java.util.Vector;
20.9 +import java.util.HashMap;
20.10 +import java.util.ArrayList;
20.11 import net.sourceforge.jiu.codecs.CodecMode;
20.12 import net.sourceforge.jiu.codecs.ImageCodec;
20.13 import net.sourceforge.jiu.codecs.InvalidFileStructureException;
20.14 @@ -174,10 +174,10 @@
20.15 private int byteOrder;
20.16 private int nextIfdOffset;
20.17
20.18 - private static Hashtable decoders;
20.19 + private static HashMap<Integer, Class<? extends TIFFDecoder>> decoders;
20.20 static
20.21 {
20.22 - decoders = new Hashtable();
20.23 + decoders = new HashMap<Integer, Class<? extends TIFFDecoder>>();
20.24 registerDecoder(TIFFDecoderDeflated.class);
20.25 registerDecoder(TIFFDecoderModifiedHuffman.class);
20.26 registerDecoder(TIFFDecoderPackbits.class);
20.27 @@ -227,41 +227,33 @@
20.28 UnsupportedTypeException
20.29 {
20.30 Integer compression = new Integer(ifd.getCompression());
20.31 - Class decoderClass = (Class)decoders.get(compression);
20.32 + Class<? extends TIFFDecoder> decoderClass = decoders.get(compression);
20.33 if (decoderClass == null)
20.34 {
20.35 throw new UnsupportedTypeException("Could not create decoder for this compression type: " +
20.36 compression.intValue());
20.37 }
20.38 - Object instance;
20.39 + TIFFDecoder decoder;
20.40 try
20.41 {
20.42 - instance = decoderClass.newInstance();
20.43 + decoder = decoderClass.newInstance();
20.44 }
20.45 catch (Exception e)
20.46 {
20.47 throw new UnsupportedTypeException("Could not create decoder for this compression type.");
20.48 }
20.49 - if (instance instanceof TIFFDecoder)
20.50 + decoder.setCodec(codec);
20.51 + decoder.setTileIndex(tileIndex);
20.52 + decoder.setImageFileDirectory(ifd);
20.53 + try
20.54 {
20.55 - TIFFDecoder decoder = (TIFFDecoder)instance;
20.56 - decoder.setCodec(codec);
20.57 - decoder.setTileIndex(tileIndex);
20.58 - decoder.setImageFileDirectory(ifd);
20.59 - try
20.60 - {
20.61 - decoder.initialize();
20.62 - }
20.63 - catch (MissingParameterException mpe)
20.64 - {
20.65 - throw new UnsupportedTypeException("Unable to initialize decoder: " + mpe.toString());
20.66 - }
20.67 - return decoder;
20.68 + decoder.initialize();
20.69 }
20.70 - else
20.71 + catch (MissingParameterException mpe)
20.72 {
20.73 - throw new UnsupportedTypeException("Could not create decoder for this compression type.");
20.74 + throw new UnsupportedTypeException("Unable to initialize decoder: " + mpe.toString());
20.75 }
20.76 + return decoder;
20.77 }
20.78
20.79 /**
20.80 @@ -407,42 +399,42 @@
20.81 PixelImage image = getImage();
20.82 if (image == null)
20.83 {
20.84 - int imageType = ifd.getImageType();
20.85 + TIFFImageType imageType = ifd.getImageType();
20.86 switch (imageType)
20.87 {
20.88 - case(TIFFImageFileDirectory.TYPE_BILEVEL_BYTE):
20.89 - case(TIFFImageFileDirectory.TYPE_BILEVEL_PACKED):
20.90 + case BILEVEL_BYTE:
20.91 + case BILEVEL_PACKED:
20.92 {
20.93 image = new MemoryBilevelImage(width, height);
20.94 break;
20.95 }
20.96 - case(TIFFImageFileDirectory.TYPE_GRAY4):
20.97 - case(TIFFImageFileDirectory.TYPE_GRAY8):
20.98 - case(TIFFImageFileDirectory.TYPE_LOGL):
20.99 + case GRAY4:
20.100 + case GRAY8:
20.101 + case LOGL:
20.102 {
20.103 image = new MemoryGray8Image(width, height);
20.104 break;
20.105 }
20.106 - case(TIFFImageFileDirectory.TYPE_GRAY16):
20.107 + case GRAY16:
20.108 {
20.109 image = new MemoryGray16Image(width, height);
20.110 break;
20.111 }
20.112 - case(TIFFImageFileDirectory.TYPE_PALETTED4):
20.113 - case(TIFFImageFileDirectory.TYPE_PALETTED8):
20.114 + case PALETTED4:
20.115 + case PALETTED8:
20.116 {
20.117 image = new MemoryPaletted8Image(width, height, ifd.getPalette());
20.118 break;
20.119 }
20.120 - case(TIFFImageFileDirectory.TYPE_CMYK32_INTERLEAVED):
20.121 - case(TIFFImageFileDirectory.TYPE_CMYK32_PLANAR):
20.122 - case(TIFFImageFileDirectory.TYPE_RGB24_INTERLEAVED):
20.123 - case(TIFFImageFileDirectory.TYPE_LOGLUV32_INTERLEAVED):
20.124 + case CMYK32_INTERLEAVED:
20.125 + case CMYK32_PLANAR:
20.126 + case RGB24_INTERLEAVED:
20.127 + case LOGLUV32_INTERLEAVED:
20.128 {
20.129 image = new MemoryRGB24Image(width, height);
20.130 break;
20.131 }
20.132 - case(TIFFImageFileDirectory.TYPE_RGB48_INTERLEAVED):
20.133 + case RGB48_INTERLEAVED:
20.134 {
20.135 image = new MemoryRGB48Image(width, height);
20.136 break;
20.137 @@ -618,7 +610,7 @@
20.138 private String readString(int length) throws IOException
20.139 {
20.140 RandomAccessFile in = getRandomAccessFile();
20.141 - StringBuffer sb = new StringBuffer(length - 1);
20.142 + StringBuilder sb = new StringBuilder(length - 1);
20.143 while (length-- > 0)
20.144 {
20.145 int value = in.read();
20.146 @@ -653,7 +645,7 @@
20.147 //throw new InvalidFileStructureException("Invalid count value for tag " + id + " (" + count + ").");
20.148 return null;
20.149 }
20.150 - Vector vector = null;
20.151 + ArrayList<Object> vector = null;
20.152 // perform weird bitshifting magic if necessary
20.153 if (count == 1 &&
20.154 (type == TAG_TYPE_BYTE || type == TAG_TYPE_SHORT || type == TAG_TYPE_LONG))
20.155 @@ -663,11 +655,11 @@
20.156 else
20.157 if (count <= 4 && type == TAG_TYPE_BYTE)
20.158 {
20.159 - vector = new Vector();
20.160 + vector = new ArrayList<Object>();
20.161 for (int i = 0; i < count; i++)
20.162 {
20.163 byte b = (byte)((offset << (i * 8)) & 0xff);
20.164 - vector.addElement(new Byte(b));
20.165 + vector.add(new Byte(b));
20.166 }
20.167 }
20.168 else
20.169 @@ -675,10 +667,10 @@
20.170 {
20.171 long oldOffset = in.getFilePointer();
20.172 in.seek(offset);
20.173 - vector = new Vector();
20.174 + vector = new ArrayList<Object>();
20.175 if (type == TAG_TYPE_ASCII)
20.176 {
20.177 - vector.addElement(readString(count));
20.178 + vector.add(readString(count));
20.179 }
20.180 else
20.181 if (type == TAG_TYPE_BYTE)
20.182 @@ -686,7 +678,7 @@
20.183 for (int i = 0; i < count; i++)
20.184 {
20.185 byte b = in.readByte();
20.186 - vector.addElement(new Byte(b));
20.187 + vector.add(new Byte(b));
20.188 }
20.189 }
20.190 else
20.191 @@ -695,7 +687,7 @@
20.192 for (int i = 0; i < count; i++)
20.193 {
20.194 int s = readShort();
20.195 - vector.addElement(new Short((short)s));
20.196 + vector.add(new Short((short)s));
20.197 }
20.198 }
20.199 else
20.200 @@ -704,7 +696,7 @@
20.201 for (int i = 0; i < count; i++)
20.202 {
20.203 int v = adjustInt(readInt(), type);
20.204 - vector.addElement(new Integer(v));
20.205 + vector.add(new Integer(v));
20.206 }
20.207 }
20.208 else
20.209 @@ -714,13 +706,13 @@
20.210 {
20.211 int v1 = adjustInt(readInt(), TAG_TYPE_LONG);
20.212 int v2 = adjustInt(readInt(), TAG_TYPE_LONG);
20.213 - vector.addElement(new TIFFRational(v1, v2));
20.214 + vector.add(new TIFFRational(v1, v2));
20.215 }
20.216 }
20.217 in.seek(oldOffset);
20.218 }
20.219 TIFFTag result = new TIFFTag(id, type, count, offset);
20.220 - result.setVector(vector);
20.221 + result.setArrayList(vector);
20.222 return result;
20.223 }
20.224
20.225 @@ -738,7 +730,7 @@
20.226 * (each decoder knows about the compression types it supports via the getCompressionTypes method)
20.227 * and for each tile or strip such a decoder object will be created.
20.228 */
20.229 - public static void registerDecoder(Class decoderClass)
20.230 + public static void registerDecoder(Class<? extends TIFFDecoder> decoderClass)
20.231 {
20.232 if (decoderClass == null)
20.233 {
21.1 --- a/net/sourceforge/jiu/codecs/tiff/TIFFDecoder.java Mon Aug 03 23:22:22 2009 +0200
21.2 +++ b/net/sourceforge/jiu/codecs/tiff/TIFFDecoder.java Sat Aug 08 23:06:58 2009 +0200
21.3 @@ -309,7 +309,7 @@
21.4 numPixels -= (rightPixels + leftPixels);
21.5 switch(ifd.getImageType())
21.6 {
21.7 - case(TIFFImageFileDirectory.TYPE_BILEVEL_BYTE):
21.8 + case BILEVEL_BYTE:
21.9 {
21.10 BilevelImage image = (BilevelImage)codec.getImage();
21.11 int index = offset + leftPixels;
21.12 @@ -327,14 +327,14 @@
21.13 }
21.14 break;
21.15 }
21.16 - case(TIFFImageFileDirectory.TYPE_BILEVEL_PACKED):
21.17 + case BILEVEL_PACKED:
21.18 {
21.19 BilevelImage image = (BilevelImage)codec.getImage();
21.20 int x = getX1() - codec.getBoundsX1() + leftPixels;
21.21 image.putPackedBytes(x, y, numPixels, data, offset + (leftPixels / 8), leftPixels % 8);
21.22 break;
21.23 }
21.24 - case(TIFFImageFileDirectory.TYPE_GRAY4):
21.25 + case GRAY4:
21.26 {
21.27 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.28 byte[] dest = new byte[data.length * 2];
21.29 @@ -348,7 +348,7 @@
21.30 image.putByteSamples(0, getX1() - codec.getBoundsX1() + leftPixels, y, numPixels, 1, dest, offset + leftPixels);
21.31 break;
21.32 }
21.33 - case(TIFFImageFileDirectory.TYPE_PALETTED4):
21.34 + case PALETTED4:
21.35 {
21.36 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.37 byte[] dest = new byte[data.length * 2];
21.38 @@ -356,14 +356,14 @@
21.39 image.putByteSamples(0, getX1() - codec.getBoundsX1() + leftPixels, y, numPixels, 1, dest, offset + leftPixels);
21.40 break;
21.41 }
21.42 - case(TIFFImageFileDirectory.TYPE_GRAY8):
21.43 - case(TIFFImageFileDirectory.TYPE_PALETTED8):
21.44 + case GRAY8:
21.45 + case PALETTED8:
21.46 {
21.47 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.48 image.putByteSamples(0, getX1() - codec.getBoundsX1() + leftPixels, y, numPixels, 1, data, offset + leftPixels);
21.49 break;
21.50 }
21.51 - case(TIFFImageFileDirectory.TYPE_CMYK32_INTERLEAVED):
21.52 + case CMYK32_INTERLEAVED:
21.53 {
21.54 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.55 byte[] dest = new byte[data.length];
21.56 @@ -379,7 +379,7 @@
21.57 image.putByteSamples(RGBIndex.INDEX_BLUE, getX1() - codec.getBoundsX1() + leftPixels, y, numPixels, 1, dest, 2 * numSamples + leftPixels);
21.58 break;
21.59 }
21.60 -/* case(TIFFImageFileDirectory.TYPE_CMYK32_PLANAR):
21.61 +/* case CMYK32_PLANAR:
21.62 {
21.63 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.64 byte[] dest = new byte[data.length];
21.65 @@ -398,7 +398,7 @@
21.66 image.putByteSamples(RGBIndex.INDEX_BLUE, getX1() - codec.getBoundsX1() + leftPixels, y, numPixels, 1, dest, 2 * numSamples + leftPixels);
21.67 break;
21.68 }*/
21.69 - case(TIFFImageFileDirectory.TYPE_RGB24_INTERLEAVED):
21.70 + case RGB24_INTERLEAVED:
21.71 {
21.72 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.73 offset += leftPixels * 3;
21.74 @@ -410,7 +410,7 @@
21.75 }
21.76 break;
21.77 }
21.78 - case(TIFFImageFileDirectory.TYPE_RGB48_INTERLEAVED):
21.79 + case RGB48_INTERLEAVED:
21.80 {
21.81 ShortChannelImage image = (ShortChannelImage)codec.getImage();
21.82 offset += leftPixels * 3;
21.83 @@ -435,7 +435,7 @@
21.84 }
21.85 break;
21.86 }
21.87 - case(TIFFImageFileDirectory.TYPE_LOGLUV32_INTERLEAVED):
21.88 + case LOGLUV32_INTERLEAVED:
21.89 {
21.90 if (getImageFileDirectory().getCompression() == TIFFConstants.COMPRESSION_SGI_LOG_RLE)
21.91 {
21.92 @@ -464,7 +464,7 @@
21.93 }
21.94 break;
21.95 }
21.96 - case(TIFFImageFileDirectory.TYPE_LOGL):
21.97 + case LOGL:
21.98 {
21.99 ByteChannelImage image = (ByteChannelImage)codec.getImage();
21.100 int numSamples = ifd.getTileWidth();
22.1 --- a/net/sourceforge/jiu/codecs/tiff/TIFFImageFileDirectory.java Mon Aug 03 23:22:22 2009 +0200
22.2 +++ b/net/sourceforge/jiu/codecs/tiff/TIFFImageFileDirectory.java Sat Aug 08 23:06:58 2009 +0200
22.3 @@ -12,7 +12,7 @@
22.4 import java.util.Date;
22.5 import java.util.GregorianCalendar;
22.6 import java.util.TimeZone;
22.7 -import java.util.Vector;
22.8 +import java.util.ArrayList;
22.9 import net.sourceforge.jiu.codecs.InvalidFileStructureException;
22.10 import net.sourceforge.jiu.codecs.UnsupportedTypeException;
22.11 import net.sourceforge.jiu.codecs.tiff.TIFFConstants;
22.12 @@ -26,20 +26,6 @@
22.13 */
22.14 public class TIFFImageFileDirectory implements TIFFConstants
22.15 {
22.16 - public static final int TYPE_BILEVEL_PACKED = 0;
22.17 - public static final int TYPE_GRAY4 = 1;
22.18 - public static final int TYPE_GRAY8 = 2;
22.19 - public static final int TYPE_GRAY16 = 3;
22.20 - public static final int TYPE_PALETTED4 = 4;
22.21 - public static final int TYPE_PALETTED8 = 5;
22.22 - public static final int TYPE_RGB24_INTERLEAVED = 6;
22.23 - public static final int TYPE_RGB48_INTERLEAVED = 7;
22.24 - public static final int TYPE_BILEVEL_BYTE = 8;
22.25 - public static final int TYPE_CMYK32_INTERLEAVED = 9;
22.26 - public static final int TYPE_CMYK32_PLANAR = 10;
22.27 - public static final int TYPE_LOGLUV32_INTERLEAVED = 11;
22.28 - public static final int TYPE_LOGL = 12;
22.29 -
22.30 private String artist;
22.31 private int[] bitsPerSample;
22.32 private int bitsPerPixel;
22.33 @@ -58,7 +44,7 @@
22.34 private int horizontalTiles;
22.35 private String hostComputer;
22.36 private String imageDescription;
22.37 - private int imageType;
22.38 + private TIFFImageType imageType;
22.39 private boolean invertGraySamples;
22.40 private String make;
22.41 private String model;
22.42 @@ -77,13 +63,13 @@
22.43 private int rowsPerStrip;
22.44 private int samplesPerPixel;
22.45 private String software;
22.46 - private Vector stripByteCounts;
22.47 - private Vector stripOffsets;
22.48 + private ArrayList<Object> stripByteCounts;
22.49 + private ArrayList<Object> stripOffsets;
22.50 private int t4Options;
22.51 private int t6Options;
22.52 - private Vector tags;
22.53 - private Vector tileByteCounts;
22.54 - private Vector tileOffsets;
22.55 + private ArrayList<TIFFTag> tags;
22.56 + private ArrayList<Object> tileByteCounts;
22.57 + private ArrayList<Object> tileOffsets;
22.58 private TimeZone timeZone;
22.59 private int tileWidth;
22.60 private int tileHeight;
22.61 @@ -97,7 +83,7 @@
22.62 public TIFFImageFileDirectory()
22.63 {
22.64 initMembers();
22.65 - tags = new Vector();
22.66 + tags = new ArrayList<TIFFTag>();
22.67 }
22.68
22.69 /**
22.70 @@ -106,7 +92,7 @@
22.71 */
22.72 public void append(TIFFTag tag)
22.73 {
22.74 - tags.addElement(tag);
22.75 + tags.add(tag);
22.76 }
22.77
22.78 private void checkContent() throws
22.79 @@ -142,18 +128,18 @@
22.80 {
22.81 if (bitsPerSample[0] == 1)
22.82 {
22.83 - imageType = TYPE_BILEVEL_PACKED;
22.84 + imageType = TIFFImageType.BILEVEL_PACKED;
22.85 }
22.86 else
22.87 {
22.88 if (bitsPerSample[0] == 4)
22.89 {
22.90 - imageType = TYPE_GRAY4;
22.91 + imageType = TIFFImageType.GRAY4;
22.92 }
22.93 else
22.94 if (bitsPerSample[0] == 8)
22.95 {
22.96 - imageType = TYPE_GRAY8;
22.97 + imageType = TIFFImageType.GRAY8;
22.98 }
22.99 else
22.100 {
22.101 @@ -182,12 +168,12 @@
22.102 }
22.103 if (bitsPerPixel == 24)
22.104 {
22.105 - imageType = TYPE_RGB24_INTERLEAVED;
22.106 + imageType = TIFFImageType.RGB24_INTERLEAVED;
22.107 }
22.108 else
22.109 if (bitsPerPixel == 48)
22.110 {
22.111 - imageType = TYPE_RGB48_INTERLEAVED;
22.112 + imageType = TIFFImageType.RGB48_INTERLEAVED;
22.113 }
22.114 else
22.115 {
22.116 @@ -199,7 +185,7 @@
22.117 {
22.118 if (planarConfiguration == PLANAR_CONFIGURATION_CHUNKY)
22.119 {
22.120 - imageType = TYPE_LOGLUV32_INTERLEAVED;
22.121 + imageType = TIFFImageType.LOGLUV32_INTERLEAVED;
22.122 }
22.123 else
22.124 {
22.125 @@ -209,14 +195,14 @@
22.126 }
22.127 case(PHOTOMETRIC_LOGL):
22.128 {
22.129 - imageType = TYPE_LOGL;
22.130 + imageType = TIFFImageType.LOGL;
22.131 break;
22.132 }
22.133 case(PHOTOMETRIC_TRUECOLOR_CMYK):
22.134 {
22.135 if (planarConfiguration == PLANAR_CONFIGURATION_CHUNKY)
22.136 {
22.137 - imageType = TYPE_CMYK32_INTERLEAVED;
22.138 + imageType = TIFFImageType.CMYK32_INTERLEAVED;
22.139 }
22.140 /*else
22.141 if (planarConfiguration == PLANAR_CONFIGURATION_PLANAR)
22.142 @@ -241,7 +227,7 @@
22.143 throw new UnsupportedTypeException("Number of bits per pixel must be 1 for " +
22.144 "compression type: " + getCompressionName(compression) + ".");
22.145 }
22.146 - imageType = TYPE_BILEVEL_BYTE;
22.147 + imageType = TIFFImageType.BILEVEL_BYTE;
22.148 }
22.149 // TODO more validity checks
22.150 }
22.151 @@ -253,7 +239,7 @@
22.152 {
22.153 if (bitsPerPixel == 1)
22.154 {
22.155 - if (imageType == TYPE_BILEVEL_BYTE)
22.156 + if (imageType == TIFFImageType.BILEVEL_BYTE)
22.157 {
22.158 return numPixels;
22.159 }
22.160 @@ -324,12 +310,12 @@
22.161 {
22.162 if (stripByteCounts != null)
22.163 {
22.164 - return ((Number)stripByteCounts.elementAt(tileIndex)).intValue();
22.165 + return ((Number)stripByteCounts.get(tileIndex)).intValue();
22.166 }
22.167 else
22.168 if (tileByteCounts != null)
22.169 {
22.170 - return ((Number)tileByteCounts.elementAt(tileIndex)).intValue();
22.171 + return ((Number)tileByteCounts.get(tileIndex)).intValue();
22.172 }
22.173 else
22.174 {
22.175 @@ -449,7 +435,7 @@
22.176 return imageDescription;
22.177 }
22.178
22.179 - public int getImageType()
22.180 + public TIFFImageType getImageType()
22.181 {
22.182 return imageType;
22.183 }
22.184 @@ -509,7 +495,7 @@
22.185 return software;
22.186 }
22.187
22.188 - public Vector getStripOffsets()
22.189 + public ArrayList<Object> getStripOffsets()
22.190 {
22.191 return stripOffsets;
22.192 }
22.193 @@ -533,13 +519,13 @@
22.194 {
22.195 if (stripOffsets != null)
22.196 {
22.197 - Number number = (Number)stripOffsets.elementAt(tileIndex);
22.198 + Number number = (Number)stripOffsets.get(tileIndex);
22.199 return number.longValue();
22.200 }
22.201 else
22.202 if (tileOffsets != null)
22.203 {
22.204 - Number number = (Number)tileOffsets.elementAt(tileIndex);
22.205 + Number number = (Number)tileOffsets.get(tileIndex);
22.206 return number.longValue();
22.207 }
22.208 else
22.209 @@ -644,7 +630,7 @@
22.210 int index = 0;
22.211 while (index < tags.size())
22.212 {
22.213 - TIFFTag tag = (TIFFTag)tags.elementAt(index++);
22.214 + TIFFTag tag = tags.get(index++);
22.215 int id = tag.getId();
22.216 int count = tag.getCount();
22.217 int type = tag.getType();
22.218 @@ -905,12 +891,12 @@
22.219 throw new InvalidFileStructureException("There is " +
22.220 "only one strip offset, but its type is not integer.");
22.221 }
22.222 - stripByteCounts = new Vector();
22.223 - stripByteCounts.addElement(new Long(tag.getOffset()));
22.224 + stripByteCounts = new ArrayList<Object>();
22.225 + stripByteCounts.add(new Long(tag.getOffset()));
22.226 }
22.227 else
22.228 {
22.229 - stripByteCounts = tag.getVector();
22.230 + stripByteCounts = tag.getArrayList();
22.231 }
22.232 break;
22.233 }
22.234 @@ -927,12 +913,12 @@
22.235 throw new InvalidFileStructureException("There is " +
22.236 "only one strip offset, but its type is not integer.");
22.237 }
22.238 - stripOffsets = new Vector();
22.239 - stripOffsets.addElement(new Long(tag.getOffset()));
22.240 + stripOffsets = new ArrayList<Object>();
22.241 + stripOffsets.add(new Long(tag.getOffset()));
22.242 }
22.243 else
22.244 {
22.245 - stripOffsets = tag.getVector();
22.246 + stripOffsets = tag.getArrayList();
22.247 }
22.248 numStrips = count;
22.249 numTiles = count;
22.250 @@ -993,12 +979,12 @@
22.251 throw new InvalidFileStructureException("There is " +
22.252 "only one tile offset, but its type is not integer.");
22.253 }
22.254 - tileOffsets = new Vector();
22.255 - tileOffsets.addElement(new Long(tag.getOffset()));
22.256 + tileOffsets = new ArrayList<Object>();
22.257 + tileOffsets.add(new Long(tag.getOffset()));
22.258 }
22.259 else
22.260 {
22.261 - tileOffsets = tag.getVector();
22.262 + tileOffsets = tag.getArrayList();
22.263 }
22.264 numStrips = count;
22.265 numTiles = count;
22.266 @@ -1036,12 +1022,12 @@
22.267 {
22.268 if (bitsPerPixel == 4)
22.269 {
22.270 - imageType = TYPE_PALETTED4;
22.271 + imageType = TIFFImageType.PALETTED4;
22.272 }
22.273 else
22.274 if (bitsPerPixel == 8)
22.275 {
22.276 - imageType = TYPE_PALETTED8;
22.277 + imageType = TIFFImageType.PALETTED8;
22.278 }
22.279 else
22.280 {
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/net/sourceforge/jiu/codecs/tiff/TIFFImageType.java Sat Aug 08 23:06:58 2009 +0200
23.3 @@ -0,0 +1,44 @@
23.4 +/*
23.5 + * Copyright (C) 2007, 2008, 2009 Knut Arild Erstad
23.6 + *
23.7 + * This file is part of JIU, the Java Imaging Utilities.
23.8 + *
23.9 + * JIU is free software; you can redistribute it and/or modify
23.10 + * it under the terms of the GNU General Public License version 2,
23.11 + * as published by the Free Software Foundation.
23.12 + *
23.13 + * Contributions by Knut Arild Erstad can be redistributed and/or
23.14 + * modified under GPL 2 or any later versions.
23.15 + *
23.16 + * JIU is distributed in the hope that it will be useful,
23.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.19 + * GNU General Public License for more details.
23.20 + *
23.21 + * You should have received a copy of the GNU General Public License
23.22 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
23.23 + */
23.24 +package net.sourceforge.jiu.codecs.tiff;
23.25 +
23.26 +/**
23.27 + * Enumerates the supported TIFF image types.
23.28 + *
23.29 + * @author Marco Schmidt
23.30 + * @author Knut Arild Erstad
23.31 + */
23.32 +public enum TIFFImageType
23.33 +{
23.34 + BILEVEL_PACKED,
23.35 + GRAY4,
23.36 + GRAY8,
23.37 + GRAY16,
23.38 + PALETTED4,
23.39 + PALETTED8,
23.40 + RGB24_INTERLEAVED,
23.41 + RGB48_INTERLEAVED,
23.42 + BILEVEL_BYTE,
23.43 + CMYK32_INTERLEAVED,
23.44 + CMYK32_PLANAR,
23.45 + LOGLUV32_INTERLEAVED,
23.46 + LOGL;
23.47 +}
24.1 --- a/net/sourceforge/jiu/codecs/tiff/TIFFTag.java Mon Aug 03 23:22:22 2009 +0200
24.2 +++ b/net/sourceforge/jiu/codecs/tiff/TIFFTag.java Sat Aug 08 23:06:58 2009 +0200
24.3 @@ -7,7 +7,7 @@
24.4
24.5 package net.sourceforge.jiu.codecs.tiff;
24.6
24.7 -import java.util.Vector;
24.8 +import java.util.ArrayList;
24.9 import net.sourceforge.jiu.codecs.tiff.TIFFConstants;
24.10
24.11 /**
24.12 @@ -36,7 +36,7 @@
24.13 private int type;
24.14 private int count;
24.15 private int offset;
24.16 - private Vector objects;
24.17 + private ArrayList<Object> objects;
24.18
24.19 /**
24.20 * Creates a new tag with the given ID, type, number of objects / primitives stored in it
24.21 @@ -56,7 +56,7 @@
24.22 objects = null;
24.23 }
24.24
24.25 - public TIFFTag(int id, int type, int count, int offset, Vector vector)
24.26 + public TIFFTag(int id, int type, int count, int offset, ArrayList<Object> vector)
24.27 {
24.28 this(id, type, count, offset);
24.29 objects = vector;
24.30 @@ -105,8 +105,8 @@
24.31 }
24.32
24.33 /**
24.34 - * Returns an object from this tag's Vector of items,
24.35 - * or <code>null</code> if no such Vector exists.
24.36 + * Returns an object from this tag's ArrayList of items,
24.37 + * or <code>null</code> if no such ArrayList exists.
24.38 */
24.39 public Object getObject(int index)
24.40 {
24.41 @@ -116,7 +116,7 @@
24.42 }
24.43 else
24.44 {
24.45 - return objects.elementAt(index);
24.46 + return objects.get(index);
24.47 }
24.48 }
24.49
24.50 @@ -129,7 +129,7 @@
24.51 }
24.52
24.53 /**
24.54 - * If this tag has a Vector of items and if the first item
24.55 + * If this tag has a ArrayList of items and if the first item
24.56 * is a String, that String is returned, <code>null</code>
24.57 * otherwise.
24.58 */
24.59 @@ -137,7 +137,7 @@
24.60 {
24.61 if (objects != null && objects.size() > 0)
24.62 {
24.63 - Object o = objects.elementAt(0);
24.64 + Object o = objects.get(0);
24.65 if (o != null && o instanceof String)
24.66 {
24.67 return (String)o;
24.68 @@ -155,10 +155,10 @@
24.69 }
24.70
24.71 /**
24.72 - * Returns the Vector encapsulating the items stored in this tag.
24.73 - * @see #setVector
24.74 + * Returns the ArrayList encapsulating the items stored in this tag.
24.75 + * @see #setArrayList
24.76 */
24.77 - public Vector getVector()
24.78 + public ArrayList<Object> getArrayList()
24.79 {
24.80 return objects;
24.81 }
24.82 @@ -177,14 +177,14 @@
24.83
24.84 /**
24.85 * If this tag encapsulates more than one item or a single
24.86 - * item that does not fit into four bytes, this Vector
24.87 + * item that does not fit into four bytes, this ArrayList
24.88 * will store all elements in it.
24.89 - * The size() method called on that Vector object returns
24.90 + * The size() method called on that ArrayList object returns
24.91 * the same value as getCount().
24.92 - * @param vector the Vector with the items to be encapsulated by this tag
24.93 - * @see #getVector
24.94 + * @param vector the ArrayList with the items to be encapsulated by this tag
24.95 + * @see #getArrayList
24.96 */
24.97 - public void setVector(Vector vector)
24.98 + public void setArrayList(ArrayList<Object> vector)
24.99 {
24.100 objects = vector;
24.101 }
25.1 --- a/net/sourceforge/jiu/color/adjustment/Brightness.java Mon Aug 03 23:22:22 2009 +0200
25.2 +++ b/net/sourceforge/jiu/color/adjustment/Brightness.java Sat Aug 08 23:06:58 2009 +0200
25.3 @@ -95,7 +95,7 @@
25.4 {
25.5 if (brightness < 0)
25.6 {
25.7 - result[i] = (int)((float)i * (100.0f + brightness) / 100.0f);
25.8 + result[i] = (int)(i * (100.0f + brightness) / 100.0f);
25.9 }
25.10 else
25.11 {
26.1 --- a/net/sourceforge/jiu/color/adjustment/EqualizeHistogram.java Mon Aug 03 23:22:22 2009 +0200
26.2 +++ b/net/sourceforge/jiu/color/adjustment/EqualizeHistogram.java Sat Aug 08 23:06:58 2009 +0200
26.3 @@ -52,7 +52,7 @@
26.4 {
26.5 sum += hist.getEntry(i);
26.6 long result = sum * MAX_SAMPLE / NUM_PIXELS;
26.7 - if (result > (long)Integer.MAX_VALUE)
26.8 + if (result > Integer.MAX_VALUE)
26.9 {
26.10 throw new IllegalStateException("Result does not fit into an int.");
26.11 }
27.1 --- a/net/sourceforge/jiu/color/adjustment/HueSaturationValue.java Mon Aug 03 23:22:22 2009 +0200
27.2 +++ b/net/sourceforge/jiu/color/adjustment/HueSaturationValue.java Sat Aug 08 23:06:58 2009 +0200
27.3 @@ -304,7 +304,7 @@
27.4 else
27.5 if (saturation > 0)
27.6 {
27.7 - sMult = ((float)saturation) / 100.0f;
27.8 + sMult = saturation / 100.0f;
27.9 }
27.10 else
27.11 {
27.12 @@ -322,7 +322,7 @@
27.13 else
27.14 if (value > 0)
27.15 {
27.16 - vMult = ((float)value) / 100.0f;
27.17 + vMult = value / 100.0f;
27.18 }
27.19 else
27.20 {
28.1 --- a/net/sourceforge/jiu/color/analysis/Histogram1DCreator.java Mon Aug 03 23:22:22 2009 +0200
28.2 +++ b/net/sourceforge/jiu/color/analysis/Histogram1DCreator.java Sat Aug 08 23:06:58 2009 +0200
28.3 @@ -10,7 +10,6 @@
28.4 import net.sourceforge.jiu.color.data.ArrayHistogram1D;
28.5 import net.sourceforge.jiu.color.data.Histogram1D;
28.6 import net.sourceforge.jiu.data.IntegerImage;
28.7 -import net.sourceforge.jiu.data.RGBIntegerImage;
28.8 import net.sourceforge.jiu.ops.Operation;
28.9 import net.sourceforge.jiu.ops.MissingParameterException;
28.10 import net.sourceforge.jiu.ops.WrongParameterException;
28.11 @@ -81,7 +80,7 @@
28.12 try
28.13 {
28.14 Histogram1DCreator hc = new Histogram1DCreator();
28.15 - hc.setImage((RGBIntegerImage)image);
28.16 + hc.setImage(image);
28.17 hc.process();
28.18 Histogram1D hist = hc.getHistogram();
28.19 return new Integer(hist.getNumUsedEntries());
29.1 --- a/net/sourceforge/jiu/color/analysis/Histogram3DCreator.java Mon Aug 03 23:22:22 2009 +0200
29.2 +++ b/net/sourceforge/jiu/color/analysis/Histogram3DCreator.java Sat Aug 08 23:06:58 2009 +0200
29.3 @@ -11,7 +11,6 @@
29.4 import net.sourceforge.jiu.color.data.NaiveHistogram3D;
29.5 import net.sourceforge.jiu.color.data.OnDemandHistogram3D;
29.6 import net.sourceforge.jiu.data.IntegerImage;
29.7 -import net.sourceforge.jiu.data.RGBIntegerImage;
29.8 import net.sourceforge.jiu.ops.Operation;
29.9 import net.sourceforge.jiu.ops.MissingParameterException;
29.10 import net.sourceforge.jiu.ops.WrongParameterException;
29.11 @@ -49,7 +48,7 @@
29.12 try
29.13 {
29.14 Histogram3DCreator hc = new Histogram3DCreator();
29.15 - hc.setImage((RGBIntegerImage)image);
29.16 + hc.setImage(image);
29.17 hc.process();
29.18 Histogram3D hist = hc.getHistogram();
29.19 return new Integer(hist.getNumUsedEntries());
30.1 --- a/net/sourceforge/jiu/color/data/BaseCoOccurrenceFrequencyMatrix.java Mon Aug 03 23:22:22 2009 +0200
30.2 +++ b/net/sourceforge/jiu/color/data/BaseCoOccurrenceFrequencyMatrix.java Sat Aug 08 23:06:58 2009 +0200
30.3 @@ -39,7 +39,7 @@
30.4 {
30.5 result += getValue(i, j);
30.6 }
30.7 - cofMean[j] = result / ((double)getDimension());
30.8 + cofMean[j] = result / getDimension();
30.9 }
30.10 //System.out.println("DEBUG: done computing cofm mean values");
30.11 }
31.1 --- a/net/sourceforge/jiu/color/data/OnDemandHistogram3D.java Mon Aug 03 23:22:22 2009 +0200
31.2 +++ b/net/sourceforge/jiu/color/data/OnDemandHistogram3D.java Sat Aug 08 23:06:58 2009 +0200
31.3 @@ -7,7 +7,7 @@
31.4
31.5 package net.sourceforge.jiu.color.data;
31.6
31.7 -import java.util.Hashtable;
31.8 +import java.util.HashMap;
31.9 import net.sourceforge.jiu.color.data.Histogram3D;
31.10
31.11 /**
31.12 @@ -91,7 +91,7 @@
31.13 */
31.14 public class OnDemandHistogram3D implements Histogram3D
31.15 {
31.16 - private Hashtable hash;
31.17 + private HashMap<Histogram3DNode, Histogram3DNode> hash;
31.18 private int numUniqueValues;
31.19 private final int maxValue1;
31.20 private final int maxValue2;
31.21 @@ -117,7 +117,7 @@
31.22 {
31.23 if (hash == null)
31.24 {
31.25 - hash = new Hashtable();
31.26 + hash = new HashMap<Histogram3DNode, Histogram3DNode>();
31.27 }
31.28 else
31.29 {
31.30 @@ -142,7 +142,7 @@
31.31 public int getEntry(int index1, int index2, int index3)
31.32 {
31.33 Histogram3DNode searchNode = createNode(index1, index2, index3);
31.34 - Histogram3DNode counter = (Histogram3DNode)hash.get(searchNode);
31.35 + Histogram3DNode counter = hash.get(searchNode);
31.36 if (counter == null)
31.37 {
31.38 return 0;
31.39 @@ -172,7 +172,7 @@
31.40 public void increaseEntry(int index1, int index2, int index3)
31.41 {
31.42 Histogram3DNode searchNode = createNode(index1, index2, index3);
31.43 - Histogram3DNode counter = (Histogram3DNode)hash.get(searchNode);
31.44 + Histogram3DNode counter = hash.get(searchNode);
31.45 if (counter == null)
31.46 {
31.47 searchNode.setCounter(1);
31.48 @@ -188,7 +188,7 @@
31.49 public void setEntry(int index1, int index2, int index3, int newValue)
31.50 {
31.51 Histogram3DNode searchNode = createNode(index1, index2, index3);
31.52 - Histogram3DNode counter = (Histogram3DNode)hash.get(searchNode);
31.53 + Histogram3DNode counter = hash.get(searchNode);
31.54 if (counter == null)
31.55 {
31.56 searchNode.setCounter(newValue);
32.1 --- a/net/sourceforge/jiu/color/dithering/ClusteredDotDither.java Mon Aug 03 23:22:22 2009 +0200
32.2 +++ b/net/sourceforge/jiu/color/dithering/ClusteredDotDither.java Sat Aug 08 23:06:58 2009 +0200
32.3 @@ -7,6 +7,9 @@
32.4
32.5 package net.sourceforge.jiu.color.dithering;
32.6
32.7 +import java.util.Arrays;
32.8 +import java.util.Comparator;
32.9 +
32.10 import net.sourceforge.jiu.data.BilevelImage;
32.11 import net.sourceforge.jiu.data.GrayIntegerImage;
32.12 import net.sourceforge.jiu.data.MemoryBilevelImage;
32.13 @@ -14,8 +17,6 @@
32.14 import net.sourceforge.jiu.ops.ImageToImageOperation;
32.15 import net.sourceforge.jiu.ops.MissingParameterException;
32.16 import net.sourceforge.jiu.ops.WrongParameterException;
32.17 -import net.sourceforge.jiu.util.ComparatorInterface;
32.18 -import net.sourceforge.jiu.util.Sort;
32.19
32.20 /**
32.21 * Apply a clustered dot ordered dither to a grayscale image, converting
32.22 @@ -185,14 +186,12 @@
32.23 */
32.24 public void setDitherMatrix(int width, int height, SpotFunction f)
32.25 {
32.26 - class MatrixElement implements ComparatorInterface
32.27 + class MatrixElement implements Comparator<MatrixElement>
32.28 {
32.29 int index;
32.30 double value;
32.31 - public int compare(Object o1, Object o2)
32.32 + public int compare(MatrixElement e1, MatrixElement e2)
32.33 {
32.34 - MatrixElement e1 = (MatrixElement)o1;
32.35 - MatrixElement e2 = (MatrixElement)o2;
32.36 if (e1.value < e2.value)
32.37 {
32.38 return -1;
32.39 @@ -238,7 +237,7 @@
32.40 boolean balanced = f.isBalanced();
32.41 if (!balanced)
32.42 {
32.43 - Sort.sort(matrixElements, matrixElements[0]);
32.44 + Arrays.sort(matrixElements, matrixElements[0]);
32.45 }
32.46 for (int i = 0; i < data.length; i++)
32.47 {
33.1 --- a/net/sourceforge/jiu/color/dithering/ErrorDiffusionDithering.java Mon Aug 03 23:22:22 2009 +0200
33.2 +++ b/net/sourceforge/jiu/color/dithering/ErrorDiffusionDithering.java Sat Aug 08 23:06:58 2009 +0200
33.3 @@ -2,6 +2,7 @@
33.4 * ErrorDiffusionDithering
33.5 *
33.6 * Copyright (c) 2001, 2002, 2003, 2004 Marco Schmidt.
33.7 + * Copyright (c) 2009 Knut Arild Erstad.
33.8 * All rights reserved.
33.9 */
33.10
33.11 @@ -91,47 +92,48 @@
33.12 */
33.13 public class ErrorDiffusionDithering extends ImageToImageOperation implements RGBIndex
33.14 {
33.15 - /**
33.16 - * Constant for Floyd-Steinberg error diffusion.
33.17 - * The quantization error is distributed to four neighboring pixels.
33.18 - */
33.19 - public static final int TYPE_FLOYD_STEINBERG = 0;
33.20 -
33.21 - /**
33.22 - * Constant for Stucki error diffusion.
33.23 - * The quantization error is distributed to twelve neighboring pixels.
33.24 - */
33.25 - public static final int TYPE_STUCKI = 1;
33.26 -
33.27 - /**
33.28 - * Constant for Burkes error diffusion.
33.29 - * The quantization error is distributed to seven neighboring pixels.
33.30 - */
33.31 - public static final int TYPE_BURKES = 2;
33.32 -
33.33 - /**
33.34 - * Constant for Burkes error diffusion.
33.35 - * The quantization error is distributed to ten neighboring pixels.
33.36 - */
33.37 - public static final int TYPE_SIERRA = 3;
33.38 -
33.39 - /**
33.40 - * Constant for Burkes error diffusion.
33.41 - * The quantization error is distributed to twelve neighboring pixels.
33.42 - */
33.43 - public static final int TYPE_JARVIS_JUDICE_NINKE= 4;
33.44 -
33.45 - /**
33.46 - * Constant for Burkes error diffusion.
33.47 - * The quantization error is distributed to twelve neighboring pixels.
33.48 - */
33.49 - public static final int TYPE_STEVENSON_ARCE = 5;
33.50 -
33.51 - /**
33.52 - * The default error diffusion type, to be used if none is specified by the user:
33.53 - * (@link #TYPE_FLOYD_STEINBERG}.
33.54 - */
33.55 - public static final int DEFAULT_TYPE = TYPE_FLOYD_STEINBERG;
33.56 + public enum ErrorDiffusionType
33.57 + {
33.58 + /**
33.59 + * Floyd-Steinberg error diffusion.
33.60 + * The quantization error is distributed to four neighboring pixels.
33.61 + */
33.62 + FLOYD_STEINBERG,
33.63 + /**
33.64 + * Stucki error diffusion.
33.65 + * The quantization error is distributed to twelve neighboring pixels.
33.66 + */
33.67 + STUCKI,
33.68 + /**
33.69 + * Burkes error diffusion.
33.70 + * The quantization error is distributed to seven neighboring pixels.
33.71 + */
33.72 + BURKES,
33.73 + /**
33.74 + * Sierra error diffusion.
33.75 + * The quantization error is distributed to ten neighboring pixels.
33.76 + */
33.77 + SIERRA,
33.78 + /**
33.79 + * Jarvis-Judice-Ninke error diffusion.
33.80 + * The quantization error is distributed to twelve neighboring pixels.
33.81 + */
33.82 + JARVIS_JUDICE_NINKE,
33.83 + /**
33.84 + * Stevenson-Arce error diffusion.
33.85 + * The quantization error is distributed to twelve neighboring pixels.
33.86 + */
33.87 + STEVENSON_ARCE;
33.88 +
33.89 + /**
33.90 + * The default error diffusion type, to be used if none is specified by the user.
33.91 + * @return FLOYD_STEINBERG
33.92 + */
33.93 + public static ErrorDiffusionType getDefault()
33.94 + {
33.95 + return FLOYD_STEINBERG;
33.96 + }
33.97 + }
33.98
33.99 /**
33.100 * The index for the horizontal position of a neighbor pixel.
33.101 @@ -235,11 +237,11 @@
33.102
33.103 /**
33.104 * Creates a new object of this class and set the dithering type to
33.105 - * {@link #DEFAULT_TYPE}.
33.106 + * {@link ErrorDiffusionType.getDefault()}.
33.107 */
33.108 public ErrorDiffusionDithering()
33.109 {
33.110 - setTemplateType(DEFAULT_TYPE);
33.111 + setTemplateType(ErrorDiffusionType.getDefault());
33.112 }
33.113
33.114 /**
33.115 @@ -832,36 +834,36 @@
33.116 * @param type int value, one of the TYPE_xyz constants of this class
33.117 * @throws IllegalArgumentException if the argument is not of the TYPE_xyz constants
33.118 */
33.119 - public void setTemplateType(int type)
33.120 + public void setTemplateType(ErrorDiffusionType type)
33.121 {
33.122 switch(type)
33.123 {
33.124 - case(TYPE_FLOYD_STEINBERG):
33.125 + case FLOYD_STEINBERG:
33.126 {
33.127 templateData = FLOYD_STEINBERG_DATA;
33.128 break;
33.129 }
33.130 - case(TYPE_STUCKI):
33.131 + case STUCKI:
33.132 {
33.133 templateData = STUCKI_DATA;
33.134 break;
33.135 }
33.136 - case(TYPE_BURKES):
33.137 + case BURKES:
33.138 {
33.139 templateData = BURKES_DATA;
33.140 break;
33.141 }
33.142 - case(TYPE_SIERRA):
33.143 + case SIERRA:
33.144 {
33.145 templateData = SIERRA_DATA;
33.146 break;
33.147 }
33.148 - case(TYPE_JARVIS_JUDICE_NINKE):
33.149 + case JARVIS_JUDICE_NINKE:
33.150 {
33.151 templateData = JARVIS_JUDICE_NINKE_DATA;
33.152 break;
33.153 }
33.154 - case(TYPE_STEVENSON_ARCE):
33.155 + case STEVENSON_ARCE:
33.156 {
33.157 templateData = STEVENSON_ARCE_DATA;
33.158 break;
34.1 --- a/net/sourceforge/jiu/color/io/MatrixSerialization.java Mon Aug 03 23:22:22 2009 +0200
34.2 +++ b/net/sourceforge/jiu/color/io/MatrixSerialization.java Sat Aug 08 23:06:58 2009 +0200
34.3 @@ -33,7 +33,7 @@
34.4 out.println(Integer.toString(dim));
34.5 for (int i = 0; i < dim; i++)
34.6 {
34.7 - StringBuffer sb = new StringBuffer();
34.8 + StringBuilder sb = new StringBuilder();
34.9 for (int j = 0; j < dim; j++)
34.10 {
34.11 sb.append(matrix.getValue(i, j));
34.12 @@ -53,7 +53,7 @@
34.13 out.println(Integer.toString(dim));
34.14 for (int i = 0; i < dim; i++)
34.15 {
34.16 - StringBuffer sb = new StringBuffer();
34.17 + StringBuilder sb = new StringBuilder();
34.18 for (int j = 0; j < dim; j++)
34.19 {
34.20 sb.append(matrix.getValue(i, j));
35.1 --- a/net/sourceforge/jiu/color/io/PaletteSerialization.java Mon Aug 03 23:22:22 2009 +0200
35.2 +++ b/net/sourceforge/jiu/color/io/PaletteSerialization.java Sat Aug 08 23:06:58 2009 +0200
35.3 @@ -10,7 +10,6 @@
35.4 import java.io.File;
35.5 import java.io.FileOutputStream;
35.6 import java.io.IOException;
35.7 -import java.util.Vector;
35.8 import net.sourceforge.jiu.codecs.ImageLoader;
35.9 import net.sourceforge.jiu.codecs.PNMCodec;
35.10 import net.sourceforge.jiu.data.MemoryRGB24Image;
35.11 @@ -92,7 +91,7 @@
35.12 PixelImage image;
35.13 try
35.14 {
35.15 - image = ImageLoader.load(paletteFile, (Vector)null);
35.16 + image = ImageLoader.load(paletteFile, null);
35.17 }
35.18 catch (Exception e)
35.19 {
36.1 --- a/net/sourceforge/jiu/color/quantization/MedianCutContourRemoval.java Mon Aug 03 23:22:22 2009 +0200
36.2 +++ b/net/sourceforge/jiu/color/quantization/MedianCutContourRemoval.java Sat Aug 08 23:06:58 2009 +0200
36.3 @@ -7,8 +7,10 @@
36.4
36.5 package net.sourceforge.jiu.color.quantization;
36.6
36.7 -import java.util.Hashtable;
36.8 -import java.util.Vector;
36.9 +import java.util.Arrays;
36.10 +import java.util.Comparator;
36.11 +import java.util.HashSet;
36.12 +import java.util.ArrayList;
36.13 import net.sourceforge.jiu.codecs.BMPCodec;
36.14 import net.sourceforge.jiu.codecs.CodecMode;
36.15 import net.sourceforge.jiu.codecs.ImageLoader;
36.16 @@ -25,8 +27,6 @@
36.17 import net.sourceforge.jiu.ops.MissingParameterException;
36.18 import net.sourceforge.jiu.ops.OperationFailedException;
36.19 import net.sourceforge.jiu.ops.WrongParameterException;
36.20 -import net.sourceforge.jiu.util.ComparatorInterface;
36.21 -import net.sourceforge.jiu.util.Sort;
36.22 import net.sourceforge.jiu.util.Statistics;
36.23
36.24 /**
36.25 @@ -36,7 +36,7 @@
36.26 * @author Marco Schmidt
36.27 * @see MedianCutContourRemoval
36.28 */
36.29 -class ContouringColorPair implements ComparatorInterface
36.30 +class ContouringColorPair implements Comparator<Object>
36.31 {
36.32 private int index1;
36.33 private int index2;
36.34 @@ -233,8 +233,8 @@
36.35 */
36.36 public static final int DEFAULT_NUM_PASSES = 8;
36.37
36.38 - private Vector compressibleNodes;
36.39 - private Vector contouringPairs;
36.40 + private ArrayList<MedianCutNode> compressibleNodes;
36.41 + private ArrayList<ContouringColorPair> contouringPairs;
36.42 private MedianCutNode[] leaves;
36.43 private double[] meanC;
36.44 private double meanS;
36.45 @@ -295,26 +295,26 @@
36.46 * Takes
36.47 * @return
36.48 */
36.49 - private Vector createContouringIndexList()
36.50 + private ArrayList<Integer> createContouringIndexList()
36.51 {
36.52 - Hashtable table = new Hashtable(contouringPairs.size() * 2);
36.53 - Vector indexes = new Vector();
36.54 - Object[] contouringPairArray = toArray(contouringPairs);
36.55 - Sort.sort(contouringPairArray, new ContouringColorPair());
36.56 + HashSet<Integer> set = new HashSet<Integer>(contouringPairs.size() * 2);
36.57 + ArrayList<Integer> indexes = new ArrayList<Integer>();
36.58 + Object[] contouringPairArray = contouringPairs.toArray();
36.59 + Arrays.sort(contouringPairArray, new ContouringColorPair());
36.60 for (int i = contouringPairArray.length - 1; i >= 0; i--)
36.61 {
36.62 ContouringColorPair pair = (ContouringColorPair)contouringPairArray[i];
36.63 - Integer index = new Integer(pair.getColorIndex(false));
36.64 - if (table.get(index) == null)
36.65 + int index = pair.getColorIndex(false);
36.66 + if (!set.contains(index))
36.67 {
36.68 - table.put(index, index);
36.69 - indexes.addElement(index);
36.70 + set.add(index);
36.71 + indexes.add(index);
36.72 }
36.73 - index = new Integer(pair.getColorIndex(true));
36.74 - if (table.get(index) == null)
36.75 + index = pair.getColorIndex(true);
36.76 + if (!set.contains(index))
36.77 {
36.78 - table.put(index, index);
36.79 - indexes.addElement(index);
36.80 + set.add(index);
36.81 + indexes.add(index);
36.82 }
36.83 }
36.84 return indexes;
36.85 @@ -322,8 +322,8 @@
36.86
36.87 private void findColorPairs(CoOccurrenceFrequencyMatrix matrix, final CoOccurrenceMatrix A)
36.88 {
36.89 - compressibleNodes = new Vector();
36.90 - contouringPairs = new Vector();
36.91 + compressibleNodes = new ArrayList<MedianCutNode>();
36.92 + contouringPairs = new ArrayList<ContouringColorPair>();
36.93 final int N = quantizer.getPaletteSize();
36.94 for (int i = 0; i < N; i++)
36.95 {
36.96 @@ -338,7 +338,7 @@
36.97 matrix.getValue(j, i) > meanC[i] + stdDevC[i] &&
36.98 computeDistance(i, j) <= tau)
36.99 {
36.100 - contouringPairs.addElement(new ContouringColorPair(i, j, SI, SJ));
36.101 + contouringPairs.add(new ContouringColorPair(i, j, SI, SJ));
36.102 }
36.103 }
36.104 else
36.105 @@ -350,7 +350,7 @@
36.106 if (parentI == parentJ && A.getValue(i, j) == 0 && parentI.getNumColors() > 1)
36.107 {
36.108 System.out.println("compressible: " + i + "/" + j);
36.109 - compressibleNodes.addElement(parentI);
36.110 + compressibleNodes.add(parentI);
36.111 }
36.112 }
36.113 }
36.114 @@ -392,17 +392,17 @@
36.115
36.116 private void mergeAndSplit()
36.117 {
36.118 - Vector contouringIndexes = createContouringIndexList();
36.119 + ArrayList<Integer> contouringIndexes = createContouringIndexList();
36.120 final int ITERATIONS = Math.min(contouringIndexes.size(), compressibleNodes.size());
36.121 int index = 0;
36.122 do
36.123 {
36.124 // make the node a leaf by setting its two successors (which are leaves) to null
36.125 - MedianCutNode compressibleNode = (MedianCutNode)compressibleNodes.elementAt(index);
36.126 + MedianCutNode compressibleNode = compressibleNodes.get(index);
36.127 compressibleNode.setSuccessors(null, null);
36.128 // split the contouring color into two
36.129 - Integer contouringIndex = (Integer)contouringIndexes.elementAt(index);
36.130 - MedianCutNode contouringNode = leaves[contouringIndex.intValue()];
36.131 + int contouringIndex = contouringIndexes.get(index);
36.132 + MedianCutNode contouringNode = leaves[contouringIndex];
36.133 quantizer.splitNode(contouringNode);
36.134 index++;
36.135 }
36.136 @@ -515,21 +515,4 @@
36.137 }
36.138 tau = newValue;
36.139 }
36.140 -
36.141 - /**
36.142 - * Converts a Vector to an Object array.
36.143 - * Since Java 1.2 Vector has a toArray method, but we cannot rely
36.144 - * on 1.2 being available.
36.145 - * @param list Vector with objects
36.146 - * @return Object array with elements from list, in the same order
36.147 - */
36.148 - private Object[] toArray(Vector list)
36.149 - {
36.150 - Object[] result = new Object[list.size()];
36.151 - for (int i = 0; i < list.size(); i++)
36.152 - {
36.153 - result[i] = list.elementAt(i);
36.154 - }
36.155 - return result;
36.156 - }
36.157 }
37.1 --- a/net/sourceforge/jiu/color/quantization/MedianCutQuantizer.java Mon Aug 03 23:22:22 2009 +0200
37.2 +++ b/net/sourceforge/jiu/color/quantization/MedianCutQuantizer.java Sat Aug 08 23:06:58 2009 +0200
37.3 @@ -2,6 +2,7 @@
37.4 * MedianCutQuantizer
37.5 *
37.6 * Copyright (c) 2001, 2002, 2003 Marco Schmidt.
37.7 + * Copyright (c) 2009 Knut Arild Erstad.
37.8 * All rights reserved.
37.9 */
37.10
37.11 @@ -57,48 +58,48 @@
37.12 public class MedianCutQuantizer extends ImageToImageOperation implements RGBIndex, RGBQuantizer
37.13 {
37.14 /**
37.15 - * Constant value for a method of determining the representative color
37.16 - * for a set of colors by computing the average of all samples for each
37.17 - * of the three components red, green and blue.
37.18 - * #getMethodToDetermineRepresentativeColors
37.19 - * #setMethodToDetermineRepresentativeColors
37.20 + * Enumeration of methods of determining the representative color for a set of colors.
37.21 + * @see #getMethodToDetermineRepresentativeColors
37.22 + * @see #setMethodToDetermineRepresentativeColors
37.23 */
37.24 - public static final int METHOD_REPR_COLOR_AVERAGE = 0;
37.25 -
37.26 - /**
37.27 - * Constant value for a method of determining the representative color
37.28 - * for a set of colors by computing the weighted average of all samples for each
37.29 - * of the three components red, green and blue.
37.30 - * Weighted means that each color is multiplied by the number of times it occurs
37.31 - * in the input image.
37.32 - * The values of samples multiplied by their frequency are then divided by the total
37.33 - * number of times the colors appear in the image.
37.34 - * #getMethodToDetermineRepresentativeColors
37.35 - * #setMethodToDetermineRepresentativeColors
37.36 - */
37.37 - public static final int METHOD_REPR_COLOR_WEIGHTED_AVERAGE = 1;
37.38 -
37.39 - /**
37.40 - * Constant value for a method of determining the representative color
37.41 - * for a set of colors by picking the median value of all samples for each
37.42 - * of the three components red, green and blue.
37.43 - * #getMethodToDetermineRepresentativeColors
37.44 - * #setMethodToDetermineRepresentativeColors
37.45 - */
37.46 - public static final int METHOD_REPR_COLOR_MEDIAN = 2;
37.47 -
37.48 - /**
37.49 - * The default method to determine the representative color
37.50 - * from a list of colors.
37.51 - * Will be used if none is set by the user of this class via
37.52 - * {@link #setMethodToDetermineRepresentativeColors}.
37.53 - */
37.54 - public static final int DEFAULT_METHOD_REPR_COLOR = METHOD_REPR_COLOR_MEDIAN;
37.55 + public enum RepresentativeColorMethod
37.56 + {
37.57 + /**
37.58 + * Determine the representative color for a set of colors by computing the
37.59 + * average of all samples for each of the three components red, green and blue.
37.60 + */
37.61 + AVERAGE,
37.62 + /**
37.63 + * Determine the representative color for a set of colors by computing the
37.64 + * weighted average of all samples for each of the three components red,
37.65 + * green and blue.
37.66 + * Weighted means that each color is multiplied by the number of times it occurs
37.67 + * in the input image.
37.68 + * The values of samples multiplied by their frequency are then divided by the total
37.69 + * number of times the colors appear in the image.
37.70 + */
37.71 + WEIGHTED_AVERAGE,
37.72 + /**
37.73 + * Determine the representative color for a set of colors by picking the median
37.74 + * value of all samples for each of the three components red, green and blue.
37.75 + */
37.76 + MEDIAN;
37.77 +
37.78 + /**
37.79 + * Returns the default method.
37.80 + * Will be used if none is set by the user of this class via
37.81 + * {@link #setMethodToDetermineRepresentativeColors}.
37.82 + * @return {@link #AVERAGE}
37.83 + */
37.84 + public static RepresentativeColorMethod getDefault() {
37.85 + return AVERAGE;
37.86 + }
37.87 + }
37.88
37.89 private boolean doNotMap;
37.90 private RGBColorList list;
37.91 private int maxValue;
37.92 - private int method;
37.93 + private RepresentativeColorMethod method;
37.94 private boolean outputTruecolor;
37.95 private int paletteSize;
37.96 private MedianCutNode root;
37.97 @@ -111,7 +112,7 @@
37.98 {
37.99 doNotMap = false;
37.100 maxValue = -1;
37.101 - method = METHOD_REPR_COLOR_AVERAGE;
37.102 + method = RepresentativeColorMethod.getDefault();
37.103 maxValue = 255;
37.104 outputTruecolor = false;
37.105 paletteSize = 256;
37.106 @@ -336,7 +337,7 @@
37.107 temp[2] = 0;
37.108 switch(method)
37.109 {
37.110 - case(METHOD_REPR_COLOR_AVERAGE):
37.111 + case AVERAGE:
37.112 {
37.113 int num = index2 - index1 + 1;
37.114 for (int i = index1; i <= index2; i++)
37.115 @@ -351,7 +352,7 @@
37.116 result[2] = (int)(temp[2] / num);
37.117 return result;
37.118 }
37.119 - case(METHOD_REPR_COLOR_WEIGHTED_AVERAGE):
37.120 + case WEIGHTED_AVERAGE:
37.121 {
37.122 long num = 0;
37.123 for (int i = index1; i <= index2; i++)
37.124 @@ -373,7 +374,7 @@
37.125 result[2] = (int)(temp[2] / num);
37.126 return result;
37.127 }
37.128 - case(METHOD_REPR_COLOR_MEDIAN):
37.129 + case MEDIAN:
37.130 {
37.131 RGBColor color = list.getColor((index1 + index2) / 2);
37.132 result[0] = color.getSample(0);
37.133 @@ -409,10 +410,10 @@
37.134 /**
37.135 * Returns the method (to be) used to determine the representative
37.136 * color for the list of colors of a node.
37.137 - * Default is {@link #DEFAULT_METHOD_REPR_COLOR}.
37.138 - * @return the method, one of the METHOD_xyz constants
37.139 + * Default is defined in {@link RepresentativeColorMethod#getDefault()}.
37.140 + * @return the method enum value
37.141 */
37.142 - public int getMethodToDetermineRepresentativeColors()
37.143 + public RepresentativeColorMethod getMethodToDetermineRepresentativeColors()
37.144 {
37.145 return method;
37.146 }
37.147 @@ -575,13 +576,11 @@
37.148 * the algorithm will determine that color
37.149 * @param newMethod the new method, one of the METHOD_xyz constants in this class
37.150 */
37.151 - public void setMethodToDetermineRepresentativeColors(int newMethod)
37.152 + public void setMethodToDetermineRepresentativeColors(RepresentativeColorMethod newMethod)
37.153 {
37.154 - if (newMethod != METHOD_REPR_COLOR_AVERAGE &&
37.155 - newMethod != METHOD_REPR_COLOR_WEIGHTED_AVERAGE &&
37.156 - newMethod != METHOD_REPR_COLOR_MEDIAN)
37.157 + if (newMethod == null)
37.158 {
37.159 - throw new IllegalArgumentException("Method must be one of the METHOD_xyz constants.");
37.160 + throw new IllegalArgumentException("Method cannot be null");
37.161 }
37.162 method = newMethod;
37.163 }
38.1 --- a/net/sourceforge/jiu/color/quantization/OctreeColorQuantizer.java Mon Aug 03 23:22:22 2009 +0200
38.2 +++ b/net/sourceforge/jiu/color/quantization/OctreeColorQuantizer.java Sat Aug 08 23:06:58 2009 +0200
38.3 @@ -7,6 +7,8 @@
38.4
38.5 package net.sourceforge.jiu.color.quantization;
38.6
38.7 +import java.util.Arrays;
38.8 +
38.9 import net.sourceforge.jiu.color.quantization.RGBQuantizer;
38.10 import net.sourceforge.jiu.data.MemoryPaletted8Image;
38.11 import net.sourceforge.jiu.data.Palette;
38.12 @@ -17,7 +19,6 @@
38.13 import net.sourceforge.jiu.ops.ImageToImageOperation;
38.14 import net.sourceforge.jiu.ops.MissingParameterException;
38.15 import net.sourceforge.jiu.ops.WrongParameterException;
38.16 -import net.sourceforge.jiu.util.Sort;
38.17
38.18 /**
38.19 * Performs the octree color quantization algorithm for a given RGB truecolor image.
38.20 @@ -298,7 +299,7 @@
38.21 // than the desired palette size
38.22 while (length < paletteSize)
38.23 {
38.24 - Sort.sort(a, 0, length - 1, comparator);
38.25 + Arrays.sort(a, 0, length - 1, comparator);
38.26 int index = length - 1;
38.27 while (index >= 0)
38.28 {
39.1 --- a/net/sourceforge/jiu/color/quantization/OctreeNode.java Mon Aug 03 23:22:22 2009 +0200
39.2 +++ b/net/sourceforge/jiu/color/quantization/OctreeNode.java Sat Aug 08 23:06:58 2009 +0200
39.3 @@ -7,8 +7,9 @@
39.4
39.5 package net.sourceforge.jiu.color.quantization;
39.6
39.7 +import java.util.Comparator;
39.8 +
39.9 import net.sourceforge.jiu.data.RGBIndex;
39.10 -import net.sourceforge.jiu.util.ComparatorInterface;
39.11
39.12 /**
39.13 * A single node in an octree.
39.14 @@ -16,7 +17,7 @@
39.15 * @since 0.6.0
39.16 * @see OctreeColorQuantizer
39.17 */
39.18 -public class OctreeNode implements ComparatorInterface, RGBIndex
39.19 +public class OctreeNode implements Comparator<OctreeNode>, RGBIndex
39.20 {
39.21 private int paletteIndex;
39.22 private int pixelCount;
39.23 @@ -76,10 +77,8 @@
39.24 while (true);
39.25 }
39.26
39.27 - public int compare(Object o1, Object o2)
39.28 + public int compare(OctreeNode n1, OctreeNode n2)
39.29 {
39.30 - OctreeNode n1 = (OctreeNode)o1;
39.31 - OctreeNode n2 = (OctreeNode)o2;
39.32 int pc1 = n1.pixelCount;
39.33 int pc2 = n2.pixelCount;
39.34 if (pc1 < pc2)
40.1 --- a/net/sourceforge/jiu/color/quantization/RGBColor.java Mon Aug 03 23:22:22 2009 +0200
40.2 +++ b/net/sourceforge/jiu/color/quantization/RGBColor.java Sat Aug 08 23:06:58 2009 +0200
40.3 @@ -98,6 +98,15 @@
40.4 return (samples[0] == c.samples[0] && samples[1] == c.samples[1] && samples[2] == c.samples[2]);
40.5 }
40.6
40.7 + /**
40.8 + * Overridden to ensure RGBColor objects with equal intensity values
40.9 + * produce the same hash code.
40.10 + */
40.11 + public int hashCode()
40.12 + {
40.13 + return samples[0] ^ (samples[1] << 1) ^ (samples[2] << 2);
40.14 + }
40.15 +
40.16 public int getCounter()
40.17 {
40.18 return counter;
41.1 --- a/net/sourceforge/jiu/color/quantization/RGBColorComparator.java Mon Aug 03 23:22:22 2009 +0200
41.2 +++ b/net/sourceforge/jiu/color/quantization/RGBColorComparator.java Sat Aug 08 23:06:58 2009 +0200
41.3 @@ -7,15 +7,16 @@
41.4
41.5 package net.sourceforge.jiu.color.quantization;
41.6
41.7 +import java.util.Comparator;
41.8 +
41.9 import net.sourceforge.jiu.data.RGBIndex;
41.10 -import net.sourceforge.jiu.util.ComparatorInterface;
41.11
41.12 /**
41.13 * Compares two {@link RGBColor} objects.
41.14 * @author Marco Schmidt
41.15 */
41.16 public class RGBColorComparator implements
41.17 - ComparatorInterface,
41.18 + Comparator<RGBColor>,
41.19 RGBIndex
41.20 {
41.21 private int sortOrder;
41.22 @@ -25,9 +26,9 @@
41.23 setSortOrder(aSortOrder);
41.24 }
41.25
41.26 - public int compare(Object o1, Object o2)
41.27 + public int compare(RGBColor o1, RGBColor o2)
41.28 {
41.29 - return ((RGBColor)o1).compareTo((RGBColor)o2, sortOrder);
41.30 + return o1.compareTo(o2, sortOrder);
41.31 }
41.32
41.33 /**
42.1 --- a/net/sourceforge/jiu/color/quantization/RGBColorList.java Mon Aug 03 23:22:22 2009 +0200
42.2 +++ b/net/sourceforge/jiu/color/quantization/RGBColorList.java Sat Aug 08 23:06:58 2009 +0200
42.3 @@ -7,10 +7,11 @@
42.4
42.5 package net.sourceforge.jiu.color.quantization;
42.6
42.7 +import java.util.Arrays;
42.8 +import java.util.Comparator;
42.9 +
42.10 import net.sourceforge.jiu.color.data.Histogram3D;
42.11 import net.sourceforge.jiu.data.RGBIndex;
42.12 -import net.sourceforge.jiu.util.ComparatorInterface;
42.13 -import net.sourceforge.jiu.util.Sort;
42.14
42.15 /**
42.16 * Holds an array of {@link RGBColor} objects.
42.17 @@ -151,7 +152,7 @@
42.18 */
42.19 public void sortByAxis(int index1, int index2, int axis)
42.20 {
42.21 - Sort.sort(list, index1, index2, new RGBColorComparator(axis));
42.22 + Arrays.sort(list, index1, index2, new RGBColorComparator(axis));
42.23 }
42.24
42.25 /**
42.26 @@ -161,12 +162,10 @@
42.27 */
42.28 public void sortByCounter(int index1, int index2)
42.29 {
42.30 - Sort.sort(list, index1, index2, new ComparatorInterface()
42.31 + Arrays.sort(list, index1, index2, new Comparator<RGBColor>()
42.32 {
42.33 - public int compare(Object obj1, Object obj2)
42.34 + public int compare(RGBColor col1, RGBColor col2)
42.35 {
42.36 - RGBColor col1 = (RGBColor)obj1;
42.37 - RGBColor col2 = (RGBColor)obj2;
42.38 return col1.getCounter() - col2.getCounter();
42.39 }
42.40 });
43.1 --- a/net/sourceforge/jiu/color/reduction/AutoDetectColorType.java Mon Aug 03 23:22:22 2009 +0200
43.2 +++ b/net/sourceforge/jiu/color/reduction/AutoDetectColorType.java Sat Aug 08 23:06:58 2009 +0200
43.3 @@ -2,6 +2,7 @@
43.4 * AutoDetectColorType
43.5 *
43.6 * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Marco Schmidt.
43.7 + * Copyright (c) 2009 Knut Arild Erstad.
43.8 * All rights reserved.
43.9 */
43.10
43.11 @@ -63,24 +64,30 @@
43.12 */
43.13 public class AutoDetectColorType extends Operation
43.14 {
43.15 - public static final int TYPE_UNKNOWN = -1;
43.16 - public static final int TYPE_BILEVEL = 0;
43.17 - public static final int TYPE_GRAY16 = 4;
43.18 - public static final int TYPE_GRAY8 = 1;
43.19 - public static final int TYPE_PALETTED8 = 2;
43.20 - public static final int TYPE_RGB24 = 3;
43.21 - public static final int TYPE_RGB48 = 5;
43.22 -
43.23 + /**
43.24 + * Enumerates the possible color types.
43.25 + * <code>null</code> is used to represent an unknown color type.
43.26 + */
43.27 + public enum ColorType
43.28 + {
43.29 + BILEVEL,
43.30 + GRAY8,
43.31 + PALETTED8,
43.32 + RGB24,
43.33 + GRAY16,
43.34 + RGB48,
43.35 + }
43.36 +
43.37 private PixelImage inputImage;
43.38 private PixelImage outputImage;
43.39 private boolean doConvert;
43.40 - private int type;
43.41 + private ColorType type;
43.42 private Histogram3D hist;
43.43
43.44 public AutoDetectColorType()
43.45 {
43.46 doConvert = true;
43.47 - type = TYPE_UNKNOWN;
43.48 + type = null;
43.49 }
43.50
43.51 /**
43.52 @@ -275,7 +282,7 @@
43.53 * of this class).
43.54 * Can only be called after a successful call to process.
43.55 */
43.56 - public int getType()
43.57 + public ColorType getType()
43.58 {
43.59 return type;
43.60 }
43.61 @@ -290,7 +297,7 @@
43.62 */
43.63 public boolean isReducible()
43.64 {
43.65 - return type != TYPE_UNKNOWN;
43.66 + return type != null;
43.67 }
43.68
43.69 // works for Gray8 and Gray16
43.70 @@ -492,7 +499,7 @@
43.71 {
43.72 if (isGrayBilevel((Gray8Image)inputImage))
43.73 {
43.74 - type = TYPE_BILEVEL;
43.75 + type = ColorType.BILEVEL;
43.76 if (doConvert)
43.77 {
43.78 createBilevelFromGrayOrRgb((Gray8Image)inputImage);
43.79 @@ -505,7 +512,7 @@
43.80 {
43.81 if (isGrayBilevel((Gray16Image)inputImage))
43.82 {
43.83 - type = TYPE_BILEVEL;
43.84 + type = ColorType.BILEVEL;
43.85 if (doConvert)
43.86 {
43.87 createBilevelFromGrayOrRgb((Gray16Image)inputImage);
43.88 @@ -514,7 +521,7 @@
43.89 else
43.90 if (isGray16Gray8((Gray16Image)inputImage))
43.91 {
43.92 - type = TYPE_GRAY16;
43.93 + type = ColorType.GRAY16;
43.94 if (doConvert)
43.95 {
43.96 createGray8FromGray16((Gray16Image)inputImage);
43.97 @@ -527,7 +534,7 @@
43.98 {
43.99 if (isRgbBilevel((RGB24Image)inputImage))
43.100 {
43.101 - type = TYPE_BILEVEL;
43.102 + type = ColorType.BILEVEL;
43.103 if (doConvert)
43.104 {
43.105 createBilevelFromGrayOrRgb((RGB24Image)inputImage);
43.106 @@ -536,7 +543,7 @@
43.107 else
43.108 if (isRgbGray((RGB24Image)inputImage))
43.109 {
43.110 - type = TYPE_GRAY8;
43.111 + type = ColorType.GRAY8;
43.112 if (doConvert)
43.113 {
43.114 outputImage = new MemoryGray8Image(inputImage.getWidth(), inputImage.getHeight());
43.115 @@ -546,7 +553,7 @@
43.116 else
43.117 if (isRgb24Paletted8((RGB24Image)inputImage))
43.118 {
43.119 - type = TYPE_PALETTED8;
43.120 + type = ColorType.PALETTED8;
43.121 if (doConvert)
43.122 {
43.123 createPaletted8FromRgb24((RGB24Image)inputImage);
43.124 @@ -559,7 +566,7 @@
43.125 {
43.126 if (isRgbBilevel((RGB48Image)inputImage))
43.127 {
43.128 - type = TYPE_BILEVEL;
43.129 + type = ColorType.BILEVEL;
43.130 if (doConvert)
43.131 {
43.132 createBilevelFromGrayOrRgb((RGB48Image)inputImage);
43.133 @@ -568,7 +575,7 @@
43.134 else
43.135 if (isRgb48Gray8((RGB48Image)inputImage))
43.136 {
43.137 - type = TYPE_GRAY8;
43.138 + type = ColorType.GRAY8;
43.139 if (doConvert)
43.140 {
43.141 outputImage = new MemoryGray8Image(inputImage.getWidth(), inputImage.getHeight());
43.142 @@ -580,7 +587,7 @@
43.143 else
43.144 if (isRgbGray((RGB48Image)inputImage))
43.145 {
43.146 - type = TYPE_GRAY16;
43.147 + type = ColorType.GRAY16;
43.148 if (doConvert)
43.149 {
43.150 outputImage = new MemoryGray8Image(inputImage.getWidth(), inputImage.getHeight());
43.151 @@ -593,7 +600,7 @@
43.152 // RGB48 input is RGB24; is it also Paletted8?
43.153 if (isRgb48Paletted8((RGB48Image)inputImage))
43.154 {
43.155 - type = TYPE_PALETTED8;
43.156 + type = ColorType.PALETTED8;
43.157 if (doConvert)
43.158 {
43.159 createPaletted8FromRgb48((RGB48Image)inputImage);
43.160 @@ -601,7 +608,7 @@
43.161 }
43.162 else
43.163 {
43.164 - type = TYPE_RGB24;
43.165 + type = ColorType.RGB24;
43.166 if (doConvert)
43.167 {
43.168 outputImage = new MemoryRGB24Image(inputImage.getWidth(), inputImage.getHeight());
43.169 @@ -618,7 +625,7 @@
43.170 Palette palette = in.getPalette();
43.171 if (palette.isBlackAndWhite())
43.172 {
43.173 - type = TYPE_BILEVEL;
43.174 + type = ColorType.BILEVEL;
43.175 if (doConvert)
43.176 {
43.177 createBilevelFromPaletted(in);
43.178 @@ -627,7 +634,7 @@
43.179 else
43.180 if (palette.isGray())
43.181 {
43.182 - type = TYPE_GRAY8;
43.183 + type = ColorType.GRAY8;
43.184 if (doConvert)
43.185 {
43.186 Gray8Image out = new MemoryGray8Image(in.getWidth(), in.getHeight());
44.1 --- a/net/sourceforge/jiu/data/MemoryBilevelImage.java Mon Aug 03 23:22:22 2009 +0200
44.2 +++ b/net/sourceforge/jiu/data/MemoryBilevelImage.java Sat Aug 08 23:06:58 2009 +0200
44.3 @@ -151,7 +151,7 @@
44.4 return HEIGHT;
44.5 }
44.6
44.7 - public Class getImageType()
44.8 + public Class<? extends PixelImage> getImageType()
44.9 {
44.10 return BilevelImage.class;
44.11 }
45.1 --- a/net/sourceforge/jiu/data/MemoryByteChannelImage.java Mon Aug 03 23:22:22 2009 +0200
45.2 +++ b/net/sourceforge/jiu/data/MemoryByteChannelImage.java Sat Aug 08 23:06:58 2009 +0200
45.3 @@ -125,7 +125,7 @@
45.4 // get the correct channel as byte[]
45.5 final byte[] CHANNEL = data[channelIndex];
45.6 // fill channel with the argument value
45.7 - final byte VALUE = (byte)newValue;
45.8 + final byte VALUE = newValue;
45.9 final int LENGTH = CHANNEL.length;
45.10 for (int i = 0; i < LENGTH; i++)
45.11 {
46.1 --- a/net/sourceforge/jiu/data/MemoryGray16Image.java Mon Aug 03 23:22:22 2009 +0200
46.2 +++ b/net/sourceforge/jiu/data/MemoryGray16Image.java Sat Aug 08 23:06:58 2009 +0200
46.3 @@ -37,7 +37,7 @@
46.4 return new MemoryGray16Image(width, height);
46.5 }
46.6
46.7 - public Class getImageType()
46.8 + public Class<? extends PixelImage> getImageType()
46.9 {
46.10 return Gray16Image.class;
46.11 }
47.1 --- a/net/sourceforge/jiu/data/MemoryGray8Image.java Mon Aug 03 23:22:22 2009 +0200
47.2 +++ b/net/sourceforge/jiu/data/MemoryGray8Image.java Sat Aug 08 23:06:58 2009 +0200
47.3 @@ -37,7 +37,7 @@
47.4 return new MemoryGray8Image(width, height);
47.5 }
47.6
47.7 - public Class getImageType()
47.8 + public Class<? extends PixelImage> getImageType()
47.9 {
47.10 return Gray8Image.class;
47.11 }
48.1 --- a/net/sourceforge/jiu/data/MemoryPaletted8Image.java Mon Aug 03 23:22:22 2009 +0200
48.2 +++ b/net/sourceforge/jiu/data/MemoryPaletted8Image.java Sat Aug 08 23:06:58 2009 +0200
48.3 @@ -88,7 +88,7 @@
48.4 return result;
48.5 }
48.6
48.7 - public Class getImageType()
48.8 + public Class<? extends PixelImage> getImageType()
48.9 {
48.10 return Paletted8Image.class;
48.11 }
49.1 --- a/net/sourceforge/jiu/data/MemoryRGB24Image.java Mon Aug 03 23:22:22 2009 +0200
49.2 +++ b/net/sourceforge/jiu/data/MemoryRGB24Image.java Sat Aug 08 23:06:58 2009 +0200
49.3 @@ -33,7 +33,7 @@
49.4 return new MemoryRGB24Image(width, height);
49.5 }
49.6
49.7 - public Class getImageType()
49.8 + public Class<? extends PixelImage> getImageType()
49.9 {
49.10 return RGB24Image.class;
49.11 }
50.1 --- a/net/sourceforge/jiu/data/MemoryRGB48Image.java Mon Aug 03 23:22:22 2009 +0200
50.2 +++ b/net/sourceforge/jiu/data/MemoryRGB48Image.java Sat Aug 08 23:06:58 2009 +0200
50.3 @@ -34,7 +34,7 @@
50.4 return new MemoryRGB48Image(width, height);
50.5 }
50.6
50.7 - public Class getImageType()
50.8 + public Class<? extends PixelImage> getImageType()
50.9 {
50.10 return RGB48Image.class;
50.11 }
51.1 --- a/net/sourceforge/jiu/data/MemoryShortChannelImage.java Mon Aug 03 23:22:22 2009 +0200
51.2 +++ b/net/sourceforge/jiu/data/MemoryShortChannelImage.java Sat Aug 08 23:06:58 2009 +0200
51.3 @@ -119,7 +119,7 @@
51.4 // get the correct channel as short[]
51.5 final short[] CHANNEL = data[channelIndex];
51.6 // fill channel with the argument value
51.7 - final short VALUE = (short)newValue;
51.8 + final short VALUE = newValue;
51.9 final int LENGTH = CHANNEL.length;
51.10 for (int i = 0; i < LENGTH; i++)
51.11 {
52.1 --- a/net/sourceforge/jiu/data/PixelImage.java Mon Aug 03 23:22:22 2009 +0200
52.2 +++ b/net/sourceforge/jiu/data/PixelImage.java Sat Aug 08 23:06:58 2009 +0200
52.3 @@ -75,7 +75,7 @@
52.4 * Example: {@link net.sourceforge.jiu.data.MemoryGray8Image} returns
52.5 * <code>net.sourceforge.jiu.data.Gray8Image.class</code>.
52.6 */
52.7 - Class getImageType();
52.8 + Class<? extends PixelImage> getImageType();
52.9
52.10 /**
52.11 * Returns the number of channels in this image.
53.1 --- a/net/sourceforge/jiu/filters/ConvolutionKernelFilter.java Mon Aug 03 23:22:22 2009 +0200
53.2 +++ b/net/sourceforge/jiu/filters/ConvolutionKernelFilter.java Sat Aug 08 23:06:58 2009 +0200
53.3 @@ -2,6 +2,7 @@
53.4 * ConvolutionKernelFilter
53.5 *
53.6 * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Marco Schmidt.
53.7 + * Copyright (c) 2009 Knut Arild Erstad.
53.8 * All rights reserved.
53.9 */
53.10
53.11 @@ -64,16 +65,34 @@
53.12 */
53.13 public class ConvolutionKernelFilter extends ImageToImageOperation
53.14 {
53.15 - public static final int TYPE_BLUR = 0;
53.16 - public static final int TYPE_SHARPEN = 1;
53.17 - public static final int TYPE_EDGE_DETECTION = 2;
53.18 - public static final int TYPE_EMBOSS = 3;
53.19 - public static final int TYPE_PSYCHEDELIC_DISTILLATION = 4;
53.20 - public static final int TYPE_LITHOGRAPH = 5;
53.21 - public static final int TYPE_HORIZONTAL_SOBEL = 6;
53.22 - public static final int TYPE_VERTICAL_SOBEL = 7;
53.23 - public static final int TYPE_HORIZONTAL_PREWITT = 8;
53.24 - public static final int TYPE_VERTICAL_PREWITT = 9;
53.25 + /**
53.26 + * Enumerates the predefined convolution kernel types.
53.27 + */
53.28 + public enum KernelType
53.29 + {
53.30 + BLUR ("Blur", BLUR_DATA, 3, 3, 9, 0),
53.31 + SHARPEN ("Sharpen", SHARPEN_DATA, 3, 3, 1, 0),
53.32 + EDGE_DETECTION ("Edge detection", EDGE_DETECTION_DATA, 3, 3, 1, 0),
53.33 + EMBOSS ("Emboss", EMBOSS_DATA, 3, 3, 1, 128),
53.34 + PSYCHEDELIC_DISTILLATION ("Psychedelic Distillation", PSYCHEDELIC_DISTILLATION_DATA, 5, 5, 1, 0),
53.35 + LITHOGRAPH ("Lithograph", LITHOGRAPH_DATA, 5, 5, 1, 0),
53.36 + HORIZONTAL_SOBEL ("Horizontal Sobel", HORIZONTAL_SOBEL_DATA, 3, 3, 1, 0),
53.37 + VERTICAL_SOBEL ("Vertical Sobel", VERTICAL_SOBEL_DATA, 3, 3, 1, 0),
53.38 + HORIZONTAL_PREWITT ("Horizontal Prewitt", HORIZONTAL_PREWITT_DATA, 3, 3, 1, 0),
53.39 + VERTICAL_PREWITT ("Vertical Prewitt", VERTICAL_PREWITT_DATA, 3, 3, 1, 0);
53.40 +
53.41 + private ConvolutionKernelData predefinedKernel;
53.42 +
53.43 + private KernelType(String name, int[] data, int width, int height, int div, int bias)
53.44 + {
53.45 + predefinedKernel = new ConvolutionKernelData(name, data, width, height, div, bias);
53.46 + }
53.47 +
53.48 + public ConvolutionKernelData getKernel()
53.49 + {
53.50 + return predefinedKernel;
53.51 + }
53.52 + }
53.53
53.54 private static final int[] BLUR_DATA = {1, 1, 1, 1, 1, 1, 1, 1, 1};
53.55 private static final int[] SHARPEN_DATA = {0, -1, 0, -1, 5, -1, 0, -1, 0};
53.56 @@ -85,19 +104,7 @@
53.57 private static final int[] VERTICAL_SOBEL_DATA = {-1, -2, -1, 0, 0, 0, 1, 2, 1};
53.58 private static final int[] HORIZONTAL_PREWITT_DATA = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
53.59 private static final int[] VERTICAL_PREWITT_DATA = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
53.60 - private static ConvolutionKernelData[] PREDEFINED_KERNELS =
53.61 - {
53.62 - new ConvolutionKernelData("Blur", BLUR_DATA, 3, 3, 9, 0),
53.63 - new ConvolutionKernelData("Sharpen", SHARPEN_DATA, 3, 3, 1, 0),
53.64 - new ConvolutionKernelData("Edge detection", EDGE_DETECTION_DATA, 3, 3, 1, 0),
53.65 - new ConvolutionKernelData("Emboss", EMBOSS_DATA, 3, 3, 1, 128),
53.66 - new ConvolutionKernelData("Psychedelic Distillation", PSYCHEDELIC_DISTILLATION_DATA, 5, 5, 1, 0),
53.67 - new ConvolutionKernelData("Lithograph", LITHOGRAPH_DATA, 5, 5, 1, 0),
53.68 - new ConvolutionKernelData("Horizontal Sobel", HORIZONTAL_SOBEL_DATA, 3, 3, 1, 0),
53.69 - new ConvolutionKernelData("Vertical Sobel", VERTICAL_SOBEL_DATA, 3, 3, 1, 0),
53.70 - new ConvolutionKernelData("Horizontal Prewitt", HORIZONTAL_PREWITT_DATA, 3, 3, 1, 0),
53.71 - new ConvolutionKernelData("Vertical Prewitt", VERTICAL_PREWITT_DATA, 3, 3, 1, 0)
53.72 - };
53.73 +
53.74 private int kernelBias;
53.75 private int[] kernelData;
53.76 private int kernelDiv;
53.77 @@ -140,9 +147,9 @@
53.78 * Static convenience method to do filtering with one line of code:
53.79 * <pre>PixelImage blurredImage = ConvolutionKernelFilter.filter(in, ConvolutionKernelFilter.TYPE_BLUR);</pre>
53.80 */
53.81 - public static PixelImage filter(PixelImage input, int kernelType)
53.82 + public static PixelImage filter(PixelImage input, KernelType kernelType)
53.83 {
53.84 - return filter(input, PREDEFINED_KERNELS[kernelType]);
53.85 + return filter(input, kernelType.getKernel());
53.86 }
53.87
53.88 public static PixelImage filter(PixelImage input, ConvolutionKernelData data)
53.89 @@ -276,7 +283,7 @@
53.90 PixelImage out = getOutputImage();
53.91 if (out == null)
53.92 {
53.93 - out = (IntegerImage)in.createCompatibleImage(in.getWidth(), in.getHeight());
53.94 + out = in.createCompatibleImage(in.getWidth(), in.getHeight());
53.95 setOutputImage(out);
53.96 }
53.97 process((IntegerImage)in, (IntegerImage)out);
53.98 @@ -348,18 +355,10 @@
53.99
53.100 /**
53.101 * Sets one of the predefined kernel types to be used for filtering.
53.102 - * @param type one of the TYPE_xyz constants of this class
53.103 - * @throws IllegalArgumentException if the argument is not a valid TYPE_xyz constant
53.104 + * @param a {@link KernelType} enum value
53.105 */
53.106 - public void setKernel(int type)
53.107 + public void setKernel(KernelType type)
53.108 {
53.109 - if (type < 0 || type >= PREDEFINED_KERNELS.length)
53.110 - {
53.111 - throw new IllegalArgumentException("Not a valid type index for predefined kernels: " + type);
53.112 - }
53.113 - else
53.114 - {
53.115 - setKernel(PREDEFINED_KERNELS[type]);
53.116 - }
53.117 + setKernel(type.getKernel());
53.118 }
53.119 }
54.1 --- a/net/sourceforge/jiu/geometry/Resample.java Mon Aug 03 23:22:22 2009 +0200
54.2 +++ b/net/sourceforge/jiu/geometry/Resample.java Sat Aug 08 23:06:58 2009 +0200
54.3 @@ -2,6 +2,7 @@
54.4 * Resample
54.5 *
54.6 * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Marco Schmidt.
54.7 + * Copyright (c) 2009 Knut Arild Erstad.
54.8 * All rights reserved.
54.9 */
54.10
54.11 @@ -166,39 +167,38 @@
54.12 public class Resample extends ImageToImageOperation
54.13 {
54.14 /**
54.15 - * Constant for the Box filter (also known as Nearest Neighbor filter).
54.16 + * Enumerates the standard filter types.
54.17 */
54.18 - public static final int FILTER_TYPE_BOX = 0;
54.19 -
54.20 - /**
54.21 - * Constant for the Triangle filter (also known as Linear filter or Bilinear filter).
54.22 - */
54.23 - public static final int FILTER_TYPE_TRIANGLE = 1;
54.24 -
54.25 - /**
54.26 - * Constant for the Hermite filter.
54.27 - */
54.28 - public static final int FILTER_TYPE_HERMITE = 2;
54.29 -
54.30 - /**
54.31 - * Constant for the Bell filter.
54.32 - */
54.33 - public static final int FILTER_TYPE_BELL = 3;
54.34 -
54.35 - /**
54.36 - * Constant for the B-Spline filter.
54.37 - */
54.38 - public static final int FILTER_TYPE_B_SPLINE = 4;
54.39 -
54.40 - /**
54.41 - * Constant for the Lanczos3 filter.
54.42 - */
54.43 - public static final int FILTER_TYPE_LANCZOS3 = 5;
54.44 -
54.45 - /**
54.46 - * Constant for the Mitchell filter.
54.47 - */
54.48 - public static final int FILTER_TYPE_MITCHELL = 6;
54.49 + public enum FilterType {
54.50 + /**
54.51 + * Box filter (also known as Nearest Neighbor filter).
54.52 + */
54.53 + BOX,
54.54 + /**
54.55 + * Triangle filter (also known as Linear filter or Bilinear filter).
54.56 + */
54.57 + TRIANGLE,
54.58 + /**
54.59 + * Hermite filter.
54.60 + */
54.61 + HERMITE,
54.62 + /**
54.63 + * Bell filter.
54.64 + */
54.65 + BELL,
54.66 + /**
54.67 + * B-Spline filter.
54.68 + */
54.69 + B_SPLINE,
54.70 + /**
54.71 + * Lanczos3 filter.
54.72 + */
54.73 + LANCZOS3,
54.74 + /**
54.75 + * Mitchell filter.
54.76 + */
54.77 + MITCHELL,
54.78 + }
54.79
54.80 class Contributor
54.81 {
54.82 @@ -216,17 +216,17 @@
54.83 private Integer outHeight;
54.84 private ResampleFilter filter;
54.85
54.86 - private static ResampleFilter createFilter(int filterType)
54.87 + private static ResampleFilter createFilter(FilterType filterType)
54.88 {
54.89 switch(filterType)
54.90 {
54.91 - case(FILTER_TYPE_BOX): return new BoxFilter();
54.92 - case(FILTER_TYPE_TRIANGLE): return new TriangleFilter();
54.93 - case(FILTER_TYPE_HERMITE): return new HermiteFilter();
54.94 - case(FILTER_TYPE_BELL): return new BellFilter();
54.95 - case(FILTER_TYPE_B_SPLINE): return new BSplineFilter();
54.96 - case(FILTER_TYPE_LANCZOS3): return new Lanczos3Filter();
54.97 - case(FILTER_TYPE_MITCHELL): return new MitchellFilter();
54.98 + case BOX: return new BoxFilter();
54.99 + case TRIANGLE: return new TriangleFilter();
54.100 + case HERMITE: return new HermiteFilter();
54.101 + case BELL: return new BellFilter();
54.102 + case B_SPLINE: return new BSplineFilter();
54.103 + case LANCZOS3: return new Lanczos3Filter();
54.104 + case MITCHELL: return new MitchellFilter();
54.105 default:
54.106 {
54.107 throw new IllegalArgumentException("Unknown filter type in Resample: " + filterType);
54.108 @@ -252,25 +252,17 @@
54.109 */
54.110 public static String[] getFilterNames()
54.111 {
54.112 - String[] result = new String[getNumFilters()];
54.113 - for (int i = 0; i < getNumFilters(); i++)
54.114 + FilterType[] filterTypes = FilterType.values();
54.115 + String[] result = new String[filterTypes.length];
54.116 + for (int i = 0; i < filterTypes.length; i++)
54.117 {
54.118 - ResampleFilter filter = createFilter(i);
54.119 + ResampleFilter filter = createFilter(filterTypes[i]);
54.120 result[i] = filter.getName();
54.121 }
54.122 return result;
54.123 }
54.124
54.125 /**
54.126 - * Returns the number of predefined filters.
54.127 - * @return number of filters
54.128 - */
54.129 - public static int getNumFilters()
54.130 - {
54.131 - return 7;
54.132 - }
54.133 -
54.134 - /**
54.135 * This method does the actual work of rescaling an image.
54.136 */
54.137 private void process(IntegerImage in, IntegerImage out)
54.138 @@ -680,19 +672,19 @@
54.139
54.140 /**
54.141 * Sets a new filter type, using the default sampling radius of that filter.
54.142 - * @param filterType the new filter type, one of the FILTER_TYPE_xyz constants of this class
54.143 + * @param filterType the new filter type
54.144 */
54.145 - public void setFilter(int filterType)
54.146 + public void setFilter(FilterType filterType)
54.147 {
54.148 setFilter(createFilter(filterType));
54.149 }
54.150
54.151 /**
54.152 * Sets a new filter type with a user-defined sampling radius.
54.153 - * @param filterType the new filter type, one of the FILTER_TYPE_xyz constants of this class
54.154 + * @param filterType the new filter type
54.155 * @param samplingRadius the sampling radius to be used with that filter, must be larger than 0.0f
54.156 */
54.157 - public void setFilter(int filterType, float samplingRadius)
54.158 + public void setFilter(FilterType filterType, float samplingRadius)
54.159 {
54.160 ResampleFilter newFilter = createFilter(filterType);
54.161 newFilter.setSamplingRadius(samplingRadius);
55.1 --- a/net/sourceforge/jiu/geometry/ScaleReplication.java Mon Aug 03 23:22:22 2009 +0200
55.2 +++ b/net/sourceforge/jiu/geometry/ScaleReplication.java Sat Aug 08 23:06:58 2009 +0200
55.3 @@ -52,10 +52,10 @@
55.4 int OUT_HEIGHT = outHeight.intValue();
55.5 for (int y = 0; y < OUT_HEIGHT; y++)
55.6 {
55.7 - final int SRC_Y = (int)(IN_MAX_Y * (y + 1) / OUT_HEIGHT);
55.8 + final int SRC_Y = IN_MAX_Y * (y + 1) / OUT_HEIGHT;
55.9 for (int x = 0; x < OUT_WIDTH; x++)
55.10 {
55.11 - final int SRC_X = (int)(IN_MAX_X * (x + 1) / OUT_WIDTH);
55.12 + final int SRC_X = IN_MAX_X * (x + 1) / OUT_WIDTH;
55.13 for (int c = 0; c < in.getNumChannels(); c++)
55.14 {
55.15 out.putSample(c, x, y, in.getSample(c, SRC_X, SRC_Y));
56.1 --- a/net/sourceforge/jiu/gui/awt/AwtInfo.java Mon Aug 03 23:22:22 2009 +0200
56.2 +++ b/net/sourceforge/jiu/gui/awt/AwtInfo.java Sat Aug 08 23:06:58 2009 +0200
56.3 @@ -36,7 +36,7 @@
56.4 {
56.5 Toolkit toolkit = Toolkit.getDefaultToolkit();
56.6 Dimension screen = toolkit.getScreenSize();
56.7 - StringBuffer result = new StringBuffer();
56.8 + StringBuilder result = new StringBuilder();
56.9 result.append(strings.get(StringIndexConstants.SCREEN_RESOLUTION) + "=" + screen.width + " x " + screen.height + "\n");
56.10 ColorModel model = toolkit.getColorModel();
56.11 if (model != null)
57.1 --- a/net/sourceforge/jiu/gui/awt/AwtOperationProcessor.java Mon Aug 03 23:22:22 2009 +0200
57.2 +++ b/net/sourceforge/jiu/gui/awt/AwtOperationProcessor.java Sat Aug 08 23:06:58 2009 +0200
57.3 @@ -10,20 +10,26 @@
57.4 import java.awt.*;
57.5 import java.io.*;
57.6 import net.sourceforge.jiu.apps.*;
57.7 +import net.sourceforge.jiu.apps.EditorState.Interpolation;
57.8 import net.sourceforge.jiu.color.*;
57.9 import net.sourceforge.jiu.color.adjustment.*;
57.10 import net.sourceforge.jiu.color.analysis.*;
57.11 import net.sourceforge.jiu.color.data.*;
57.12 import net.sourceforge.jiu.color.dithering.*;
57.13 +import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering.ErrorDiffusionType;
57.14 import net.sourceforge.jiu.color.io.*;
57.15 import net.sourceforge.jiu.color.promotion.*;
57.16 import net.sourceforge.jiu.color.quantization.*;
57.17 +import net.sourceforge.jiu.color.quantization.MedianCutQuantizer.RepresentativeColorMethod;
57.18 import net.sourceforge.jiu.color.reduction.*;
57.19 import net.sourceforge.jiu.gui.awt.dialogs.*;
57.20 +import net.sourceforge.jiu.gui.awt.dialogs.MapToArbitraryPaletteDialog.PaletteType;
57.21 import net.sourceforge.jiu.codecs.*;
57.22 import net.sourceforge.jiu.data.*;
57.23 import net.sourceforge.jiu.filters.*;
57.24 +import net.sourceforge.jiu.filters.ConvolutionKernelFilter.KernelType;
57.25 import net.sourceforge.jiu.geometry.*;
57.26 +import net.sourceforge.jiu.geometry.Resample.FilterType;
57.27 import net.sourceforge.jiu.ops.*;
57.28 import net.sourceforge.jiu.util.*;
57.29
57.30 @@ -219,7 +225,7 @@
57.31 catch (MissingParameterException mpe)
57.32 {
57.33 }
57.34 - StringBuffer text = new StringBuffer();
57.35 + StringBuilder text = new StringBuilder();
57.36 text.append(strings.get(StringIndexConstants.CONTRAST) + "=" + ta.getContrast() + "\n");
57.37 text.append(strings.get(StringIndexConstants.CORRELATION) + "=" + ta.getCorrelation() + "\n");
57.38 text.append(strings.get(StringIndexConstants.DISSIMILARITY) + "=" + ta.getDissimilarity() + "\n");
57.39 @@ -403,7 +409,7 @@
57.40 PixelImage image = state.getImage();
57.41 int maxBits = image.getBitsPerPixel() - 1;
57.42 ReduceGrayscaleDialog rgd = new ReduceGrayscaleDialog(frame, strings, 1, maxBits,
57.43 - ReduceGrayscaleDialog.TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION);
57.44 + DitheringMethod.FLOYD_STEINBERG_ERROR_DIFFUSION);
57.45 rgd.setVisible(true);
57.46 if (!rgd.hasPressedOk())
57.47 {
57.48 @@ -413,7 +419,7 @@
57.49 ImageToImageOperation op = null;
57.50 switch (rgd.getDitheringMethod())
57.51 {
57.52 - case(ReduceGrayscaleDialog.TYPE_DITHERING_NONE):
57.53 + case NONE:
57.54 {
57.55 ReduceShadesOfGray rsog;
57.56 rsog = new ReduceShadesOfGray();
57.57 @@ -421,57 +427,57 @@
57.58 op = rsog;
57.59 break;
57.60 }
57.61 - case(ReduceGrayscaleDialog.TYPE_ORDERED_DITHERING):
57.62 + case ORDERED:
57.63 {
57.64 OrderedDither od = new OrderedDither();
57.65 od.setOutputBits(numBits);
57.66 op = od;
57.67 break;
57.68 }
57.69 - case(ReduceGrayscaleDialog.TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION):
57.70 + case FLOYD_STEINBERG_ERROR_DIFFUSION:
57.71 {
57.72 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.73 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_FLOYD_STEINBERG);
57.74 + ed.setTemplateType(ErrorDiffusionType.FLOYD_STEINBERG);
57.75 ed.setGrayscaleOutputBits(numBits);
57.76 op = ed;
57.77 break;
57.78 }
57.79 - case(ReduceGrayscaleDialog.TYPE_STUCKI_ERROR_DIFFUSION):
57.80 + case STUCKI_ERROR_DIFFUSION:
57.81 {
57.82 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.83 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_STUCKI);
57.84 + ed.setTemplateType(ErrorDiffusionType.STUCKI);
57.85 ed.setGrayscaleOutputBits(numBits);
57.86 op = ed;
57.87 break;
57.88 }
57.89 - case(ReduceGrayscaleDialog.TYPE_BURKES_ERROR_DIFFUSION):
57.90 + case BURKES_ERROR_DIFFUSION:
57.91 {
57.92 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.93 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_BURKES);
57.94 + ed.setTemplateType(ErrorDiffusionType.BURKES);
57.95 ed.setGrayscaleOutputBits(numBits);
57.96 op = ed;
57.97 break;
57.98 }
57.99 - case(ReduceGrayscaleDialog.TYPE_SIERRA_ERROR_DIFFUSION):
57.100 + case SIERRA_ERROR_DIFFUSION:
57.101 {
57.102 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.103 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_SIERRA);
57.104 + ed.setTemplateType(ErrorDiffusionType.SIERRA);
57.105 ed.setGrayscaleOutputBits(numBits);
57.106 op = ed;
57.107 break;
57.108 }
57.109 - case(ReduceGrayscaleDialog.TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION):
57.110 + case JARVIS_JUDICE_NINKE_ERROR_DIFFUSION:
57.111 {
57.112 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.113 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_JARVIS_JUDICE_NINKE);
57.114 + ed.setTemplateType(ErrorDiffusionType.JARVIS_JUDICE_NINKE);
57.115 ed.setGrayscaleOutputBits(numBits);
57.116 op = ed;
57.117 break;
57.118 }
57.119 - case(ReduceGrayscaleDialog.TYPE_STEVENSON_ARCE_ERROR_DIFFUSION):
57.120 + case STEVENSON_ARCE_ERROR_DIFFUSION:
57.121 {
57.122 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.123 - ed.setTemplateType(ErrorDiffusionDithering.TYPE_STEVENSON_ARCE);
57.124 + ed.setTemplateType(ErrorDiffusionType.STEVENSON_ARCE);
57.125 ed.setGrayscaleOutputBits(numBits);
57.126 op = ed;
57.127 break;
57.128 @@ -500,7 +506,7 @@
57.129 frame,
57.130 strings,
57.131 256,
57.132 - MedianCutQuantizer.METHOD_REPR_COLOR_WEIGHTED_AVERAGE,
57.133 + RepresentativeColorMethod.AVERAGE,
57.134 true,
57.135 MedianCutContourRemoval.DEFAULT_NUM_PASSES,
57.136 MedianCutContourRemoval.DEFAULT_TAU);
57.137 @@ -510,7 +516,7 @@
57.138 return;
57.139 }
57.140 int numColors = mcd.getNumColors();
57.141 - int method = mcd.getReprColorMethod();
57.142 + RepresentativeColorMethod method = mcd.getReprColorMethod();
57.143 boolean palettedOutput = mcd.isOutputTypePaletted();
57.144 //int numBitsToBeCleared = 0;
57.145 ImageToImageOperation op = null;
57.146 @@ -669,17 +675,24 @@
57.147 process(red);
57.148 }
57.149
57.150 - private int convertUniformToErrorDiffusion(int utype)
57.151 + private ErrorDiffusionType convertUniformToErrorDiffusion(DitheringMethod method)
57.152 {
57.153 - switch(utype)
57.154 + switch(method)
57.155 {
57.156 - case(UniformPaletteQuantizerDialog.TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_FLOYD_STEINBERG;
57.157 - case(UniformPaletteQuantizerDialog.TYPE_BURKES_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_BURKES;
57.158 - case(UniformPaletteQuantizerDialog.TYPE_STUCKI_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_STUCKI;
57.159 - case(UniformPaletteQuantizerDialog.TYPE_SIERRA_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_SIERRA;
57.160 - case(UniformPaletteQuantizerDialog.TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_JARVIS_JUDICE_NINKE;
57.161 - case(UniformPaletteQuantizerDialog.TYPE_STEVENSON_ARCE_ERROR_DIFFUSION): return ErrorDiffusionDithering.TYPE_STEVENSON_ARCE;
57.162 - default: return -1;
57.163 + case FLOYD_STEINBERG_ERROR_DIFFUSION:
57.164 + return ErrorDiffusionType.FLOYD_STEINBERG;
57.165 + case BURKES_ERROR_DIFFUSION:
57.166 + return ErrorDiffusionType.BURKES;
57.167 + case STUCKI_ERROR_DIFFUSION:
57.168 + return ErrorDiffusionType.STUCKI;
57.169 + case SIERRA_ERROR_DIFFUSION:
57.170 + return ErrorDiffusionType.SIERRA;
57.171 + case JARVIS_JUDICE_NINKE_ERROR_DIFFUSION:
57.172 + return ErrorDiffusionType.JARVIS_JUDICE_NINKE;
57.173 + case STEVENSON_ARCE_ERROR_DIFFUSION:
57.174 + return ErrorDiffusionType.STEVENSON_ARCE;
57.175 + default:
57.176 + return null;
57.177 }
57.178 }
57.179
57.180 @@ -688,7 +701,7 @@
57.181 EditorState state = getEditorState();
57.182 Strings strings = state.getStrings();
57.183 UniformPaletteQuantizerDialog upqd = new UniformPaletteQuantizerDialog
57.184 - (frame, strings, 3, 3, 2, UniformPaletteQuantizerDialog.TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION);
57.185 + (frame, strings, 3, 3, 2, DitheringMethod.FLOYD_STEINBERG_ERROR_DIFFUSION);
57.186 upqd.setVisible(true);
57.187 if (!upqd.hasPressedOk())
57.188 {
57.189 @@ -700,25 +713,25 @@
57.190 int sum = redBits + greenBits + blueBits;
57.191 switch (upqd.getDitheringMethod())
57.192 {
57.193 - case(UniformPaletteQuantizerDialog.TYPE_DITHERING_NONE):
57.194 + case NONE:
57.195 {
57.196 UniformPaletteQuantizer upq = new UniformPaletteQuantizer(redBits, greenBits, blueBits);
57.197 process(upq);
57.198 return;
57.199 }
57.200 - case(UniformPaletteQuantizerDialog.TYPE_ORDERED_DITHERING):
57.201 + case ORDERED:
57.202 {
57.203 OrderedDither od = new OrderedDither();
57.204 od.setRgbBits(redBits, greenBits, blueBits);
57.205 process(od);
57.206 return;
57.207 }
57.208 - case(UniformPaletteQuantizerDialog.TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION):
57.209 - case(UniformPaletteQuantizerDialog.TYPE_BURKES_ERROR_DIFFUSION):
57.210 - case(UniformPaletteQuantizerDialog.TYPE_STUCKI_ERROR_DIFFUSION):
57.211 - case(UniformPaletteQuantizerDialog.TYPE_SIERRA_ERROR_DIFFUSION):
57.212 - case(UniformPaletteQuantizerDialog.TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION):
57.213 - case(UniformPaletteQuantizerDialog.TYPE_STEVENSON_ARCE_ERROR_DIFFUSION):
57.214 + case FLOYD_STEINBERG_ERROR_DIFFUSION:
57.215 + case BURKES_ERROR_DIFFUSION:
57.216 + case STUCKI_ERROR_DIFFUSION:
57.217 + case SIERRA_ERROR_DIFFUSION:
57.218 + case JARVIS_JUDICE_NINKE_ERROR_DIFFUSION:
57.219 + case STEVENSON_ARCE_ERROR_DIFFUSION:
57.220 {
57.221 ErrorDiffusionDithering ed = new ErrorDiffusionDithering();
57.222 ed.setTemplateType(convertUniformToErrorDiffusion(upqd.getDitheringMethod()));
57.223 @@ -746,8 +759,8 @@
57.224 {
57.225 return;
57.226 }
57.227 - int paletteType = d.getPaletteType();
57.228 - if (paletteType < 0)
57.229 + PaletteType paletteType = d.getPaletteType();
57.230 + if (paletteType == null)
57.231 {
57.232 return;
57.233 }
57.234 @@ -755,7 +768,7 @@
57.235 Palette palette;
57.236 switch(paletteType)
57.237 {
57.238 - case(MapToArbitraryPaletteDialog.PALETTE_FILE):
57.239 + case FILE:
57.240 {
57.241 String name = getUserFileName(null, StringIndexConstants.LOAD_PALETTE, FileDialog.LOAD);
57.242 if (name == null)
57.243 @@ -766,27 +779,27 @@
57.244 palette = PaletteSerialization.load(file);
57.245 break;
57.246 }
57.247 - case(MapToArbitraryPaletteDialog.PALETTE_WEBSAFE):
57.248 + case WEBSAFE:
57.249 {
57.250 palette = WebsafePaletteCreator.create();
57.251 break;
57.252 }
57.253 - case(MapToArbitraryPaletteDialog.PALETTE_PALM_256_COLORS):
57.254 + case PALM_256_COLORS:
57.255 {
57.256 palette = PalmCodec.createSystem8BitPalette();
57.257 break;
57.258 }
57.259 - case(MapToArbitraryPaletteDialog.PALETTE_PALM_16_COLORS):
57.260 + case PALM_16_COLORS:
57.261 {
57.262 palette = PalmCodec.createSystem4BitColorPalette();
57.263 break;
57.264 }
57.265 - case(MapToArbitraryPaletteDialog.PALETTE_PALM_16_GRAY):
57.266 + case PALM_16_GRAY:
57.267 {
57.268 palette = PalmCodec.createSystem4BitGrayscalePalette();
57.269 break;
57.270 }
57.271 - case(MapToArbitraryPaletteDialog.PALETTE_PALM_4_GRAY):
57.272 + case PALM_4_GRAY:
57.273 {
57.274 palette = PalmCodec.createSystem2BitGrayscalePalette();
57.275 break;
57.276 @@ -861,7 +874,7 @@
57.277 StringIndexConstants.DO_YOU_REALLY_WANT_TO_CLOSE_WITHOUT_SAVING,
57.278 false);
57.279 dialog.setVisible(true);
57.280 - if (dialog.getResult() == YesNoDialog.RESULT_NO)
57.281 + if (dialog.getResult() == YesNoDialog.Result.NO)
57.282 {
57.283 return;
57.284 }
57.285 @@ -884,7 +897,7 @@
57.286 StringIndexConstants.DO_YOU_REALLY_WANT_TO_QUIT_WITHOUT_SAVING,
57.287 false);
57.288 dialog.setVisible(true);
57.289 - if (dialog.getResult() == YesNoDialog.RESULT_NO)
57.290 + if (dialog.getResult() == YesNoDialog.Result.NO)
57.291 {
57.292 return;
57.293 }
57.294 @@ -905,7 +918,7 @@
57.295 StringIndexConstants.DO_YOU_REALLY_WANT_TO_CLOSE_WITHOUT_SAVING,
57.296 false);
57.297 dialog.setVisible(true);
57.298 - if (dialog.getResult() == YesNoDialog.RESULT_NO)
57.299 + if (dialog.getResult() == YesNoDialog.Result.NO)
57.300 {
57.301 return;
57.302 }
57.303 @@ -1184,7 +1197,7 @@
57.304 frame.updateImage();
57.305 }
57.306
57.307 - public void filterConvolutionFilter(int type)
57.308 + public void filterConvolutionFilter(KernelType type)
57.309 {
57.310 ConvolutionKernelFilter ckf = new ConvolutionKernelFilter();
57.311 ckf.setKernel(type);
57.312 @@ -1193,52 +1206,52 @@
57.313
57.314 public void filtersBlur()
57.315 {
57.316 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_BLUR);
57.317 + filterConvolutionFilter(KernelType.BLUR);
57.318 }
57.319
57.320 public void filtersSharpen()
57.321 {
57.322 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_SHARPEN);
57.323 + filterConvolutionFilter(KernelType.SHARPEN);
57.324 }
57.325
57.326 public void filtersEdgeDetection()
57.327 {
57.328 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_EDGE_DETECTION);
57.329 + filterConvolutionFilter(KernelType.EDGE_DETECTION);
57.330 }
57.331
57.332 public void filtersEmboss()
57.333 {
57.334 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_EMBOSS);
57.335 + filterConvolutionFilter(KernelType.EMBOSS);
57.336 }
57.337
57.338 public void filtersPsychedelicDistillation()
57.339 {
57.340 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_PSYCHEDELIC_DISTILLATION);
57.341 + filterConvolutionFilter(KernelType.PSYCHEDELIC_DISTILLATION);
57.342 }
57.343
57.344 public void filtersLithograph()
57.345 {
57.346 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_LITHOGRAPH);
57.347 + filterConvolutionFilter(KernelType.LITHOGRAPH);
57.348 }
57.349
57.350 public void filtersHorizontalSobel()
57.351 {
57.352 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_HORIZONTAL_SOBEL);
57.353 + filterConvolutionFilter(KernelType.HORIZONTAL_SOBEL);
57.354 }
57.355
57.356 public void filtersVerticalSobel()
57.357 {
57.358 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_VERTICAL_SOBEL);
57.359 + filterConvolutionFilter(KernelType.VERTICAL_SOBEL);
57.360 }
57.361
57.362 public void filtersHorizontalPrewitt()
57.363 {
57.364 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_HORIZONTAL_PREWITT);
57.365 + filterConvolutionFilter(KernelType.HORIZONTAL_PREWITT);
57.366 }
57.367
57.368 public void filtersVerticalPrewitt()
57.369 {
57.370 - filterConvolutionFilter(ConvolutionKernelFilter.TYPE_VERTICAL_PREWITT);
57.371 + filterConvolutionFilter(KernelType.VERTICAL_PREWITT);
57.372 }
57.373
57.374 public void filtersMaximum()
57.375 @@ -1493,14 +1506,14 @@
57.376 Strings strings = state.getStrings();
57.377 // a type can be chosen by the user if rgb or gray image
57.378 boolean pickType = image instanceof RGB24Image || image instanceof Gray8Image;
57.379 - int initialType;
57.380 + Resample.FilterType initialType;
57.381 if (pickType)
57.382 {
57.383 - initialType = Resample.FILTER_TYPE_B_SPLINE;
57.384 + initialType = FilterType.B_SPLINE;
57.385 }
57.386 else
57.387 {
57.388 - initialType = Resample.FILTER_TYPE_BOX;
57.389 + initialType = FilterType.BOX;
57.390 }
57.391 ScaleDialog sd = new ScaleDialog(frame, strings, image.getWidth(),
57.392 image.getHeight(), pickType, Resample.getFilterNames(), initialType);
57.393 @@ -1543,21 +1556,21 @@
57.394 public void viewInterpolationTypeBicubic()
57.395 {
57.396 EditorState state = getEditorState();
57.397 - state.setInterpolation(EditorState.INTERPOLATION_BICUBIC);
57.398 + state.setInterpolation(Interpolation.BICUBIC);
57.399 frame.updateCanvas();
57.400 }
57.401
57.402 public void viewInterpolationTypeBilinear()
57.403 {
57.404 EditorState state = getEditorState();
57.405 - state.setInterpolation(EditorState.INTERPOLATION_BILINEAR);
57.406 + state.setInterpolation(Interpolation.BILINEAR);
57.407 frame.updateCanvas();
57.408 }
57.409
57.410 public void viewInterpolationTypeNearestNeighbor()
57.411 {
57.412 EditorState state = getEditorState();
57.413 - state.setInterpolation(EditorState.INTERPOLATION_NEAREST_NEIGHBOR);
57.414 + state.setInterpolation(Interpolation.NEAREST_NEIGHBOR);
57.415 frame.updateCanvas();
57.416 }
57.417
58.1 --- a/net/sourceforge/jiu/gui/awt/BufferedRGB24Image.java Mon Aug 03 23:22:22 2009 +0200
58.2 +++ b/net/sourceforge/jiu/gui/awt/BufferedRGB24Image.java Sat Aug 08 23:06:58 2009 +0200
58.3 @@ -177,7 +177,7 @@
58.4 BufferedImage allows for all kinds of data buffers;
58.5 for a more accurate approximation these data buffers
58.6 must be examined */
58.7 - return 4L * (long)getWidth() * (long)getHeight();
58.8 + return 4L * getWidth() * getHeight();
58.9 }
58.10
58.11 public int getBitsPerPixel()
58.12 @@ -221,7 +221,7 @@
58.13 return HEIGHT;
58.14 }
58.15
58.16 - public Class getImageType()
58.17 + public Class<? extends PixelImage> getImageType()
58.18 {
58.19 return RGB24Image.class;
58.20 }
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/net/sourceforge/jiu/gui/awt/DitheringMethod.java Sat Aug 08 23:06:58 2009 +0200
59.3 @@ -0,0 +1,59 @@
59.4 +/*
59.5 + * Copyright (C) 2009 Knut Arild Erstad
59.6 + *
59.7 + * This file is part of JIU, the Java Imaging Utilities.
59.8 + *
59.9 + * JIU is free software; you can redistribute it and/or modify
59.10 + * it under the terms of the GNU General Public License version 2,
59.11 + * as published by the Free Software Foundation.
59.12 + *
59.13 + * Contributions by Knut Arild Erstad can be redistributed and/or
59.14 + * modified under GPL 2 or any later versions.
59.15 + *
59.16 + * JIU is distributed in the hope that it will be useful,
59.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
59.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59.19 + * GNU General Public License for more details.
59.20 + *
59.21 + * You should have received a copy of the GNU General Public License
59.22 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
59.23 + */
59.24 +package net.sourceforge.jiu.gui.awt;
59.25 +
59.26 +import net.sourceforge.jiu.apps.StringIndexConstants;
59.27 +import net.sourceforge.jiu.apps.Strings;
59.28 +
59.29 +/**
59.30 + * Enumerates the possible dithering methods and their string index values
59.31 + * (used by several dialogs).
59.32 + *
59.33 + * @author Marco Schmidt
59.34 + * @author Knut Arild Erstad
59.35 + */
59.36 +public enum DitheringMethod
59.37 +{
59.38 + NONE (Strings.DITHERING_NONE),
59.39 + ORDERED (Strings.ORDERED_DITHERING),
59.40 + FLOYD_STEINBERG_ERROR_DIFFUSION (Strings.FLOYD_STEINBERG_ERROR_DIFFUSION),
59.41 + STUCKI_ERROR_DIFFUSION (Strings.STUCKI_ERROR_DIFFUSION),
59.42 + BURKES_ERROR_DIFFUSION (Strings.BURKES_ERROR_DIFFUSION),
59.43 + SIERRA_ERROR_DIFFUSION (Strings.SIERRA_ERROR_DIFFUSION),
59.44 + JARVIS_JUDICE_NINKE_ERROR_DIFFUSION (Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION),
59.45 + STEVENSON_ARCE_ERROR_DIFFUSION (Strings.STEVENSON_ARCE_ERROR_DIFFUSION);
59.46 +
59.47 + private int stringConstant;
59.48 +
59.49 + private DitheringMethod(int stringConstant)
59.50 + {
59.51 + this.stringConstant = stringConstant;
59.52 + }
59.53 +
59.54 + /**
59.55 + * Get a string resource index which describes the enum value.
59.56 + * @return a {@link StringIndexConstants} value.
59.57 + */
59.58 + public int getStringConstant()
59.59 + {
59.60 + return stringConstant;
59.61 + }
59.62 +}
59.63 \ No newline at end of file
60.1 --- a/net/sourceforge/jiu/gui/awt/ImageCanvas.java Mon Aug 03 23:22:22 2009 +0200
60.2 +++ b/net/sourceforge/jiu/gui/awt/ImageCanvas.java Sat Aug 08 23:06:58 2009 +0200
60.3 @@ -15,7 +15,8 @@
60.4 import java.awt.Rectangle;
60.5 //import java.awt.RenderingHints;
60.6 import java.awt.ScrollPane;
60.7 -import net.sourceforge.jiu.apps.EditorState;
60.8 +
60.9 +import net.sourceforge.jiu.apps.EditorState.Interpolation;
60.10
60.11 /**
60.12 * An AWT canvas that displays an {@link java.awt.Image} object.
60.13 @@ -160,26 +161,24 @@
60.14 }
60.15
60.16 /**
60.17 - * Sets the interpolation type used for drawing to the argument
60.18 - * (must be one of the
60.19 - * INTERPOLATION_xyz constants of EditorState), but does not
60.20 - * do a redraw.
60.21 + * Sets the interpolation type used for drawing to the argument.
60.22 + * TODO: this function currently does nothing at all!
60.23 */
60.24 - public void setInterpolation(int newType)
60.25 + public void setInterpolation(Interpolation newType)
60.26 {
60.27 switch(newType)
60.28 {
60.29 - case(EditorState.INTERPOLATION_BICUBIC):
60.30 + case BICUBIC:
60.31 {
60.32 //interpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
60.33 break;
60.34 }
60.35 - case(EditorState.INTERPOLATION_BILINEAR):
60.36 + case BILINEAR:
60.37 {
60.38 //interpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
60.39 break;
60.40 }
60.41 - case(EditorState.INTERPOLATION_NEAREST_NEIGHBOR):
60.42 + case NEAREST_NEIGHBOR:
60.43 {
60.44 //interpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
60.45 break;
61.1 --- a/net/sourceforge/jiu/gui/awt/JiuAwtFrame.java Mon Aug 03 23:22:22 2009 +0200
61.2 +++ b/net/sourceforge/jiu/gui/awt/JiuAwtFrame.java Sat Aug 08 23:06:58 2009 +0200
61.3 @@ -324,7 +324,7 @@
61.4 */
61.5 public void updateTitle()
61.6 {
61.7 - StringBuffer sb = new StringBuffer(APP_NAME);
61.8 + StringBuilder sb = new StringBuilder(APP_NAME);
61.9 String fileName = editor.getFileName();
61.10 if (fileName != null && fileName.length() > 0)
61.11 {
62.1 --- a/net/sourceforge/jiu/gui/awt/ToolkitLoader.java Mon Aug 03 23:22:22 2009 +0200
62.2 +++ b/net/sourceforge/jiu/gui/awt/ToolkitLoader.java Sat Aug 08 23:06:58 2009 +0200
62.3 @@ -12,12 +12,13 @@
62.4 import java.awt.MediaTracker;
62.5 import java.awt.Toolkit;
62.6 import java.io.IOException;
62.7 -import java.util.Vector;
62.8 +import java.util.ArrayList;
62.9 import net.sourceforge.jiu.codecs.ImageLoader;
62.10 import net.sourceforge.jiu.data.PixelImage;
62.11 import net.sourceforge.jiu.data.RGB24Image;
62.12 import net.sourceforge.jiu.gui.awt.ImageCreator;
62.13 import net.sourceforge.jiu.ops.OperationFailedException;
62.14 +import net.sourceforge.jiu.ops.ProgressListener;
62.15
62.16 /**
62.17 * This class loads an instance of {@link java.awt.Image} using
62.18 @@ -139,7 +140,7 @@
62.19 * @param fileName name of the image file
62.20 * @return image object or <code>null</code> on failure
62.21 */
62.22 - public static PixelImage loadViaToolkitOrCodecs(String fileName, boolean preferToolkit, Vector progressListeners)
62.23 + public static PixelImage loadViaToolkitOrCodecs(String fileName, boolean preferToolkit, ArrayList<ProgressListener> progressListeners)
62.24 {
62.25 PixelImage result = null;
62.26 try
63.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/MapToArbitraryPaletteDialog.java Mon Aug 03 23:22:22 2009 +0200
63.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/MapToArbitraryPaletteDialog.java Sat Aug 08 23:06:58 2009 +0200
63.3 @@ -19,8 +19,11 @@
63.4 import java.awt.Panel;
63.5 import java.awt.event.ActionEvent;
63.6 import java.awt.event.ActionListener;
63.7 +
63.8 +import net.sourceforge.jiu.apps.StringIndexConstants;
63.9 import net.sourceforge.jiu.apps.Strings;
63.10 -import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering;
63.11 +import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering.ErrorDiffusionType;
63.12 +import net.sourceforge.jiu.util.EnumHelper;
63.13
63.14 /**
63.15 * A dialog to enter the parameters for an operation to map an RGB truecolor
63.16 @@ -33,22 +36,34 @@
63.17 public class MapToArbitraryPaletteDialog extends Dialog implements
63.18 ActionListener
63.19 {
63.20 - public static final int PALETTE_FILE = 0;
63.21 - public static final int PALETTE_WEBSAFE = 1;
63.22 - public static final int PALETTE_PALM_256_COLORS = 2;
63.23 - public static final int PALETTE_PALM_16_COLORS = 3;
63.24 - public static final int PALETTE_PALM_16_GRAY = 4;
63.25 - public static final int PALETTE_PALM_4_GRAY = 5;
63.26 - public static final int NUM_PALETTE_TYPES = 6;
63.27 - private static final int[] PALETTE_STRING_CONSTANTS =
63.28 + /**
63.29 + * Enumerates the supported palette types.
63.30 + */
63.31 + public enum PaletteType
63.32 {
63.33 - Strings.PALETTE_FROM_FILE,
63.34 - Strings.WEBSAFE_PALETTE,
63.35 - Strings.PALETTE_PALM_256_COLORS,
63.36 - Strings.PALETTE_PALM_16_COLORS,
63.37 - Strings.PALETTE_PALM_16_GRAY,
63.38 - Strings.PALETTE_PALM_4_GRAY,
63.39 - };
63.40 + FILE (Strings.PALETTE_FROM_FILE),
63.41 + WEBSAFE (Strings.WEBSAFE_PALETTE),
63.42 + PALM_256_COLORS (Strings.PALETTE_PALM_256_COLORS),
63.43 + PALM_16_COLORS (Strings.PALETTE_PALM_16_COLORS),
63.44 + PALM_16_GRAY (Strings.PALETTE_PALM_16_GRAY),
63.45 + PALM_4_GRAY (Strings.PALETTE_PALM_4_GRAY);
63.46 +
63.47 + private int stringConstant;
63.48 +
63.49 + private PaletteType(int stringConstant)
63.50 + {
63.51 + this.stringConstant = stringConstant;
63.52 + }
63.53 +
63.54 + /**
63.55 + * Get a string resource index which describes the enum value.
63.56 + * @return a {@link StringIndexConstants} value.
63.57 + */
63.58 + public int getStringConstant()
63.59 + {
63.60 + return stringConstant;
63.61 + }
63.62 + }
63.63
63.64 private static final int[] DITHERING_STRING_CONSTANTS =
63.65 {
63.66 @@ -60,15 +75,7 @@
63.67 Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
63.68 Strings.STEVENSON_ARCE_ERROR_DIFFUSION
63.69 };
63.70 - private static final int[] ERROR_DIFFUSION_TYPES =
63.71 - {
63.72 - ErrorDiffusionDithering.TYPE_FLOYD_STEINBERG,
63.73 - ErrorDiffusionDithering.TYPE_STUCKI,
63.74 - ErrorDiffusionDithering.TYPE_BURKES,
63.75 - ErrorDiffusionDithering.TYPE_SIERRA,
63.76 - ErrorDiffusionDithering.TYPE_JARVIS_JUDICE_NINKE,
63.77 - ErrorDiffusionDithering.TYPE_STEVENSON_ARCE
63.78 - };
63.79 +
63.80 private Button ok;
63.81 private Button cancel;
63.82
63.83 @@ -98,11 +105,13 @@
63.84 // 1.2 radio buttons (CheckboxGroup) with palette type
63.85 panel = new Panel(new GridLayout(0, 1));
63.86 paletteType = new CheckboxGroup();
63.87 - checkboxes = new Checkbox[PALETTE_STRING_CONSTANTS.length];
63.88 + PaletteType[] paletteTypes = PaletteType.values();
63.89 + checkboxes = new Checkbox[paletteTypes.length];
63.90 boolean selected = true;
63.91 - for (int i = 0; i < NUM_PALETTE_TYPES; i++)
63.92 + for (int i = 0; i < paletteTypes.length; i++)
63.93 {
63.94 - checkboxes[i] = new Checkbox(strings.get(PALETTE_STRING_CONSTANTS[i]), paletteType, selected);
63.95 + checkboxes[i] = new Checkbox(strings.get(paletteTypes[i].getStringConstant()),
63.96 + paletteType, selected);
63.97 selected = false;
63.98 panel.add(checkboxes[i]);
63.99 }
63.100 @@ -160,35 +169,29 @@
63.101
63.102 /**
63.103 * If the use of error diffusion was selected, this method
63.104 - * returns on of the ErrorDiffusionDithering TYPE constants
63.105 + * returns one of the ErrorDiffusionType enum values.
63.106 + * Otherwise, it returns <code>null</code>.
63.107 */
63.108 - public int getErrorDiffusionType()
63.109 + public ErrorDiffusionType getErrorDiffusionType()
63.110 {
63.111 int sel = dithering.getSelectedIndex();
63.112 - if (sel > 0 && sel <= ERROR_DIFFUSION_TYPES.length)
63.113 - {
63.114 - return ERROR_DIFFUSION_TYPES[sel - 1];
63.115 - }
63.116 - else
63.117 - {
63.118 - return -1;
63.119 - }
63.120 + return EnumHelper.fromOrdinal(ErrorDiffusionType.values(), sel - 1);
63.121 }
63.122
63.123 /**
63.124 * Return the palette type (one of the PALETTE_xyz constants of this class)
63.125 * that is currently selected in the dialog.
63.126 */
63.127 - public int getPaletteType()
63.128 + public PaletteType getPaletteType()
63.129 {
63.130 for (int i = 0; i < checkboxes.length; i++)
63.131 {
63.132 if (checkboxes[i].getState())
63.133 {
63.134 - return i;
63.135 + return EnumHelper.fromOrdinal(PaletteType.values(), i);
63.136 }
63.137 }
63.138 - return -1;
63.139 + return null;
63.140 }
63.141
63.142 /**
64.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/MedianCutDialog.java Mon Aug 03 23:22:22 2009 +0200
64.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/MedianCutDialog.java Sat Aug 08 23:06:58 2009 +0200
64.3 @@ -26,8 +26,9 @@
64.4 import java.awt.event.KeyEvent;
64.5 import java.awt.event.KeyListener;
64.6 import net.sourceforge.jiu.apps.Strings;
64.7 -import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering;
64.8 -import net.sourceforge.jiu.color.quantization.MedianCutQuantizer;
64.9 +import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering.ErrorDiffusionType;
64.10 +import net.sourceforge.jiu.color.quantization.MedianCutQuantizer.RepresentativeColorMethod;
64.11 +import net.sourceforge.jiu.util.EnumHelper;
64.12
64.13 /**
64.14 * A dialog to enter the parameters for a Median Cut color quantization operation.
64.15 @@ -37,18 +38,18 @@
64.16 public class MedianCutDialog extends Dialog implements
64.17 ActionListener, ItemListener, KeyListener
64.18 {
64.19 - public final int[][] METHODS =
64.20 + public final int[] METHOD_STRINGS =
64.21 {
64.22 - {
64.23 - MedianCutQuantizer.METHOD_REPR_COLOR_WEIGHTED_AVERAGE,
64.24 - MedianCutQuantizer.METHOD_REPR_COLOR_AVERAGE,
64.25 - MedianCutQuantizer.METHOD_REPR_COLOR_MEDIAN
64.26 - },
64.27 - {
64.28 - Strings.METHOD_REPR_COLOR_WEIGHTED_AVERAGE,
64.29 - Strings.METHOD_REPR_COLOR_AVERAGE,
64.30 - Strings.METHOD_REPR_COLOR_MEDIAN
64.31 - }
64.32 + Strings.METHOD_REPR_COLOR_WEIGHTED_AVERAGE,
64.33 + Strings.METHOD_REPR_COLOR_AVERAGE,
64.34 + Strings.METHOD_REPR_COLOR_MEDIAN
64.35 + };
64.36 + // Note: reordering of enum values
64.37 + public final RepresentativeColorMethod[] METHOD_VALUES =
64.38 + {
64.39 + RepresentativeColorMethod.WEIGHTED_AVERAGE,
64.40 + RepresentativeColorMethod.AVERAGE,
64.41 + RepresentativeColorMethod.MEDIAN,
64.42 };
64.43 public final int[] ERROR_DIFFUSION_STRINGS =
64.44 {
64.45 @@ -59,15 +60,6 @@
64.46 Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
64.47 Strings.STEVENSON_ARCE_ERROR_DIFFUSION
64.48 };
64.49 - public final int[] ERROR_DIFFUSION_TYPES =
64.50 - {
64.51 - ErrorDiffusionDithering.TYPE_FLOYD_STEINBERG,
64.52 - ErrorDiffusionDithering.TYPE_STUCKI,
64.53 - ErrorDiffusionDithering.TYPE_BURKES,
64.54 - ErrorDiffusionDithering.TYPE_SIERRA,
64.55 - ErrorDiffusionDithering.TYPE_JARVIS_JUDICE_NINKE,
64.56 - ErrorDiffusionDithering.TYPE_STEVENSON_ARCE
64.57 - };
64.58 private Button ok;
64.59 private Button cancel;
64.60 private TextField numColorsField;
64.61 @@ -89,7 +81,7 @@
64.62 * @param numPasses number of contour removal iterations
64.63 * @param initialTau maximum distance for two colors to be considered similar in contour removal
64.64 */
64.65 - public MedianCutDialog(Frame owner, Strings strings, int numColors, int representativeColorMethod, boolean paletted, int numPasses, double initialTau)
64.66 + public MedianCutDialog(Frame owner, Strings strings, int numColors, RepresentativeColorMethod representativeColorMethod, boolean paletted, int numPasses, double initialTau)
64.67 {
64.68 super(owner, strings.get(Strings.MEDIAN_CUT_COLOR_QUANTIZATION), true);
64.69 pressedOk = false;
64.70 @@ -111,10 +103,10 @@
64.71
64.72 panel.add(new Label(strings.get(Strings.METHOD_REPR_COLOR)));
64.73 reprColorMethod = new Choice();
64.74 - for (int i = 0; i < METHODS[0].length; i++)
64.75 + for (int i = 0; i < METHOD_STRINGS.length; i++)
64.76 {
64.77 - reprColorMethod.add(strings.get(METHODS[1][i]));
64.78 - if (representativeColorMethod == METHODS[0][i])
64.79 + reprColorMethod.add(strings.get(METHOD_STRINGS[i]));
64.80 + if (METHOD_VALUES[i] == representativeColorMethod)
64.81 {
64.82 reprColorMethod.select(i);
64.83 }
64.84 @@ -198,15 +190,15 @@
64.85 (screenSize.height / 2) - (height / 2));
64.86 }
64.87
64.88 - public int getErrorDiffusion()
64.89 + public ErrorDiffusionType getErrorDiffusion()
64.90 {
64.91 if (algorithms.getSelectedIndex() == 1)
64.92 {
64.93 - return ERROR_DIFFUSION_TYPES[errorDiffusion.getSelectedIndex()];
64.94 + return EnumHelper.fromOrdinal(ErrorDiffusionType.values(), errorDiffusion.getSelectedIndex());
64.95 }
64.96 else
64.97 {
64.98 - return -1;
64.99 + return null;
64.100 }
64.101 }
64.102
64.103 @@ -246,9 +238,9 @@
64.104 return getIntValue(numPassesField);
64.105 }
64.106
64.107 - public int getReprColorMethod()
64.108 + public RepresentativeColorMethod getReprColorMethod()
64.109 {
64.110 - return METHODS[0][reprColorMethod.getSelectedIndex()];
64.111 + return METHOD_VALUES[reprColorMethod.getSelectedIndex()];
64.112 }
64.113
64.114 public double getTau()
65.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/OctreeDialog.java Mon Aug 03 23:22:22 2009 +0200
65.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/OctreeDialog.java Sat Aug 08 23:06:58 2009 +0200
65.3 @@ -24,7 +24,8 @@
65.4 import java.awt.event.KeyEvent;
65.5 import java.awt.event.KeyListener;
65.6 import net.sourceforge.jiu.apps.Strings;
65.7 -import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering;
65.8 +import net.sourceforge.jiu.color.dithering.ErrorDiffusionDithering.ErrorDiffusionType;
65.9 +import net.sourceforge.jiu.util.EnumHelper;
65.10
65.11 /**
65.12 * A dialog to enter the parameters for an Octree color quantization operation.
65.13 @@ -47,16 +48,6 @@
65.14 Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
65.15 Strings.STEVENSON_ARCE_ERROR_DIFFUSION
65.16 };
65.17 - public final int[] DITHERING_TYPES =
65.18 - {
65.19 - 0,
65.20 - ErrorDiffusionDithering.TYPE_FLOYD_STEINBERG,
65.21 - ErrorDiffusionDithering.TYPE_STUCKI,
65.22 - ErrorDiffusionDithering.TYPE_BURKES,
65.23 - ErrorDiffusionDithering.TYPE_SIERRA,
65.24 - ErrorDiffusionDithering.TYPE_JARVIS_JUDICE_NINKE,
65.25 - ErrorDiffusionDithering.TYPE_STEVENSON_ARCE
65.26 - };
65.27 private Button ok;
65.28 private Button cancel;
65.29 private TextField numColorsField;
65.30 @@ -147,17 +138,10 @@
65.31 (screenSize.height / 2) - (height / 2));
65.32 }
65.33
65.34 - public int getErrorDiffusion()
65.35 + public ErrorDiffusionType getErrorDiffusion()
65.36 {
65.37 int sel = dithering.getSelectedIndex();
65.38 - if (sel > 0)
65.39 - {
65.40 - return DITHERING_TYPES[sel];
65.41 - }
65.42 - else
65.43 - {
65.44 - return -1;
65.45 - }
65.46 + return EnumHelper.fromOrdinal(ErrorDiffusionType.values(), sel-1);
65.47 }
65.48
65.49 private int getIntValue(TextField textField)
66.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/ReduceGrayscaleDialog.java Mon Aug 03 23:22:22 2009 +0200
66.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/ReduceGrayscaleDialog.java Sat Aug 08 23:06:58 2009 +0200
66.3 @@ -23,7 +23,10 @@
66.4 import java.awt.event.ActionListener;
66.5 import java.awt.event.AdjustmentEvent;
66.6 import java.awt.event.AdjustmentListener;
66.7 +
66.8 import net.sourceforge.jiu.apps.Strings;
66.9 +import net.sourceforge.jiu.gui.awt.DitheringMethod;
66.10 +import net.sourceforge.jiu.util.EnumHelper;
66.11
66.12 /**
66.13 * A dialog to enter the parameters for a grayscale reduction operation.
66.14 @@ -31,37 +34,6 @@
66.15 */
66.16 public class ReduceGrayscaleDialog extends Dialog implements ActionListener, AdjustmentListener
66.17 {
66.18 - public static final int TYPE_DITHERING_NONE = 0;
66.19 - public static final int TYPE_ORDERED_DITHERING = 1;
66.20 - public static final int TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION = 2;
66.21 - public static final int TYPE_STUCKI_ERROR_DIFFUSION = 3;
66.22 - public static final int TYPE_BURKES_ERROR_DIFFUSION = 4;
66.23 - public static final int TYPE_SIERRA_ERROR_DIFFUSION = 5;
66.24 - public static final int TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION = 6;
66.25 - public static final int TYPE_STEVENSON_ARCE_ERROR_DIFFUSION = 7;
66.26 - public final int[][] DITHERING_METHODS =
66.27 - {
66.28 - {
66.29 - TYPE_DITHERING_NONE,
66.30 - TYPE_ORDERED_DITHERING,
66.31 - TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION,
66.32 - TYPE_STUCKI_ERROR_DIFFUSION,
66.33 - TYPE_BURKES_ERROR_DIFFUSION,
66.34 - TYPE_SIERRA_ERROR_DIFFUSION,
66.35 - TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
66.36 - TYPE_STEVENSON_ARCE_ERROR_DIFFUSION
66.37 - },
66.38 - {
66.39 - Strings.DITHERING_NONE,
66.40 - Strings.ORDERED_DITHERING,
66.41 - Strings.FLOYD_STEINBERG_ERROR_DIFFUSION,
66.42 - Strings.STUCKI_ERROR_DIFFUSION,
66.43 - Strings.BURKES_ERROR_DIFFUSION,
66.44 - Strings.SIERRA_ERROR_DIFFUSION,
66.45 - Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
66.46 - Strings.STEVENSON_ARCE_ERROR_DIFFUSION
66.47 - }
66.48 - };
66.49 private Strings strings;
66.50 private Button ok;
66.51 private Button cancel;
66.52 @@ -80,7 +52,7 @@
66.53 * @param ditheringMethodSelection initial selection of dithering method
66.54 */
66.55 public ReduceGrayscaleDialog(Frame owner, Strings strings, int bits, int maxBits,
66.56 - int ditheringMethodSelection)
66.57 + DitheringMethod ditheringMethodSelection)
66.58 {
66.59 super(owner, strings.get(Strings.REDUCE_NUMBER_OF_SHADES_OF_GRAY), true);
66.60 pressedOk = false;
66.61 @@ -100,12 +72,12 @@
66.62
66.63 panel.add(new Label(strings.get(Strings.DITHERING_METHOD)));
66.64 ditheringMethod = new Choice();
66.65 - for (int i = 0; i < DITHERING_METHODS[0].length; i++)
66.66 + for (DitheringMethod method: DitheringMethod.values())
66.67 {
66.68 - ditheringMethod.add(strings.get(DITHERING_METHODS[1][i]));
66.69 - if (ditheringMethodSelection == i)
66.70 + ditheringMethod.add(strings.get(method.getStringConstant()));
66.71 + if (method == ditheringMethodSelection)
66.72 {
66.73 - ditheringMethod.select(i);
66.74 + ditheringMethod.select(method.ordinal());
66.75 }
66.76 }
66.77 panel.add(ditheringMethod);
66.78 @@ -164,9 +136,9 @@
66.79 (screenSize.height / 2) - (height / 2));
66.80 }
66.81
66.82 - public int getDitheringMethod()
66.83 + public DitheringMethod getDitheringMethod()
66.84 {
66.85 - return DITHERING_METHODS[0][ditheringMethod.getSelectedIndex()];
66.86 + return EnumHelper.fromOrdinal(DitheringMethod.values(), ditheringMethod.getSelectedIndex());
66.87 }
66.88
66.89 public int getNumBits()
67.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/ScaleDialog.java Mon Aug 03 23:22:22 2009 +0200
67.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/ScaleDialog.java Sat Aug 08 23:06:58 2009 +0200
67.3 @@ -26,6 +26,8 @@
67.4 import java.awt.event.KeyEvent;
67.5 import java.awt.event.KeyListener;
67.6 import net.sourceforge.jiu.apps.Strings;
67.7 +import net.sourceforge.jiu.geometry.Resample.FilterType;
67.8 +import net.sourceforge.jiu.util.EnumHelper;
67.9
67.10 /**
67.11 * A dialog to enter the parameters for an image scaling operation.
67.12 @@ -44,7 +46,7 @@
67.13 private String oldHeightString;
67.14 private int oldWidth;
67.15 private int oldHeight;
67.16 - private int type;
67.17 + private FilterType type;
67.18
67.19 /**
67.20 * Creates an InfoDialog, a modal dialog to display a text message, centered on the desktop.
67.21 @@ -56,7 +58,7 @@
67.22 * @param typeNames names of the image scaling algorithms
67.23 * @param initialType algorithm type to be initially selected
67.24 */
67.25 - public ScaleDialog(Frame owner, Strings strings, int width, int height, boolean pickType, String[] typeNames, int initialType)
67.26 + public ScaleDialog(Frame owner, Strings strings, int width, int height, boolean pickType, String[] typeNames, FilterType initialType)
67.27 {
67.28 super(owner, strings.get(Strings.SCALE_IMAGE), true);
67.29 pressedOk = false;
67.30 @@ -94,7 +96,7 @@
67.31 {
67.32 types.add(typeNames[i]);
67.33 }
67.34 - types.select(initialType);
67.35 + types.select(initialType.ordinal());
67.36 panel.add(types);
67.37 }
67.38 add(panel, BorderLayout.CENTER);
67.39 @@ -149,7 +151,7 @@
67.40 return getValue(heightTextField);
67.41 }
67.42
67.43 - public int getType()
67.44 + public FilterType getType()
67.45 {
67.46 if (types == null)
67.47 {
67.48 @@ -157,7 +159,7 @@
67.49 }
67.50 else
67.51 {
67.52 - return types.getSelectedIndex();
67.53 + return EnumHelper.fromOrdinal(FilterType.values(), types.getSelectedIndex());
67.54 }
67.55 }
67.56
67.57 @@ -194,7 +196,7 @@
67.58 int w = getValue(widthTextField);
67.59 if (w > 0)
67.60 {
67.61 - oldHeightString = Integer.toString((int)(w * (float)oldHeight / (float)oldWidth));
67.62 + oldHeightString = Integer.toString((int)(w * oldHeight / (float)oldWidth));
67.63 heightTextField.setText(oldHeightString);
67.64 }
67.65 }
67.66 @@ -209,7 +211,7 @@
67.67 int h = getValue(heightTextField);
67.68 if (h > 0)
67.69 {
67.70 - oldWidthString = Integer.toString((int)(h * (float)oldWidth / (float)oldHeight));
67.71 + oldWidthString = Integer.toString((int)(h * oldWidth / (float)oldHeight));
67.72 widthTextField.setText(oldWidthString);
67.73 }
67.74 }
68.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/UniformPaletteQuantizerDialog.java Mon Aug 03 23:22:22 2009 +0200
68.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/UniformPaletteQuantizerDialog.java Sat Aug 08 23:06:58 2009 +0200
68.3 @@ -26,6 +26,8 @@
68.4 import java.awt.event.ItemEvent;
68.5 import java.awt.event.ItemListener;
68.6 import net.sourceforge.jiu.apps.Strings;
68.7 +import net.sourceforge.jiu.gui.awt.DitheringMethod;
68.8 +import net.sourceforge.jiu.util.EnumHelper;
68.9
68.10 /**
68.11 * An AWT dialog to enter the parameters for a uniform palette color quantization operation.
68.12 @@ -33,37 +35,6 @@
68.13 */
68.14 public class UniformPaletteQuantizerDialog extends Dialog implements ActionListener, AdjustmentListener, ItemListener
68.15 {
68.16 - public static final int TYPE_DITHERING_NONE = 0;
68.17 - public static final int TYPE_ORDERED_DITHERING = 1;
68.18 - public static final int TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION = 2;
68.19 - public static final int TYPE_STUCKI_ERROR_DIFFUSION = 3;
68.20 - public static final int TYPE_BURKES_ERROR_DIFFUSION = 4;
68.21 - public static final int TYPE_SIERRA_ERROR_DIFFUSION = 5;
68.22 - public static final int TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION = 6;
68.23 - public static final int TYPE_STEVENSON_ARCE_ERROR_DIFFUSION = 7;
68.24 - public final int[][] DITHERING_METHODS =
68.25 - {
68.26 - {
68.27 - TYPE_DITHERING_NONE,
68.28 - TYPE_ORDERED_DITHERING,
68.29 - TYPE_FLOYD_STEINBERG_ERROR_DIFFUSION,
68.30 - TYPE_STUCKI_ERROR_DIFFUSION,
68.31 - TYPE_BURKES_ERROR_DIFFUSION,
68.32 - TYPE_SIERRA_ERROR_DIFFUSION,
68.33 - TYPE_JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
68.34 - TYPE_STEVENSON_ARCE_ERROR_DIFFUSION
68.35 - },
68.36 - {
68.37 - Strings.DITHERING_NONE,
68.38 - Strings.ORDERED_DITHERING,
68.39 - Strings.FLOYD_STEINBERG_ERROR_DIFFUSION,
68.40 - Strings.STUCKI_ERROR_DIFFUSION,
68.41 - Strings.BURKES_ERROR_DIFFUSION,
68.42 - Strings.SIERRA_ERROR_DIFFUSION,
68.43 - Strings.JARVIS_JUDICE_NINKE_ERROR_DIFFUSION,
68.44 - Strings.STEVENSON_ARCE_ERROR_DIFFUSION
68.45 - }
68.46 - };
68.47 private Strings strings;
68.48 private Button ok;
68.49 private Button cancel;
68.50 @@ -88,7 +59,7 @@
68.51 * @param ditheringMethodSelection initial selection for dithering method
68.52 */
68.53 public UniformPaletteQuantizerDialog(Frame owner, Strings strings, int redBits,
68.54 - int greenBits, int blueBits, int ditheringMethodSelection)
68.55 + int greenBits, int blueBits, DitheringMethod ditheringMethodSelection)
68.56 {
68.57 super(owner, strings.get(Strings.UNIFORM_PALETTE_COLOR_QUANTIZATION), true);
68.58 pressedOk = false;
68.59 @@ -121,12 +92,12 @@
68.60
68.61 panel.add(new Label(strings.get(Strings.DITHERING_METHOD)));
68.62 ditheringMethod = new Choice();
68.63 - for (int i = 0; i < DITHERING_METHODS[0].length; i++)
68.64 + for (DitheringMethod method: DitheringMethod.values())
68.65 {
68.66 - ditheringMethod.add(strings.get(DITHERING_METHODS[1][i]));
68.67 - if (ditheringMethodSelection == i)
68.68 + ditheringMethod.add(strings.get(method.getStringConstant()));
68.69 + if (method == ditheringMethodSelection)
68.70 {
68.71 - ditheringMethod.select(i);
68.72 + ditheringMethod.select(method.ordinal());
68.73 }
68.74 }
68.75 ditheringMethod.addItemListener(this);
68.76 @@ -191,9 +162,9 @@
68.77 return getValue(numColorsField);
68.78 }*/
68.79
68.80 - public int getDitheringMethod()
68.81 + public DitheringMethod getDitheringMethod()
68.82 {
68.83 - return DITHERING_METHODS[0][ditheringMethod.getSelectedIndex()];
68.84 + return EnumHelper.fromOrdinal(DitheringMethod.values(), ditheringMethod.getSelectedIndex());
68.85 }
68.86
68.87 public int getBlueBits()
68.88 @@ -222,7 +193,7 @@
68.89 int g = getGreenBits();
68.90 int b = getBlueBits();
68.91 int sum = r + g + b;
68.92 - if (getDitheringMethod() == TYPE_DITHERING_NONE)
68.93 + if (getDitheringMethod() == DitheringMethod.NONE)
68.94 {
68.95 return (sum < 9);
68.96 }
69.1 --- a/net/sourceforge/jiu/gui/awt/dialogs/YesNoDialog.java Mon Aug 03 23:22:22 2009 +0200
69.2 +++ b/net/sourceforge/jiu/gui/awt/dialogs/YesNoDialog.java Sat Aug 08 23:06:58 2009 +0200
69.3 @@ -2,6 +2,7 @@
69.4 * YesNoDialog
69.5 *
69.6 * Copyright (c) 2003 Marco Schmidt.
69.7 + * Copyright (c) 2009 Knut Arild Erstad.
69.8 * All rights reserved.
69.9 */
69.10
69.11 @@ -26,23 +27,23 @@
69.12 public class YesNoDialog extends Dialog implements ActionListener
69.13 {
69.14 /**
69.15 - * Will be returned in {@link #getResult} if the YES button was chosen.
69.16 + * Enumerates the possible dialog results.
69.17 + * @see YesNoDialog#getResult()
69.18 */
69.19 - public static final int RESULT_YES = 0;
69.20 + public enum Result
69.21 + {
69.22 + /** The YES button was chosen. */
69.23 + YES,
69.24 + /** The NO button was chosen. */
69.25 + NO,
69.26 + /** The CANCEL button was chosen. */
69.27 + CANCEL,
69.28 + }
69.29
69.30 - /**
69.31 - * Will be returned in {@link #getResult} if the NO button was chosen.
69.32 - */
69.33 - public static final int RESULT_NO = 1;
69.34 -
69.35 - /**
69.36 - * Will be returned in {@link #getResult} if the CANCEL button was chosen.
69.37 - */
69.38 - public static final int RESULT_CANCEL = 2;
69.39 private Button yes;
69.40 private Button no;
69.41 private Button cancel;
69.42 - private int result;
69.43 + private Result result;
69.44
69.45 /**
69.46 * Creates a new YesNoDialog object and shows it centered on the screen.
69.47 @@ -86,28 +87,28 @@
69.48 {
69.49 if (e.getSource() == yes)
69.50 {
69.51 - result = RESULT_YES;
69.52 + result = Result.YES;
69.53 setVisible(false);
69.54 }
69.55 else
69.56 if (e.getSource() == no)
69.57 {
69.58 - result = RESULT_NO;
69.59 + result = Result.NO;
69.60 setVisible(false);
69.61 }
69.62 else
69.63 if (e.getSource() == cancel)
69.64 {
69.65 - result = RESULT_CANCEL;
69.66 + result = Result.CANCEL;
69.67 setVisible(false);
69.68 }
69.69 }
69.70
69.71 /**
69.72 - * Returns one of the RESULT_xyz constants of this class.
69.73 - * @return the RESULT constant of the button which the user has chosen
69.74 + * Returns the result enum value
69.75 + * @return the {@link Result} of the button the user has chosen
69.76 */
69.77 - public int getResult()
69.78 + public Result getResult()
69.79 {
69.80 return result;
69.81 }
70.1 --- a/net/sourceforge/jiu/ops/BatchProcessorOperation.java Mon Aug 03 23:22:22 2009 +0200
70.2 +++ b/net/sourceforge/jiu/ops/BatchProcessorOperation.java Sat Aug 08 23:06:58 2009 +0200
70.3 @@ -8,7 +8,7 @@
70.4 package net.sourceforge.jiu.ops;
70.5
70.6 import java.io.File;
70.7 -import java.util.Vector;
70.8 +import java.util.ArrayList;
70.9
70.10 /**
70.11 * Small data class for names of directories that are to be
70.12 @@ -37,9 +37,9 @@
70.13 public abstract class BatchProcessorOperation extends Operation
70.14 {
70.15 private boolean collectErrors;
70.16 - private Vector directoryTrees = new Vector();
70.17 - private Vector errorMessages = new Vector();
70.18 - private Vector inputFileNames = new Vector();
70.19 + private ArrayList<DirectoryTree> directoryTrees = new ArrayList<DirectoryTree>();
70.20 + private ArrayList<String> errorMessages = new ArrayList<String>();
70.21 + private ArrayList<String> inputFileNames = new ArrayList<String>();
70.22 private String outputDirectory;
70.23 private boolean overwrite;
70.24
70.25 @@ -65,7 +65,7 @@
70.26 DirectoryTree tree = new DirectoryTree();
70.27 tree.input = rootDirectoryName;
70.28 tree.output = outputRootDirectoryName;
70.29 - directoryTrees.addElement(tree);
70.30 + directoryTrees.add(tree);
70.31 }
70.32
70.33 /**
70.34 @@ -74,20 +74,18 @@
70.35 */
70.36 public void addInputFileName(String fileName)
70.37 {
70.38 - inputFileNames.addElement(fileName);
70.39 + inputFileNames.add(fileName);
70.40 }
70.41
70.42 /**
70.43 * Adds a number of file names to the internal list of file names to be processed.
70.44 * @param fileNameList list of file names, each object in the list must be a String
70.45 */
70.46 - public void addInputFileNames(Vector fileNameList)
70.47 + public void addInputFileNames(ArrayList<String> fileNameList)
70.48 {
70.49 - int index = 0;
70.50 - while (index < fileNameList.size())
70.51 + for (String fileName: fileNameList)
70.52 {
70.53 - String fileName = (String)fileNameList.elementAt(index++);
70.54 - inputFileNames.addElement(fileName);
70.55 + inputFileNames.add(fileName);
70.56 }
70.57 }
70.58
70.59 @@ -95,7 +93,7 @@
70.60 * Returns a list of error messages collected during the execution of {@link #process}.
70.61 * @return list of error messages, each object is a String
70.62 */
70.63 - public Vector getErrorMessages()
70.64 + public ArrayList<String> getErrorMessages()
70.65 {
70.66 return errorMessages;
70.67 }
70.68 @@ -119,7 +117,7 @@
70.69 int index = 0;
70.70 while (index < directoryTrees.size())
70.71 {
70.72 - DirectoryTree tree = (DirectoryTree)directoryTrees.elementAt(index++);
70.73 + DirectoryTree tree = directoryTrees.get(index++);
70.74 String output = tree.output;
70.75 if (output == null)
70.76 {
70.77 @@ -131,13 +129,13 @@
70.78 index = 0;
70.79 while (index < inputFileNames.size())
70.80 {
70.81 - String fileName = (String)inputFileNames.elementAt(index++);
70.82 + String fileName = inputFileNames.get(index++);
70.83 File file = new File(fileName);
70.84 if (!file.isFile())
70.85 {
70.86 if (collectErrors)
70.87 {
70.88 - errorMessages.addElement("Cannot process \"" + fileName + "\" (not a file).");
70.89 + errorMessages.add("Cannot process \"" + fileName + "\" (not a file).");
70.90 }
70.91 }
70.92 String inDir = file.getParent();
70.93 @@ -173,7 +171,7 @@
70.94 {
70.95 if (collectErrors)
70.96 {
70.97 - errorMessages.addElement("Cannot create output directory \"" +
70.98 + errorMessages.add("Cannot create output directory \"" +
70.99 outSubDir.getAbsolutePath() + "\" because a file of that name already exists.");
70.100 }
70.101 continue;
70.102 @@ -185,7 +183,7 @@
70.103 {
70.104 if (collectErrors)
70.105 {
70.106 - errorMessages.addElement("Could not create output directory \"" +
70.107 + errorMessages.add("Could not create output directory \"" +
70.108 outSubDir.getAbsolutePath() + "\".");
70.109 }
70.110 continue;
71.1 --- a/net/sourceforge/jiu/ops/ImagesToImageOperation.java Mon Aug 03 23:22:22 2009 +0200
71.2 +++ b/net/sourceforge/jiu/ops/ImagesToImageOperation.java Sat Aug 08 23:06:58 2009 +0200
71.3 @@ -7,7 +7,7 @@
71.4
71.5 package net.sourceforge.jiu.ops;
71.6
71.7 -import java.util.Vector;
71.8 +import java.util.ArrayList;
71.9 import net.sourceforge.jiu.data.PixelImage;
71.10 import net.sourceforge.jiu.ops.Operation;
71.11 import net.sourceforge.jiu.ops.WrongParameterException;
71.12 @@ -20,7 +20,7 @@
71.13 */
71.14 public abstract class ImagesToImageOperation extends Operation
71.15 {
71.16 - private Vector inputImages = new Vector();
71.17 + private ArrayList<PixelImage> inputImages = new ArrayList<PixelImage>();
71.18 private PixelImage outputImage;
71.19
71.20 /**
71.21 @@ -36,13 +36,13 @@
71.22 * Constructs a new ImagesToImageOperation and initializes
71.23 * input images and output image to the arguments.
71.24 */
71.25 - public ImagesToImageOperation(Vector in, PixelImage out)
71.26 + public ImagesToImageOperation(ArrayList<PixelImage> in, PixelImage out)
71.27 {
71.28 if (in != null)
71.29 {
71.30 - for (int i = 0; i < in.size(); i++)
71.31 + for (PixelImage image: in)
71.32 {
71.33 - addInputImage((PixelImage)in.elementAt(i));
71.34 + addInputImage(image);
71.35 }
71.36 }
71.37 setOutputImage(out);
71.38 @@ -54,7 +54,7 @@
71.39 */
71.40 public void addInputImage(PixelImage in)
71.41 {
71.42 - inputImages.addElement(in);
71.43 + inputImages.add(in);
71.44 }
71.45
71.46 /**
71.47 @@ -133,7 +133,7 @@
71.48 */
71.49 public PixelImage getInputImage(int index)
71.50 {
71.51 - return (PixelImage)inputImages.elementAt(index);
71.52 + return inputImages.get(index);
71.53 }
71.54
71.55 /**
72.1 --- a/net/sourceforge/jiu/ops/Operation.java Mon Aug 03 23:22:22 2009 +0200
72.2 +++ b/net/sourceforge/jiu/ops/Operation.java Sat Aug 08 23:06:58 2009 +0200
72.3 @@ -7,7 +7,7 @@
72.4
72.5 package net.sourceforge.jiu.ops;
72.6
72.7 -import java.util.Vector;
72.8 +import java.util.ArrayList;
72.9 import net.sourceforge.jiu.ops.MissingParameterException;
72.10 import net.sourceforge.jiu.ops.OperationFailedException;
72.11 import net.sourceforge.jiu.ops.ProgressListener;
72.12 @@ -53,7 +53,7 @@
72.13 * </p>
72.14 */
72.15 private boolean abort;
72.16 - private Vector progressListeners;
72.17 + private ArrayList<ProgressListener> progressListeners;
72.18
72.19 /**
72.20 * This constructor creates two internal empty lists for progress listeners and parameters.
72.21 @@ -61,7 +61,7 @@
72.22 public Operation()
72.23 {
72.24 abort = false;
72.25 - progressListeners = new Vector();
72.26 + progressListeners = new ArrayList<ProgressListener>();
72.27 }
72.28
72.29 /**
72.30 @@ -80,7 +80,7 @@
72.31 }
72.32 if (!progressListeners.contains(progressListener))
72.33 {
72.34 - progressListeners.addElement(progressListener);
72.35 + progressListeners.add(progressListener);
72.36 }
72.37 }
72.38
72.39 @@ -89,14 +89,12 @@
72.40 * @param progressListeners contains zero or more objects implementing ProgressListener;
72.41 * each will be added by calling {@link #addProgressListener} on it
72.42 */
72.43 - public void addProgressListeners(Vector progressListeners)
72.44 + public void addProgressListeners(ArrayList<ProgressListener> progressListeners)
72.45 {
72.46 if (progressListeners != null)
72.47 {
72.48 - int index = 0;
72.49 - while (index < progressListeners.size())
72.50 + for (ProgressListener listener: progressListeners)
72.51 {
72.52 - ProgressListener listener = (ProgressListener)progressListeners.elementAt(index++);
72.53 addProgressListener(listener);
72.54 }
72.55 }
72.56 @@ -136,7 +134,7 @@
72.57 */
72.58 public void removeProgressListener(ProgressListener progressListener)
72.59 {
72.60 - progressListeners.removeElement(progressListener);
72.61 + progressListeners.remove(progressListener);
72.62 }
72.63
72.64 /**
72.65 @@ -165,11 +163,8 @@
72.66 throw new IllegalArgumentException("Progress values must be from" +
72.67 " 0.0f to 1.0f; got " + progress);
72.68 }
72.69 - int index = 0;
72.70 - while (index < progressListeners.size())
72.71 + for (ProgressListener pl : progressListeners)
72.72 {
72.73 - ProgressListener pl =
72.74 - (ProgressListener)progressListeners.elementAt(index++);
72.75 if (pl != null)
72.76 {
72.77 pl.setProgress(progress);
73.1 --- a/net/sourceforge/jiu/util/ComparatorInterface.java Mon Aug 03 23:22:22 2009 +0200
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,28 +0,0 @@
73.4 -/*
73.5 - * ComparatorInterface
73.6 - *
73.7 - * Copyright (c) 2001, 2002, 2003, 2004, 2005 Marco Schmidt
73.8 - * All rights reserved.
73.9 - */
73.10 -
73.11 -package net.sourceforge.jiu.util;
73.12 -
73.13 -/**
73.14 - * To be able to do sorting in Java 1.1 as defined in java.util.Arrays (which
73.15 - * is only available in Java 1.2 and higher), we offer a java.util.Comparator
73.16 - * clone under a different name: ComparatorInterface.
73.17 - * Sorting will be provided by the {@link Sort} class of this package.
73.18 - */
73.19 -public interface ComparatorInterface
73.20 -{
73.21 - /**
73.22 - * Compares the two argument objects and returns their relation.
73.23 - * Returns
73.24 - * <ul>
73.25 - * <li>a value < 0 if <code>o1</code> is smaller than <code>o2</code>,</li>
73.26 - * <li>0 if <code>o1</code> is equal to <code>o2</code> and</li>
73.27 - * <li>a value > 0 if <code>o1</code> is greater than <code>o2</code>.</li>
73.28 - * </ul>
73.29 - */
73.30 - int compare(Object o1, Object o2);
73.31 -}
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
74.2 +++ b/net/sourceforge/jiu/util/EnumHelper.java Sat Aug 08 23:06:58 2009 +0200
74.3 @@ -0,0 +1,53 @@
74.4 +/*
74.5 + * Copyright (C) 2009 Knut Arild Erstad
74.6 + *
74.7 + * This file is part of JIU, the Java Imaging Utilities.
74.8 + *
74.9 + * JIU is free software; you can redistribute it and/or modify
74.10 + * it under the terms of the GNU General Public License as published by
74.11 + * the Free Software Foundation version 2.
74.12 + *
74.13 + * Contributions by Knut Arild Erstad (including this file) can be
74.14 + * redistributed and/or modified under GPL 2 or any later versions.
74.15 + *
74.16 + * JIU is distributed in the hope that it will be useful,
74.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
74.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74.19 + * GNU General Public License for more details.
74.20 + *
74.21 + * You should have received a copy of the GNU General Public License
74.22 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
74.23 + */
74.24 +package net.sourceforge.jiu.util;
74.25 +
74.26 +/**
74.27 + * Helper functions for enums.
74.28 + * @author Knut Arild Erstad
74.29 + */
74.30 +public class EnumHelper
74.31 +{
74.32 + /**
74.33 + * Disallow construction by declaring a private constructor.
74.34 + */
74.35 + private EnumHelper()
74.36 + {
74.37 + }
74.38 +
74.39 + /**
74.40 + * Convert an integer to an enum value.
74.41 + * Returns <code>null</code> for out-of-range values.
74.42 + *
74.43 + * @param <E> An enum type.
74.44 + * @param enumValues An array of enum values, which should be retrieved from E.values().
74.45 + * @param ordinal An integer.
74.46 + * @return An enum value if the integer is in range, otherwise <code>null</code>.
74.47 + */
74.48 + public static <E extends Enum<E>> E fromOrdinal(E[] enumValues, int ordinal)
74.49 + {
74.50 + if (ordinal < 0 || ordinal >= enumValues.length)
74.51 + return null;
74.52 + E value = enumValues[ordinal];
74.53 + assert value.ordinal() == ordinal;
74.54 + return value;
74.55 + }
74.56 +}
75.1 --- a/net/sourceforge/jiu/util/Sort.java Mon Aug 03 23:22:22 2009 +0200
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,175 +0,0 @@
75.4 -/*
75.5 - * Sort
75.6 - *
75.7 - * Copyright (c) 2001, 2002, 2003 Marco Schmidt.
75.8 - * All rights reserved.
75.9 - */
75.10 -
75.11 -package net.sourceforge.jiu.util;
75.12 -
75.13 -import net.sourceforge.jiu.util.ComparatorInterface;
75.14 -
75.15 -/**
75.16 - * Provides sorting of an Object array.
75.17 - * @author Marco Schmidt
75.18 - */
75.19 -public class Sort
75.20 -{
75.21 - /**
75.22 - * This class is supposed to have static methods only.
75.23 - * To hide any constructor, we define an empty private one.
75.24 - */
75.25 - private Sort()
75.26 - {
75.27 - }
75.28 -
75.29 - /**
75.30 - * Sorts some (or all) elements of an Object array according to a specified comparator.
75.31 - * This method does exactly the same as java.util.Arrays.sort(Object[], int, int, Comparator).
75.32 - * Unfortunately, this method is not available in Java 1.1, so it must be provided here.
75.33 - * <p>
75.34 - * As for the implementation of this method, it is taken from Arrays.java as found in
75.35 - * Classpath 0.0.2 (2001-01-06).
75.36 - * Go to <a href="http://www.classpath.org">www.classpath.org</a> to learn more
75.37 - * about the project, which implements the Java core libraries under the GPL.
75.38 - *
75.39 - * @param a the array which is to be sorted
75.40 - * @param from the index value of the first element of the interval to be sorted
75.41 - * @param to the index value of the last element of the interval to be sorted
75.42 - * @param c the comparator used to query the relation between two objects
75.43 - */
75.44 - public static void sort(Object[] a, int from, int to, ComparatorInterface c)
75.45 - {
75.46 - if (a == null)
75.47 - {
75.48 - throw new IllegalArgumentException("The object array to be sorted must be non-null.");
75.49 - }
75.50 - if (from > to)
75.51 - {
75.52 - throw new IllegalArgumentException("The from parameter (" + from + ") must be smaller than or equal to the to parameter (" + to + ").");
75.53 - }
75.54 - if (to >= a.length)
75.55 - {
75.56 - throw new IllegalArgumentException("The to parameter (" + to + ") must be smaller than the array length (" + a.length + ").");
75.57 - }
75.58 - if (c == null)
75.59 - {
75.60 - throw new IllegalArgumentException("The comparator parameter must be non-null.");
75.61 - }
75.62 - // First presort the array in chunks of length 6 with insertion sort.
75.63 - // mergesort would give too much overhead for this length.
75.64 - for (int chunk = from; chunk < to; chunk += 6)
75.65 - {
75.66 - int end = Math.min(chunk + 6, to);
75.67 - for (int i = chunk + 1; i < end; i++)
75.68 - {
75.69 - if (c.compare(a[i - 1], a[i]) > 0)
75.70 - {
75.71 - // not already sorted
75.72 - int j = i;
75.73 - Object elem = a[j];
75.74 - do
75.75 - {
75.76 - a[j] = a[j - 1];
75.77 - j--;
75.78 - }
75.79 - while (j > chunk && c.compare(a[j - 1], elem) > 0);
75.80 - a[j] = elem;
75.81 - }
75.82 - }
75.83 - }
75.84 -
75.85 - int len = to - from;
75.86 - // If length is smaller or equal 6 we are done.
75.87 - if (len <= 6)
75.88 - return;
75.89 -
75.90 - Object[]src = a;
75.91 - Object[]dest = new Object[len];
75.92 - Object[]t = null; // t is used for swapping src and dest
75.93 -
75.94 - // The difference of the fromIndex of the src and dest array.
75.95 - int srcDestDiff = -from;
75.96 -
75.97 - // The merges are done in this loop
75.98 - for (int size = 6; size < len; size <<= 1)
75.99 - {
75.100 - for (int start = from; start < to; start += size << 1)
75.101 - {
75.102 - // mid ist the start of the second sublist;
75.103 - // end the start of the next sublist (or end of array).
75.104 - int mid = start + size;
75.105 - int end = Math.min(to, mid + size);
75.106 -
75.107 - // The second list is empty or the elements are already in
75.108 - // order - no need to merge
75.109 - if (mid >= end || c.compare(src[mid - 1], src[mid]) <= 0)
75.110 - {
75.111 - System.arraycopy(src, start,
75.112 - dest, start + srcDestDiff, end - start);
75.113 -
75.114 - // The two halves just need swapping - no need to merge
75.115 - }
75.116 - else if (c.compare(src[start], src[end - 1]) > 0)
75.117 - {
75.118 - System.arraycopy(src, start,
75.119 - dest, end - size + srcDestDiff, size);
75.120 - System.arraycopy(src, mid,
75.121 - dest, start + srcDestDiff, end - mid);
75.122 -
75.123 - }
75.124 - else
75.125 - {
75.126 - // Declare a lot of variables to save repeating
75.127 - // calculations. Hopefully a decent JIT will put these
75.128 - // in registers and make this fast
75.129 - int p1 = start;
75.130 - int p2 = mid;
75.131 - int i = start + srcDestDiff;
75.132 -
75.133 - // The main merge loop; terminates as soon as either
75.134 - // half is ended
75.135 - while (p1 < mid && p2 < end)
75.136 - {
75.137 - dest[i++] =
75.138 - src[c.compare(src[p1], src[p2]) <= 0 ? p1++ : p2++];
75.139 - }
75.140 -
75.141 - // Finish up by copying the remainder of whichever half
75.142 - // wasn't finished.
75.143 - if (p1 < mid)
75.144 - System.arraycopy(src, p1, dest, i, mid - p1);
75.145 - else
75.146 - System.arraycopy(src, p2, dest, i, end - p2);
75.147 - }
75.148 - }
75.149 - // swap src and dest ready for the next merge
75.150 - t = src;
75.151 - src = dest;
75.152 - dest = t;
75.153 - from += srcDestDiff;
75.154 - to += srcDestDiff;
75.155 - srcDestDiff = -srcDestDiff;
75.156 - }
75.157 -
75.158 - // make sure the result ends up back in the right place. Note
75.159 - // that src and dest may have been swapped above, so src
75.160 - // contains the sorted array.
75.161 - if (src != a)
75.162 - {
75.163 - // Note that from == 0.
75.164 - System.arraycopy(src, 0, a, srcDestDiff, to);
75.165 - }
75.166 - }
75.167 -
75.168 - /**
75.169 - * Sort the complete argument array according to the argument comparator.
75.170 - * Simply calls <code>sort(a, 0, a.length - 1, comparator);</code>
75.171 - * @param a array to be sorted
75.172 - * @param comparator the comparator used to compare to array entries
75.173 - */
75.174 - public static void sort(Object[] a, ComparatorInterface comparator)
75.175 - {
75.176 - sort(a, 0, a.length - 1, comparator);
75.177 - }
75.178 -}
76.1 --- a/net/sourceforge/jiu/util/SystemInfo.java Mon Aug 03 23:22:22 2009 +0200
76.2 +++ b/net/sourceforge/jiu/util/SystemInfo.java Sat Aug 08 23:06:58 2009 +0200
76.3 @@ -86,7 +86,7 @@
76.4 CPU_ENDIANNESS,
76.5 CPU_ISALIST
76.6 };
76.7 - StringBuffer sb = new StringBuffer();
76.8 + StringBuilder sb = new StringBuilder();
76.9 for (int i = 0; i < PROPERTIES.length; i++)
76.10 {
76.11 try