当前位置: 首页>>代码示例>>Java>>正文


Java XML.getChildren方法代码示例

本文整理汇总了Java中processing.data.XML.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java XML.getChildren方法的具体用法?Java XML.getChildren怎么用?Java XML.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.data.XML的用法示例。


在下文中一共展示了XML.getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:dantetam,项目名称:civgame,代码行数:27,代码来源:RobloxXMLTest.java

示例2: readModelDomain

import processing.data.XML; //导入方法依赖的package包/类
public ModelDomain readModelDomain(Model model,XML element){
    ModelDomain md=null; 
    if(element.hasAttribute("Name"))  {
        String Name=element.getString("Name");
        md=model.getDomain(Name);
        if(md==null){
            Domain dom=p.dm.getDomain(Name); //The Domain was created before the model even exist !
            if(dom!=null)  md=new ModelDomain(p, dom);
        }
    }
    if(md!=null){
       XML[]children=element.getChildren();
       for(int j=0;j<children.length;j++)
          if(children[j].getName().equals("Step")) readModelStep(model, children[j], md);
   } else p.mm.addMessage("We don't have this domain " + element.getString("Name"));
   return md;
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:18,代码来源:RuleReader.java

示例3: readModelStep

import processing.data.XML; //导入方法依赖的package包/类
public void readModelStep(Model model, XML element,ModelDomain md){
  int s=-1; if(element.hasAttribute("Number"))  s=element.getInt("Number");
  int hpf=-1; if(element.hasAttribute("hpf"))  hpf=element.getInt("hpf");
  int d=-1; if(element.hasAttribute("Draw"))  d=element.getInt("Draw");
  
  if(s>=0){
      model.step=p.max(model.step,s);
      model.ActualStep=model.step;
      model.Correspons[s]=hpf;
      XML[]children=element.getChildren();
      for(int j=0;j<children.length;j++)
        if(children[j].getName().equals("Gene")) 
              readModelGene(children[j], md, s);
  } else p.mm.addMessage("We didn't fint step number " );
   
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:17,代码来源:RuleReader.java

示例4: parseChildren

import processing.data.XML; //导入方法依赖的package包/类
protected void parseChildren(final XML graphics) {
	final XML[] elements = graphics.getChildren();
	children = new PShape[elements.length];
	childCount = 0;

	for (final XML elem : elements) {
		final PShape kid = parseChild(elem);
		if (kid != null) {
			// if (kid.name != null) {
			// System.out.println("adding child " + kid.name);
			// }
			this.addChild(kid);
		}
	}
	children = (PShape[]) PApplet.subset(children, 0, childCount);
}
 
开发者ID:aarongolliver,项目名称:FractalFlameV3,代码行数:17,代码来源:PShapeSVG.java

示例5: findChild

import processing.data.XML; //导入方法依赖的package包/类
private static XML findChild(XML xml, String name)
{
	for (int i = 0; i < xml.getChildren().length; i++)
	{
		if (xml.getChildren()[i].hasChildren())
			if (xml.getChildren()[i].hasAttribute("name"))
				if (xml.getChildren()[i].getString("name").equals(name))
					return xml.getChildren()[i];
	}
	return null;
}
 
开发者ID:dantetam,项目名称:civgame,代码行数:12,代码来源:RobloxXMLTest.java

示例6: ReadExpression

import processing.data.XML; //导入方法依赖的package包/类
public void ReadExpression(XML element) throws ModelLoadingException {
  if(element.hasAttribute("timeUnit")) p.rm.timeUnit=element.getString("timeUnit");
  
   XML[]children=element.getChildren();
  for(int j=0;j<children.length;j++){
    if(children[j].getName().equals("Gene")) this.ReadDataGene(children[j]);
  }
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:9,代码来源:RuleReader.java

示例7: ReadRule

import processing.data.XML; //导入方法依赖的package包/类
public void ReadRule(XML element) throws ModelLoadingException {
  if(element.hasAttribute("type"))  p.mm.addMessage("Read " +element.getString("type"));

  XML[]children=element.getChildren();
  for(int j=0;j<children.length;j++){
    if(children[j].getName().equals("Rule")) this.ReadGene(children[j]);
  }
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:9,代码来源:RuleReader.java

示例8: ReadDomains

import processing.data.XML; //导入方法依赖的package包/类
public void ReadDomains(XML element){
    String domains_format_field = "format";
    int domains_format = element.getInt(domains_format_field, 0);

    XML[]children=element.getChildren();
  for(int j=0;j<children.length;j++){
    if(children[j].getName().equals("Domain")) ReadDomain(children[j]);
  }
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:10,代码来源:RuleReader.java

示例9: 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;
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:31,代码来源:RuleReader.java

示例10: ReadConfig

import processing.data.XML; //导入方法依赖的package包/类
public void ReadConfig(XML element){
  if(element.hasAttribute("Version"))  { p.Version=element.getString("Version"); p.mm.addMessage("Load GRNBoolModel Version "+p.Version);}
  
  XML[]children=element.getChildren();
  for(int j=0;j<children.length;j++){
    if(children[j].getName().equals("Menu")) readMenu(children[j]);
    if(children[j].getName().equals("Color")) readColor(children[j]);
    if(children[j].getName().equals("Font")) readFont(children[j]);
    if(children[j].getName().equals("Screen")) readScreen(children[j]);
  }
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:12,代码来源:SaveManager.java

示例11: Gradient

import processing.data.XML; //导入方法依赖的package包/类
public Gradient(final PShapeSVG parent, final XML properties) {
	super(parent, properties, true);

	final XML elements[] = properties.getChildren();
	offset = new double[elements.length];
	color = new int[elements.length];

	// <stop offset="0" style="stop-color:#967348"/>
	for (final XML elem : elements) {
		final String name = elem.getName();
		if (name.equals("stop")) {
			String offsetAttr = elem.getString("offset");
			double div = 1.0f;
			if (offsetAttr.endsWith("%")) {
				div = 100.0f;
				offsetAttr = offsetAttr.substring(0, offsetAttr.length() - 1);
			}
			offset[count] = PApplet.parseFloat(offsetAttr) / div;
			final String style = elem.getString("style");
			final HashMap<String, String> styles = PShapeSVG.parseStyleAttributes(style);

			String colorStr = styles.get("stop-color");
			if (colorStr == null) {
				colorStr = "#000000";
			}
			String opacityStr = styles.get("stop-opacity");
			if (opacityStr == null) {
				opacityStr = "1";
			}
			final int tupacity = (int) (PApplet.parseFloat(opacityStr) * 255);
			color[count] = (tupacity << 24) | Integer.parseInt(colorStr.substring(1), 16);
			count++;
		}
	}
	offset = PApplet.subset(offset, 0, count);
	color = PApplet.subset(color, 0, count);
}
 
开发者ID:aarongolliver,项目名称:FractalFlameV3,代码行数:38,代码来源:PShapeSVG.java

示例12: Font

import processing.data.XML; //导入方法依赖的package包/类
public Font(final PShapeSVG parent, final XML properties) {
	super(parent, properties, false);
	// handle(parent, properties);

	final XML[] elements = properties.getChildren();

	horizAdvX = properties.getInt("horiz-adv-x", 0);

	namedGlyphs = new HashMap<String, FontGlyph>();
	unicodeGlyphs = new HashMap<Character, FontGlyph>();
	glyphCount = 0;
	glyphs = new FontGlyph[elements.length];

	for (final XML elem : elements) {
		final String name = elem.getName();
		if (name == null) {
			// skip it
		} else if (name.equals("glyph")) {
			final FontGlyph fg = new FontGlyph(this, elem, this);
			if (fg.isLegit()) {
				if (fg.name != null) {
					namedGlyphs.put(fg.name, fg);
				}
				if (fg.unicode != 0) {
					unicodeGlyphs.put(new Character(fg.unicode), fg);
				}
			}
			glyphs[glyphCount++] = fg;

		} else if (name.equals("missing-glyph")) {
			// System.out.println("got missing glyph inside <font>");
			missingGlyph = new FontGlyph(this, elem, this);
		} else if (name.equals("font-face")) {
			face = new FontFace(this, elem);
		} else {
			System.err.println("Ignoring " + name + " inside <font>");
		}
	}
}
 
开发者ID:aarongolliver,项目名称:FractalFlameV3,代码行数:40,代码来源:PShapeSVG.java

示例13: 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));
      }
    }
  }
}
 
开发者ID:linux-man,项目名称:ptmx,代码行数:46,代码来源:Ptmx.java

示例14: ReadRules

import processing.data.XML; //导入方法依赖的package包/类
public void ReadRules(String Name){
  deleteModel();
  p.lm.lastModelLoaded=Name;
 
  XML element=p.loadXML(Name);
  
  if(element.hasAttribute("MaxTime")) p.rm.MaxTime=p.parseInt(element.getString("MaxTime"));
  
  XML[]version=element.getChildren();
  int nbVersion=0;

  try {
    for (int j = 0; j < version.length; j++) if (version[j].getName().equals("Regions")) ReadRegion(version[j]);
    for (int j = 0; j < version.length; j++) if (version[j].getName().equals("Domains")) ReadDomains(version[j]);
    for (int j = 0; j < version.length; j++) {
      if (version[j].getName().equals("Expression")) ReadExpression(version[j]);
    }
    for (int j = 0; j < version.length; j++) {
      if (version[j].getName().equals("Rules")) {
        ReadRule(version[j]);
        p.gm.Genes = p.gm.sortGene(p.gm.Genes);
      }
    }
    for (int j = 0; j < version.length; j++) if (version[j].getName().equals("Compare")) ReadCompare(version[j]);
    for (int j = 0; j < version.length; j++) if (version[j].getName().equals("Config")) p.sm.ReadConfig(version[j]);
    for (int j = 0; j < version.length; j++) if (version[j].getName().equals("Version")) nbVersion++;
  }
  catch (ModelLoadingException mle) {
    p.eh.alert("Error while loading the model XML:\n" + mle.getMessage());
    mle.printStackTrace();

    // Empty the partially loaded model
    deleteModel();
    return;
  }

  if(nbVersion>0){
     p.mm.active(2,1); 
     p.mm.addMessage("Found " + nbVersion  +" versions");
     p.lm.MyModels=new Model[nbVersion]; // the number of version
     int numVersion=0;
     for(int i=0;i<version.length;i++)
           if(version[i].getName().equals("Version")){  //For Each Version
                int number=i; if(version[i].hasAttribute("number"))  number=p.parseInt(version[i].getString("number"));
                String date=p.uf.now();  if(version[i].hasAttribute("date"))  date=version[i].getString("date");
                Model model=new Model(p, number,date);
                if(version[i].hasAttribute("Name"))  model.Name=version[i].getString("Name");
                if(version[i].hasAttribute("lock"))  model.lock=p.uf.parseBool(version[i].getString("lock"));
                if(version[i].hasAttribute("step"))  { model.step=p.parseInt(version[i].getString("step"));model.reset();};
          
                XML[]children=version[i].getChildren();
                for(int j=0;j<children.length;j++) //Second we load the data we had the domains
                      if(children[j].getName().equals("Domains")) model.addDomain(readModelDomain(model,children[j])); 
              
                p.lm.MyModels[numVersion]=model;
                
                if(numVersion==nbVersion-1){ //Take the last Version
                    p.lm.MyModel=model; 
                    p.lm.MyModel.ActiveDomain=p.lm.MyModel.getDomain(0);
                }
                numVersion++;
          }
   }
   p.dm.computeData();
   p.eh.GeneDef=null;
   
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:68,代码来源:RuleReader.java

示例15: ReadRegion

import processing.data.XML; //导入方法依赖的package包/类
public void ReadRegion(XML element){
  XML[]children=element.getChildren();
  for(int j=0;j<children.length;j++){
    if(children[j].getName().equals("Tree")) ReadTree(children[j]);
  }
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:7,代码来源:RuleReader.java


注:本文中的processing.data.XML.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。