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

📄 drawingattributes.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                URL textureImageURL = PropUtils.getResourceOrFileOrURL(this,                        fPattern);                if (textureImageURL != null) {                    BufferedImage bi = BufferedImageHelper.getBufferedImage(textureImageURL,                            0,                            0,                            -1,                            -1);                    fillPattern = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));                }            } catch (MalformedURLException murle) {                Debug.error("DrawingAttributes.init: bad texture URL - \n     "                        + realPrefix + fillPatternProperty);                fillPattern = null;            } catch (InterruptedException ie) {                Debug.error("DrawingAttributes.init: bad problems getting texture URL - \n"                        + ie);                fillPattern = null;            }        }    }    /**     * PropertyConsumer method, to fill in a Properties object,     * reflecting the current values of the layer. If the layer has a     * propertyPrefix set, the property keys should have that prefix     * plus a separating '.' prepended to each propery key it uses for     * configuration.     *      * @param props a Properties object to load the PropertyConsumer     *        properties into. If props equals null, then a new     *        Properties object should be created.     * @return Properties object containing PropertyConsumer property     *         values. If getList was not null, this should equal     *         getList. Otherwise, it should be the Properties object     *         created by the PropertyConsumer.     */    public Properties getProperties(Properties props) {        if (props == null) {            props = new Properties();        }        String prefix = PropUtils.getScopedPropertyPrefix(this);        if (linePaint instanceof Color) {            props.put(prefix + linePaintProperty,                    PropUtils.getProperty((Color) linePaint));        }        //      if (textPaint instanceof Color) {        //          props.put(prefix + textPaintProperty,        //                    PropUtils.getProperty((Color)textPaint));        //      }        if (fillPaint instanceof Color) {            props.put(prefix + fillPaintProperty,                    PropUtils.getProperty((Color) fillPaint));        }        if (selectPaint instanceof Color) {            props.put(prefix + selectPaintProperty,                    PropUtils.getProperty((Color) selectPaint));        }        if (mattingPaint instanceof Color) {            props.put(prefix + mattingPaintProperty,                    PropUtils.getProperty((Color) mattingPaint));        }        props.put(prefix + PointRadiusProperty, Integer.toString(pointRadius));        props.put(prefix + PointOvalProperty, new Boolean(pointOval).toString());        props.put(prefix + fillPatternProperty, (fPattern == null ? ""                : fPattern));        Stroke bs = getStroke();        if (bs == null) {            bs = new BasicStroke();        }        if (bs instanceof BasicStroke) {            props.put(prefix + lineWidthProperty,                    Float.toString(((BasicStroke) bs).getLineWidth()));            float[] fa = ((BasicStroke) bs).getDashArray();            if (fa != null) {                StringBuffer dp = new StringBuffer();                for (int i = 0; i < fa.length; i++) {                    dp.append(" " + Float.toString(fa[i]));                }                props.put(prefix + dashPatternProperty, dp.toString());                props.put(prefix + dashPhaseProperty,                        Float.toString(((BasicStroke) bs).getDashPhase()));            } else {                props.put(prefix + dashPatternProperty, "");                props.put(prefix + dashPhaseProperty, "");            }        }        if (baseScale != NONE) {            props.put(prefix + baseScaleProperty, Float.toString(baseScale));        }        props.put(prefix + mattedProperty, new Boolean(matted).toString());        return props;    }    /**     * Method to fill in a Properties object with values reflecting     * the properties able to be set on this PropertyConsumer. The key     * for each property should be the raw property name (without a     * prefix) with a value that is a String that describes what the     * property key represents, along with any other information about     * the property that would be helpful (range, default value,     * etc.).     *      * @param list a Properties object to load the PropertyConsumer     *        properties into. If getList equals null, then a new     *        Properties object should be created.     * @return Properties object containing PropertyConsumer property     *         values. If getList was not null, this should equal     *         getList. Otherwise, it should be the Properties object     *         created by the PropertyConsumer.     */    public Properties getPropertyInfo(Properties list) {        if (list == null) {            list = new Properties();        }        String interString;        interString = i18n.get(DrawingAttributes.class,                linePaintProperty,                I18n.TOOLTIP,                "Edge color for graphics.");        list.put(linePaintProperty, interString);        interString = i18n.get(DrawingAttributes.class,                linePaintProperty,                linePaintProperty);        list.put(linePaintProperty + LabelEditorProperty, interString);        list.put(linePaintProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor");        //      list.put(textPaintProperty, "Text color for graphics.");        //      list.put(textPaintProperty + ScopedEditorProperty,        //               "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                fillPaintProperty,                I18n.TOOLTIP,                "Fill color for graphics.");        list.put(fillPaintProperty, interString);        interString = i18n.get(DrawingAttributes.class,                fillPaintProperty,                fillPaintProperty);        list.put(fillPaintProperty + LabelEditorProperty, interString);        list.put(fillPaintProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                selectPaintProperty,                I18n.TOOLTIP,                "Selected edge color for graphics.");        list.put(selectPaintProperty, interString);        interString = i18n.get(DrawingAttributes.class,                selectPaintProperty,                selectPaintProperty);        list.put(selectPaintProperty + LabelEditorProperty, interString);        list.put(selectPaintProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                mattingPaintProperty,                I18n.TOOLTIP,                "Matting edge color for graphics.");        list.put(mattingPaintProperty, interString);        interString = i18n.get(DrawingAttributes.class,                mattingPaintProperty,                mattingPaintProperty);        list.put(mattingPaintProperty + LabelEditorProperty, interString);        list.put(mattingPaintProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                fillPatternProperty,                I18n.TOOLTIP,                "Image file to use for fill pattern for graphics (optional).");        list.put(fillPatternProperty, interString);        interString = i18n.get(DrawingAttributes.class,                fillPatternProperty,                fillPatternProperty);        list.put(fillPatternProperty + LabelEditorProperty, interString);        list.put(fillPatternProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                lineWidthProperty,                I18n.TOOLTIP,                "Line width for edges of graphics");        list.put(lineWidthProperty, interString);        interString = i18n.get(DrawingAttributes.class,                lineWidthProperty,                lineWidthProperty);        list.put(lineWidthProperty + LabelEditorProperty, interString);        //      list.put(dashPatternProperty, "<HTML><BODY>Line dash        // pattern, represented by<br>space separated numbers<br> (on        // off on ...)</BODY></HTML>");        interString = i18n.get(DrawingAttributes.class,                dashPatternProperty,                I18n.TOOLTIP,                "Line dash pattern, represented by space separated numbers (on off on ...)");        list.put(dashPatternProperty, interString);        interString = i18n.get(DrawingAttributes.class,                dashPatternProperty,                dashPatternProperty);        list.put(dashPatternProperty + LabelEditorProperty, interString);        interString = i18n.get(DrawingAttributes.class,                dashPhaseProperty,                I18n.TOOLTIP,                "Phase for dash pattern (Default is 0)");        list.put(dashPhaseProperty, interString);        interString = i18n.get(DrawingAttributes.class,                dashPhaseProperty,                dashPhaseProperty);        list.put(dashPhaseProperty + LabelEditorProperty, interString);        interString = i18n.get(DrawingAttributes.class,                baseScaleProperty,                I18n.TOOLTIP,                "<HTML><BODY>Scale which should be used as the base scale for the <br>patterns and line width. If set, size of pattern and <br>widths will be adjusted to the map scale</BODY></HTML>");        list.put(baseScaleProperty, interString);        interString = i18n.get(DrawingAttributes.class,                baseScaleProperty,                baseScaleProperty);        list.put(baseScaleProperty + LabelEditorProperty, interString);        interString = i18n.get(DrawingAttributes.class,                mattedProperty,                I18n.TOOLTIP,                "Flag to enable a thin black matting to be drawn around graphics.");        list.put(mattedProperty, interString);        interString = i18n.get(DrawingAttributes.class,                mattedProperty,                mattedProperty);        list.put(mattedProperty + LabelEditorProperty, interString);        list.put(mattedProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.OnOffPropertyEditor");        interString = i18n.get(DrawingAttributes.class,                PointRadiusProperty,                I18n.TOOLTIP,                "Pixel radius of point objects.");        list.put(PointRadiusProperty, interString);        interString = i18n.get(DrawingAttributes.class,                PointRadiusProperty,                "Point pixel radius");        list.put(PointRadiusProperty + LabelEditorProperty, interString);        interString = i18n.get(DrawingAttributes.class,                PointOvalProperty,                I18n.TOOLTIP,                "Set points to be oval or rectangular.");        list.put(PointOvalProperty, interString);        interString = i18n.get(DrawingAttributes.class,                PointOvalProperty,                "Points are oval");        list.put(PointOvalProperty + LabelEditorProperty, interString);        list.put(PointOvalProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");        //         list.put(initPropertiesProperty, getInitPropertiesOrder());        return list;    }    public String getInitPropertiesOrder() {        return " " + linePaintProperty + " " + selectPaintProperty + " "                + fillPaintProperty + " "                + /* textPaintProperty + " " + */mattingPaintProperty + " "                + fillPatternProperty + " " + mattedProperty + " "                + lineWidthProperty + " " + dashPatternProperty + " "                + dashPhaseProperty + " " + PointRadiusProperty + " "                + PointOvalProperty;    }    /**     * Set the property key prefix that should be used by the     * PropertyConsumer. The prefix, along with a '.', should be     * prepended to the property keys known by the PropertyConsumer.     *      * @param prefix the prefix String.     */    public void setPropertyPrefix(String prefix) {        propertyPrefix = prefix;    }    /**     * Get the property key prefix that is being used to prepend to     * the property keys for Properties lookups.     *      * @return the prefix String.     */    public String getPropertyPrefix() {        return propertyPrefix;    }    public void propertyChange(PropertyChangeEvent pce) {        if (pce.getSource() instanceof BasicStrokeEditorMenu) {            setStroke((BasicStroke) pce.getNewValue());        }    }    public String toString() {        StringBuffer sb = new StringBuffer("DrawingAttributes[");        sb.append("linePaint(" + linePaint + "), ");        sb.append("selectPaint(" + selectPaint + "), ");        //      sb.append("textPaint(" + textPaint + "), ");        sb.append("mattingPaint(" + mattingPaint + "), ");        sb.append("fillPaint(" + fillPaint + "), ");        sb.append("fillPattern(" + fillPattern + "), ");        sb.append("stroke(" + stroke + "), ");        sb.append("baseScale(" + baseScale + "), ");        sb.append("matted(" + new Boolean(matted).toString() + ")]");        return sb.toString();    }    /**     * Render the Shape into the Graphics2D object, using the     * mattingPaint, fillPaint, fillPattern, linePaint and stroke     * contained in this DrawingAttributes object.     */    public void render(Graphics2D g, Shape shape) {        render(g, shape, false);    }    /**     * Render the Shape into the Graphics2D object, using the     * mattingPaint, fillPaint, fillPattern, linePaint and stroke     * contained in this DrawingAttributes object.     *      * @param g java.awt.Graphics2D object to render into     * @param shape java.awt.Shape to draw     * @param replaceColorWithGradient flag to specify replacement of     *        fill and edge colors with a GradientPaint to give a     *        light to dark look. You can set the Paints in the     *        DrawingAttributes object with GradientPaints if you want     *        more control over the GradientPaint, but this will let     *        the DrawingAttributes object take a shot at creating one     *        for a Color that fits the shape given.     */    public void render(Graphics2D g, Shape shape,                       boolean replaceColorWithGradient) {        if (matted) {            if (stroke instanceof BasicStroke) {                g.setStroke(new BasicStro

⌨️ 快捷键说明

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