?? vpfspecialist.java
字號:
boolean showText = (getHashedValueAsBoolean(dynArgs, DynArgText) || buttons[1].checked); warehouse.setTextFeatures(showText); boolean showAreas = (getHashedValueAsBoolean(dynArgs, DynArgArea) || buttons[2].checked); warehouse.setAreaFeatures(showAreas); // Changeable String objects for processTokens call StringBuffer retcov = new StringBuffer(); StringBuffer retaltcov = new StringBuffer(""); // Now need to know in advance if we are using an // alternate coverage // for arguments boolean usealt; if (p.scale >= altCovScale) usealt = true; else usealt = false; java.util.Properties props = processTokens(staticArgs, retcov, retaltcov, usealt); if (Debug.debugging("vpfspecialist")) { Debug.output("VPFSpecialist: with prefix " + prefix + ", properties: " + props); } // After processing properties, make sure they're // available warehouse.setProperties(prefix, props); // Trim whitespace on coverages String cov = retcov.toString().trim(); String altcov = retaltcov.toString().trim(); // If got nothing back, null this object (hack to convert // StringBuffer to String if (altcov.equals("")) { Debug.message("vpfspecialist", "Altcov = null"); altcov = null; } //warehouse.showPointFeatures(false); // tokenize the staticArgs. should be coverage type // followed by alternate coverage type. // Check both dynamic args and palette values when // deciding what to draw. lst.drawTile(p.scale, p.width, p.height, ((altcov != null) && (p.scale >= altCovScale)) ? altcov : cov, warehouse, newll1, newll2); UGraphic[] retlist = warehouse.packGraphics(); if (Debug.debugging("vpfspecialist")) { Debug.output("retlist.size(): " + retlist.length); } // DFD - I've commented the comphash method because I // can't figure out where it is used. In the // MATT Specialists, we processed mouse events on // particular objects, and allowed things to happen on the // server side. For this specialist, the receiveGesture // method doesn't do anything, and we risk keeping all // these objects around if the client dies before coming // back to clean up. // comphash.put(uniqueID, warehouse.getComps()); warehouse = null; // clean up. Debug.message("vpfspecialist", "returning from fillRectangle"); return retlist; } catch (Throwable t) { t.printStackTrace(); return new UGraphic[0]; } } private synchronized void forgetComps(String uniqueID) { Comp[] oldcomps = (Comp[]) comphash.remove(uniqueID); if (oldcomps != null) { Debug.message("vpfspecialist", "Releasing comps"); // Not sure how to do this in POA, but shouldn't be // a problem because we aren't adding the comp objects to // the graphics in the warehouse either. // for (int i = 0; i < oldcomps.length; i++) { // if (boa != null) // boa.deactivate_obj(oldcomps[i]); // } } } public void receiveGesture(MouseEvent gesture, String uniqueID) { // System.out.println("Gesture away..."); // addInfoText("Some text string"); } public void makePalette(WidgetChange notifyOnChange, String staticArgs, org.omg.CORBA.StringHolder dynamicArgs, String uniqueID) { clearPalette(); CheckButton buttons[] = new CheckButton[3]; buttons[0] = new CheckButton("Edges", false); buttons[1] = new CheckButton("Text", false); buttons[2] = new CheckButton("Area", false); SCheckBox cb = new UsefulCheckbox("Feature Types:", buttons); checkboxes.put(uniqueID, cb); addPalette(cb.widget()); } public void parseArgs(String[] args) { for (int i = 0; i < args.length; i++) { if (args[i].equalsIgnoreCase("-dcwpath") || args[i].equalsIgnoreCase("-datapath")) { // dcwpath = new File(args[++i]); dcwpath = args[++i]; } if (args[i].equalsIgnoreCase("-verbose")) { Debug.put("vpfspecialist"); } } super.parseArgs(args); initDcwFiles(); } public void initDcwFiles() { if (dcwpath == null) { dcwpath = "/usr/local/matt/data/dcw"; } try { // Parse the string to get all the possible paths... String[] paths = parsePaths(dcwpath); if (paths != null) { lst = new LibrarySelectionTable(); for (int i = 0; i < paths.length; i++) { System.out.println("VPFSpecialist: adding " + paths[i] + " to server"); lst.addDataPath(paths[i]); } } } catch (com.bbn.openmap.io.FormatException f) { throw new java.lang.IllegalArgumentException(f.getMessage()); } } /** * Take a string that represents a bunch of path names separated * by ";", and return an array of Strings. */ public String[] parsePaths(String path) { String[] ret = null; String tok = ";"; if (path != null) { if (Debug.debugging("vpfspecialist")) { System.out.println("VPFSpecialist: parsing path string: " + path); } try { StringTokenizer token = new StringTokenizer(path, tok); int numPaths = token.countTokens(); ret = new String[numPaths]; for (int i = 0; i < numPaths; i++) { ret[i] = token.nextToken(); } return ret; } catch (java.util.NoSuchElementException e) { e.printStackTrace(); } } return ret; } public void printHelp() { System.err.println("usage: java <specialist> -ior <file> -datapath <path1;path2;path3>"); } public void signOff(String uniqueID) { forgetComps(uniqueID); if (Debug.debugging("vpfspecialist")) { Debug.output("Client |" + uniqueID + "| going away..."); } } /** * Start an HttpServer on a port to listen for table requests * * @param port the port to bind. 0 picks an arbitrary port * @return the HttpServer that got constructed, <code>null</code> * if there was a problem. */ public static HttpServer startHttpServer(int port) { try { HttpServer server = new HttpServer(port, true); server.addHttpRequestListener(new TableListener()); return server; } catch (java.io.IOException e) { Debug.output("Unable to start http server:"); return null; } } public final static String DynArgEdges = "edges"; public final static String DynArgText = "text"; public final static String DynArgArea = "area"; /** * Parses dynamic args passed by specialist client. A * <code>Hashtable</code> is returned as a unified holder of all * dynamic arguments. */ public static Hashtable parseDynamicArgs(String args) { Hashtable dynArgs = new Hashtable(); if (args != null) { String lowerArgs = args.toLowerCase(); dynArgs.put(DynArgEdges, new Boolean(lowerArgs.indexOf(DynArgEdges) != -1)); dynArgs.put(DynArgText, new Boolean(lowerArgs.indexOf(DynArgText) != -1)); dynArgs.put(DynArgArea, new Boolean(lowerArgs.indexOf(DynArgArea) != -1)); } return dynArgs; } /** * If <code>arg</code> maps to a <code>Boolean</code> in the * Hashtable, that value is returned, <code>false</code> * otherwise. * * @param dynArgs the Hashtable to look in * @param arg the argument to return */ public static boolean getHashedValueAsBoolean(Hashtable dynArgs, String arg) { Object obj = dynArgs.get(arg); if (obj == null) { return false; } else if (obj instanceof Boolean) { return ((Boolean) obj).booleanValue(); } else { return false; } } public static void main(String[] args) { Debug.init(System.getProperties()); Debug.message("vpfspecialist", "VPFSpecialist starting up"); int port = 0; startHttpServer(port); // Create the specialist server VPFSpecialist srv = new VPFSpecialist("VPFSpecialist"); srv.start(args); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -