List of usage examples for org.jdom2 Element getName
public String getName()
From source file:com.ardor3d.extension.model.collada.jdom.ColladaNodeUtils.java
License:Open Source License
/** * Combines a list of transform elements into an Ardor3D Transform object. * /*from ww w . jav a 2 s . co m*/ * @param transforms * List of transform elements * @return an Ardor3D Transform object */ public Transform getNodeTransforms(final List<Element> transforms) { final Matrix4 workingMat = Matrix4.fetchTempInstance(); final Matrix4 finalMat = Matrix4.fetchTempInstance(); finalMat.setIdentity(); for (final Element transform : transforms) { final double[] array = _colladaDOMUtil.parseDoubleArray(transform); if ("translate".equals(transform.getName())) { workingMat.setIdentity(); workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0)); finalMat.multiplyLocal(workingMat); } else if ("rotate".equals(transform.getName())) { if (array[3] != 0) { workingMat.setIdentity(); final Matrix3 rotate = new Matrix3().fromAngleAxis(array[3] * MathUtils.DEG_TO_RAD, new Vector3(array[0], array[1], array[2])); workingMat.set(rotate); finalMat.multiplyLocal(workingMat); } } else if ("scale".equals(transform.getName())) { workingMat.setIdentity(); workingMat.scale(new Vector4(array[0], array[1], array[2], 1), workingMat); finalMat.multiplyLocal(workingMat); } else if ("matrix".equals(transform.getName())) { workingMat.fromArray(array); finalMat.multiplyLocal(workingMat); } else if ("lookat".equals(transform.getName())) { final Vector3 pos = new Vector3(array[0], array[1], array[2]); final Vector3 target = new Vector3(array[3], array[4], array[5]); final Vector3 up = new Vector3(array[6], array[7], array[8]); final Matrix3 rot = new Matrix3(); rot.lookAt(target.subtractLocal(pos), up); workingMat.set(rot); workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1)); finalMat.multiplyLocal(workingMat); } else { logger.warning("transform not currently supported: " + transform.getClass().getCanonicalName()); } } return new Transform().fromHomogeneousMatrix(finalMat); }
From source file:com.ardor3d.extension.model.collada.jdom.plugin.GoogleEarthPlugin.java
License:Open Source License
@Override public boolean processExtra(final Element extra, final Object[] params) { if (params.length > 0 && params[0] instanceof Mesh) { final Mesh mesh = (Mesh) params[0]; // should have a child: <technique profile="GOOGLEEARTH"> final Element technique = extra.getChild("technique"); if (technique != null) { final Attribute profile = technique.getAttribute("profile"); if (profile != null && "GOOGLEEARTH".equalsIgnoreCase(profile.getValue())) { for (final Element child : technique.getChildren()) { // disable back face culling if it's been enabled. if ("double_sided".equalsIgnoreCase(child.getName()) && "1".equals(child.getTextTrim())) { final CullState cs = new CullState(); cs.setEnabled(false); mesh.setRenderState(cs); }// w w w .ja va2 s. c o m } return true; } } } return false; }
From source file:com.astronomy.project.Alignment.java
/** * /*from w ww. j a v a2 s .c om*/ * @param e XML element * @throws ProcessException Format error */ public Alignment(Element e) throws ProcessException { pComments = new SimpleStringProperty(); for (Element el : e.getChildren()) { switch (el.getName()) { case "lugar": if (el.getAttributeValue("tipo").equals("origen")) { observatory = new ReferencePoint(el); pObservatory = new SimpleStringProperty(observatory.getName()); } else if (el.getAttributeValue("tipo").equals("referencia")) { foresight = new ReferencePoint(el); pForesight = new SimpleStringProperty(foresight.getName()); } break; case "direccion": orientation = new Orientation(el); pAzimuth = new SimpleStringProperty( String.format("%.1f", orientation.getAzimuth().getSignedValue()).replace(",", ".")); pAltitude = new SimpleStringProperty( String.format("%.1f", orientation.getAltitude().getSignedValue()).replace(",", ".")); break; case "descripcion": description = new Tag("descripcion", el); pComments.set(description.getValue()); break; case "imagen": imagenPath = new Tag("imagen", el); break; case "declinacion": declination = new Declination(el); pDeclination = new SimpleStringProperty( String.format("%.1f", getDeclination().getSignedValue()).replace(",", ".")); break; } } if (imagenPath == null) imagenPath = new Tag("imagen", ""); }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ?? Data setting (data class : PDFMetadataDefinition) * /*from ww w.j a v a 2s .c om*/ * @param root * @param rootData * @param upload * @throws Exception */ public static void setDynamicSection(Element root, PDFMetadataDefinition rootData, Upload upload) throws Exception { List<Element> childs = new ArrayList<Element>(); AnalyzeDefinition data = rootData.getEarDefinition(); setDynamicSection(root, data, upload); for (Element e : root.getChildren()) { if (e.getName().equals("section")) { if (e.getChild("war_child_deploy") != null) { //ear Web Applications childs = setChildDeployData(rootData, upload, "war"); } else if (e.getChild("jar_child_deploy") != null) { //ear EJB Applications childs = setChildDeployData(rootData, upload, "jar"); } else if (e.getChild("trans_application_xml_info") != null) { //?? - application Deployment Descriptor childs = setTransXmlData(rootData, upload, "application"); } else if (e.getChild("trans_web_xml_info") != null) { //?? - Web Deployment Descriptor childs = setTransXmlData(rootData, upload, "web"); } else if (e.getChild("trans_ejb_xml_info") != null) { //?? - EJB Deployment Descriptor childs = setTransXmlData(rootData, upload, "ejb"); } } for (Element child : childs) { e.addContent(child); } childs = new ArrayList<Element>(); } //?? ? start(chapter ? ?? section? ? ) for (Element e : root.getChildren()) { if (e.getName().equals("exception_info")) { childs = setExceptionData(rootData, upload); } } for (Element child : childs) { root.addContent(child); } childs = new ArrayList<Element>(); //?? ? end }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ?? Data setting (data class : AnalyzeDefinition) * //from w w w .j a v a 2 s. co m * @param root * @param data * @param upload */ public static void setDynamicSection(Element root, AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); int index = 0; for (Element e : root.getChildren()) { if (e.getName().equals("section")) { // Section ? setDynamicSection(e, data, upload); } else if (e.getName().equals("file_summary")) { // ? childs = setFileSummary(data); } else if (e.getName().equals("pattern_servlet")) { // Servlet ?? ? childs = setPatternData(data, "servlet"); } else if (e.getName().equals("pattern_ejb")) { // EJB ?? ? childs = setPatternData(data, "ejb"); } else if (e.getName().equals("dependency_java")) { // Java ? childs = setDependencyData(data, "java"); } else if (e.getName().equals("dependency_jsp")) { // jsp ? childs = setDependencyData(data, "jsp"); } else if (e.getName().equals("dependency_property")) { // Properties ? childs = setDependencyData(data, "property"); } else if (e.getName().equals("dependency_class")) { // Class ? childs = setDependencyData(data, "class"); } else if (e.getName().equals("jsp_analyze_result")) { // JSP ? ? childs = setJspAnalyzeData(data, upload); } else if (e.getName().equals("deploy_application_text")) { // ? ? childs = setDeployApplicationText(data, upload); index = 1; } else if (e.getName().equals("web_xml_info")) { // ? ? childs = setApplicationData(data, upload); } else if (e.getName().equals("jar_xml_info")) { // EJB ? ? childs = setApplicationData(data, upload); } else if (e.getName().equals("lib_list")) { // lib childs = setLibData(data, upload, ""); } else if (e.getName().equals("delete_lib_list")) { // ? lib childs = setLibData(data, upload, "D"); } else if (e.getName().equals("class_info")) { // classes childs = setClassData(data, upload); } else if (e.getName().equals("application_list")) { // ?? ? ? ? childs = setApplicationListData(data, upload); index = 2; } else if (e.getName().equals("application_info")) { // ?? ? ? childs = setApplicationData(data, upload); } else if (e.getName().equals("ejb_application_list")) { // ?? ?? EJB childs = setEjbApplicationData(data, upload); } else if (e.getName().equals("maven_dependency")) { // Maven Dependency childs = setMavenDependencyList(data, upload); } else if (e.getName().equals("convert_encoding")) { //? ? childs = setConvertEncodingData(data, upload); index = 7; } } //index 0? ? index ? ? if (index == 0) { root.addContent(childs); } else { root.addContent(index, childs); index = 0; } }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * Element Mapping//w w w. ja v a 2s .co m * * @param section section ? * @param e element * @return Section * @throws Exception */ public static Section setElement(PdfWriter writer, Section section, Element e) throws Exception { for (org.jdom2.Element e1 : e.getChildren()) { if (e1.getName().equals("section")) { // section? setSectionElement(writer, section, e1); } else if (e1.getName().equals("text")) { /* ? text ? attribute : padding - padding */ if (e1.getAttributeValue("padding") != null) { Paragraph text = getDefault(e1.getText()); text.setIndentationLeft( text.getIndentationLeft() + Float.parseFloat(e1.getAttributeValue("padding"))); section.add(text); } else { section.add(getDefault(e1.getText())); } } else if (e1.getName().equals("table")) { // ? setTable(section, e1); } else if (e1.getName().equals("textR")) { //?? ? text ? section.add(getDefaultRed(e1.getText(), Font.ITALIC)); } else if (e1.getName().equals("textP")) { //? ? text ? section.add(getDefaultPoint(e1.getText())); } else if (e1.getName().equals("box")) { //text box ? setBox(section, e1); } else if (e1.getName().equals("boxB")) { //? ? text box ? setBoxB(section, e1); } else if (e1.getName().equals("boxW")) { //text box ? setBoxW(section, e1); } else if (e1.getName().equals("list")) { //? ? setList(section, e1); } else if (e1.getName().equals("img")) { //? ? setImage(section, e1); } else if (e1.getName().equals("chart")) { // ? setChart(writer, section, e1); } } return section; }
From source file:com.bc.ceres.binio.binx.BinX.java
License:Open Source License
private void parseParameters(Element binxElement) throws BinXException { Element parametersElement = getChild(binxElement, "parameters", false); if (parametersElement != null) { // todo - implement parameters (nf - 2008-11-27) throw new BinXException( MessageFormat.format("Element ''{0}'': Not implemented", parametersElement.getName())); }/* ww w .j av a 2s . com*/ }
From source file:com.bc.ceres.binio.binx.BinX.java
License:Open Source License
private void parseDefinitions(Element binxElement) throws IOException, BinXException { Element definitionsElement = getChild(binxElement, "definitions", false); if (definitionsElement != null) { List defineTypeElements = getChildren(definitionsElement, "defineType", false); for (int i = 0; i < defineTypeElements.size(); i++) { Element defineTypeElement = (Element) defineTypeElements.get(i); String typeName = getTypeName(defineTypeElement, true); Element child = getChild(defineTypeElement, true); Type type = parseNonSimpleType(child); if (type == null) { throw new BinXException(MessageFormat.format("Element ''{0}'': ''{1}'' not expected here", defineTypeElement.getName(), child.getName())); }//w w w.ja va 2s .c om if (definitions.containsKey(typeName)) { throw new BinXException( MessageFormat.format("Element ''{0}'': Duplicate type definition ''{1}''", definitionsElement.getName(), typeName)); } if (type instanceof CompoundType && type.getName().startsWith(ANONYMOUS_COMPOUND_PREFIX)) { type = COMPOUND(typeName, ((CompoundType) type).getMembers()); } definitions.put(typeName, type); } } }
From source file:com.bc.ceres.binio.binx.BinX.java
License:Open Source License
private Type parseNonSimpleType(Element typeElement) throws BinXException { String childName = typeElement.getName(); Type type = null;//from www. java2s . c o m if (childName.equals("struct")) { type = parseStruct(typeElement); } else if (childName.equals("union")) { type = parseUnion(typeElement); } else if (childName.equals("arrayFixed")) { type = parseArrayFixed(typeElement); } else if (childName.equals("arrayStreamed")) { type = parseArrayStreamed(typeElement); } else if (childName.equals("arrayVariable")) { type = parseArrayVariable(typeElement); } return type; }
From source file:com.bc.ceres.binio.binx.BinX.java
License:Open Source License
private Type parseAnyType(Element typeElement) throws BinXException { String typeName = typeElement.getName(); Type type;//from w ww.j a v a 2s . c o m if (typeName.equals("useType")) { type = parseUseType(typeElement); } else { type = parseNonSimpleType(typeElement); if (type == null) { type = primitiveTypes.get(typeElement.getName()); if (type == null) { throw new BinXException(MessageFormat.format("Element ''{0}'': Unknown type: {1}", typeElement.getName(), typeName)); } } } return type; }