Package com.bbn.openmap.examples.beanbox

Source Code of com.bbn.openmap.examples.beanbox.ContainerGraphic

/* **********************************************************************
*
*    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);

        }

    }

}
TOP

Related Classes of com.bbn.openmap.examples.beanbox.ContainerGraphic

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.