containergraphic.java

来自「openmap java写的开源数字地图程序. 用applet实现,可以像g」· Java 代码 · 共 82 行

JAVA
82
字号
/* ********************************************************************** *  *    Use, duplication, or disclosure by the Government is subject to *           restricted rights as set forth in the DFARS. *   *                         BBNT Solutions LLC *                             A Part of  *                  Verizon       *                          10 Moulton Street *                         Cambridge, MA 02138 *                          (617) 873-3000 * *    Copyright (C) 2002 by BBNT Solutions, LLC *                 All Rights Reserved. * ********************************************************************** */package com.bbn.openmap.examples.beanbox;import com.bbn.openmap.omGraphics.OMGraphic;import com.bbn.openmap.omGraphics.OMRect;import com.bbn.openmap.omGraphics.OMGraphicConstants;/** * A custom graphic class for representing objects of type * {@link com.bbn.openmap.examples.beanbox.SimpleBeanContainer}as a * rectangular box. */public class ContainerGraphic extends CustomGraphic {    public ContainerGraphic(SimpleBeanObject object) {        super(object);        this.setRenderType(OMGraphicConstants.RENDERTYPE_LATLON);    }    /**     * Returns an OMRect object with dimensions equal to the width and     * height of the SimpleBeanContainer and position equal to the     * center lat/lon position of the SimpleBeanContainer object.     */    public OMGraphic createGraphic(SimpleBeanObject object) {        if (!(object instanceof SimpleBeanContainer)) {            throw new IllegalArgumentException(object                    + " not instance of SimpleBeanContainer");        }        SimpleBeanContainer bc = (SimpleBeanContainer) object;        return new OMRect(bc.getTopLatitude(), bc.getLeftLongitude(), bc.getBottomLatitude(), bc.getRightLongitude(), OMGraphicConstants.LINETYPE_RHUMB);    }    /**     * Updates the width, height and position of OMRect object used to     * represent the SimpleBeanContainer object with the corresponding     * values in the SimpleBeanContainer object.     */    public void updateGraphic(SimpleBeanObject object) {        if (!(object instanceof SimpleBeanContainer)) {            throw new IllegalArgumentException(object                    + " not instance of SimpleBeanContainer");        }        SimpleBeanContainer bc = (SimpleBeanContainer) object;        OMGraphic graphic = super.getOMGraphicAt(0);        if (graphic instanceof OMRect) {            OMRect rect = (OMRect) graphic;            rect.setLocation(bc.getTopLatitude(),                    bc.getLeftLongitude(),                    bc.getBottomLatitude(),                    bc.getRightLongitude(),                    OMGraphicConstants.LINETYPE_RHUMB);        }    }}

⌨️ 快捷键说明

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