Logo Search packages:      
Sourcecode: javamorph version File versions  Download package

void javamorph::CMeshDecorator::load (  )  [inline]

Load the mesh on startup from file.

Definition at line 183 of file CMeshDecorator.java.

References f_mesh, image, mesh, and parent.

Referenced by CMeshDecorator().

                      {
        try{
            /* Make the collection empty. */
            mesh.clear();
            /* Provide the file. */
            FileInputStream in = new FileInputStream(f_mesh);
            BufferedReader read= 
                new BufferedReader(new InputStreamReader(in));
            String line = read.readLine();
            /* Add one mesh point for each file's line. */
            while(null != (line = read.readLine())){
                StringTokenizer st = new StringTokenizer(line, " ");
                Point p = new Point();
                /* Read both coordinates. */
                p.x = Integer.parseInt(st.nextToken());
                p.y = Integer.parseInt(st.nextToken());
                p.x = Math.min(p.x, image.getWidth() - 1);
                p.y = Math.min(p.y, image.getHeight() - 1);
                mesh.add(p);
            }
            read.close();
        }catch(Exception e){
            System.err.println(e.getMessage());
            e.printStackTrace();
            /* Show error pop up. */
            JOptionPane.showMessageDialog
                (parent, "Can't load mesh. See also console output!");
        }
        
    }


Generated by  Doxygen 1.6.0   Back to index