Java Code Examples for processing.data.XML#getString()

The following examples show how to use processing.data.XML#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarkerSVGReader.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public MarkerSVGReader(XML in) {
        xml = in;

        // All sizes are in millimeters now in inkscape ?
        checkMmOrPixelsSizes();
//        if (!this.millimeterMode) {
        checkDPI();
//        } else {
//            System.out.println("Markerboard: Millimeter mode.");
//        }

        sheetWidthMm = computeSizeMM(xml.getString("width"));
        sheetHeightMm = computeSizeMM(xml.getString("height"));
        
//        System.out.println("Size of the markerboard: " + sheetWidthMm  + " " + sheetHeightMm);

        // Find if it uses any weird scales
        XML view = xml.getChild("sodipodi:namedview");
        if (view != null) {
            String units = view.getString("units");

            if (units == null) {
                units = view.getString("inkscape:document-units");
            }
            if (units != null && units.equals("px")) {
                String scale = view.getString("scale-x");
                if (scale == null) {
                    unitsToMM = PX_TO_MM_96_DPI; // default inkscape value...
                } else {
                    unitsToMM = Float.parseFloat(scale);
                }
            }
            if (units != null && units.equals("mm")) {
                unitsToMM = 1f;
            }
        }
    }
 
Example 2
Source File: CameraConfiguration.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void loadCameraFrom(XML cameraNode) {
    this.cameraName = cameraNode.getString(CAMERA_NAME_XML_NAME);
    this.cameraFormat = cameraNode.getString(CAMERA_FORMAT_XML_NAME);
    this.cameraType = Camera.Type.valueOf(cameraNode.getString(CAMERA_TYPE_XML_NAME));
}
 
Example 3
Source File: Manifest.java    From APDE with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Save a new version of the manifest info to the build location.
 * Also fill in any missing attributes that aren't yet set properly.
 */
protected void writeCopy(File file, String className, ComponentTarget appComp) {
	// write a copy to the build location
	save(file);
	
	// load the copy from the build location and start messing with it
	try {
		XML mf = new XML(file);
		
		// package name, or default
		String p = mf.getString("package").trim();
		if (p.length() == 0) {
			mf.setString("package", SketchProperties.defaultPackageName(context.getSketchName()));
		}
		
		// app name and label, or the class name
		XML app = mf.getChild("application");
		String label = app.getString("android:label");
		if (label.length() == 0) {
			app.setString("android:label", className);
		}
		app.setString("android:debuggable", "true");
		
		// Services need the label also in the service section
		if (appComp == ComponentTarget.WALLPAPER || appComp == ComponentTarget.WATCHFACE) {
			XML serv = app.getChild("service");
			if (serv == null) {
				serv = app.addChild("service");
				serv.setString("android:label", className);
			} else {
				label = serv.getString("android:label");
				if (label.length() == 0) {
					serv.setString("android:label", className);
				}
			}
		}
		
		save(file);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
Source File: EditorActivity.java    From APDE with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Load specified key bindings from the XML resource
 * 
 * @param xml
 */
public void loadKeyBindings(XML xml) {
	XML[] bindings = xml.getChildren();
	for(XML binding : bindings) {
		//Make sure that this is a "binding" element
		if(!binding.getName().equals("binding"))
			continue;
		
		//Parse the key binding
		String name = binding.getContent();
		int key = binding.getInt("key");
		
		//Load the list of possible key modifiers
		String modifiers = binding.getString("mod");
		String[] mods = modifiers.split("\\|"); // "|" is a REGEX keyword... need to escape it
		
		//The possible modifiers (these are available in API level 11+)
		boolean ctrl = false;
		boolean meta = false;
		boolean func = false;
		
		// (and these are available across all API levels)
		boolean alt = false;
		boolean sym = false;
		boolean shift = false;
		
		//This isn't very elegant... but it gets the job done
		for(String mod : mods) {
			if(mod.equals("ctrl")) ctrl = true;
			if(mod.equals("meta")) meta = true;
			if(mod.equals("func")) func = true;
			
			if(mod.equals("alt")) alt = true;
			if(mod.equals("sym")) sym = true;
			if(mod.equals("shift")) shift = true;
		}
		
		//Build the KeyBinding
		KeyBinding bind = new KeyBinding(name, key, ctrl, meta, func, alt, sym, shift);
		
		//Add the key binding
		keyBindings.put(name, bind);
	}
}