⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtedcoveragespecialist.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    protected String[] initPathsFromProperties(String rawPaths) {        String[] retPaths = null;        if (rawPaths != null) {            try {                StringTokenizer token = new StringTokenizer(rawPaths, File.pathSeparator);                int numPaths = token.countTokens();                retPaths = new String[numPaths];                for (int i = 0; i < numPaths; i++) {                    retPaths[i] = token.nextToken();                }                return retPaths;            } catch (java.util.NoSuchElementException e) {                e.printStackTrace();            }        }        return retPaths;    }    /**     * Take a string, representing the hex values for a color, and     * convert it to a java Color.     *      * @param p properties.     * @param propName the name of the property.     * @param dfault the default color to use if the property value doesn't     *        work.     * @return the java Color.     */    protected Color parseColor(Properties p, String propName, Color dfault) {        String colorString = p.getProperty(propName);        if (colorString == null) {            return dfault;        } else {            try {                return parseColor(colorString);            } catch (NumberFormatException e) {                System.err.println("Unparseable number \"" + colorString                        + "\" in property \"" + propName + "\"");                return dfault;            }        }    }    /**     * Take a string, representing the hex values for a color, and     * convert it to a java Color.     *      * @param colorString the hex string value (RGB)     * @return the java Color.     */    protected Color parseColor(String colorString) throws NumberFormatException {        // parse color as hexidecimal RGB value        int colorSpec = Integer.parseInt(colorString, 16);        if (colorSpec < 0) {            return OMGraphic.clear;        } else {            return new Color(colorSpec);        }    }    public UGraphic[] fillRectangle(                                    com.bbn.openmap.CSpecialist.CProjection p,                                    com.bbn.openmap.CSpecialist.LLPoint ll1,                                    com.bbn.openmap.CSpecialist.LLPoint ll2,                                    String staticArgs,                                    org.omg.CORBA.StringHolder dynamicArgs,                                    com.bbn.openmap.CSpecialist.GraphicChange notifyOnChange,                                    String uniqueID) {        System.out.println("DTEDCoverageSpecialist.fillRectangle()");        Projection proj;        switch (p.kind) {        case CADRG.CADRGType:            proj = new CADRG(new LatLonPoint(p.center.lat, p.center.lon), p.scale, p.width, p.height);            break;        case Orthographic.OrthographicType:            proj = new Orthographic(new LatLonPoint(p.center.lat, p.center.lon), p.scale, p.width, p.height);            break;        case Gnomonic.GnomonicType:            proj = new Gnomonic(new LatLonPoint(p.center.lat, p.center.lon), p.scale, p.width, p.height);            break;        case Mercator.MercatorType:        default:            proj = new Mercator(new LatLonPoint(p.center.lat, p.center.lon), p.scale, p.width, p.height);            break;        }        OMGraphicList[] omGraphicLists = coverageManager.getCoverageRects(proj);        /////////////////////        // safe quit        if (omGraphicLists != null) {            UGraphic[] level0UGraphics = null;            UGraphic[] level1UGraphics = null;            UGraphic[] level2UGraphics = null;            for (int i = 0; i < omGraphicLists.length; i++) {                if (i == 0 && showDTEDLevel0) {                    level0UGraphics = createUGraphics(omGraphicLists[i]);                } else if (i == 1 && showDTEDLevel1) {                    level1UGraphics = createUGraphics(omGraphicLists[i]);                } else if (i == 2 && showDTEDLevel2) {                    level2UGraphics = createUGraphics(omGraphicLists[i]);                }            }            UGraphic[] ugraphics = new UGraphic[level0UGraphics.length                    + level1UGraphics.length + level2UGraphics.length];            int off = 0;            System.arraycopy(level0UGraphics,                    0,                    ugraphics,                    off,                    level0UGraphics.length);            off += level0UGraphics.length;            System.arraycopy(level1UGraphics,                    0,                    ugraphics,                    off,                    level1UGraphics.length);            off += level1UGraphics.length;            System.arraycopy(level2UGraphics,                    0,                    ugraphics,                    off,                    level2UGraphics.length);            System.out.println("DTEDCoverageSpecialist.fillRectangle(): returning "                    + ugraphics.length + " graphics");            return ugraphics;        } else {            System.out.println("DTEDCoverageSpecialist.fillRectangle(): finished with null graphics list");            return new UGraphic[0];        }    }    public void signOff(String uniqueID) {        System.out.println("DTEDCoverageSpecialist.signOff()");    }    protected UGraphic[] createUGraphics(OMGraphicList omgraphics) {        int len = omgraphics.size();        UGraphic[] ugraphics = new UGraphic[len];        ERectangle er;        OMGraphic gr;        OMRect omr;        int lineColor, fillColor;        EGraphic eg;        UGraphic ug;        for (int i = 0; i < len; i++) {            gr = omgraphics.getOMGraphicAt(i);            if (gr instanceof OMRect) {                omr = (OMRect) gr;                eg = SGraphic.createEGraphic();                lineColor = omr.getLineColor().getRGB();                eg.color = new EColor(null, (short) ((lineColor & 0xff0000) >> 8), (short) (lineColor & 0x00ff00), (short) ((lineColor & 0x0000ff) << 8));                if (fillRects) {                    fillColor = omr.getFillColor().getRGB();                    eg.fillColor = new EColor(null, (short) ((fillColor & 0xff0000) >> 8), (short) (fillColor & 0x00ff00), (short) ((fillColor & 0x0000ff) << 8));                }                er = new ERectangle(eg, nullP1, nullP1, new LLPoint(omr.getNorthLat(), omr.getWestLon()), new LLPoint(omr.getSouthLat(), omr.getEastLon()));                ug = new UGraphic();                ug.erect(er);                ugraphics[i] = ug;            } else {                // Deal with embeded OMGraphicList. HACK this is                // inefficient if there are a bunch of embedded                // OMGrahicLists...                UGraphic[] x_ugraphics = createUGraphics((OMGraphicList) gr);                len = x_ugraphics.length + ugraphics.length - 1;                UGraphic[] new_ugraphics = new UGraphic[len];                System.arraycopy(ugraphics, 0, new_ugraphics, 0, i);                System.arraycopy(x_ugraphics,                        0,                        new_ugraphics,                        i,                        x_ugraphics.length);                i += x_ugraphics.length;                ugraphics = new_ugraphics;            }        }        return ugraphics;    }    public void printHelp() {        System.err.println("usage: java [java/vbj args] <specialist class> [specialist args]");        System.err.println("");        System.err.println("       Java Args:");        System.err.println("       -mx<NUM>m               Set max Java heap in Megs");        System.err.println("       ...");        System.err.println("");        System.err.println("       VBJ Args:");        System.err.println("       -DORBmbufSize=4194304   Define the VBJ buffer size");        System.err.println("       -DORBdebug              Enable VBJ debugging");        System.err.println("       ...");        System.err.println("");        System.err.println("       Specialist Args:");        System.err.println("       -ior <iorfile>                  IOR file (MUST SPECIFY)");        System.err.println("       -covfile <covfile>              Coverage file (R/W)");        System.err.println("       -dtedpaths \"<path1> ...\"      Path to search for DTED data");        System.err.println("       -dted2paths \"<path1> ...\"     Path to search for DTED level2 data");        System.exit(1);    }    private String[] getPaths(String str) {        StringTokenizer tok = new StringTokenizer(str);        int len = tok.countTokens();        String[] paths = new String[len];        for (int j = 0; j < len; j++) {            paths[j] = tok.nextToken();        }        return paths;    }    public void parseArgs(String[] args) {        for (int i = 0; i < args.length; i++) {            if (args[i].equalsIgnoreCase("-dtedpaths")) {                paths = getPaths(args[++i]);            } else if (args[i].equalsIgnoreCase("-dted2paths")) {                paths2 = getPaths(args[++i]);            } else if (args[i].equalsIgnoreCase("-covfile")) {                coverageFile = args[++i];            }        }        super.parseArgs(args);    }    public static void main(String[] args) {        Debug.init(System.getProperties());        // Create the specialist server        DTEDCoverageSpecialist srv = new DTEDCoverageSpecialist();        srv.parseArgs(args);        srv.init();        srv.start(null);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -