Example usage for org.jdom2 Document getRootElement

List of usage examples for org.jdom2 Document getRootElement

Introduction

In this page you can find the example usage for org.jdom2 Document getRootElement.

Prototype

public Element getRootElement() 

Source Link

Document

This will return the root Element for this Document

Usage

From source file:eu.himeros.cophi.ocr.proofreader.controller.pojo.OcrPageParser.java

License:Open Source License

/**
 * Parses an hocrDocuemnt, creating an ocrPage.
 * @param hocrDocument/* ww w.j a  va2s.c om*/
 * @return the ocrPage.
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException 
 */
public OcrPage parse(Document hocrDocument)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    ocrPage.setHocrDocument(hocrDocument);
    Element root = hocrDocument.getRootElement();
    Namespace xmlns = root.getNamespace();
    String scanId = root.getChildren().get(1).getChildren().get(0).getAttributeValue("id");
    ocrPage.setScan(new PageScan<>(scanId));
    List<OcrLine> ocrLines = new ArrayList<>();
    for (Element ocrLineEl : root.getChildren().get(1).getChildren().get(0).getChildren("span", xmlns)) { //cycle on /html/body/span[@class='ocr_page']/span[@class='ocr_line']
        ocrLines.add(parseOcrLine(ocrLineEl));
    }
    ocrPage.setOcrLines(ocrLines);
    return ocrPage;
}

From source file:eu.himeros.hocr.FlatXml.java

License:Open Source License

private void init(File inFile, File outFile) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(inFile);
    Element root = doc.getRootElement();
    Namespace oldns = root.getNamespace();
    Element newRoot = new Element("html", "http://www.w3.org/1999/xhtml");
    Namespace xmlns = newRoot.getNamespace();
    Element head = root.getChild("head", oldns);
    head.setNamespace(xmlns);//w  ww . jav  a 2s  .  com
    for (Element child : head.getChildren())
        child.setNamespace(xmlns);
    Element title = new Element("title", xmlns);
    title.addContent("ocr");
    if (head != null)
        head.addContent(title);
    Element body = root.getChild("body", oldns);
    body.setNamespace(xmlns);
    /*Element oldPage;
    try{
    oldPage=body.getChild("div",xmlns);
    }catch(Exception ex){
    oldPage=new Element("div",xmlns);
    }*/
    Element page = new Element("div", xmlns);
    page.setAttribute("class", "ocr_page");
    page.setAttribute("id", "i" + inFile.getName().substring(1).replace(".html", ".png"));
    XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@class='ocr_carea']",
            Filters.element(), null, Namespace.getNamespace("ns", "http://www.w3.org/1999/xhtml"));
    List<Element> careaElL = xpath.evaluate(body);
    for (Element careaEl : careaElL) {
        page.addContent(new Comment("<div class=\"" + careaEl.getAttributeValue("class") + "\" title=\""
                + careaEl.getAttributeValue("title") + "\">"));
        for (Element pEl : careaEl.getChildren()) {
            page.addContent(new Comment("<p>"));
            for (Element lineEl : pEl.getChildren()) {
                lineEl.removeAttribute("id");
                lineEl.setNamespace(xmlns);
                for (Element child : lineEl.getChildren()) {
                    child.removeAttribute("id");
                    child.removeAttribute("lang");
                    child.removeAttribute("lang", xmlns);
                    child.setNamespace(xmlns);
                }
                page.addContent(lineEl.clone());
            }
            page.addContent(new Comment("</p>"));
        }
        page.addContent(new Comment("</div>"));
    }
    //oldPage.detach();
    if (body != null) {
        body.removeContent();
        body.addContent(page);
    }
    newRoot.addContent(root.removeContent());
    doc.detachRootElement();
    doc.setRootElement(newRoot);
    XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
    xmlOutputter.output(doc, new BufferedWriter(new FileWriter(outFile)));
}

From source file:eu.himeros.hocr.XmlWordListExtractor.java

License:Open Source License

private void init(String inFileName, String outFileName) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(inFileName);
    BufferedWriter bw = new BufferedWriter(new FileWriter(outFileName));
    Element el = doc.getRootElement();
    String s = el.getValue();//  www  . j  av a  2s . c o m
    s = s.replaceAll("\n", " ");
    s = s.replaceAll(" +", " ");
    s = s.replace("- ", "");
    s = s.replace(" ", "\n");
    String[] ss = s.split("\n");
    for (String item : ss) {
        item = item.replaceAll("[^\u0370-\u03FF\u1F00-\u1FFF]|[]", "");
        if (item.length() < 1)
            continue;
        bw.write(item);
        bw.newLine();
    }
    bw.close();
}

From source file:eu.knux.passmanager.helper.FileHelper.java

License:Apache License

public static LinkedHashMap<String, Category> loadPassword(File f) {
    SAXBuilder builder = new SAXBuilder();
    Element racine = null;/*from   w  w w  . j a  v  a  2  s. c  o  m*/
    LinkedHashMap<String, Category> categoriesReturned = new LinkedHashMap<>();
    try {
        Document doc = builder.build(f);
        racine = doc.getRootElement();
    } catch (JDOMException | IOException e) {
        e.printStackTrace();
    }

    if (racine != null) {
        List<Element> categories = racine.getChildren("category");
        categoriesReturned.put("root", new Category("root"));
        for (Element e : categories) {
            String name = e.getAttributeValue("name");
            List<Element> passes = e.getChildren("password");
            for (Element e2 : passes) {
                Category currCate = null;
                if (name != null && !categoriesReturned.containsKey(name)) {
                    categoriesReturned.put(name, new Category(name));
                }
                currCate = (name == null) ? categoriesReturned.get("root") : categoriesReturned.get(name);

                Password p = new Password();
                p.setName(e2.getChildText("name"));
                p.setPass(e2.getChildText("pass"));
                p.setComment(e2.getChildText("comment"));
                p.setEncrypted(true);
                currCate.addPassword(p);
            }
        }
    }

    return categoriesReturned;
}

From source file:fciencias.edatos.practica04.Catalogo.java

/**
 * Metodo que va iniciar Jdom para lectura y escritura de archivos XML
 * @param xmlOtroNombre elNombre original del archivo.
 * @throws JDOMException Excepcion de JDOM
 * @throws IOException Excepcion del sistema.
 *///from   w w w.j  av  a 2  s.  c o  m

private void useJDOM(String baseDeDatos) throws JDOMException, IOException {

    SAXBuilder jdomBuilder = new SAXBuilder();
    File inputFile = new File(baseDeDatos);
    Document jdomDocument = jdomBuilder.build(inputFile);
    Element firstElement = jdomDocument.getRootElement();

    //Estos son los profesores
    for (Element elementProfesor : firstElement.getChildren()) {
        int[] salario = new int[12];
        int c = 0;
        for (Element elementSalario : elementProfesor.getChildren()) {
            String salarioRealEnString = elementSalario.getValue();
            int salarioRealMes = Integer.parseInt(salarioRealEnString);

            salario[c] = salarioRealMes;
            c++;

        }

        //           System.out.println(Arrays.toString(salario));

        String id = elementProfesor.getAttributeValue("id");
        int id_int = Integer.parseInt(id);
        String nombre = elementProfesor.getAttributeValue("nombre");
        String carreraString = elementProfesor.getAttributeValue("carrera");
        Carrera carrera = Carrera.NO_CARRERA;

        if (carreraString.equals("MATEMATICAS")) {
            carrera = Carrera.MATEMATICAS;
        } else if (carreraString.equals("ACTUARIA")) {
            carrera = Carrera.ACTUARIA;
        } else if (carreraString.equals("FISICA")) {
            carrera = Carrera.FISICA;
        } else if (carreraString.equals("BIOLOGIA")) {
            carrera = Carrera.BIOLOGIA;
        } else if (carreraString.equals("CIENCIAS_DE_LA_COMPUTACION")) {
            carrera = Carrera.CIENCIAS_DE_LA_COMPUTACION;
        } else if (carreraString.equals("FISICA_BIOMEDICA")) {
            carrera = Carrera.FISICA_BIOMEDICA;
        } else if (carreraString.equals("CIENCIAS_DE_LA_TIERRA")) {
            carrera = Carrera.CIENCIAS_DE_LA_TIERRA;
        }

        String gradoString = elementProfesor.getAttributeValue("grado");

        Grado grado = Grado.NO_GRADO;

        if (gradoString.equals("LICENCIADO")) {
            grado = Grado.LICENCIADO;
        } else if (gradoString.equals("MAESTRO")) {
            grado = Grado.MAESTRO;
        } else if (gradoString.equals("DOCTOR")) {
            grado = Grado.DOCTOR;
        }

        else if (gradoString.equals("ESPECIALISTA")) {
            grado = Grado.ESPECIALISTA;
        }

        Profesor profestorEnMemoria = null;

        profestorEnMemoria = new Profesor(id_int, nombre, carrera, grado, salario);

        @SuppressWarnings("unchecked")
        T prof = (T) profestorEnMemoria;

        listaProfesores.agregaFinal(prof);

    }

}

From source file:fi.ni.bcfextractor.BCFExtractorController.java

License:Open Source License

private void openBCFZip(File file) {
    FileInputStream inputStream = null;
    try {/*from w  ww . java2s. com*/
        inputStream = new FileInputStream(file);
        ZipInputStream zInputStream = new ZipInputStream(inputStream);
        try {
            data.clear();
            for (ZipEntry entry = zInputStream.getNextEntry(); entry != null; entry = zInputStream
                    .getNextEntry()) {
                String name = entry.getName();
                if (name.endsWith(".bcf")) {

                    BufferedReader inputReader = new BufferedReader(new InputStreamReader(zInputStream));
                    StringBuilder sb = new StringBuilder();
                    String inline = "";
                    while ((inline = inputReader.readLine()) != null) {
                        sb.append(inline);
                    }

                    System.out.println(sb.toString());
                    SAXBuilder builder = new SAXBuilder();

                    try {
                        Document doc = (Document) builder
                                .build(new ByteArrayInputStream(sb.toString().getBytes()));
                        listChildren(doc.getRootElement());
                    } catch (JDOMException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                zInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } finally {
        try {
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:filter.Filter.java

public void convertFiles() {
    try {//w w w.  ja  v a  2  s .  c om
        int idProject = new ProjectDAO().register(this.project);
        this.project.setId(idProject);
        for (File f : this.files) {
            Document doc = this.builder.build(f);
            Element root = doc.getRootElement();
            progressBar.initialize(getLines(root),
                    "Importing software metrics from the file '" + Paths.get(f.getName()) + "'. Please, wait.");
            incrementValue();
            List element = root.getChildren();
            Iterator i = element.iterator();
            converterProject(i);
            progressBar.finish();
        }
        finish();
        frame.refresh();

    } catch (JDOMException | IOException ex) {
        exception();
        Logger.getLogger(Filter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fourmiz.engine.Engine.java

License:Open Source License

/**
 * Load a specific game//from   w w  w .ja v a2s  .  c om
 * @param name
 * @throws JDOMException
 * @throws IOException
 * @throws SlickException
 */
public void loadLevel(String name) throws JDOMException, IOException, SlickException {
    currentGame = name;
    ressources.load(resourcePath + currentGame + renderSuffix);
    SAXBuilder sax = new SAXBuilder();
    Document doc = sax.build(new File(resourcePath + currentGame + mapSuffix));
    Element root = doc.getRootElement();
    List<Element> listElem = root.getChildren();

    for (Element elem : listElem) {
        switch (elem.getName()) {
        case "Config":
            loadConfig(elem.getChildren());
            break;
        case "Entity":
            loadEntity(elem.getChildren());
            break;
        default:
            log.warn("loadLevel: unknown type object -> " + elem.getName());
            continue;
        }
    }

    this.loaded = true;
}

From source file:fr.amap.lidar.amapvox.gui.viewer3d.Viewer3DFrameController.java

/**
 * Initializes the controller class.//from  w w w .java2 s.  c  o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    treeviewSceneObjects
            .setCellFactory(new Callback<TreeView<SceneObjectWrapper>, TreeCell<SceneObjectWrapper>>() {
                @Override
                public TreeCell<SceneObjectWrapper> call(TreeView<SceneObjectWrapper> param) {

                    return new SceneObjectTreeCell();
                }
            });

    root = new TreeItem<>();
    root.setExpanded(true);
    treeviewSceneObjects.setRoot(root);

    checkMenuItemPerspective.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            checkMenuItemOrthographic.setSelected(!newValue);
        }
    });

    checkMenuItemOrthographic.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            checkMenuItemPerspective.setSelected(!newValue);
        }
    });

    checkMenuItemOrthographic.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {

                try {
                    float near = Float.valueOf(textfieldCameraNear.getText());
                    float far = Float.valueOf(textfieldCameraFar.getText());
                    viewer3D.getJoglContext().getScene().getCamera().setViewToOrthographic(near, far, far, far,
                            near, far);
                    viewer3D.getJoglContext().updateCamera();
                    viewer3D.getJoglContext().refresh();
                } catch (Exception e) {
                }

            }
        }
    });

    checkMenuItemPerspective.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {

                try {
                    float fov = Float.valueOf(textFieldPerspective.getText());
                    float near = Float.valueOf(textfieldCameraNear.getText());
                    float far = Float.valueOf(textfieldCameraFar.getText());

                    viewer3D.getJoglContext().getScene().getCamera().setViewToPerspective(fov, near, far);
                    viewer3D.getJoglContext().updateCamera();
                    viewer3D.getJoglContext().refresh();

                } catch (Exception e) {
                }

            }
        }
    });

    textFieldPerspective.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            try {
                float fov = Float.valueOf(newValue);
                TrackballCamera camera = viewer3D.getJoglContext().getScene().getCamera();
                viewer3D.getJoglContext().getScene().getCamera().setPerspective(fov, camera.getAspect(),
                        camera.getNearPersp(), camera.getFarPersp());
                viewer3D.getJoglContext().refresh();

            } catch (Exception e) {
            }
        }
    });

    tableColumnName.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<Viewer3DFrameController.Attribut, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(TableColumn.CellDataFeatures<Attribut, String> param) {
                    return new SimpleStringProperty(param.getValue().getName());
                }
            });

    tableColumnValue.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<Viewer3DFrameController.Attribut, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(TableColumn.CellDataFeatures<Attribut, String> param) {
                    return new SimpleStringProperty(String.valueOf(param.getValue().getValue()));
                }
            });

    comboboxGradient.getItems().addAll(Util.AVAILABLE_GRADIENT_COLOR_NAMES);
    comboboxGradient.getSelectionModel().select("HEAT");

    isHidden = false;

    colorPickerBackgroundColor.valueProperty().addListener(new ChangeListener<javafx.scene.paint.Color>() {
        @Override
        public void changed(ObservableValue<? extends javafx.scene.paint.Color> observable,
                javafx.scene.paint.Color oldValue, javafx.scene.paint.Color newValue) {

            try {

                //read sgv file
                URL resource = Viewer3DFrameController.class.getResource("/fxml/icons/pinceau.svg");

                SAXBuilder sxb = new SAXBuilder();
                Document document = sxb.build(resource);

                final Element root = document.getRootElement();

                //edit svg file
                final List<Element> graphicElements = root.getChildren("g", root.getNamespace());

                String hexColor = null;

                for (Element element : graphicElements) {
                    String attributeValue = element.getAttributeValue("label",
                            Namespace.getNamespace("http://www.inkscape.org/namespaces/inkscape"));

                    if (attributeValue != null && attributeValue.equals("ciel")) {
                        final Element ellipse = element.getChild("ellipse", root.getNamespace());
                        String style = ellipse.getAttributeValue("style");

                        int indexOf = style.indexOf("fill:#");
                        hexColor = Integer.toHexString((int) (newValue.getRed() * 255))
                                + Integer.toHexString((int) (newValue.getGreen() * 255))
                                + Integer.toHexString((int) (newValue.getBlue() * 255));

                        style = style.substring(0, indexOf + 6) + hexColor + style.substring(indexOf + 12);

                        ellipse.setAttribute("style", style);
                    } else if (attributeValue != null && attributeValue.equals("peinture")) {

                        final Element path = element.getChild("path", root.getNamespace());
                        String style = path.getAttributeValue("style");

                        int indexOf = style.indexOf("fill:#");
                        DecimalFormat df = new DecimalFormat("##");
                        hexColor = Integer.toHexString((int) (newValue.getRed() * 255))
                                + Integer.toHexString((int) (newValue.getGreen() * 255))
                                + Integer.toHexString((int) (newValue.getBlue() * 255));

                        style = style.substring(0, indexOf + 6) + hexColor + style.substring(indexOf + 12);

                        path.setAttribute("style", style);
                    }

                }

                if (hexColor != null) {

                    SVGConverter conv = new SVGConverter();

                    conv.setWidth(32.0f);
                    conv.setHeight(32.0f);

                    conv.setMediaType("image/png");

                    File tmpSVGFile = File.createTempFile("skycolor", ".svg");
                    File tmpPNGFile = File.createTempFile("skycolor", ".png");

                    //convert svg to png
                    conv.setSources(new String[] { tmpSVGFile.toURI().toURL().toString() });

                    conv.setDst(tmpPNGFile);

                    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
                    output.output(document, new BufferedOutputStream(new FileOutputStream(tmpSVGFile)));

                    conv.execute();

                    //change sky icon
                    Image image = new Image(tmpPNGFile.toURI().toURL().toString());
                    imageviewSkyColor.setImage(image);
                }

            } catch (Exception ex) {
                java.util.logging.Logger.getLogger(Viewer3DFrameController.class.getName()).log(Level.SEVERE,
                        null, ex);
            }

            if (viewer3D != null) {
                viewer3D.getJoglContext().setWorldColor(new Vec3F((float) newValue.getRed(),
                        (float) newValue.getGreen(), (float) newValue.getBlue()));
                viewer3D.getJoglContext().refresh();
            }
        }
    });

    comboboxGradient.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {

            String gradient = newValue;
            Color[] gradientColor = ColorGradient.GRADIENT_RAINBOW;

            for (int i = 0; i < Util.AVAILABLE_GRADIENT_COLORS.size(); i++) {

                if (Util.AVAILABLE_GRADIENT_COLOR_NAMES.get(i).equals(gradient)) {
                    gradientColor = Util.AVAILABLE_GRADIENT_COLORS.get(i);
                    i = Util.AVAILABLE_GRADIENT_COLOR_NAMES.size() - 1;
                }
            }

            //recalculate voxel color with the new gradient
            voxelSpace.updateColorValue(gradientColor);

            //update instance color buffer to gpu
            voxelSpace.updateInstanceColorBuffer();

            viewer3D.getJoglContext().refresh();

        }
    });

    colorPickerBackgroundColor.setValue(new javafx.scene.paint.Color(0.8, 0.8, 0.8, 1));
    colorpickerLightingAmbientColor.setValue(new javafx.scene.paint.Color(1.0, 1.0, 1.0, 1));
    colorpickerLightingDiffuseColor.setValue(new javafx.scene.paint.Color(1.0, 1.0, 1.0, 1));
    colorpickerLightingSpecularColor.setValue(new javafx.scene.paint.Color(1.0, 1.0, 1.0, 1));

    colorpickerLightingAmbientColor.valueProperty().addListener(new ChangeListener<javafx.scene.paint.Color>() {

        @Override
        public void changed(ObservableValue<? extends javafx.scene.paint.Color> observable,
                javafx.scene.paint.Color oldValue, javafx.scene.paint.Color newValue) {
            viewer3D.getJoglContext().getScene().setLightAmbientValue(new Vec3F((float) newValue.getRed(),
                    (float) newValue.getGreen(), (float) newValue.getBlue()));
            viewer3D.getJoglContext().refresh();
        }
    });

    colorpickerLightingDiffuseColor.valueProperty().addListener(new ChangeListener<javafx.scene.paint.Color>() {

        @Override
        public void changed(ObservableValue<? extends javafx.scene.paint.Color> observable,
                javafx.scene.paint.Color oldValue, javafx.scene.paint.Color newValue) {
            viewer3D.getJoglContext().getScene().setLightDiffuseValue(new Vec3F((float) newValue.getRed(),
                    (float) newValue.getGreen(), (float) newValue.getBlue()));
            viewer3D.getJoglContext().refresh();
        }
    });

    colorpickerLightingSpecularColor.valueProperty()
            .addListener(new ChangeListener<javafx.scene.paint.Color>() {

                @Override
                public void changed(ObservableValue<? extends javafx.scene.paint.Color> observable,
                        javafx.scene.paint.Color oldValue, javafx.scene.paint.Color newValue) {
                    viewer3D.getJoglContext().getScene()
                            .setLightSpecularValue(new Vec3F((float) newValue.getRed(),
                                    (float) newValue.getGreen(), (float) newValue.getBlue()));
                    viewer3D.getJoglContext().refresh();
                }
            });

    comboBoxAttributeToShow.getSelectionModel().selectedItemProperty()
            .addListener(new ChangeListener<String>() {

                @Override
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    try {
                        voxelSpace.resetAttributValueRange();
                        voxelSpace.changeCurrentAttribut(newValue);
                        voxelSpace.updateVao();
                        voxelSpace.updateInstanceColorBuffer();
                        viewer3D.getJoglContext().refresh();
                        textFieldMinValue.getEditor()
                                .setText(String.valueOf(voxelSpace.getRealAttributValueMin()));
                        textFieldMaxValue.getEditor()
                                .setText(String.valueOf(voxelSpace.getRealAttributValueMax()));

                    } catch (Exception e) {
                    }

                }
            });

    final InstanceLightedShader ils = new InstanceLightedShader();
    final InstanceShader is = new InstanceShader();

    checkMenuItemEnableLighting.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {

            if (newValue) {
                voxelSpace.setShader(ils);
            } else {
                voxelSpace.setShader(is);
            }

            viewer3D.getJoglContext().refresh();
        }
    });

    /*textFieldFilterValues.setOnKeyReleased(new EventHandler<KeyEvent>() {
            
    @Override
    public void handle(KeyEvent event) {
                
        if(event.getCode() == KeyCode.ENTER){
            updateValuesFilter();
        }
    }
    });*/

    checkboxStretched.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                voxelSpace.setStretched(true);
                voxelSpace.updateValue();
                voxelSpace.updateInstanceColorBuffer();

                viewer3D.getJoglContext().refresh();
            } else {
                voxelSpace.setStretched(false);
                voxelSpace.updateValue();
                voxelSpace.updateInstanceColorBuffer();

                viewer3D.getJoglContext().refresh();
            }

        }
    });
    /*
            
    textfieldCameraNear.textProperty().addListener(new ChangeListener<String>() {
            
    @Override
    public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
        try{
            float near = Float.valueOf(newValue);
            TrackballCamera camera = joglContext.getScene().getCamera();
            if(radiobuttonOrthographicCamera.isSelected()){
                joglContext.getScene().getCamera().setOrthographic(camera.getLeft(), camera.getRight(), camera.getTop(), camera.getBottom(), near, camera.getFarOrtho());
                joglContext.updateCamera();
                joglContext.refresh();
            }else{
                joglContext.getScene().getCamera().setPerspective(camera.getFovy(), camera.getAspect(), near, camera.getFarPersp());
                joglContext.updateCamera();
                joglContext.refresh();
            }
                    
            joglContext.refresh();
                    
        }catch(Exception e){}
    }
    });
            
    textfieldCameraFar.textProperty().addListener(new ChangeListener<String>() {
            
    @Override
    public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
        try{
            float far = Float.valueOf(newValue);
            TrackballCamera camera = joglContext.getScene().getCamera();
            if(radiobuttonOrthographicCamera.isSelected()){
                camera.setOrthographic(camera.getLeft(), camera.getRight(), camera.getTop(), camera.getBottom(), camera.getNearOrtho(), far);
                joglContext.updateCamera();
                joglContext.refresh();
            }else{
                camera.setPerspective(camera.getFovy(), camera.getAspect(), camera.getNearPersp(), far);
                joglContext.updateCamera();
                joglContext.refresh();
            }
                    
            joglContext.refresh();
                    
        }catch(Exception e){}
    }
    });
    */

    comboBoxScalarField.setItems(comboBoxAttributeToShow.getItems());
    comboBoxScalarField.getItems().addListener(new ListChangeListener<String>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends String> c) {
            if (c.getList().size() > 0) {
                comboBoxScalarField.getSelectionModel().selectFirst();
            }
        }
    });

    checkMenuItemShowColorScale.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            viewer3D.getScene().getSceneObject("color scale").setVisible(newValue);
            viewer3D.getJoglContext().refresh();
        }
    });

    ToggleGroup group = new ToggleGroup();
    radiobuttonDisplay.setToggleGroup(group);
    radiobuttonDontDisplay.setToggleGroup(group);

    CombinedFilter combFilter1 = new CombinedFilter(new Filter("x", 0.0f, Filter.EQUAL), null,
            CombinedFilter.AND);
    CombinedFilter combFilter2 = new CombinedFilter(new Filter("x", Float.NaN, Filter.EQUAL), null,
            CombinedFilter.AND);

    listviewFilters.getItems().add(new CombinedFilterItem("PadBVTotal", false, combFilter1.getFilter1(),
            combFilter1.getFilter2(), combFilter1.getType()));

    listviewFilters.getItems().add(new CombinedFilterItem("PadBVTotal", false, combFilter2.getFilter1(),
            combFilter2.getFilter2(), combFilter2.getType()));

}

From source file:fr.ms.tomcat.manager.ContextFileUtils.java

License:Apache License

public static File creationFichierContextDocBase(final File fichierContext, final File webappDirectory)
        throws JDOMException, IOException {

    Element context = null;/* www  . j a  va 2s  .  co  m*/
    Document document = null;

    if (fichierContext.exists()) {
        LOG.debug("Le fichier context existe dj dans la webapps : {}.", fichierContext.getAbsolutePath());
        final SAXBuilder sxb = new SAXBuilder();
        document = sxb.build(fichierContext);
        context = document.getRootElement();
    } else {
        LOG.debug("Le fichier context n'existe pas dans la webapps : {}.", fichierContext.getAbsolutePath());
        context = new Element("Context");
        document = new Document(context);
    }

    final Attribute docBase = new Attribute("docBase", webappDirectory.getAbsolutePath());
    final Attribute workDir = new Attribute("workDir", webappDirectory.getAbsolutePath() + "-workDir");
    context.setAttribute(docBase);
    context.setAttribute(workDir);

    final XMLOutputter xmlContextFile = new XMLOutputter(Format.getPrettyFormat());

    if (LOG.isDebugEnabled()) {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        xmlContextFile.output(document, baos);

        LOG.debug(baos.toString());
    }

    final File fichierContextTemporaire = File.createTempFile("contextTomcat", ".xml");

    final FileOutputStream fichierContextTemporaireOutputStream = new FileOutputStream(
            fichierContextTemporaire);

    xmlContextFile.output(document, fichierContextTemporaireOutputStream);
    fichierContextTemporaireOutputStream.close();
    return fichierContextTemporaire;
}