\hypertarget{classThreeBLoader}{
\subsection{ThreeBLoader Class Reference}
\label{classThreeBLoader}\index{ThreeBLoader@{ThreeBLoader}}
}


Plugin class to load up an old 3B run.  


\subsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{classThreeBLoader_adb4823b079ca61a72a6d17ed3852c4f8}{run} (String arg)
\end{DoxyCompactItemize}
\subsubsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{classThreeBLoader_a461515c153087d426c18f0602141f2a1}{close} (InputStream i)
\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
Plugin class to load up an old 3B run. 

Definition at line 27 of file ThreeBLoader.java.



\subsubsection{Member Function Documentation}
\hypertarget{classThreeBLoader_a461515c153087d426c18f0602141f2a1}{
\index{ThreeBLoader@{ThreeBLoader}!close@{close}}
\index{close@{close}!ThreeBLoader@{ThreeBLoader}}
\paragraph[{close}]{\setlength{\rightskip}{0pt plus 5cm}void ThreeBLoader::close (
\begin{DoxyParamCaption}
\item[{InputStream}]{i}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline, private\mbox{]}}}}
\label{classThreeBLoader_a461515c153087d426c18f0602141f2a1}


Definition at line 29 of file ThreeBLoader.java.



Referenced by run().


\begin{DoxyCode}
    {
        //Not sure what to do here...
        if(i != null)
        {
            try{
                i.close();
            }
            catch(IOException ioe)
            {
                Toolkit.getDefaultToolkit().beep();
                ij.IJ.showStatus("Error closing file: " + ioe.getMessage());
            }
        }
    }
\end{DoxyCode}
\hypertarget{classThreeBLoader_adb4823b079ca61a72a6d17ed3852c4f8}{
\index{ThreeBLoader@{ThreeBLoader}!run@{run}}
\index{run@{run}!ThreeBLoader@{ThreeBLoader}}
\paragraph[{run}]{\setlength{\rightskip}{0pt plus 5cm}void ThreeBLoader::run (
\begin{DoxyParamCaption}
\item[{String}]{arg}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classThreeBLoader_adb4823b079ca61a72a6d17ed3852c4f8}


Definition at line 45 of file ThreeBLoader.java.



References EControlPanel::append(), close(), EControlPanel::send\_\-status\_\-text\_\-message(), EControlPanel::send\_\-update\_\-canvas\_\-event(), Spot::x, and Spot::y.


\begin{DoxyCode}
                                {
        InputStream in = null;
        String name;
        double ps;

        try{
            if(arg.equals("test"))
            {
                name = "test_data.txt";

                try{
                    in = new GZIPInputStream(getClass().getClassLoader().getResou
      rceAsStream("test_data.txt.gz"));
                }
                catch(IOException ioe)
                {
                    Toolkit.getDefaultToolkit().beep();
                    ij.IJ.showStatus("Could not open test data: " + ioe.getMessag
      e());
                    return;
                }
                ps=100;
            }
            else
            {
                OpenDialog o = new OpenDialog("Open 3B run...", null);
                name = o.getFileName();
                
                try{
                    in = new FileInputStream(o.getDirectory() + o.getFileName());
      
                }
                catch(java.io.FileNotFoundException ferr)
                {
                    Toolkit.getDefaultToolkit().beep();
                    ij.IJ.showStatus("Error opening file: " + ferr.getMessage());
      
                    return;
                }



                GenericDialog g = new GenericDialog("Pixel size");
                g.addNumericField("Pixel size", 100., 0, 5, "nm");
                g.showDialog();
                ps = g.getNextNumber();
            }

            //Yay @ cargoculting
            InputStreamReader d = new InputStreamReader(in);
            BufferedReader r = new BufferedReader(d);

            String line;
            final ArrayList<Spot> spots = new ArrayList<Spot>();
            int iterations=0;
            Rectangle roi=null;
            final double pixel_size_in_nm_ = ps;

            while((line = r.readLine()) != null)
            {
                String tokens[] = line.split("\\p{Space}+");

                if(tokens[0].equals("PIXELS"))
                {
                    if((tokens.length - 1)%2 != 0)
                        throw new IOException("corrupt file (bad pixels line)");

                    for(int i=1; i < tokens.length; i+= 2)
                    {
                        int x, y;
                        try
                        {
                            x = Integer.parseInt(tokens[i+0]);
                            y = Integer.parseInt(tokens[i+1]);
                        }
                        catch(NumberFormatException nerr)
                        {
                            throw new IOException("corrupt file (bad pixel coordi
      nate)");
                        }

                        if(roi == null)
                            roi = new Rectangle(x, y, 1, 1);
                        else
                            roi.add(x, y);
                    }
                }

                if(tokens[0].matches("PASS[0-9]+:"))
                {
                    iterations++;

                    if((tokens.length - 1)%4 != 0)
                        throw new IOException("corrupt file (pad pass line)");

                    for(int i=1; i < tokens.length; i+= 4)
                    {
                        Spot s = new Spot();
                        try
                        {
                            s.x = Double.parseDouble(tokens[i+2]);
                            s.y = Double.parseDouble(tokens[i+3]);
                        }
                        catch(NumberFormatException nerr)
                        {
                            throw new IOException("corrupt file (bad spot positio
      n)");
                        }

                        spots.add(s);
                    }
                }

            }
            if(roi == null)
                throw new IOException("corrupt file (no ROI)");

            final String fname = name;
            final Rectangle roi_ = roi;
            final int its = iterations;
            SwingUtilities.invokeLater(
            new Runnable() {
                    public void run() {
                            EControlPanel e = new EControlPanel(roi_, pixel_size_
      in_nm_, fname, null);
                            e.append(spots, its);
                            e.send_update_canvas_event();
                            e.send_status_text_message("Using " + fname + ": " + 
      Integer.toString(its) + " iterations.");
                    }
            }
            );




        }
        catch(IOException another_ioe){
            Toolkit.getDefaultToolkit().beep();
            ij.IJ.showStatus("Error reading data: " + another_ioe.getMessage());
        }
        finally{
            close(in);
        }

    }
\end{DoxyCode}


The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
\hyperlink{ThreeBLoader_8java}{ThreeBLoader.java}\end{DoxyCompactItemize}
