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

📄 standardrenderpolicy.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/policy/StandardRenderPolicy.java,v $// $RCSfile: StandardRenderPolicy.java,v $// $Revision: 1.6.2.3 $// $Date: 2005/10/26 15:47:15 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.policy;import java.awt.Composite;import java.awt.Graphics;import java.awt.Graphics2D;import com.bbn.openmap.OMComponent;import com.bbn.openmap.layer.OMGraphicHandlerLayer;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;/** * The StandardRenderPolicy is a RenderPolicy that simply paints the * current graphic list. No conditions or deviations are considered. */public class StandardRenderPolicy extends OMComponent implements RenderPolicy {    /**     * Don't let this be null, nothing will happen. At all.     */    protected OMGraphicHandlerLayer layer;    protected boolean DEBUG = false;    protected Composite composite;    public StandardRenderPolicy() {        DEBUG = Debug.debugging("layer") || Debug.debugging("policy");    }    /**     * Don't pass in a null layer.     */    public StandardRenderPolicy(OMGraphicHandlerLayer layer) {        this();        setLayer(layer);    }    public void setLayer(OMGraphicHandlerLayer l) {        layer = l;    }    public OMGraphicHandlerLayer getLayer() {        return layer;    }    public Composite getComposite() {        return composite;    }    /**     * Can be used to set Composite objects (like AlphaComposite) on     * Graphics2D objects before the layer is painted.     *      * @param composite     */    public void setComposite(Composite composite) {        this.composite = composite;    }    /**     * Call made by the policy from the paint(g) method in order to     * set the composite on the Graphics2D object. This method is     * meant to be overridden if needed.     *      * @param g Graphics2D that the Composite will be set on.     */    protected void setCompositeOnGraphics(Graphics2D g) {        if (composite != null) {            g.setComposite(composite);        }    }    public OMGraphicList prepare() {        if (layer != null) {            return layer.prepare();        } else {            return null;        }    }    public void paint(Graphics g) {        if (layer != null) {            OMGraphicList list = layer.getList();            Projection proj = layer.getProjection();            if (list != null && layer.isProjectionOK(proj)) {                if (proj != null) {                    g.setClip(0, 0, proj.getWidth(), proj.getHeight());                }                setCompositeOnGraphics((Graphics2D) g);                list.render(g);            } else if (DEBUG) {                Debug.output(layer.getName()                        + ".paint(): "                        + (list == null ? "NULL list, skipping..."                                : " skipping due to projection."));            }        } else {            Debug.error("RenderPolicy.paint():  NULL layer, skipping...");        }    }}

⌨️ 快捷键说明

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