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

📄 datelayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 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/openmap/com/bbn/openmap/layer/DateLayer.java,v $// $RCSfile: DateLayer.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:27:01 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer;import java.awt.*;import java.util.*;import java.text.*;import com.bbn.openmap.event.*;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.Taskable;import com.bbn.openmap.util.PropUtils;/** * Layer that displays date and time. This Layer is a Taskable * (ActionListener) object so that it can be prompted by a * javax.swing.Timer object. This layer understands the following * properties: <code><pre> *  *  # display font as a Java font string *  date.font=SansSerif-Bold *  # like XWindows geometry: [+-]X[+-]Y, `+' indicates relative to *  # left edge or top edges, `-' indicates relative to right or bottom *  # edges, XX is x coordinate, YY is y coordinate *  date.geometry=+20-30 *  # background rectangle color (ARGB) *  date.color.bg=ffb3b3b3 *  # foreground text color (ARGB) *  date.color.fg=ff000000 *  # date format (using java.text.SimpleDateFormat patterns) *  date.format=EEE, d MMM yyyy HH:mm:ss z *   * </pre></code> * <p> * In addition to the previous properties, you can get this layer to * work with the OpenMap viewer by adding/editing the additional * properties in your <code>openmap.properties</code> file: * <code><pre> *  *  # layers *  openmap.layers=date ... *  # class *  date.class=com.bbn.openmap.layer.DateLayer *  # name *  date.prettyName=Date &amp; Time *   * </pre></code> NOTE: the color properties do not support alpha value if * running on JDK 1.1... */public class DateLayer extends LabelLayer implements Taskable, MapMouseListener {    // property keys    public final static transient String dateFormatProperty = "date.format";    // properties    // Dateformat default is similar to IETF standard date syntax:    // "Sat, 12 Aug 1995 13:30:00 GMT", except for the local timezone.    protected DateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");    /**     * Sets the properties for the <code>Layer</code>.     *      * @param prefix the token to prefix the property names     * @param props the <code>Properties</code> object     */    public void setProperties(String prefix, Properties props) {        super.setProperties(prefix, props);        prefix = PropUtils.getScopedPropertyPrefix(prefix);        String dateFormatString = props.getProperty(prefix + dateFormatProperty,                ((SimpleDateFormat) dateFormat).toPattern());        dateFormat = new SimpleDateFormat(dateFormatString);    }    /**     * Get a string representation of the current time. Format the     * string using the current DateFormat.     *      * @return String     */    public String getCurrentTimeString() {        Calendar cal = Calendar.getInstance(TimeZone.getDefault());        return " " + dateFormat.format(cal.getTime()) + " ";    }    /**     * Set the DateFormat used to display the date.     *      * @param df DateFormat     */    protected void setDateFormat(DateFormat df) {        dateFormat = df;    }    /**     * Get the DateFormat used to display the date.     *      * @return DateFormat     */    protected DateFormat getDateFormat() {        return dateFormat;    }    /**     * Paints the layer.     *      * @param g the Graphics context for painting     */    public void paint(Graphics g) {        String data = getCurrentTimeString();        if (Debug.debugging("datelayer")) {            System.out.println("DateLayer.paint(): " + data);        }        labelText = data;        super.paint(g);    }    /**     * Get the sleep hint in milliseconds. The Taskable implementation     * should determine the sleep (delay) interval between invocations     * of its <code>actionPerformed()</code>.     * <p>     * NOTE: this is only a hint for the timer. It's the Taskable's     * responsibility to determine if too little or too much time has     * elapsed between invocations of <code>actionPerformed()</code>     * (if it really matters).     *      * @return int milliseconds of sleep interval     */    public int getSleepHint() {        return 1000;//update every second    }}

⌨️ 快捷键说明

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