Package com.bbn.openmap.gui

Source Code of com.bbn.openmap.gui.LayerStatusPane

// **********************************************************************
//
// <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/gui/LayerStatusPane.java,v $
// $RCSfile: LayerStatusPane.java,v $
// $Revision: 1.4.2.1 $
// $Date: 2004/10/14 18:26:52 $
// $Author: dietrick $
//
// **********************************************************************

package com.bbn.openmap.gui;

import java.awt.*;
import java.net.URL;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;

import com.bbn.openmap.Layer;
import com.bbn.openmap.LayerHandler;
import com.bbn.openmap.event.LayerStatusEvent;
import com.bbn.openmap.event.LayerStatusListener;

/**
* A LayerStatusPane is an extension to the LayerPane, where it is a
* listener to the Layer and shows the layer status in the GUI.
*/
public class LayerStatusPane extends LayerPane implements LayerStatusListener {

    // the icons
    protected static transient ImageIcon layerWorking;
    protected static transient ImageIcon layerDone;

    public transient final static String showPaletteCmd = "showPalette";
    public transient final static String toggleLayerCmd = "toggleLayerCmd";

    protected Color offColor;
    protected Color onColor = new Color(0xFF0066CC);

    // default initializations, extended from LayerPane...
    static {
        URL working = LayerStatusPane.class.getResource("BulbWorking.gif");
        layerWorking = new ImageIcon(working, "layer working");
        URL done = LayerStatusPane.class.getResource("BulbDone.gif");
        layerDone = new ImageIcon(done, "layer displayed");
    }

    /**
     * @param layer the layer to be represented by the pane.
     * @param bg the buttongroup for the layer
     * @param layerHandler the LayerHandler that contains information
     *        about the Layers.
     */
    public LayerStatusPane(Layer layer, LayerHandler layerHandler,
            ButtonGroup bg) {
        super(layer, layerHandler, bg);
        getLayer().addLayerStatusListener(this);
    }

    protected LayerStatusPane(String title) {
        super(title);
    }

    /**
     * Update the Layer status. LayerStatusListener interface method.
     *
     * @param evt LayerStatusEvent
     */
    public void updateLayerStatus(LayerStatusEvent evt) {
        switch (evt.getStatus()) {
        case LayerStatusEvent.START_WORKING:
            onoffButton.setSelectedIcon(layerWorking);
            break;
        case LayerStatusEvent.FINISH_WORKING:
            onoffButton.setSelectedIcon(layerDone);
            break;
        }
    }

    public void cleanup() {
        Layer l = getLayer();
        if (l != null) {
            l.removeLayerStatusListener(this);
        }
        super.cleanup();
    }
}
TOP

Related Classes of com.bbn.openmap.gui.LayerStatusPane

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.