Commit 8acdc0f1 authored by Matti Pulkkinen's avatar Matti Pulkkinen
Browse files

added capability query loop

parent fba46d50
......@@ -15,6 +15,11 @@ import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
// Kartankatseluohjelman graafinen käyttöliittymä
public class MapDialog extends JFrame {
......@@ -129,8 +134,20 @@ public class MapDialog extends JFrame {
// ALLA OLEVIEN KOLMEN TESTIRIVIN TILALLE SILMUKKA JOKA LISÄÄ
// KÄYTTÖLIITTYMÄÄN KAIKKIEN XML-DATASTA HAETTUJEN KERROSTEN
// VALINTALAATIKOT MALLIN MUKAAN
this.leftPanel.add(new LayerCheckBox("bluemarble", "Maapallo", true));
this.leftPanel.add(new LayerCheckBox("cities", "Kaupungit", false));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse(new URL("http://demo.mapserver.org/cgi-bin/"
+ "wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities").openStream());
Element mapservice = document.getDocumentElement();
NodeList capabilities = mapservice.getElementsByTagName("Layer");
for (int i = 0; i < capabilities.getLength(); i++) {
if (capabilities.item(i) instanceof Element) {
Element layer = (Element) capabilities.item(i);
String name = layer.getElementsByTagName("Name").item(0).getTextContent();
String title = layer.getElementsByTagName("Title").item(0).getTextContent();
this.leftPanel.add(new LayerCheckBox(name, title, false));
}
}
this.leftPanel.add(this.refreshB);
this.leftPanel.add(Box.createVerticalStrut(20));
......
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