ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
NuclideChart.java
Go to the documentation of this file.
00001 import java.io.*;
00002 import java.awt.*;
00003 import java.awt.geom.*;
00004 import java.text.*;
00005 import java.awt.image.*;
00006 import java.awt.font.*;
00007 import javax.imageio.*;
00008 import javax.swing.ImageIcon;
00009 import javax.swing.*;
00010 import java.util.ArrayList;
00011 
00023 public class NuclideChart
00024 {    
00028     public static void main(String[] args)
00029     {
00030         if(args.length == 0)
00031             {
00032                 printHelp();
00033                 System.exit(0);
00034             }
00035         
00036         IndataParameters myParameters = new IndataParameters(args);
00037         
00038         ArrayList<JIsotope> isotopeList  = readJIsotopeList(myParameters.getJIsotopeFiles(), myParameters.getRGBVectorList());
00039 
00040         EPSCreator myEPSCreator;
00041         if(!myParameters.getSectionSpecified())
00042             myEPSCreator = new EPSCreator(isotopeList);
00043         else
00044             {
00045                 NuclideSquare mySquare = myParameters.getSection();
00046                 myEPSCreator = new EPSCreator(isotopeList, mySquare.bottomLeftZ, mySquare.bottomLeftA, mySquare.upperRightZ, mySquare.upperRightA);
00047             }
00048 
00049         myEPSCreator.createEPSDocument(myParameters.getFilename());             
00050     }
00051     
00052 
00055     public static ArrayList<JIsotope> readJIsotopeList(ArrayList<String> iLists, ArrayList<RGBVector> rgbVec)
00056     {
00057         ArrayList<JIsotope> isotopeList = new ArrayList<JIsotope>();
00058         //      isotopeLists.add(new ArrayList<JIsotope>());    
00059         for(int i=0; i<iLists.size(); i++)
00060             {
00061                 
00062                 int listIndex = 0;
00063                 
00064                 try
00065                     {
00066                         BufferedReader in = new BufferedReader(new FileReader(iLists.get(i)));  
00067                         String input = in.readLine();
00068                         
00069                         // read all lines and create an isotope object from each of them
00070                         // and add it to the last isotopeList in isotopeLists
00071                         // that is, the list in isotopeLists with index (isotopeLists.size()-1)
00072                         while (input != null && input.length()>0)
00073                             {
00074                                 
00075                                 JIsotope localJIsotope;
00076                                 boolean isInList = false;
00077                                 
00078                                 
00079                                 int index1 = 0, index2 = 0;                     // indices of the first and second whitespace in the string
00080                                 
00081                                 // find the first and second whitespaces
00082                                 for (int j = 0; j < input.length(); j++)
00083                                     {
00084                                         if (input.charAt(j) == ' ' && index1 == 0)
00085                                             index1 = j;                 
00086                                         else if (input.charAt(j) == ' ' && index1 != 0)
00087                                             {
00088                                                 index2 = j;
00089                                                 break;
00090                                             }
00091                                     }
00092                                 
00093                                 // set the member variables
00094                                 int Z = Integer.parseInt(input.substring(0, index1));
00095                                 int A = Integer.parseInt(input.substring(index1+1, index2));
00096                                 int N = A-Z;
00097                                 
00098                                 String name = input.substring(index2+1);
00099                                 
00100                                 
00101                                 for(int k=0; k<isotopeList.size(); k++)
00102                                     {
00103                                         if(name.equals(isotopeList.get(k).getName()) && A == isotopeList.get(k).getA())
00104                                             {
00105                                                 isInList = true;
00106                                                 listIndex = k;
00107                                                 break;
00108                                             }
00109                                     }
00110                                 
00111                                 if(isInList)
00112                                     {
00113                                         isotopeList.get(listIndex).addColor(rgbVec.get(i));
00114                                     }
00115 
00116                                 else
00117                                     {
00118                                         localJIsotope = new JIsotope(Z, A, name, rgbVec.get(i));
00119                                         isotopeList.add(localJIsotope);
00120                                     }
00121                                 input = in.readLine();
00122                             }
00123                     }
00124                 
00125                 catch (IOException e)
00126                     {
00127                         System.out.println("Error reading file:" + listIndex);
00128                     }
00129             }
00130         return isotopeList;
00131     }
00132 
00133     /*
00135     public static void printAllJIsotopeList()
00136     {
00137     for (int i = 0; i < isotopeList.size(); i++)
00138             {
00139                 System.out.println("JIsotope number " + i + ": " +isotopeList.get(i).getZ() +" "+ isotopeList.get(i).getA() + isotopeList.get(i).getName() + " " + isotopeList.get(i).getColorList().get(0).getR()+ " " + isotopeList.get(i).getColorList().get(0).getG()+ " " + isotopeList.get(i).getColorList().get(0).getB());
00140             }
00141     }
00142     */
00143 
00144 
00146     private static void printHelp()
00147     {
00148         System.out.println("Program to draw a nuclide chart from given input nuclide lists.");
00149         System.out.println("Usage: java NuclideChart <Output file> [-n BottomLeftZ BottomLeftA UpperRightZ UpperRightA] [allNuclidesFile R1 G1 B1] [stableJIsotopes R2 G2 B2] n*[additionalNuclideList Ri Gi Bi]");
00150         System.out.println("Parameters:");
00151         System.out.println("<Output file>: EPS file to print to. Will be overwritten if it exists.");
00152         System.out.println("-n BottomLeftZ BottomLeftA UpperRightZ UpperRightA: plot only the square between the nuclide with A and Z as BottomLeftA and BottomLeftZ, and A and Z as UpperRightZ and UpperRightA.");
00153         System.out.println("allNuclidesFile: File containing all nuclides for the chart.");
00154         System.out.println("Ri, Gi, Bi: R, G and B components of coloring for that specific isotope list.");
00155         System.out.println("stableJIsotopes: File containing all stable isotopes.");
00156         System.out.println("additionalNuclideList: list containing additional nuclear data for coloring purposes.");
00157         /*
00158         System.out.println("In order to plot the entire nuclide chart, type the following command line arguments in the given order and press \"Enter\":");
00159         System.out.println();
00160         System.out.println("1 Type the name of the .txt file containing ALL nuclides, followed by its RGB coloring code on the form \"R G B\".");
00161         System.out.println();
00162         System.out.println("2 (Optional) Enter the name of the .txt file containing all stable isotopes, followed by its RGB coloring code on the form \"R G B\".");
00163         System.out.println();
00164         System.out.println("3 Type the names of all remaining .txt files to be plotted, each followed by its respective RGB coloring code on the form \"R G B\".");     
00165         System.out.println();
00166         System.out.println("In order to plot a specific region of the nuclide chart, BEFORE the above mentioned, also type:");
00167         System.out.println();
00168         System.out.println("\"-n BottomLeftZ BottomLeftA UpperRightZ UpperRightA\", where the last four arguments specify the specific region to be viewed in the way that their names indicate.");
00169         */
00170     }
00171 }
00172     
00173 class IndataParameters
00174 {
00175     private String filename;
00176     public String getFilename(){return filename;}
00177     private boolean sectionSpecified;
00178     public boolean getSectionSpecified(){return sectionSpecified;}
00179     private NuclideSquare section;
00180     public NuclideSquare getSection(){return new NuclideSquare(section);}
00181     private ArrayList<RGBVector> rgbVectorList;
00182     public ArrayList<RGBVector> getRGBVectorList(){ return new ArrayList<RGBVector>(rgbVectorList);}
00183     private ArrayList<String> isotopeFiles;
00184     public ArrayList<String> getJIsotopeFiles(){ return new ArrayList<String>(isotopeFiles);}
00185 
00186 
00187     public IndataParameters(String[] args)
00188     {
00189         rgbVectorList = new ArrayList<RGBVector>();
00190         isotopeFiles = new ArrayList<String>();
00191 
00192         filename = args[0];
00193         int ptr = 1; 
00194 
00195         if (args[ptr].equalsIgnoreCase("-n"))
00196             {
00197                 sectionSpecified = true;
00198                 ptr=6;
00199                 section = new NuclideSquare();
00200                 try
00201                     {
00202                         section.bottomLeftZ = Integer.parseInt(args[2]);
00203                         section.bottomLeftA = Integer.parseInt(args[3]);
00204                         section.upperRightZ = Integer.parseInt(args[4]);
00205                         section.upperRightA = Integer.parseInt(args[5]);
00206                     }
00207                 catch(NumberFormatException ex)
00208                     {
00209                         System.out.println("Error in parsing limits.");
00210                         System.exit(1);
00211                     }
00212             }
00213         else
00214             {
00215                 sectionSpecified = false;
00216             }
00217 
00218         for (int i=ptr; i < args.length; i=i+4) //Var fjärde härifrån är en xxx.txt-fil
00219             {
00220                 isotopeFiles.add(args[i]);
00221             }
00222         
00223         for (int i=ptr+1; i < args.length; i=i+4) //överväg i+4
00224             {
00225                 int r, g, b;
00226                 try
00227                     {
00228                         rgbVectorList.add(new RGBVector(Integer.parseInt(args[i]),Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2])));
00229                     }
00230                 catch(NumberFormatException ex)
00231                     {
00232                         System.out.println("Error in parsing rgb vectors.");
00233                         System.exit(1);
00234                     }
00235             }
00236         
00237     }
00238 }
00239 
00241 class NuclideSquare
00242 {
00243     public int bottomLeftZ;
00244     public int bottomLeftA;
00245     public int upperRightZ;
00246     public int upperRightA;
00247     
00248     public NuclideSquare()
00249     {
00250         bottomLeftZ = 0;
00251         bottomLeftA = 0;
00252         upperRightZ = 0;
00253         upperRightA = 0;
00254     }
00255 
00256     public NuclideSquare(NuclideSquare toCopy)
00257     {
00258         this.bottomLeftZ = toCopy.bottomLeftZ;
00259         this.bottomLeftA = toCopy.bottomLeftA;
00260         this.upperRightZ = toCopy.upperRightZ;
00261         this.upperRightA = toCopy.upperRightA;
00262     }
00263 }
 All Classes Files Functions Variables Enumerations Enumerator Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark