Commit 526ca59c authored by Simo Vuorinen's avatar Simo Vuorinen
Browse files

Update Hajo 2

parent 921b4d0f
// Kartankatseluohjelman graafinen käyttäliittymä
import javax.swing.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.Document;
import org.w3c.dom.*;
import java.awt.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.net.*;
import org.xml.sax.*;
import java.net.*;
import javax.xml.parsers.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;
public class MapDialog extends JFrame {
// Käyttäliittymän komponentit
......@@ -59,22 +52,36 @@ import java.net.*;
// TODO:
// ALLA OLEVIEN KOLMEN TESTIRIVIN TILALLE SILMUKKA JOKA LISää KäYTTäLIITTYMääN
// KAIKKIEN XML-DATASTA HAETTUJEN KERROSTEN VALINTALAATIKOT MALLIN MUKAAN
String url = "http://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities";
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = (org.w3c.dom.Document)db.parse("http://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities");
Document doc = db.parse(url);
doc.getDocumentElement().normalize();
NodeList nodList = doc.getElementsByTagName("title");
System.out.print(nodList.getLength());
NodeList nodList = doc.getElementsByTagName("Layer");
for (int i = 0; i < nodList.getLength(); i++) {
Node nNode = nodList.item(i);
System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() != Node.ELEMENT_NODE)
continue;
Element e=(Element) nNode;
NodeList titleList = e.getElementsByTagName("Title");
Element titleElem = (Element) titleList.item(0);
Element f=(Element) nNode;
NodeList nameList = e.getElementsByTagName("Name");
Element nameElem = (Element) nameList.item(0);
Node nameNode = nameElem.getChildNodes().item(0);
Node titleNode = titleElem.getChildNodes().item(0);
System.out.println(titleNode.getNodeValue());
System.out.println(nameNode.getNodeValue());
}
}
catch (Exception e) {}
leftPanel.add(new LayerCheckBox("bluemarble", "Maapallo", true));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment