/* Copyright (C) 2001, 2007 United States Government as represented by
the Administrator of the National Aeronautics and Space Administration.
All Rights Reserved.
*/
package gov.nasa.worldwind.servers.installers;
import gov.nasa.worldwind.formats.rpf.*;
import gov.nasa.worldwind.servers.tools.*;
import org.w3c.dom.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.tree.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import javax.xml.xpath.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.atomic.*;
/**
* @author brownrigg
* @version $Id: RPFInstaller.java 8674 2009-01-30 20:33:06Z garakl $
*/
public class RPFInstaller extends javax.swing.JFrame
{
/**
* Creates new form RPFInstaller
*/
public RPFInstaller()
{
initComponents();
}
//
// Verifies that a WMS is installed on this system where we expect it to be.
// The convention for TerraRaptor is that it resides in the same directory as
// this installer.
//
private void verifyWmsLocation()
{
try
{
URL myUrl = RPFInstaller.class.getClassLoader().getResource("WEB-INF");
this.wmsDir = null;
if(null != myUrl)
this.wmsDir = new File(myUrl.toURI());
else
{
// no luck, let's try default WMS locations
String[] wms_install_dirs = {
// check current directory
new File(".").getCanonicalPath() + File.separator + "WEB-INF",
// default install on Mac OS X
"/Application/xampp/wms/WEB-INF",
// default install on Linux
"/opt/lampp/wms/WEB-INF",
// default install on Windows
"C:\\xampp\\wms\\WEB-INF"
};
for(String path:wms_install_dirs)
{
File dir = new File(path);
if(null != dir && dir.exists() && dir.isDirectory())
{
this.wmsDir = dir;
break;
}
}
}
if (this.wmsDir == null)
throw new Exception("Could not locate WMS's WEB-INF directory");
this.wmsConfigFile = new File(wmsDir.getAbsolutePath() + File.separator + "config.xml");
if (!this.wmsConfigFile.exists())
throw new Exception("Could not find WMS's config.xml as expected");
if (!wmsConfigFile.canWrite())
throw new Exception(
"WMS installation found; user does not have privileges to modify its configuration");
loadWMSConfigDoc();
showWMSLayers();
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(this, ex.getMessage(), "WMS Probe Error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
//
// Loads the WMS's config.xml file into an XML Document.
//
private void loadWMSConfigDoc() throws Exception
{
DocumentBuilderFactory docfac = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = docfac.newDocumentBuilder();
this.wmsConfigDoc = builder.parse(wmsConfigFile);
}
private void showWMSLayers()
{
try
{
numWmsGroups = 0;
numWmsLayers = 0;
groupNames.removeAllElements();
DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode();
XPathFactory xpfac = XPathFactory.newInstance();
XPath xpath = xpfac.newXPath();
Node rootNode = (Node) xpath.evaluate(WMSROOT, wmsConfigDoc, XPathConstants.NODE);
NodeList nlist = (NodeList) xpath.evaluate(MAPSOURCE, rootNode, XPathConstants.NODESET);
populateWmsTree(xpath, nlist, treeRoot);
wmsLayersTree = new JTree(treeRoot);
wmsLayersTree.setRootVisible(false);
wmsLayersTree.setShowsRootHandles(true);
wmsLayersTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(null);
renderer.setLeafIcon(null);
wmsLayersTree.setCellRenderer(renderer);
preExpandWmsTree(new TreePath(treeRoot));
wmsLayersPanel.getViewport().setView(wmsLayersTree);
wmsLayersPanel.validate();
// fix up the JLabels...
numWmsGroupsLbl.setText(Integer.toString(numWmsGroups));
numWmsLayersLbl.setText(Integer.toString(numWmsLayers));
// update the Group-combobox to reflect available groupnames...
updateGroupsCombobox();
}
catch (Exception ex)
{
//??????????
}
}
private void populateWmsTree(XPath xpath, NodeList nlist, DefaultMutableTreeNode treeBranch) throws Exception
{
for (int i = 0; i < nlist.getLength(); i++)
{
Node docNode = nlist.item(i);
WmsLayerNode wmsLayer = new WmsLayerNode();
wmsLayer.node = docNode;
DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(wmsLayer);
String label = xpath.evaluate(MAPSOURCE_NAME, docNode);
if ("".equals(label))
{
label = xpath.evaluate(MAPSOURCE_TITLE, docNode);
++numWmsGroups;
groupNames.add(label);
wmsLayer.isLeaf = false;
}
else
{
++numWmsLayers;
wmsLayer.isLeaf = true;
}
wmsLayer.text = label;
treeBranch.add(treeNode);
// walk any children...
NodeList childList = (NodeList) xpath.evaluate(MAPSOURCE, docNode, XPathConstants.NODESET);
populateWmsTree(xpath, childList, treeNode);
}
}
private void preExpandWmsTree(TreePath p)
{
wmsLayersTree.expandPath(p);
DefaultMutableTreeNode currNode = (DefaultMutableTreeNode) p.getLastPathComponent();
int numChildren = currNode.getChildCount();
for (int i = 0; i < numChildren; i++)
{
TreePath newPath = p.pathByAddingChild(currNode.getChildAt(i));
preExpandWmsTree(newPath);
}
}
private void updateGroupsCombobox()
{
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement(COMBO_PROMPT);
Iterator<String> iter = groupNames.iterator();
while (iter.hasNext())
{
model.addElement(iter.next());
}
groupsCombo.setModel(model);
}
private void testRpfRoot(File rootDir)
{
this.rpfSeries = new HashSet<Object>(10);
final RPFCrawler crawler = new RPFCrawler();
final File rpfDirTmp = rootDir;
// quick&dirty make a progress dialog...
final JDialog progress = new JDialog(this, "RPF Scan", true);
JPanel dialogPanel = new JPanel();
dialogPanel.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
p.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createBevelBorder(BevelBorder.LOWERED),
BorderFactory.createEmptyBorder(5, 5, 5, 5)));
JLabel l = new JLabel("Searching for RPF files");
l.setAlignmentX(Component.CENTER_ALIGNMENT);
p.add(l);
p.add(Box.createRigidArea(new Dimension(0, 10)));
JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZ
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
worldwind JAVA (406个子文件)
startWMS.bat 232B
stylesheet.css 1KB
jogl.dll 308KB
jogl_cg.dll 112KB
gluegen-rt.dll 20KB
jogl_awt.dll 20KB
RPFInstaller.form 19KB
inherit.gif 57B
index-7.html 85KB
RPFInstaller.html 81KB
ReadWriteFormat.html 50KB
WorldWindTiledLayer.html 49KB
WMSServiceException.html 49KB
MapSource.html 48KB
ScankortImageryPreprocessor.html 47KB
BlueMarblePreprocessor.html 45KB
NAIPPyramidBuilder.html 45KB
LandSatPreprocessor.html 45KB
ReadableFormat.html 44KB
ElevationSrtm3V4.html 44KB
BILGenerator.html 43KB
ElevationSrtm3.html 43KB
CompoundElevationsGenerator.html 41KB
BlueMarbleNG500MGenerator.html 41KB
ScankortElevationsLayer.html 41KB
DTEDGenerator.html 41KB
ElevationUSGSNED.html 41KB
ScankortGenerator.html 41KB
NAIPGenerator.html 40KB
RPFGenerator.html 40KB
EsatGenerator.html 40KB
ElevationSrtm30.html 40KB
CompoundImageryGenerator.html 40KB
index-19.html 37KB
overview-tree.html 35KB
ImageFormatter.html 35KB
MapSource.html 35KB
index-23.html 35KB
constant-values.html 35KB
WMSDataDiscoveryThread.html 33KB
WMSGetMapRequest.html 33KB
WMSGetMapRequest.html 32KB
ImageFormatter.html 31KB
ReadWriteFormat.html 30KB
BILImageFormatter.html 29KB
WorldWindTiledLayerMapSource.html 28KB
ReadableFormat.html 28KB
BasicMapRegistry.html 28KB
XMLWriter.html 27KB
WaveletCodec.html 27KB
index-9.html 26KB
WorldWindTiledLayer.NonComposableServiceInstance.html 26KB
MapGenerator.ServiceInstance.html 26KB
index-4.html 26KB
WorldWindTiledLayer.TileCacheMosaicer.html 24KB
WMSRequest.html 24KB
WorldWindTiledLayer.BasicServiceInstance.html 24KB
Option.Translate.html 24KB
index-3.html 24KB
ImageTypes.html 23KB
GDALUtils.html 23KB
WMSHttpServletResponse.html 23KB
MapGenerator.html 23KB
DataConfigurationMapSource.html 23KB
TempFile.html 22KB
WaveletCodec.ReconstructionThread.html 22KB
XMLWriter.html 22KB
WMSServiceThread.html 22KB
MapGenerator.html 22KB
Option.Warp.Resampling.html 21KB
WMSGetImageryListRequest.html 21KB
DTEDGenerator.DTEDServiceInstance.html 21KB
SRS.html 21KB
index-18.html 21KB
index-2.html 21KB
BILGenerator.TiledElevationMosaicer.html 20KB
Option.html 20KB
Configuration.html 20KB
ElevationUSGSNED.ElevationUSGSNEDServiceInstance.html 20KB
ElevationSrtm3V4.ElevationSrtmServiceInstance.html 20KB
ElevationSrtm30.ElevationSrtmServiceInstance.html 20KB
ElevationSrtm3.ElevationSrtmServiceInstance.html 20KB
WMSHttpServletRequest.html 20KB
NAIP.QuarterQuadrangle.html 19KB
NonComposableImageFormatter.html 19KB
ScankortGenerator.ScankortServiceInstance.html 19KB
WMSGetCapabilitiesRequest.html 19KB
RPFGenerator.RPFServiceInstance.html 19KB
NAIPGenerator.NAIPServiceInstance.html 19KB
WaveletEncodeRPFs.html 19KB
index-13.html 19KB
MapGenerator.ServiceInstance.html 19KB
index-6.html 19KB
Option.Warp.html 18KB
BlueMarbleNG500MGenerator.BMNGServiceInstance.html 18KB
WaveletCodec.EncodingType.html 18KB
UTMCoords.html 18KB
EsatGenerator.EsatServiceInstance.html 18KB
NAIP.html 18KB
index-5.html 18KB
共 406 条
- 1
- 2
- 3
- 4
- 5
资源评论
- wl8906272012-07-29java版本不错,C#版本也可以
- wendylau2014-12-23好久没用了,java版的就是少。难得
- andyking_cn2014-02-25c#版本现在没有了,只有java版本了,这个是开源版本的
zbevimage
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功