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

📄 imagemaster.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// // <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/openmap/com/bbn/openmap/image/ImageMaster.java,v $// $RCSfile: ImageMaster.java,v $// $Revision: 1.4.2.1 $// $Date: 2004/10/14 18:26:57 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.image;import java.awt.*;import java.util.*;import java.net.*;import java.io.*;import com.bbn.openmap.*;import com.bbn.openmap.proj.*;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;/** * The ImageMaster is an organizer for running the ImageServer to * create one or more images. It relies on a properties file, which * sets up a series of entries for an ImageServer. Each entry has * parameters for setting up a projection for an image, a parameters * for a URL for the ImageServer to use to set up the layers for an * image, and a parameter to set the name and path of the output image * file. * <P> * Each map entry in the ImageServer has parameters for the projection * and layer properties to use for the map image, and the size, * location and format of the output image. */public class ImageMaster {    /** Property for space separated image servers to be created. */    public static final String ImageServersProperty = "servers";    /**     * Property for the properties file holding property for a     * particular image.     */    public static final String ServerPropertiesProperty = "properties";    /** Property for an image's projection type. */    public static final String ImageProjectionProperty = "imageProjection";    /** Property for an image's projection center latitude. */    public static final String ImageLatitudeProperty = "imageLatitude";    /** Property for an image's projection center longitude. */    public static final String ImageLongitudeProperty = "imageLongitude";    /** Property for an image's projection scale. */    public static final String ImageScaleProperty = "imageScale";    /** Property for an image's height. */    public static final String ImageHeightProperty = "imageHeight";    /** Property for an image's width. */    public static final String ImageWidthProperty = "imageWidth";    /** Property for the image's background color. */    public static final String ImageBackgroundColorProperty = "imageBackgroundColor";    /** Property for an image's output name. */    public static final String ImageNameProperty = "outputName";    /** Property for scaling the width of image after creation. */    public static final String ScaleToWidthProperty = "scaleToWidth";    /** Property for scaling the height of image after creation. */    public static final String ScaleToHeightProperty = "scaleToHeight";    /** Property for an output log file. */    public static final String OutputLogFileProperty = "outputLogFile";    /** Property for an error log file. */    public static final String ErrorLogFileProperty = "errorLogFile";    /**     * Hashtable of instantiated layers across servers, to reduce     * duplication of same layers.     */    protected Hashtable instantiatedLayers = new Hashtable();    ImageMasterHelper[] helpers;    /** Create with properties. */    public ImageMaster(Properties props) {        setProperties(props);    }    /** Create with properties file. */    public ImageMaster(String propertiesFile) {        Properties props = new Properties();        loadProperties(props, propertiesFile);        setProperties(props);    }    /** Create with properties file URL. */    public ImageMaster(URL propertiesURL) {        Properties props = new Properties();        loadProperties(props, propertiesURL);        setProperties(props);    }    /**     * Loads properties from a java resource. This will load the named     * resource identifier into the given properties instance.     *      * @param props the Properties instance to receive the properties     * @param resourceName the name of the resource to load     * @return true if all's well.     */    protected boolean loadPropertiesFromResource(Properties props,                                                 String resourceName) {        InputStream propsIn = getClass().getResourceAsStream(resourceName);        if (propsIn == null) {            if (Debug.debugging("imagemaster")) {                Debug.error("Unable to locate resources: " + resourceName);            }            return false;        } else {            try {                props.load(propsIn);                return true;            } catch (java.io.IOException e) {                Debug.error("ImageMaster: Caught IOException loading resources: "                        + resourceName);                return false;            }        }    }    /**     * Loads properties from a java resource. This will load the named     * resource identifier into the given properties instance.     *      * @param props the Properties instance to receive the properties     * @param url the url to load     * @return true if all's well.     */    public boolean loadProperties(Properties props, URL url) {        try {            InputStream propsIn = url.openStream();            props.load(propsIn);            return true;        } catch (java.io.IOException e) {            Debug.error("ImageMaster: Caught IOException loading resources: "                    + url);            return false;        }    }    /**     * Load the named file from the named directory into the given     * <code>Properties</code> instance. If the file is not found a     * warning is issued. If an IOException occurs, a fatal error is     * printed and the application will exit.     *      * @param file the name of the file     * @return true if all's well.     */    public boolean loadProperties(Properties props, String file) {        File propsFile = new File(file);        try {            InputStream propsStream = new FileInputStream(propsFile);            props.load(propsStream);            return true;        } catch (java.io.FileNotFoundException e) {            Debug.error("ImageMaster.loadProperties(): Unable to read configuration file \""                    + propsFile + "\"");        } catch (java.io.IOException e) {            Debug.error("ImageMaster.loadProperties(): Caught IO Exception reading configuration file \""                    + propsFile + "\" \n" + e);        }        return false;    }    /**     * Set the properties for the ImageMaster, which also gets all the     * ImageMasterHelpers created.     */    public void setProperties(Properties properties) {        helpers = setImageServers(properties);    }    /** Start the ImageMaster to go through the ImageMasterHelpers. */    public void run() {        doNext();    }    /**     * This causes the ImageMaster to look through the list of     * ImageMasterHelpers and launch the next one that hasn't been     * completed. It will cause the program to exit if there is     * nothing more to do.     */    protected void doNext() {        for (int i = 0; i < helpers.length; i++) {            if (!helpers[i].complete) {                helpers[i].create();                return;            }        }        System.exit(0);    }    /**     * Creates the ImageMasterHelper array from an ImageMaster     * properties object. After this method is called, call run() to     * start the servers on their creative ways.     *      * @param properties the ImageMaster properties.     * @return ImageMasterHelper array.     */    public ImageMasterHelper[] setImageServers(Properties properties) {        String serversValue = properties.getProperty(ImageServersProperty);        if (Debug.debugging("imagemaster")) {            Debug.output("ImageMaster.setImageServers(): servers = \""                    + serversValue + "\"");        }        if (serversValue == null) {            Debug.error("ImageMaster.setImageServers(): No property \""                    + ImageServersProperty                    + "\" found in application properties.");            return new ImageMasterHelper[0];        }        // Divide up the names ...        StringTokenizer tokens = new StringTokenizer(serversValue, " ");        Vector serverNames = new Vector();        while (tokens.hasMoreTokens()) {            serverNames.addElement(tokens.nextToken());        }        if (Debug.debugging("imagemaster")) {            Debug.output("ImageMaster.setImageServers(): " + serverNames);        }        int nServerNames = serverNames.size();        ImageMasterHelper[] masterHelpers = new ImageMasterHelper[nServerNames];        for (int i = 0; i < nServerNames; i++) {            String serverName = (String) serverNames.elementAt(i);            masterHelpers[i] = new ImageMasterHelper(serverName, properties, this);        }        return masterHelpers;    }    /**

⌨️ 快捷键说明

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