本文整理汇总了Java中processing.data.XML.hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java XML.hasAttribute方法的具体用法?Java XML.hasAttribute怎么用?Java XML.hasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.data.XML
的用法示例。
在下文中一共展示了XML.hasAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ReadDataGeneRegion
import processing.data.XML; //导入方法依赖的package包/类
public void ReadDataGeneRegion(Gene g,XML element){
if(element.hasAttribute("name")) {
String name=element.getString("name");
Region region=p.rm.getRegion(name);
if(region==null) region=p.rm.addRegion(name);
if(element.hasAttribute("value")) {
String value=element.getString("value");
String[] values = p.split(value,';');
for(int j=0;j<values.length;j++){
String []tv=p.split(values[j],':');
if(tv.length==2) g.Expression[region.number][p.parseInt(tv[0])]=p.parseInt(tv[1]);
}
}
}
}
示例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;
}
示例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 " );
}
示例4: readModelGene
import processing.data.XML; //导入方法依赖的package包/类
public void readModelGene(XML element,ModelDomain md,int s){
Gene g=null;
if(element.hasAttribute("Name")) g=p.gm.getGene(element.getString("Name"));
if(g!=null){
boolean v=true; boolean blueState=false; //It's true by default
boolean Manual=false;
if(element.hasAttribute("Manual")){Manual=true; v=p.uf.parseBool(element.getString("Manual"));}
if(element.hasAttribute("BlueState"))blueState=p.uf.parseBool(element.getString("BlueState"));
int i=p.gm.getNumGene(g);
md.GenesStates[i][s]=v;
md.Manual[i][s]=Manual;
md.isBlueState[i][s]=blueState;
// addMessage("Add Genes "+element.getString("Name") + " to domain " +dom.Name);
} else p.mm.addMessage("This gene doesn't exist " + element.getString("Name"));
}
示例5: ReadDomainV1
import processing.data.XML; //导入方法依赖的package包/类
public void ReadDomainV1(XML element){
String Name="";
if(element.hasAttribute("name")) Name=element.getString("name");
Domain dom=p.dm.getDomain(Name);
if(dom==null) {
dom=new Domain(p, Name);p.dm.addDomain(dom);
if(p.verbose>=2) p.mm.addMessage("Create Domain " +Name);
} else if(p.verbose>=2) p.mm.addMessage("Found Domain " +dom.Name);
if(element.hasAttribute("tree")) {
String Tree=element.getString("tree");
String [] EletTree=p.split(Tree,";");
for(int i=0;i<EletTree.length;i++)
dom.addTree(p.trim(EletTree[i]));
}
if(element.hasAttribute("def")) {
String rule=p.trim(element.getString("def"));
String []Eq=p.split(rule,','); //Split all the different rule
dom.DefObjets=new Objet[Eq.length][2];
for(int i=0;i<Eq.length;i++)
dom.DefObjets[i]=DecodeObjetsDomain(Eq[i]);
}
}
示例6: FontGlyph
import processing.data.XML; //导入方法依赖的package包/类
public FontGlyph(final PShapeSVG parent, final XML properties, final Font font) {
super(parent, properties, true);
super.parsePath(); // ??
name = properties.getString("glyph-name");
final String u = properties.getString("unicode");
unicode = 0;
if (u != null) {
if (u.length() == 1) {
unicode = u.charAt(0);
// System.out.println("unicode for " + name + " is " + u);
} else {
System.err.println("unicode for " + name + " is more than one char: " + u);
}
}
if (properties.hasAttribute("horiz-adv-x")) {
horizAdvX = properties.getInt("horiz-adv-x");
} else {
horizAdvX = font.horizAdvX;
}
}
示例7: loadTmxProperties
import processing.data.XML; //导入方法依赖的package包/类
private void loadTmxProperties(XML e){
this.version = e.getFloat("version");
this.orientation = e.getString("orientation");
this.renderorder = e.getString("renderorder");
this.mapwidth = e.getInt("width");
this.mapheight = e.getInt("height");
this.tilewidth = e.getInt("tilewidth");
this.tileheight = e.getInt("tileheight");
this.staggerindex = 0; if(e.hasAttribute("staggerindex")) if(e.getString("staggerindex").equals("even")) this.staggerindex = 1;
this.staggeraxis = "x"; if(e.hasAttribute("staggeraxis")) this.staggeraxis = e.getString("staggeraxis");
this.hexsidelength = 0; if(e.hasAttribute("hexsidelength")) this.hexsidelength = e.getInt("hexsidelength");
this.backgroundcolor = parent.color(80, 80, 80); if(e.hasAttribute("backgroundcolor")) this.backgroundcolor = this.readColor(e.getString("backgroundcolor"));
}
示例8: 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]);
}
}
示例9: 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]);
}
}
示例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]);
}
}
示例11: readFont
import processing.data.XML; //导入方法依赖的package包/类
public void readFont(XML element){
if(element.hasAttribute("Number")) {
p.cm.font=p.parseInt(element.getString("Number"));
p.cm.myFont = (PFont)p.cm.allmyFonts.get(p.cm.font);
}
else if(element.hasAttribute("Name")) {
String Name=element.getString("Name");
for(int i=0;i<p.cm.allFonts.size();i++)
if(Name.toLowerCase().equals(((String)p.cm.allFonts.get(i)).toLowerCase())){
p.cm.font=i;
p.cm.myFont = (PFont)p.cm.allmyFonts.get(p.cm.font);
}
}
}
示例12: readColor
import processing.data.XML; //导入方法依赖的package包/类
public void readColor(XML element){
String Name=""; int colorchoose=p.color(0,0,0);
if(element.hasAttribute("Name")) Name=element.getString("Name");
if(element.hasAttribute("red")) colorchoose=p.color(p.parseFloat(element.getString("red")),p.green(colorchoose),p.blue(colorchoose),p.alpha(colorchoose));
if(element.hasAttribute("green")) colorchoose=p.color(p.red(colorchoose),p.parseFloat(element.getString("green")),p.blue(colorchoose),p.alpha(colorchoose));
if(element.hasAttribute("blue")) colorchoose=p.color(p.red(colorchoose),p.green(colorchoose),p.parseFloat(element.getString("blue")),p.alpha(colorchoose));
if(element.hasAttribute("alpha")) colorchoose=p.color(p.red(colorchoose),p.green(colorchoose),p.blue(colorchoose),p.parseFloat(element.getString("alpha")));
for(int Comp=1;Comp<=p.cm.MenuColorList.length;Comp++){
if(Name.equals(p.cm.MenuColorList[Comp-1]))
p.cm.assignColorMenu(Comp,colorchoose);
}
}
示例13: readMenu
import processing.data.XML; //导入方法依赖的package包/类
public void readMenu(XML element){
if(element.hasAttribute("Number")) {
int num=element.getInt("Number");
if(element.hasAttribute("OriginX")) p.mm.OrginMenuXY[num][0]=element.getInt("OriginX");
if(element.hasAttribute("OriginY")) p.mm.OrginMenuXY[num][1]=element.getInt("OriginY");
if(element.hasAttribute("SizeX")) p.mm.SizeMenuXY[num][0]=element.getInt("SizeX");
if(element.hasAttribute("SizeY")) p.mm.SizeMenuXY[num][1]=element.getInt("SizeY");
if(element.hasAttribute("Active")) p.mm.MenuActive[num]=p.parseInt(element.getString("Active"));
}
}
示例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: 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;
}