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

📄 drawingattributes.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// **********************************************************************// // <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/omGraphics/DrawingAttributes.java,v $// $RCSfile: DrawingAttributes.java,v $// $Revision: 1.17.2.6 $// $Date: 2005/08/09 21:17:45 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.omGraphics;/*  Java Core  */import java.awt.BasicStroke;import java.awt.Color;import java.awt.Component;import java.awt.GradientPaint;import java.awt.Graphics2D;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Image;import java.awt.Paint;import java.awt.Rectangle;import java.awt.Shape;import java.awt.Stroke;import java.awt.TexturePaint;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.image.BufferedImage;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeSupport;import java.io.Serializable;import java.net.MalformedURLException;import java.net.URL;import java.util.NoSuchElementException;import java.util.Properties;import java.util.StringTokenizer;import javax.swing.BorderFactory;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JPanel;import javax.swing.JPopupMenu;import javax.swing.JToggleButton;import javax.swing.JToolBar;import com.bbn.openmap.Environment;import com.bbn.openmap.I18n;import com.bbn.openmap.PropertyConsumer;import com.bbn.openmap.gui.GridBagToolBar;import com.bbn.openmap.image.BufferedImageHelper;import com.bbn.openmap.tools.icon.IconPartList;import com.bbn.openmap.tools.icon.OMIconFactory;import com.bbn.openmap.tools.icon.OpenMapAppPartCollection;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;/** * DrawingAttributes provides a mechanism for loading and managing * different drawing attributes that may be used. Several layers need * to be able to have Properties define how objects should be drawn, * and the list of these drawing attributes tend to be the same. The * DrawingAttributes class fishes out the applicable properties for * you, creates the objects needed, and then lets you get those * objects when needed. * <P> *  * The list of properties that the DrawingAttributes object can handle * are listed below. If a property is not set, the default value will * be used. *  * <pre> *  *   *    *     *     # The Edge or Line color *     lineColor=AARRGGBB (Hex ARGB Color, black is default) *     # The Fill color for 2D shapes *     fillColor=AARRGGBB (Hex ARGB Color, clean is default) *     # The Text Color for objects where any text should be different than the line color. *     textColor=AARRGGBB (Hex ARGB Color, black is default) *     # A highlight color to switch a graphic to when &quot;selected&quot;. *     selectColor=AARRGGBB (Hex ARGB Color, black is default) *     # A file or URL that can be used for a fill pattern, in place of the fill color. *     fillPattern=file://file (default is N/A) *     # The line width of the edge of the graphic *     lineWidth=int (1 is default) *     # A pattern to use for a dashed line, reflected as a *     # space-separated list of numbers, which are interpreted as on dash *     # length, off dash length, on dash length, etc.   *     dashPattern=10 5 3 5 (5 5 is the default if an error occurs reading the numbers, a non-dashed line is the default.)   *     The phase for the dash pattern, *     dashPhase=0.0f (0 is the default) *     # The scale to use for certain measurements, so that fill patterns *     # can be scaled depending on the map scale compaired to the *     # baseScale. *     baseScale=XXXXXX (where 1:XXXXXX is the scale to use.  N/A for the default). *     # Set whether any OMPoints that are given to the DrawingAttributes object are oval or rectangle. *     pointOval=false *     # Set the pixel radius of any OMPoint given to the DrawingAttributes object. *     pointRadius=2 *    *   *  *  */public class DrawingAttributes implements ActionListener, Serializable,        Cloneable, PropertyConsumer, PropertyChangeListener {    /**     * The name of the property that holds the line paint of the     * graphics.     */    public final static String linePaintProperty = "lineColor";    //     /**    //      * The name of the property that holds the text paint for Text,    //      * in case that should be different for labels, etc.    //      */    //     public final static String textPaintProperty = "textColor";    /**     * The name of the property that holds the fill paint of the     * graphics.     */    public final static String fillPaintProperty = "fillColor";    /**     * The name of the property that holds the select paint of the     * graphics, which is the line paint that gets set with the     * default OMGraphic.select() action.     */    public final static String selectPaintProperty = "selectColor";    /**     * The name of the property that holds the matting paint of the     * graphics, which is the wider line paint that gets set when     * matting is enabled.     */    public final static String mattingPaintProperty = "mattingColor";    /**     * The property that specifies an URL or file a image file to be     * used to construct the Paint object for a texture fill pattern.     * If the fillPattern is null, the fillPaint will be used.     */    public static final String fillPatternProperty = "fillPattern";    /**     * The name of the property that holds the lineWidth of the     * graphics.     */    public final static String lineWidthProperty = "lineWidth";    /**     * The name of the property that holds a dashed pattern for lines.     * This will be used to build the stroke object for lines. This     * pattern should be two space-separated numbers, the first     * representing the pixel length of the line in the dash, the     * second being the space pixel length of the dash.     */    public final static String dashPatternProperty = "dashPattern";    /**     * The name of the property that holds a dashed phase for lines.     * This will be used to build the stroke object for lines.     */    public final static String dashPhaseProperty = "dashPhase";    /**     * The base scale to use for the image provided for the fill     * pattern. As the scale of the map changes, the base scale can be     * used as a reference to change the resolution of the pattern.     * This scale will also be used for strokes.     */    public static final String baseScaleProperty = "baseScale";    /**     * Set whether a thin black matting should be drawing around the     * OMGraphic.     */    public static final String mattedProperty = "matted";    /** Property for whether OMPoints should be oval. "pointOval" */    public static final String PointOvalProperty = "pointOval";    /** Property for the pixel radius of OMPoints. "pointRadius" */    public static final String PointRadiusProperty = "pointRadius";    public final static int NONE = -1;    /** The default line paint. (black) */    public final static String defaultLinePaintString = "0"; // black    /** The default fill paint. (none) */    public final static String defaultFillPaintString = "-1"; // none    /** The default fill paint. (black) */    public final static String defaultSelectPaintString = "0"; // black    /** The default matting paint. (black) */    public final static String defaultMattingPaintString = "0"; // black    /** The default line width */    public final static float defaultLineWidth = 1f;    /** The default dash phase, which is zero. */    public final static float defaultDashPhase = 0f;    /** The defaule dash length, for opaque and transparent parts. */    public final static float defaultDashLength = 5f;    /** The paint to outline the shapes. */    protected Paint linePaint = Color.black;    //     /** The paint for text. Default to black. */    //     protected Paint textPaint = linePaint;    /** The select paint for the shapes. */    protected Paint selectPaint = Color.black;    /** The paint to fill the shapes. */    protected Paint fillPaint = OMColor.clear;    /** The paint to use for matting. */    protected Paint mattingPaint = OMColor.black;    /**     * A TexturePaint pattern, if defined. Overrules fillPaint if     * fillPaint is null or clear.     */    protected TexturePaint fillPattern = null;    /** The line stroke, for dashes, etc. */    protected transient Stroke stroke = new BasicStroke(1);    /**     * The base scale for scaling the fill pattern image. If NONE,     * then the resolution of the raw image will always be used.     */    protected float baseScale = NONE;    /**     * Whether a thin black matting line should be rendered around the     * OMGraphic.     */    protected boolean matted = false;    protected String propertyPrefix = null;    protected String fPattern = null; // for writing out the    // properties    /**     * The isOval setting to set on OMPoints.     */    protected boolean pointOval = OMPoint.DEFAULT_ISOVAL;    /**     * The pixel radius to set on OMPoints.     */    protected int pointRadius = OMPoint.DEFAULT_RADIUS;    /**     * A good ol' generic DrawingAttributes object for all to use.     * Black lines, clear fill paint.     */    public final static DrawingAttributes DEFAULT = new DrawingAttributes();    /**     * Support object to notify listeners when something has changed.     */    protected PropertyChangeSupport propertyChangeSupport = null;    /**     * For internationalization.     */    protected I18n i18n = Environment.getI18n();    /** Command for line color string adjustments. */    public final static String LineColorCommand = "LineColor";    /** Command for fill color string adjustments. */    public final static String FillColorCommand = "FillColor";    /** Command for select color string adjustments. */    public final static String SelectColorCommand = "SelectColor";    /** Command for matting color string adjustments. */    public final static String MattingColorCommand = "MattingColor";    /** Command for adding matting. */    public final static String MattedCommand = "MattedCommand";    private JButton lineColorButton;    private JButton fillColorButton;    private JButton selectColorButton;    private JButton mattingColorButton;    private JToggleButton mattedCheckBox;    protected final static int icon_width = 20;    protected final static int icon_height = 20;    public static boolean alwaysSetTextToBlack = false;    protected transient BasicStrokeEditorMenu bse;    /**     * The JButton used to bring up the line menu.     */    protected JButton lineButton;    /**     * Any additional JMenu items that should be added to the line     * menu.     */    protected JMenu[] lineMenuAdditions = null;    /**     * Create a DrawingAttributes with the default settings - clear     * fill paint and pattern, sold black edge line of width 1.     */    public DrawingAttributes() {        setProperties(null, null);    }    /**     * Create the DrawingAttributes and call setProperties without a     * prefix for the properties. Call setProperties without a prefix     * for the properties.     *      * @param props the Properties to look in.     */    public DrawingAttributes(Properties props) {        setProperties(null, props);    }    /**     * Create the DrawingAttributes and call setProperties with a     * prefix for the properties.     *      * @param prefix the prefix marker to use for a property, like     *        prefix.propertyName. The period is added in this     *        function.     * @param props the Properties to look in.     */    public DrawingAttributes(String prefix, Properties props) {        setProperties(prefix, props);    }    /**     * Shallow clone.     */    public Object clone() {        try {            return super.clone();        } catch (CloneNotSupportedException e) {            return null;        }    }    public Stroke cloneBasicStroke() {        if (stroke instanceof BasicStroke) {            BasicStroke bs = (BasicStroke) stroke;            return new BasicStroke(bs.getLineWidth(), bs.getEndCap(), bs.getLineJoin(), bs.getMiterLimit(), bs.getDashArray(), bs.getDashPhase());        } else {            return new BasicStroke(1);        }    }    /**     * Shallow.     */    public void setTo(DrawingAttributes clone) {        clone.linePaint = linePaint;        //      clone.textPaint = textPaint;        clone.selectPaint = selectPaint;

⌨️ 快捷键说明

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