00001 package NormalMeshAlgorithm;
00002
00003
00004 import java.io.File;
00005
00006 import junit.framework.Assert;
00007
00008 import Encoder.SnijPixelFunctieWaardenStrategy;
00009 import Encoder.SnijPixelPiercingWaardeStrategy;
00010 import ImageStuff.*;
00011
00012 public class CommandLineConfiguration extends Configuration {
00013
00014 public CommandLineConfiguration(String[] options){
00015 Debug.print("Standard use: -i inputpath -o outputpath -e error");
00016
00017 try{
00018 for(int i =0;i!=options.length;i+=2){
00019 if((i+1)>=options.length){
00020 set(options[i],"");
00021 }
00022 else{
00023 set(options[i],options[i+1]);
00024 }
00025 }
00026 }
00027 catch(Exception e){Debug.print(" use -h to see the help page");}
00028
00029 }
00030
00031
00032
00033
00034 private void printHelp(){
00035 Debug.print("-i " + "path: filepath for the image to compress");
00036 Debug.print("-o "+"path: filepath for the output image" );
00037 Debug.print("-e" +"error: value of the allowed error/pixel");
00038 Debug.print("-mb" +"[true|false]");
00039 Debug.print("-K" +"[int]");
00040 Debug.print("-L" +"[int]");
00041 Debug.print("-N" +"[int]");
00042 Debug.print("-D" +"DEGREE [int]");
00043 Debug.print("-IT" +"MeshIteratorTYPE [0 1 2]; [Error Triangle Edge]");
00044 Debug.print("-Wnr" + "WichNormToUseFoRRefinement: [0,1,2] [infty,L_1,L_2]");
00045 }
00046
00047
00048 private void set(String wat, String hoe){
00049 Assert.assertNotNull(wat);
00050 Assert.assertNotNull(hoe);
00051
00052 boolean bool=false;
00053 if(hoe.equalsIgnoreCase("true")){bool=true;}else{
00054
00055 }
00056
00057 if(wat.equalsIgnoreCase("-i")){
00058 super.setPath(hoe);
00059 int pos = hoe.lastIndexOf(File.separator);
00060 String naam = hoe.substring(pos+1,hoe.length());
00061 super.setImageName(naam);
00062 Debug.print("imagename=" + naam);
00063 }
00064
00065 if(wat.equals("-n")){
00066 super.setOutputName(hoe);
00067 }
00068
00069 if(wat.equalsIgnoreCase("-maxr")){
00070 super.setMaxRico(Integer.valueOf(hoe).intValue());
00071 }
00072
00073 if(wat.equals("-IT")){
00074 super.setIteratorType(Integer.valueOf(hoe).intValue());
00075 }
00076
00077 if(wat.equals("-Wnr")){
00078 super.setWhichNormToUseForRefinement(Integer.valueOf(hoe).intValue());
00079 }
00080
00081 if(wat.equals("-N")){
00082 super.setN(Integer.valueOf(hoe).intValue());
00083 }
00084
00085 if(wat.equalsIgnoreCase("-K")){
00086 super.setK(Integer.valueOf(hoe).intValue());
00087 }
00088
00089 if(wat.equalsIgnoreCase("-L")){
00090 super.setL(Integer.valueOf(hoe).intValue());
00091 }
00092
00093 if(wat.equalsIgnoreCase("-D")){
00094 super.setDEGREE(Integer.valueOf(hoe).intValue());
00095 }
00096
00097
00098 if(wat.equalsIgnoreCase("-o")){
00099 super.setOutputDir(hoe);
00100 }
00101
00102 if(wat.equalsIgnoreCase("-e")){
00103 super.setError(Float.valueOf(hoe).floatValue());
00104 }
00105
00106
00107 if(wat.equalsIgnoreCase("-mb")){
00108 super.setMakeBaseMesh(bool);
00109 }
00110
00111 if(wat.equalsIgnoreCase("-h")){
00112 this.printHelp();
00113 System.exit(-1);
00114 }
00115
00116 }
00117
00118
00119 }