?? vpfspecialist.java
字號:
// **********************************************************************// // <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/corba/com/bbn/openmap/layer/specialist/vpf/VPFSpecialist.java,v $// $RCSfile: VPFSpecialist.java,v $// $Revision: 1.4.2.1 $// $Date: 2004/10/14 18:26:33 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.specialist.vpf;import com.bbn.openmap.CSpecialist.*;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.MoreMath;import com.bbn.openmap.layer.specialist.*;import com.bbn.openmap.layer.util.http.HttpServer;import com.bbn.openmap.layer.vpf.*;import com.bbn.openmap.util.Debug;import java.io.File;import java.util.Hashtable;import java.util.StringTokenizer;/** * Implement the Specialist interface so that we can serve graphics to * OpenMap via CORBA. * <p> * * In the properties file for OpenMap, you can set parameters that * determine what coverages and features are sent back to the * CSpecLayer. Specifically, these parameters are listed in the * staticArgs property as (key, value) pairs. For political boundaries * and coastlines, for instance: * <p> * * staticArgs=(coverageType, bnd)(featureTypes, edge area) (edge, * polbndl coastl) (area, polbnda) (lineColor, FFFF0000) (fillColor, * FFAAAA66) (draw, edge area) * * <p> * * The (draw, edge area) pairing should be used if the user won't have * access to the palette for the CSpecLayer. The palette controls * whether certain feature types are drawn, and by default, areas are * not and need to be turned on in the palette. If you set the draw * key, the feature types listed will be forced to be returned if they * exist. The keys used here should match the featureTypes list, or * not, depending on what you want. * * <p> * * The contents of this staticArgs line should reflect the properties * that can be set via the VPFLayer properties. See those javadocs for * more details. */public class VPFSpecialist extends Specialist { private String dcwpath; private Hashtable checkboxes = new Hashtable(); private LibrarySelectionTable lst; private Hashtable comphash = new Hashtable(); public static final String prefix = "VPFSpec"; public static final float altCovScale = 30000000f; /** * default constructor is called when we're loading the class * directly into OpenMap. */ public VPFSpecialist() { super("VPFSpecialist", (short) 2, true); //startHttpServer(0); initDcwFiles(); } public VPFSpecialist(LibrarySelectionTable libtab) { super("VPFSpecialist", (short) 2, true); //startHttpServer(0); lst = libtab; } public VPFSpecialist(File dcwDataPath) { super("VPFSpecialist", (short) 2, true); //startHttpServer(0); dcwpath = dcwDataPath.getAbsolutePath(); initDcwFiles(); } public VPFSpecialist(String name) { super(name, (short) 2, true); } public java.util.Properties processTokens(String args, StringBuffer cov, StringBuffer altcov, boolean usealt) { java.util.StringTokenizer tok = new java.util.StringTokenizer(args, ")"); String token = null; java.util.Properties props = new java.util.Properties(); // First see if there are parens, otherwise just straight // coverage types while (true) { try { token = tok.nextToken(); token = token.trim(); if (token.startsWith("(")) { // Get the name // Remove the open paren token = token.substring(1, token.length()); int comma = token.indexOf(","); String key = token.substring(0, comma); String value = token.substring(comma + 1, token.length()); // Remove whitespace key = key.trim(); value = value.trim(); // Need to set cov or altcov or else props later if (key.equals("coverageType")) { // Coverage types require special handling, // since // coverage types get passed back to drawTile // routine // Check to see if one coverage or two int spacedelim = value.indexOf(" "); if (spacedelim == -1) { // One coverage cov.delete(0, cov.length()); cov = cov.append(value); altcov = altcov.delete(0, altcov.length()); altcov.append(""); } else { // Two coverages cov.delete(0, cov.length()); cov = cov.append(value.substring(0, spacedelim)); altcov = altcov.delete(0, altcov.length()); altcov = altcov.append(value.substring(spacedelim + 1, value.length())); } // Set the property props.setProperty(prefix + "." + key, value); } else { // Not a coverage type, so don't have to // fool with cov and altcov // Need to check for alt key prefix // !! Assumes coverageType has been processed // first // If there is an alternate coverage and it's // required, use it if (usealt == true && !altcov.equals("")) { if (key.startsWith("alt")) { key = key.substring(3, key.length()); // 3 is // "alt", // remove // it props.setProperty(prefix + "." + key, value); } else { // Need alt, not an alt prefix continue; } } else { // Alt not necessary if (key.startsWith("alt")) { // alt key, don't want it continue; } else { props.setProperty(prefix + "." + key, value); } } } } else { // This case is for old style static args, when // they // were not (key,value) format // Find out if there is an alternate coverage int spacedelim = token.indexOf(" "); if (spacedelim == -1) { // No alternate coverage cov.delete(0, cov.length()); cov = cov.append(token); altcov = altcov.delete(0, altcov.length()); altcov.append(""); } else { // Yes, alternate coverage cov.delete(0, cov.length()); cov = cov.append(token.substring(0, spacedelim)); cov = altcov.delete(0, altcov.length()); altcov = altcov.append(token.substring(spacedelim + 1, token.length())); } } } catch (java.util.NoSuchElementException nee) { break; } } return props; } public UGraphic[] fillRectangle( com.bbn.openmap.CSpecialist.CProjection p, com.bbn.openmap.CSpecialist.LLPoint ll1, com.bbn.openmap.CSpecialist.LLPoint ll2, java.lang.String staticArgs, org.omg.CORBA.StringHolder dynamicArgs, com.bbn.openmap.CSpecialist.GraphicChange notifyOnChange, String uniqueID) { try { LatLonPoint newll1 = new LatLonPoint(ll1.lat, ll1.lon); LatLonPoint newll2 = new LatLonPoint(ll2.lat, ll2.lon); /* * If the we are zoomed out so that we _might_ have the * entire world on the screen, then let's check to see if * east and west are approximately equal. If they are, * change them to -180 and +180 so that we get the entire * world without having trouble with the floating point * rounding errors that allow west to be slightly less * than east (by .00001) and confuse our clipping routines * into thinking that there should be nothing on the * screen since nothing falls in that .00001 slice of the * world. */ if ((p.scale > 100000000) && MoreMath.approximately_equal(ll1.lon, ll2.lon, .01)) { newll1.setLongitude(-180.0f); newll2.setLongitude(180.0f); } forgetComps(uniqueID); Debug.message("vpfspecialist", "fillRectangle.. " + staticArgs); Hashtable dynArgs = parseDynamicArgs(dynamicArgs.value); VPFSpecialistGraphicWarehouse warehouse = new VPFSpecialistGraphicWarehouse(); CheckButton buttons[] = null; SCheckBox s = (SCheckBox) checkboxes.get(uniqueID); if (s == null) { buttons = new CheckButton[3]; Debug.message("vpfspecialist", "default buttons"); buttons[0] = new CheckButton("Edges", false); buttons[1] = new CheckButton("Text", false); buttons[2] = new CheckButton("Area", false); } else { Debug.message("vpfspecialist", "palette buttons"); buttons = s.buttons(); } boolean showEdges = (getHashedValueAsBoolean(dynArgs, DynArgEdges) || buttons[0].checked); warehouse.setEdgeFeatures(showEdges);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -