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

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

Load the polygon from file.

Definition at line 231 of file CPolygonDecorator.java.

References f_poly, image, parent, and polygon.

Referenced by CPolygonDecorator().

                      {
        try{
            /* Clear the point collection. */
            polygon.clear();
            FileInputStream in = new FileInputStream(f_poly);
            BufferedReader read= 
                new BufferedReader(new InputStreamReader(in));
            String line = read.readLine();
            /* Add one point for each line of the file. */
            while(null != (line = read.readLine())){
                StringTokenizer st = new StringTokenizer(line, " ");
                Point p = new Point();
                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);
                polygon.add(p);
            }
            read.close();
           read.close();
        }catch(Exception e){
            System.err.println(e.getMessage());
            e.printStackTrace();
            /* Show error pop up. */
            JOptionPane.showMessageDialog
                (parent, "Can't load polygon. See also console output!");
        }
    }


Generated by  Doxygen 1.6.0   Back to index