All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.gov.nasa.worldwind.util.dashboard.DashboardController Maven / Gradle / Ivy

Go to download

World Wind is a collection of components that interactively display 3D geographic information within Java applications or applets.

There is a newer version: 2.0.0-986
Show newest version
/*
 * Copyright (C) 2012 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.worldwind.util.dashboard;

import gov.nasa.worldwind.*;
import gov.nasa.worldwind.util.Logging;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * @author tag
 * @version $Id: DashboardController.java 1171 2013-02-11 21:45:02Z dcollins $
 */
public class DashboardController implements MouseListener, Disposable
{
    private DashboardDialog dialog;
    private Component component;
    private WorldWindow wwd;

    public DashboardController(WorldWindow wwd, Component component)
    {
        if (wwd == null)
        {
            String msg = Logging.getMessage("nullValue.WorldWindow");
            Logging.logger().severe(msg);
            throw new IllegalArgumentException(msg);
        }

        this.wwd = wwd;
        this.component = component;
        wwd.getInputHandler().addMouseListener(this);
    }

    public void dispose()
    {
        if (this.dialog != null)
        {
            this.dialog.dispose();
            this.dialog = null;
        }

        if (this.wwd.getInputHandler() != null)
            this.wwd.getInputHandler().removeMouseListener(this);
        this.wwd = null;

        this.component = null;
    }

    public void raiseDialog()
    {
        if (this.dialog == null)
            this.dialog = new DashboardDialog(getParentFrame(this.component), wwd);

        this.dialog.raiseDialog();
    }

    public void lowerDialog()
    {
        if (this.dialog != null)
            this.dialog.lowerDialog();
    }

    private Frame getParentFrame(Component comp)
    {
        return comp != null ? (Frame) SwingUtilities.getAncestorOfClass(Frame.class, comp) : null;
    }

    public void mouseClicked(MouseEvent event)
    {
        if ((event.getButton() == MouseEvent.BUTTON1
            && (event.getModifiers() & ActionEvent.CTRL_MASK) != 0
            && (event.getModifiers() & ActionEvent.ALT_MASK) != 0
            && (event.getModifiers() & ActionEvent.SHIFT_MASK) != 0))
            raiseDialog();
    }

    public void mousePressed(MouseEvent e)
    {
    }

    public void mouseReleased(MouseEvent e)
    {
    }

    public void mouseEntered(MouseEvent e)
    {
    }

    public void mouseExited(MouseEvent e)
    {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy