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

📄 scenariographicloader.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    public void setPace(int pace) {        timeIncrement = pace;    }    public int getPace() {        return timeIncrement;    }    public long getTime() {        return time;    }    public void setTime(long t) {        time = t;        if (timeDate != null && timeLabel != null) {            timeDate.setTime(time);            timeLabel.setText(timeFormat.format(timeDate));        }        if (timeSliderSupport != null) {            timeSliderSupport.update(time);        }        manageGraphics();    }    public void startClock() {        if (!timer.isRunning()) {            pcs.firePropertyChange(TIMER_RUNNING_STATUS,                    TIMER_STOPPED,                    (getClockDirection() > 0 ? TIMER_FORWARD : TIMER_BACKWARD));        }        if (Debug.debugging("scenario")) {            Debug.output("ScenarioGraphicLoader " + getName()                    + ": Starting clock");        }        timer.restart();    }    public void stopClock() {        if (timer.isRunning()) {            pcs.firePropertyChange(TIMER_RUNNING_STATUS,                    (getClockDirection() > 0 ? TIMER_FORWARD : TIMER_BACKWARD),                    TIMER_STOPPED);            timer.stop();        }    }    /**     * Set whether time increases or decreases when the clock is run.     * If direction is zero or greater, clock runs forward. If     * direction is negative, clock runs backward.     */    public void setClockDirection(int direction) {        String oldDirection = clockDirection > 0 ? TIMER_FORWARD                : TIMER_BACKWARD;        if (direction >= 0) {            clockDirection = 1;        } else {            clockDirection = -1;        }        String newDirection = clockDirection > 0 ? TIMER_FORWARD                : TIMER_BACKWARD;        if (timer.isRunning()) {            if (oldDirection != newDirection) {                pcs.firePropertyChange(TIMER_RUNNING_STATUS,                        oldDirection,                        newDirection);            }        }    }    /**     * Get whether time increases or decreases when the clock is run.     * If direction is zero or greater, clock runs forward. If     * direction is negative, clock runs backward.     */    public int getClockDirection() {        return clockDirection;    }    /**     * Call setTime with the amount given added to the current time.     * The amount should be negative if you are going backward through     * time. You need to make sure manageGraphics is called for the     * map to update.     * <p>     *      * This method calls changeTimeBy(amount, wrapAroundTimeLimits),     * with wrapAroundTimeLimits being true of the mode of the     * ScenarioGraphicLoader is SNAPSHOT_SCENARIO_MODE.     *      * @param amount to change the current time by, in milliseconds.     */    protected void changeTimeBy(long amount) {        changeTimeBy(amount, timeWrap);    }    /**     * Call setTime with the amount given added to the current time.     * The amount should be negative if you are going backward through     * time. You need to make sure manageGraphics is called for the     * map to update.     *      * @param amount to change the current time by, in milliseconds.     * @param wrapAroundTimeLimits if true, the time will be set as if     *        the start and end times ofthe scenario are connected, so     *        that moving the time past the time scale in either     *        direction will put the time at the other end of the     *        scale.     */    protected void changeTimeBy(long amount, boolean wrapAroundTimeLimits) {        long oldTime = getTime();        long newTime;        if (oldTime > endTime || oldTime < startTime) {            if (wrapAroundTimeLimits) {                if (amount >= 0) {                    newTime = startTime + amount;                } else {                    newTime = endTime + amount;                }            } else {                if (amount >= 0) {                    newTime = startTime;                } else {                    newTime = endTime;                }                if (timer.isRunning()) {                    stopClock();                    setTime(newTime);                    return;                }            }        } else {            newTime = oldTime + amount;        }        if (Debug.debugging("scenario")) {            Debug.output("ScenarioGraphicLoader (" + getName()                    + ") changing time by [" + amount + "] to (" + newTime                    + ")");        }        setTime(newTime);    }    /**     * Move the clock forward one clock interval.     */    public void stepForward() {        changeTimeBy(timeIncrement, true);    }    /**     * Move the clock back one clock interval.     */    public void stepBackward() {        changeTimeBy(-timeIncrement, true);    }    /**     * ActionListener interface, gets called when the timer goes ping     * if their isn't a command with the ActionEvent. Otherwise, the     * command should be filled in.     */    public void actionPerformed(ActionEvent ae) {        // Will check to see if any GUI commands trigger this        // method, otherwise, it should just change the time.        String cmd = ae.getActionCommand();        if (cmd == SCENARIO_MODE_CMD) {            timeWrap = ((JToggleButton) ae.getSource()).isSelected();        } else {            changeTimeBy(timeIncrement * clockDirection);        }    }    /**     * Read the data files and construct the ScenarioPoints.     */    public synchronized ScenarioGraphicList createData() {        ScenarioGraphicList list = new ScenarioGraphicList();        Hashtable library = new Hashtable();        // Create location data        if (locationFile != null && nameIndex != -1) {            Debug.message("scenario", "Reading location file...");            try {                CSVFile locations = new CSVFile(locationFile);                locations.loadData();                Iterator records = locations.iterator();                while (records.hasNext()) {                    String name = null;                    String icon = null;                    Vector record = (Vector) records.next();                    if (record.size() == 0)                        continue;                    name = (String) record.elementAt(nameIndex);                    if (iconIndex != -1) {                        icon = (String) record.elementAt(iconIndex);                    }                    if (name != null) {                        ScenarioPoint location = new ScenarioPoint(name, icon);                        location.setShowName(showNames);                        drawingAttributes.setTo(location);                        library.put(name.intern(), location);                        list.add(location);                    } else {                        Debug.error("ScenaroGraphicLoader: no name to use to create location: "                                + name);                    }                }            } catch (MalformedURLException murle) {                Debug.error("ScenarioGraphicLoader: problem finding the location file: "                        + locationFile);                return list;            } catch (ArrayIndexOutOfBoundsException aioobe) {                Debug.error("ScenarioGraphicLoader: problem with parsing location file: "                        + locationFile);                if (Debug.debugging("scenario")) {                    Debug.output("The problem is with one of the indexes into the file: \n"                            + aioobe.getMessage());                    aioobe.printStackTrace();                }            } catch (NullPointerException npe) {                Debug.error("ScenarioGraphicLoader ("                        + getName()                        + ") null pointer exception, most likely a problem finding the organization data file");            }        } else {            Debug.error("ScenarioGraphicLoader(" + getName()                    + "): Location file (" + locationFile + ") not configured.");            return list;        }        // OK, got the locations built up, need to fill up the        // scenario        // Create location data        if (activityFile != null && activityNameIndex != -1 && latIndex != -1                && lonIndex != -1 && timeIndex != -1) {            Debug.message("scenario", "Reading activity file...");            try {                CSVFile activities = new CSVFile(activityFile);                activities.loadData(); // numbers as strings == false                Iterator records = activities.iterator();                while (records.hasNext()) {                    String name = null;                    float lat;                    float lon;                    long time;                    Vector record = (Vector) records.next();                    if (record.size() == 0)                        continue;                    name = record.elementAt(activityNameIndex)                            .toString()                            .intern();                    try {                        lat = ((Double) record.elementAt(latIndex)).floatValue();                        lon = ((Double) record.elementAt(lonIndex)).floatValue();                        // parse time from string, ending up with                        // milliseconds from time epoch.                        String timeString = (String) record.elementAt(timeIndex);                        timeDate = timeFormat.parse(timeString);                        time = timeDate.getTime();                        if (time < startTime) {                            startTime = time;                        }                        if (time > endTime) {                            endTime = time;                        }                        dataBounds.add((double) lon, (double) lat);                        if (name != null) {                            ScenarioPoint point = (ScenarioPoint) library.get(name);                            if (point != null) {                                TimeStamp ts = new TimeStamp(lat, lon, time);                                point.addTimeStamp(ts);                            } else {                                Debug.error("SenaroGraphicLoader: ScenarioPoint not found for "                                        + name + ", entry: " + record);                            }                        } else {                            Debug.error("SenaroGraphicLoader: no name to use to create activity point: "

⌨️ 快捷键说明

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