List of usage examples for org.jdom2 Element getAttribute
public Attribute getAttribute(final String attname)
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.
From source file:de.openVJJ.imagePublisher.XuggleVideoFileInput.java
License:Open Source License
@Override public void setConfig(Element element) { Attribute inputFileName = element.getAttribute("inputFileName"); if (inputFileName != null) { setInputFileName(inputFileName.getValue()); }//from w w w.j a v a 2 s. c o m }
From source file:de.openVJJ.InputComponents.java
License:Open Source License
public static void load(String fileName) { try {/* w w w . ja v a 2s . co m*/ Document document = new SAXBuilder().build(fileName); Element rootElement = document.getRootElement(); if (rootElement.getName() != ROOT_ELEMET_NAME) { System.err.println("is notan Open-VJJ Project"); return; } Element gpuElement = rootElement.getChild(GPU_ELEMENT_NAME); if (gpuElement != null) { Attribute gpuActiv = gpuElement.getAttribute(GPU_ACTIV_ATTRIBUTE_NAME); if (gpuActiv != null) { useGPU = gpuActiv.getBooleanValue(); } } removeAll(); Element components = rootElement.getChild(COMPONENTS_ELEMENT_NAME); List<Element> elements = components.getChildren(COMPONENT_ELEMENT_NAME); for (Element rootComponente : elements) { addComponent((ImagePublisher) loadComponent(rootComponente)); } } catch (JDOMException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.openVJJ.InputComponents.java
License:Open Source License
private static VJJComponent loadComponent(Element element) { String className = element.getAttribute(CLASS_NAME_ATTRIBUTE_NAME).getValue(); try {/*from w w w .j av a2 s. c o m*/ Class<?> c = Class.forName(className); Object classInstance = c.newInstance(); if (VJJComponent.class.isInstance(classInstance)) { VJJComponent vjjComponent = (VJJComponent) classInstance; Element componentSetup = element.getChild(COMPONENT_SETUP_ELEMENT_NAME); if (componentSetup != null) { vjjComponent.setConfig(componentSetup); } if (ImagePublisher.class.isInstance(vjjComponent)) { ImagePublisher imagePublisher = (ImagePublisher) classInstance; Element components = element.getChild(COMPONENTS_ELEMENT_NAME); if (components != null) { List<Element> elements = components.getChildren(COMPONENT_ELEMENT_NAME); for (Element subComponentElement : elements) { ImageListener imageListener = (ImageListener) loadComponent(subComponentElement); if (imageListener == null) { continue; } addComponent(imageListener, imagePublisher); } } } return vjjComponent; } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.openVJJ.processor.GammaCorrection.java
License:Open Source License
@Override public void setConfig(Element element) { String gammaR = element.getAttribute("gammaR").getValue(); if (gammaR != null) { this.gammaR = Double.parseDouble(gammaR); }/*w w w. j a v a2 s. c o m*/ String gammaG = element.getAttribute("gammaG").getValue(); if (gammaG != null) { this.gammaG = Double.parseDouble(gammaG); } String gammaB = element.getAttribute("gammaB").getValue(); if (gammaB != null) { this.gammaB = Double.parseDouble(gammaB); } }
From source file:de.openVJJ.processor.LinearRGBCorrection.java
License:Open Source License
@Override public void setConfig(Element element) { String mulR = element.getAttribute("mulR").getValue(); if (mulR != null) { this.mulR = Double.parseDouble(mulR); }/*from w w w. j a va2s . com*/ String mulG = element.getAttribute("mulG").getValue(); if (mulG != null) { this.mulG = Double.parseDouble(mulG); } String mulB = element.getAttribute("mulB").getValue(); if (mulB != null) { this.mulB = Double.parseDouble(mulB); } }
From source file:de.openVJJ.processor.Resolution.java
License:Open Source License
@Override public void setConfig(Element element) { String width = element.getAttribute("width").getValue(); if (width != null) { this.width = Integer.parseInt(width); }//from ww w. j a v a 2 s .c o m String height = element.getAttribute("height").getValue(); if (height != null) { this.height = Integer.parseInt(height); } }
From source file:de.openVJJ.processor.Warping.java
License:Open Source License
@Override public void setConfig(Element element) { String pointTLx = element.getAttribute("pointTLx").getValue(); String pointTLy = element.getAttribute("pointTLy").getValue(); String pointBLx = element.getAttribute("pointBLx").getValue(); String pointBLy = element.getAttribute("pointBLy").getValue(); String pointTRx = element.getAttribute("pointTRx").getValue(); String pointTRy = element.getAttribute("pointTRy").getValue(); String pointBRx = element.getAttribute("pointBRx").getValue(); String pointBRy = element.getAttribute("pointBRy").getValue(); if (pointTLx != null && pointTLy != null && pointBLx != null && pointBLy != null && pointTRx != null && pointTRy != null && pointBRx != null && pointBRy != null) { int pointTLxInt = Integer.parseInt(pointTLx); int pointTLyInt = Integer.parseInt(pointTLy); Point pointTL = new Point(pointTLxInt, pointTLyInt); int pointBLxInt = Integer.parseInt(pointBLx); int pointBLyInt = Integer.parseInt(pointBLy); Point pointBL = new Point(pointBLxInt, pointBLyInt); int pointTRxInt = Integer.parseInt(pointTRx); int pointTRyInt = Integer.parseInt(pointTRy); Point pointTR = new Point(pointTRxInt, pointTRyInt); int pointBRxInt = Integer.parseInt(pointBRx); int pointBRyInt = Integer.parseInt(pointBRy); Point pointBR = new Point(pointBRxInt, pointBRyInt); setWarp(pointTL, pointTR, pointBR, pointBL); }/*w w w .ja va2s .co m*/ }
From source file:de.relaunch64.popelganda.database.Settings.java
License:Open Source License
/** * /* w w w. j a va 2 s . c o m*/ * @param nr * @return */ public Assembler getRecentDocAssembler(int nr) { // checl for valid parameter if (nr < 0) return Assemblers.ASM_KICKASSEMBLER; // retrieve element Element el = root.getChild(SETTING_RECENT_DOC + String.valueOf(nr)); // if we have any valid document if (el != null) { // retrieve compiler attribute Attribute comp = el.getAttribute(REC_DOC_ASSEMBLER); // if we have any valid attribute if (comp != null) { try { return Assemblers.byID(Integer.parseInt(comp.getValue())); } catch (NumberFormatException ex) { return Assemblers.ASM_KICKASSEMBLER; } } } // else return null return Assemblers.ASM_KICKASSEMBLER; }
From source file:de.relaunch64.popelganda.database.Settings.java
License:Open Source License
/** * //w w w. jav a2 s . c o m * @param nr * @return */ public int getRecentDocScript(int nr) { // checl for valid parameter if (nr < 0) return 0; // retrieve element Element el = root.getChild(SETTING_RECENT_DOC + String.valueOf(nr)); // if we have any valid document if (el != null) { // retrieve compiler attribute Attribute comp = el.getAttribute(REC_DOC_SCRIPT); // if we have any valid attribute if (comp != null) { try { return Integer.parseInt(comp.getValue()); } catch (NumberFormatException ex) { return 0; } } } // else return null return 0; }
From source file:de.smartics.maven.alias.domain.AliasesProcessor.java
License:Apache License
/** * Applies the alias information from the XML file to the given * {@code builders}.//w w w . jav a 2 s . c om * * @param builders the builders to create alias scripts. */ public void process(final AliasCollector... builders) { final Element root = doc.getRootElement(); for (final Element extensionElement : root.getChildren("extension", nsAlias)) { final AliasExtension extension = createExtension(extensionElement); final ExtensionGroup extensionGroup = new ExtensionGroup(extension); extensionGroups.add(extensionGroup); } for (final Element groupElement : root.getChildren("group", nsAlias)) { final Attribute groupName = groupElement.getAttribute("name"); final String comment = readComment(groupElement); final AliasGroup group = new AliasGroup(groupName.getValue(), comment); for (final Element aliasElement : groupElement.getChildren("alias", nsAlias)) { final Alias alias = createAlias(aliasElement); for (final ExtensionGroup extensionGroup : extensionGroups) { extensionGroup.addAlias(group.getName(), alias); } group.addAlias(alias); } for (final AliasCollector builder : builders) { builder.addAliases(group); } } for (final AliasCollector builder : builders) { builder.setExtensionGroups(extensionGroups); } }