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

The following examples show how to use processing.data.XML#addChild() . 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: ProjectiveDeviceCalibration.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void addTo(XML xml) {
    xml.addChild(resolutionNode());
    xml.addChild(intrinsicNode());

    if (hasExtrinsics) {
        xml.addChild(extrinsicsNode());
    }
}
 
Example 2
Source File: PlaneCalibration.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void addTo(XML xml) {
    XML root = new XML(PLANE_XML_NAME);
    XML pos = createXML(PLANE_POS_XML_NAME, (Vec3D) plane);
    XML normal = createXML(PLANE_NORMAL_XML_NAME, plane.normal);
    XML height = new XML(PLANE_HEIGHT_XML_NAME);
    height.setFloat(PLANE_HEIGHT_XML_NAME, this.height);

    root.addChild(pos);
    root.addChild(normal);
    root.addChild(height);
    xml.addChild(root);
}
 
Example 3
Source File: SurfaceMapper.java    From sketch-mapper with MIT License 5 votes vote down vote up
/**
 * Puts all projection mapping data in the XMLElement
 *
 * @param root
 */
public void save(XML root) {
    root.setName("ProjectionMap");
    // create XML elements for each surface containing the resolution
    // and control point data
    for (SuperSurface s : surfaces) {
        XML surf = new XML("surface");
        surf.setInt("type", s.getSurfaceType());
        surf.setInt("id", s.getId());
        surf.setString("name", s.getSurfaceName());
        surf.setInt("res", s.getRes());
        surf.setString("lock", String.valueOf(s.isLocked()));
        surf.setInt("horizontalForce", s.getHorizontalForce());
        surf.setInt("verticalForce", s.getVerticalForce());
        surf.setString("sketch", s.getSketch().getName());

        for (int i = 0; i < s.getCornerPoints().length; i++) {
            XML cp = new XML("cornerpoint");
            cp.setInt("i", i);
            cp.setFloat("x", s.getCornerPoint(i).x);
            cp.setFloat("y", s.getCornerPoint(i).y);
            surf.addChild(cp);

        }

        if (s.getSurfaceType() == SuperSurface.BEZIER) {
            for (int i = 0; i < 8; i++) {
                XML bp = new XML("bezierpoint");
                bp.setInt("i", i);
                bp.setFloat("x", s.getBezierPoint(i).x);
                bp.setFloat("y", s.getBezierPoint(i).y);
                surf.addChild(bp);
            }
        }
        root.addChild(surf);
    }
}
 
Example 4
Source File: ScreenConfiguration.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
 public void addTo(XML xml) {
     xml.addChild(createScreenNode()); 
}
 
Example 5
Source File: CameraConfiguration.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void addTo(XML xml) {
    xml.addChild(createCameraNode());
}
 
Example 6
Source File: PlanarTouchCalibration.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void addTo(XML xml) {
    xml.addChild(createXML());
}
 
Example 7
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();
	}
}