Package cybop.basic

Examples of cybop.basic.String


        Vector allAlternativeOverlays = new Vector();
        if (xmlImageDocuments != null) {
            // For every xmlImageDoc: put name and properties of the image in a hashtable
            // properties e.g. are the overlayRegions and the image own data structure for an image? (class?)
            for (int i = 0; i < xmlImageDocuments.size(); i++) {
                String overlayName = getNameFromDocument((Document) xmlImageDocuments.elementAt(i));
                String description = getDescriptionFromDocument((Document) xmlImageDocuments.elementAt(i));
                Image image = getImageFromDocument((Document) xmlImageDocuments.elementAt(i));
                Hashtable overlayRegions = getOverlayRegionsFromDocument((Document) xmlImageDocuments.elementAt(i));
                Hashtable diseases = getDiseasesFromDocument((Document) xmlImageDocuments.elementAt(i));
                Vector alternativeOverlays = new Vector();
                alternativeOverlays = getAlternativeOverlaysFromDocument((Document) xmlImageDocuments.elementAt(i));
View Full Code Here


        if (doc != null) {
            NodeList imageList = doc.getElementsByTagName("IsAlternative");
            if(imageList!=null){
                if (imageList.item(0) != null) {
                    if (hasNodeValue(imageList.item(0))) {
                        String booleanString = getNodeValue(imageList.item(0));
                        if(booleanString.equals("true")){
                            return true;
                        }
                    }
                }
            }
View Full Code Here

                    }
                }
                System.out.println("Es existieren " + alternativeOverlaysVector.size() + " alternative Regionen.");
                for (int e = 0; e < alternativeOverlaysVector.size(); e++) {
                    Node alternativeOverlay = (Node) alternativeOverlaysVector.elementAt(e);
                    String alternativeOverlayName = getNodeValue(alternativeOverlay);
                    System.out.println("Adding " + alternativeOverlayName + " to List.");
                    returnVector.add(alternativeOverlayName);
                }
                return returnVector;
            } else {
View Full Code Here

     *Gets diseases from an overlay document
     *@param doc the document from which the overlayRegions should be taken
     *@return hashtable with diseases
     */
    public Hashtable getDiseasesFromDocument(Document doc){
        String diseaseName = new String();
        String diseaseDescription = new String();
        Hashtable diseaseHashtable = new Hashtable();
        if (doc != null) {
             NodeList diseaseNodeList = doc.getElementsByTagName("Disease");
             if (diseaseNodeList != null) {
                 for(int i=0;i<diseaseNodeList.getLength();i++){
View Full Code Here

     *Gets regions from an overlay document
     *@param doc the document from which the overlayRegions should be taken
     *@return vector with overlayRegions
     */
    public Hashtable getOverlayRegionsFromDocument(Document doc) {
        String x, y;
        Vector xvector = new Vector();
        Vector yvector = new Vector();
        Vector overlayRegionVector = new Vector();
        Vector returnVector = new Vector();
        Vector pointVector = new Vector();
        Vector neighbourVector = new Vector();
        String topNeighbour = new String();
        String bottomNeighbour = new String();
        String rightNeighbour = new String();
        String leftNeighbour = new String();
        if (doc != null) {
            //get root element named overlayRegions
            NodeList overlayRegionsList = doc.getElementsByTagName("Overlay");
            if (overlayRegionsList != null) {
                Node overlayRegions = overlayRegionsList.item(0);
                NodeList overlayRegionList = overlayRegions.getChildNodes();
                //get all nodes that are childnodes of overlayRegions and named "overlayRegion"
                //and store them in vector
                for (int i = 0; i < overlayRegionList.getLength(); i++) {
                    if (overlayRegionList.item(i).getNodeName().equals("OverlayRegion")) {
                        overlayRegionVector.add(overlayRegionList.item(i));
                    }
                }
                for (int e = 0; e < overlayRegionVector.size(); e++) {
                    Node overlayRegion = (Node) overlayRegionVector.elementAt(e);
                    NodeList overlayRegionPropertyList = overlayRegion.getChildNodes();
                    pointVector.clear();
                    String overlayRegionName = new String();
                    String overlayRegionTarget = new String();
                    String overlayRegionNumber = new String();
                    for (int r = 0; r < overlayRegionPropertyList.getLength(); r++) {
                        //add points into the point vector
                        if (overlayRegionPropertyList.item(r).getNodeName().equals("Point")) {
                            pointVector.add(overlayRegionPropertyList.item(r));
                        } else
                        //get name of overlayRegion
                            if (overlayRegionPropertyList.item(r).getNodeName().equals("Name")) {
                                if (hasNodeValue(overlayRegionPropertyList.item(r))) {
                                    overlayRegionName = getNodeValue(overlayRegionPropertyList.item(r));
                                } else {
                                    overlayRegionName = RecordStrings.NO_ENTRY;
                                }
                            } else
                            //get destination of overlayRegion
                                if (overlayRegionPropertyList.item(r).getNodeName().equals("TargetImage")) {
                                    if (hasNodeValue(overlayRegionPropertyList.item(r))) {
                                        overlayRegionTarget = getNodeValue(overlayRegionPropertyList.item(r));
                                    } else {
                                        overlayRegionTarget = RecordStrings.NO_ENTRY;
                                    }
                                } else if (overlayRegionPropertyList.item(r).getNodeName().equals("Number")) {
                                    if (hasNodeValue(overlayRegionPropertyList.item(r))) {
                                        overlayRegionNumber = getNodeValue(overlayRegionPropertyList.item(r));
                                    } else {
                                        overlayRegionNumber = RecordStrings.NO_ENTRY;
                                    }
                                } else if (overlayRegionPropertyList.item(r).getNodeName().equals("Neighbours")) {
                                    neighbourVector.add(overlayRegionPropertyList.item(r));
                                    for (int we = 0; we < neighbourVector.size(); we++) {
                                        Node neighbourNode = (Node) neighbourVector.elementAt(we);
                                        NodeList neighbourNodeList = neighbourNode.getChildNodes();
                                        for (int uu = 0; uu < neighbourNodeList.getLength(); uu++) {
                                            Node neighboursAroundNode = neighbourNodeList.item(uu);
                                            if (neighboursAroundNode.getNodeName().equals("Top")) {
                                                if (hasNodeValue(neighboursAroundNode)) {
                                                    topNeighbour = getNodeValue(neighbourNodeList.item(uu));
                                                } else {
                                                    topNeighbour = RecordStrings.NO_ENTRY;
                                                }
                                            } else if (neighboursAroundNode.getNodeName().equals("Bottom")) {
                                                if (hasNodeValue(neighboursAroundNode)) {
                                                    bottomNeighbour = getNodeValue(neighbourNodeList.item(uu));
                                                } else {
                                                    bottomNeighbour = RecordStrings.NO_ENTRY;
                                                }
                                            } else if (neighboursAroundNode.getNodeName().equals("Right")) {
                                                if (hasNodeValue(neighboursAroundNode)) {
                                                    rightNeighbour = getNodeValue(neighbourNodeList.item(uu));
                                                } else {
                                                    rightNeighbour = RecordStrings.NO_ENTRY;
                                                }
                                            } else if (neighboursAroundNode.getNodeName().equals("Left")) {
                                                if (hasNodeValue(neighboursAroundNode)) {
                                                    leftNeighbour = getNodeValue(neighbourNodeList.item(uu));
                                                } else {
                                                    leftNeighbour = RecordStrings.NO_ENTRY;
                                                }
                                            }
                                        }
                                    }
                                }
                    }
                    xvector.clear();
                    yvector.clear();
                    //points of the overlayRegion are examined
                    for (int t = 0; t < pointVector.size(); t++) {
                        Node point = (Node) pointVector.elementAt(t);
                        NodeList coordList = point.getChildNodes();
                        //coordinates of the points are examined
                        int xCoordCounter = 0;
                        int yCoordCounter = 0;
                        for (int u = 0; u < coordList.getLength(); u++) {
                            //coordinates are taken first in a vector ....
                            if (coordList.item(u).getNodeName().equals("X")) {
                                if (hasNodeValue(coordList.item(u))) {
                                    xvector.add(getNodeValue(coordList.item(u)));
                                    xCoordCounter++;
                                } else {
                                    System.out.println("Warning! Missing x-Coordinate in overlay document!");
                                }
                            } else if (coordList.item(u).getNodeName().equals("Y")) {
                                if (hasNodeValue(coordList.item(u))) {
                                    yvector.add(getNodeValue(coordList.item(u)));
                                    yCoordCounter++;
                                } else {
                                    System.out.println("Warning! Missing y-Coordinate in overlay document!");
                                }
                            }
                        }
                    }
                    //...and then into an array
                    int[] xarray = new int[xvector.size()];
                    int[] yarray = new int[yvector.size()];
                    for (int p = 0; p < xvector.size(); p++) {
                        try {
                            xarray[p] = Integer.parseInt((String) xvector.elementAt(p));
                            yarray[p] = Integer.parseInt((String) yvector.elementAt(p));
                        } catch (Exception exception) {
                        }
                    }
                    //new imageoverlayRegions are created with the specific properties
                    OverlayRegion imageMapOverlayRegion = new OverlayRegion(xarray, yarray, xvector.size());
                    imageMapOverlayRegion.set(OverlayRegion.NAME, overlayRegionName);
                    imageMapOverlayRegion.set(OverlayRegion.TARGET, overlayRegionTarget);
                    imageMapOverlayRegion.set(OverlayRegion.NUMBER, overlayRegionNumber);
                    imageMapOverlayRegion.set(OverlayRegion.RIGHT_NEIGHBOUR, rightNeighbour);
                    imageMapOverlayRegion.set(OverlayRegion.LEFT_NEIGHBOUR, leftNeighbour);
                    imageMapOverlayRegion.set(OverlayRegion.TOP_NEIGHBOUR, topNeighbour);
                    imageMapOverlayRegion.set(OverlayRegion.BOTTOM_NEIGHBOUR, bottomNeighbour);
                    returnVector.add(imageMapOverlayRegion);
                }
                Hashtable returnHashtable = new Hashtable(returnVector.size());
                for (int z = 0; z < returnVector.size(); z++) {
                    String overlayRegionName = ((OverlayRegion) returnVector.elementAt(z)).getName();
                    returnHashtable.put(overlayRegionName, (OverlayRegion) returnVector.elementAt(z));
                }
                return returnHashtable;
            } else {
                System.out.println("Overlay besitzt nicht die richtige Struktur. Root-Element <overlay> fehlt.");
View Full Code Here

                    setCurrentImage(getImageFromDocument(getCurrentDocument()));
                }
                setCurrentOverlayRegions(getOverlayRegionsFromDocument(getCurrentDocument()));
                getView().getImagePanel().setImage(getCurrentImage());
                getView().getImagePanel().updateImage();
                String description = getDescriptionFromDocument(getCurrentDocument());
                getView().getImageInfoTextArea().setText(description);
                //this.setCurrentObject(null);
            } else {
                throw new Exception("Could not change file. The file was not found in the hashtable.");
            }
View Full Code Here

            }
        }
        if (nodeToChange != null) {
            NodeList overlayRegionPropertyList = nodeToChange.getChildNodes();
            for (int r = 0; r < overlayRegionPropertyList.getLength(); r++) {
                String overlayRegionName;
                String overlayRegionTarget;
                if (overlayRegionPropertyList.item(r).getNodeName().equals("Name")) {
                    setNodeValue(overlayRegionPropertyList.item(r), newName);
                } else if (overlayRegionPropertyList.item(r).getNodeName().equals("TargetImage")) {
                    setNodeValue(overlayRegionPropertyList.item(r), newTargetImage);
                }
View Full Code Here

     *Insert new document in Hashtable
     *@param doc the document whose name should be added to the image hashtable
     */
    public void updateImageHashtable(Document doc) {
        //getting name from document
        String imageName = getNameFromDocument(doc);
        this.imageHashtable.put(imageName, doc);
    }
View Full Code Here

    /**
     *Updates ComboBoxes when inserting new document. The name of the document will be added to the comboboxes
     *@param doc the document whose name should be added to comboboxes....Deprecated???
     */
    public void updateComboBoxes(Document doc) {
        String imageName = getNameFromDocument(doc);
        //getView().updateComboBoxes(imageName);
    }
View Full Code Here

     *Saves a xml file represented by a xml document. The name of the xml file is the name of the document.
     *@param doc the DOM structure to save as an xml file
     */
    public void saveOverlayToXMLFile(Document doc) {
        try {
            String fileName = getNameFromDocument(doc);
            System.out.println("Speicher der Datei " + fileName);
            FileOutputStream out = new FileOutputStream(RecordModel.RelativeXMLImagesDirectoryName + fileName + ".xml");
            XMLSerializer serializer = new XMLSerializer(out, null);
            try {
                serializer.serialize(doc);
View Full Code Here

TOP

Related Classes of cybop.basic.String

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.