本文整理汇总了Java中processing.data.XML.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java XML.getChild方法的具体用法?Java XML.getChild怎么用?Java XML.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.data.XML
的用法示例。
在下文中一共展示了XML.getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFrom
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
XML root = parent.loadXML(fileName);
XML resolutionNode = root.getChild(RESOLUTION_XML_NAME);
this.width = resolutionNode.getInt(WIDTH_XML_NAME);
this.height = resolutionNode.getInt(HEIGHT_XML_NAME);
XML intrinsicsNode = root.getChild(INTRINSICS_XML_NAME);
getMatFrom(intrinsicsNode, intrinsics);
XML extrinsicsNode = root.getChild(EXTRINSICS_XML_NAME);
if (extrinsicsNode == null) {
this.hasExtrinsics = false;
return;
}
getMatFrom(extrinsicsNode, extrinsics);
checkExtrinsics();
}
示例2: loadFrom
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
XML root = parent.loadXML(fileName);
XML homographyNode = root.getChild(HOMOGRAPHY_XML_NAME);
pmatrix = new PMatrix3D();
pmatrix.m00 = homographyNode.getFloat("m00");
pmatrix.m01 = homographyNode.getFloat("m01");
pmatrix.m02 = homographyNode.getFloat("m02");
pmatrix.m03 = homographyNode.getFloat("m03");
pmatrix.m10 = homographyNode.getFloat("m10");
pmatrix.m11 = homographyNode.getFloat("m11");
pmatrix.m12 = homographyNode.getFloat("m12");
pmatrix.m13 = homographyNode.getFloat("m13");
pmatrix.m20 = homographyNode.getFloat("m20");
pmatrix.m21 = homographyNode.getFloat("m21");
pmatrix.m22 = homographyNode.getFloat("m22");
pmatrix.m23 = homographyNode.getFloat("m23");
pmatrix.m30 = homographyNode.getFloat("m30");
pmatrix.m31 = homographyNode.getFloat("m31");
pmatrix.m32 = homographyNode.getFloat("m32");
pmatrix.m33 = homographyNode.getFloat("m33");
initMat();
}
示例3: loadFrom
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
XML root = parent.loadXML(fileName);
XML planeNode = root.getChild(PLANE_XML_NAME);
XML posNode = planeNode.getChild(PLANE_POS_XML_NAME);
XML normalNode = planeNode.getChild(PLANE_NORMAL_XML_NAME);
XML heightNode = planeNode.getChild(PLANE_HEIGHT_XML_NAME);
Vec3D position = getVectorFrom(posNode);
Vec3D normal = getVectorFrom(normalNode);
float h = heightNode.getFloat(PLANE_HEIGHT_XML_NAME);
this.plane = new Plane();
plane.set(position);
plane.normal.set(normal);
setHeight(h);
}
示例4: checkXML
import processing.data.XML; //导入方法依赖的package包/类
@Test
public void checkXML() {
sketch = new Sketch(); String[] args = new String[]{"--present", "test.fr.inria.papart.calibration.ProjectiveCalibrationTest"}; PApplet.runSketch(args, sketch);
instance = new PlaneCalibration();
XML root = sketch.loadXML(Common.currentPath + Common.PlaneCalibration);
assertTrue(root.getName() == Calibration.CALIBRATION_XML_NAME);
XML planeNode = root.getChild(PlaneCalibration.PLANE_XML_NAME);
assertNotNull(planeNode);
XML posNode = planeNode.getChild(PlaneCalibration.PLANE_POS_XML_NAME);
assertNotNull(posNode);
XML normalNode = planeNode.getChild(PlaneCalibration.PLANE_NORMAL_XML_NAME);
assertNotNull(normalNode);
XML heightNode = planeNode.getChild(PlaneCalibration.PLANE_HEIGHT_XML_NAME);
assertNotNull(heightNode);
assertTrue(heightNode.getFloat(PlaneCalibration.PLANE_HEIGHT_XML_NAME) == DEFAULT_PLANE_HEIGHT);
}
示例5: loadFrom
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
XML root = parent.loadXML(fileName);
XML resolutionNode = root.getChild(RESOLUTION_XML_NAME);
this.width = resolutionNode.getInt(WIDTH_XML_NAME);
this.height = resolutionNode.getInt(HEIGHT_XML_NAME);
XML intrinsicsNode = root.getChild(INTRINSICS_XML_NAME);
getMatFrom(intrinsicsNode, intrinsics);
XML extrinsicsNode = root.getChild(EXTRINSICS_XML_NAME);
if(extrinsicsNode == null){
this.hasExtrinsics = false;
return;
}
getMatFrom(extrinsicsNode, extrinsics);
checkExtrinsics();
}
示例6: loadModel
import processing.data.XML; //导入方法依赖的package包/类
public static void loadModel(String fileName)
{
try {
xml = new XML(new File("res/obj/"+fileName+".rbxm"));
} catch (Exception e) {e.printStackTrace();}
XML child = xml.getChild("Item"); //workspace?
XML[] children = child.getChildren("Item");
ArrayList<String> temp = new ArrayList<String>();
for (int i = 0; i < children.length; i++)
{
if (children[i].getString("class").equals("Part"))
temp.add(XMLToText(children[i]));
else if (children[i].getString("class").equals("Model"))
{
for (int j = 0; j < children[i].getChildCount(); j++)
if (children[i].getString("class").equals("Part"))
temp.add(XMLToText(children[i].getChild(j)));
}
}
temp.add(0,Math.abs(maxX-minX)/2 + "," + maxX + "," + Math.abs(maxY-minY)/2 + "," + maxY + "," + Math.abs(maxZ-minZ)/2 + "," + maxZ);
/*String[] toFile = new String[temp.size()];
for (int i = 0; i < temp.size(); i++)
toFile[i] = temp.get(i);*/
saveStrings("res/parsedObj/"+fileName,temp);
}
示例7: getStringVal
import processing.data.XML; //导入方法依赖的package包/类
private static String getStringVal(XML itemXML, String tagName) {
// Sets title if existing
String str = null;
XML strXML = itemXML.getChild(tagName);
// check if node exists and has content
if (strXML != null && strXML.getContent() != null) {
str = strXML.getContent();
}
return str;
}
示例8: replaceIn
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void replaceIn(XML xml) {
XML intrNode = xml.getChild(INTRINSICS_XML_NAME);
xml.removeChild(intrNode);
XML extrNode = xml.getChild(EXTRINSICS_XML_NAME);
xml.removeChild(extrNode);
XML resNode = xml.getChild(RESOLUTION_XML_NAME);
xml.removeChild(resNode);
addTo(xml);
}
示例9: loadFrom
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
XML root = parent.loadXML(fileName);
XML cameraNode = root.getChild(CAMERA_XML_NAME);
loadCameraFrom(cameraNode);
}
示例10: replaceIn
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void replaceIn(XML xml) {
XML planeNode = xml.getChild(PLANE_XML_NAME);
setVectorIn(planeNode.getChild(PLANE_POS_XML_NAME), (Vec3D) plane);
setVectorIn(planeNode.getChild(PLANE_NORMAL_XML_NAME), plane.normal);
planeNode.getChild(PLANE_HEIGHT_XML_NAME).setFloat(PLANE_HEIGHT_XML_NAME, height);
}
示例11: checkXML
import processing.data.XML; //导入方法依赖的package包/类
@Test
public void checkXML() {
sketch = new Sketch(); String[] args = new String[]{"--present", "test.fr.inria.papart.calibration.ProjectiveCalibrationTest"}; PApplet.runSketch(args, sketch);
XML root = sketch.loadXML(Common.currentPath + Common.HomographyCalibration);
assertTrue(root.getName() == Calibration.CALIBRATION_XML_NAME);
XML homographyNode = root.getChild(HomographyCalibration.HOMOGRAPHY_XML_NAME);
assertNotNull(homographyNode);
}
示例12: XMLToText
import processing.data.XML; //导入方法依赖的package包/类
private static String XMLToText(XML xml)
{
XML properties = xml.getChild("Properties");
XML size = findChild(properties,"size");
double posX = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("X").getContent()));
double posY = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("Y").getContent()));
double posZ = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("Z").getContent()));
minX = posX < minX ? posX : minX;
minY = posY < minY ? posY : minY;
minZ = posZ < minZ ? posZ : minZ;
maxX = posX > maxX ? posX : maxX;
maxY = posY > maxY ? posY : maxY;
maxZ = posZ > maxZ ? posZ : maxZ;
double r1 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R00").getContent()));
double r2 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R01").getContent()));
double r3 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R02").getContent()));
double r4 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R10").getContent()));
double r5 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R11").getContent()));
double r6 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R12").getContent()));
double r7 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R20").getContent()));
double r8 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R21").getContent()));
double r9 = round(Double.parseDouble(properties.getChild("CoordinateFrame").getChild("R22").getContent()));
double rotX = round(Math.atan2(-r6, r9));
double rotY = round(Math.asin(r3));
double rotZ = round(Math.atan2(-r2, r1));
double sizeX = round(Double.parseDouble(size.getChild("X").getContent()));
double sizeY = round(Double.parseDouble(size.getChild("Y").getContent()));
double sizeZ = round(Double.parseDouble(size.getChild("Z").getContent()));
int brickColor = Integer.parseInt(properties.getChild("int").getContent());
String name = properties.getChild("string").getContent();
return new String(posX + "," + posY + "," + posZ + "," + rotX + "," + rotY + "," + rotZ + "," + sizeX + "," + sizeY + "," + sizeZ + "," + brickColor + "," + name);
}
示例13: ReadDomainV2
import processing.data.XML; //导入方法依赖的package包/类
public void ReadDomainV2(XML element) {
String name = element.getString("name");
// Create the domain object
Domain domain = findOrCreateDomain(name);
// Read ancestors
for (XML ancestor : element.getChild("ancestors").getChildren("ancestor")) {
String ancestorName = ancestor.getString("name");
domain.addTree(ancestorName);
}
// Read spatial relations
XML definition = element.getChild("definition");
ArrayList<Objet[]> relations = new ArrayList<Objet[]>();
for (XML spatial : definition.getChildren("spatial")) {
String type = spatial.getString("type");
int min = spatial.getInt("min");
int max = spatial.getInt("max");
String targetDomain = spatial.getString("domain");
relations.add(createSpatialRelation(type, min, max, targetDomain));
}
Objet[][] result = new Objet[relations.size()][2];
for (int i = 0; i < relations.size(); i++) {
result[i] = relations.get(i);
}
domain.DefObjets = result;
}
示例14: loadTileset
import processing.data.XML; //导入方法依赖的package包/类
private void loadTileset(XML e){
XML c;
if(e.hasAttribute("source") && e.getChild("image") == null){
loadTileset(parent.loadXML(e.getString("source")));
return;
}
int tilewidth = e.getInt("tilewidth");
int tileheight = e.getInt("tileheight");
int tilecount = 0;
int columns = 0;
int spacing = 0;
int margin = 0;
int tileoffsetx = 0;
int tileoffsety = 0;
PImage source, image;
if(e.hasAttribute("tilecount")) tilecount = e.getInt("tilecount");
if(e.hasAttribute("columns")) columns = e.getInt("columns");
if(e.hasAttribute("spacing")) spacing = e.getInt("spacing");
if(e.hasAttribute("margin")) margin = e.getInt("margin");
c = e.getChild("tileoffset");
if(c != null) {
tileoffsetx = c.getInt("x");
tileoffsety = c.getInt("y");
}
c = e.getChild("image");
if(c != null) {
source = parent.loadImage(c.getString("source"));
if(columns == 0) columns = parent.floor((source.width - margin) / (tilewidth + spacing));
if(tilecount == 0) tilecount = columns * parent.floor((source.height - margin) / (tileheight + spacing));
if(c.hasAttribute("trans")) this.applyTransColor(source, c.getString("trans"));
for(int n = 0; n < tilecount; n++){
image = source.get(margin + (n % columns) * (tilewidth + spacing), margin + parent.floor(n / columns) * (tileheight + spacing), tilewidth, tileheight);
this.tile = (Tile[])parent.append(this.tile, new Tile(image, tileoffsetx, tileoffsety));
}
}
else{
XML cs[] = e.getChildren("tile");
if(cs != null){
for(XML t: cs){
image = parent.loadImage(t.getChild("image").getString("source"));
this.tile = (Tile[])parent.append(this.tile, new Tile(image, tileoffsetx, tileoffsety));
}
}
}
}
示例15: replaceIn
import processing.data.XML; //导入方法依赖的package包/类
@Override
public void replaceIn(XML xml) {
XML homographyNode = xml.getChild(HOMOGRAPHY_XML_NAME);
setHomographyTo(homographyNode);
}