src/java/com/mammen/main/MainUIModel.java
/**
     * Loads a project from file.
     */
Loads a project from file.
Loads a project from file .
public void loadProject( File path ) throws IOException, ParserConfigurationException, SAXException
    {
        if( !path.exists() || path.isDirectory() )
            return;
        if( path.getAbsolutePath().toLowerCase().endsWith( "." + PROJECT_EXTENSION ) )
        {
            DocumentBuilder db = dbFactory.newDocumentBuilder();
            Document dom = db.parse( path );
            Element docEle = dom.getDocumentElement();
            settings.setGeneratorType( Generator.Type.valueOf( docEle.getAttribute( "GeneratorType" ) ));
            settings.getSharedGeneratorVars().readXMLAttributes( docEle );
            settings.getGeneratorVars().readXMLAttributes( docEle );
            NodeList waypointEleList = docEle.getElementsByTagName( "Waypoint" );
            waypointList.clear();
            if( waypointEleList != null && waypointEleList.getLength() > 0 )
            {
                for( int i = 0; i < waypointEleList.getLength(); i++ )
                {
                    Element waypointEle = (Element) waypointEleList.item( i );
                    String xText = waypointEle.getElementsByTagName("X").item(0).getTextContent();
                    String yText = waypointEle.getElementsByTagName("Y").item(0).getTextContent();
                    String angleText = waypointEle.getElementsByTagName("Angle").item(0).getTextContent();
                    waypointList.add( new Waypoint(
                                            Double.parseDouble( xText ),
                                            Double.parseDouble( yText ),
                                            Double.parseDouble( angleText )
                                        ) );
                }
            }
            workingProject = path;
        }
    }
public void loadProject ( File path ) throws IOException , ParserConfigurationException , SAXException { if ( ! path . exists ( ) || path . isDirectory ( ) ) return ; if ( path . getAbsolutePath ( ) . toLowerCase ( ) . endsWith ( "." + PROJECT_EXTENSION ) ) { DocumentBuilder db = dbFactory . newDocumentBuilder ( ) ; Document dom = db . parse ( path ) ; Element docEle = dom . getDocumentElement ( ) ; settings . setGeneratorType ( Generator . Type . valueOf ( docEle . getAttribute ( "GeneratorType" ) ) ) ; settings . getSharedGeneratorVars ( ) . readXMLAttributes ( docEle ) ; settings . getGeneratorVars ( ) . readXMLAttributes ( docEle ) ; NodeList waypointEleList = docEle . getElementsByTagName ( "Waypoint" ) ; waypointList . clear ( ) ; if ( waypointEleList != null && waypointEleList . getLength ( ) > 0 ) { for ( int i = 0 ; i < waypointEleList . getLength ( ) ; i ++ ) { Element waypointEle = ( Element ) waypointEleList . item ( i ) ; String xText = waypointEle . getElementsByTagName ( "X" ) . item ( 0 ) . getTextContent ( ) ; String yText = waypointEle . getElementsByTagName ( "Y" ) . item ( 0 ) . getTextContent ( ) ; String angleText = waypointEle . getElementsByTagName ( "Angle" ) . item ( 0 ) . getTextContent ( ) ; waypointList . add ( new Waypoint ( Double . parseDouble ( xText ) , Double . parseDouble ( yText ) , Double . parseDouble ( angleText ) ) ) ; } } workingProject = path ; } }
Loads a project from file.
Loads a project from file .
// Get generator type // Get shared vars from xml file // TODO: Does the settings.generatorType change listener get called before the next line? //  If not, the settings.generatorVars variable will potentially be the wrong one. //  I suspect that it does. // Get generator vars from xml file. // Get waypoints from xml file.