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

📄 annotationcontrols.java

📁 world wind java sdk 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2001, 2009 United States Government as represented bythe Administrator of the National Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.examples;import gov.nasa.worldwind.avlist.*;import gov.nasa.worldwind.event.*;import gov.nasa.worldwind.examples.util.*;import gov.nasa.worldwind.geom.Position;import gov.nasa.worldwind.layers.*;import gov.nasa.worldwind.pick.*;import gov.nasa.worldwind.render.*;import gov.nasa.worldwind.util.Logging;import javax.sound.sampled.*;import javax.swing.*;import java.awt.event.*;/** * @author dcollins * @version $Id: AnnotationControls.java 10616 2009-04-28 23:28:57Z dcollins $ */public class AnnotationControls extends ApplicationTemplate{    protected final static String AUDIO = "Audio";    protected final static String IMAGES = "Images";    protected final static String ICON_AUDIO = "images/audioicon-64.png";    protected final static String ICON_IMAGES = "images/imageicon-64.png";    protected final static String URL_AUDIO_WELCOME = "http://worldwind.arc.nasa.gov/java/demos/sounds/1-welcome.wav";    protected final static String URL_AUDIO_MUSIC = "http://worldwind.arc.nasa.gov/java/demos/sounds/spacemusic.au";    protected final static String URL_AUDIO_PERU = "http://worldwind.arc.nasa.gov/java/demos/sounds/destMouse_Peru.AIF";    protected final static String URL_IMAGE_01 = "http://worldwind.arc.nasa.gov/java/demos/images/MountStHelens_01_800.jpg";    protected final static String URL_IMAGE_02 = "http://worldwind.arc.nasa.gov/java/demos/images/the_nut.jpg";    protected final static String URL_IMAGE_03 = "http://worldwind.arc.nasa.gov/java/demos/images/ireland.jpg";    protected final static String URL_IMAGE_04 = "http://worldwind.arc.nasa.gov/java/demos/images/new_zealand.gif";    protected final static String URL_IMAGE_05 = "http://worldwind.arc.nasa.gov/java/demos/images/pond.jpg";    public static class AppFrame extends ApplicationTemplate.AppFrame implements SelectListener    {        protected IconLayer iconLayer;        protected WWIcon highlit;        protected RenderableLayer contentLayer;        protected BasicDragger dragger;        public AppFrame()        {            this.iconLayer = createIconLayer();            this.contentLayer = new RenderableLayer();            insertBeforePlacenames(this.getWwd(), this.iconLayer);            insertBeforePlacenames(this.getWwd(), this.contentLayer);            this.getWwd().addSelectListener(this);            this.dragger = new BasicDragger(this.getWwd());        }        public IconLayer getIconLayer()        {            return this.iconLayer;        }        public RenderableLayer getContentLayer()        {            return this.contentLayer;        }        @SuppressWarnings({"StringEquality"})        public void selected(SelectEvent e)        {            if (e == null)                return;            PickedObject topPickedObject = e.getTopPickedObject();            if (e.getEventAction() == SelectEvent.LEFT_PRESS)            {                if (topPickedObject != null && topPickedObject.getObject() instanceof WWIcon)                {                    WWIcon selected = (WWIcon) topPickedObject.getObject();                    this.highlight(selected);                }                else                {                    this.highlight(null);                }            }            else if (e.getEventAction() == SelectEvent.LEFT_DOUBLE_CLICK)            {                if (topPickedObject != null && topPickedObject.getObject() instanceof WWIcon)                {                    WWIcon selected = (WWIcon) topPickedObject.getObject();                    this.highlight(selected);                    this.openResource(selected);                }            }            else if (e.getEventAction() == SelectEvent.DRAG || e.getEventAction() == SelectEvent.DRAG_END)            {                this.dragger.selected(e);            }        }        public void highlight(WWIcon icon)        {            if (this.highlit == icon)                return;            if (this.highlit != null)            {                this.highlit.setHighlighted(false);                this.highlit = null;            }            if (icon != null)            {                this.highlit = icon;                this.highlit.setHighlighted(true);            }            this.getWwd().redraw();                    }        protected void closeResource(ContentAnnotation content)        {            if (content == null)                return;            content.detach();        }        protected void openResource(WWIcon icon)        {            if (icon == null || !(icon instanceof AVList))                return;            ContentAnnotation content = this.createContent(icon.getPosition(), (AVList) icon);            if (content != null)            {                content.attach();            }        }        protected ContentAnnotation createContent(Position position, AVList params)        {            return createContentAnnotation(this, position, params);        }    }    public static class ContentAnnotation implements ActionListener    {        protected AppFrame appFrame;        protected DialogAnnotation annnotation;        protected DialogAnnotationController controller;        public ContentAnnotation(AppFrame appFrame, DialogAnnotation annnotation, DialogAnnotationController controller)        {            this.appFrame = appFrame;            this.annnotation = annnotation;            this.annnotation.addActionListener(this);            this.controller = controller;        }        public AppFrame getAppFrame()        {            return this.appFrame;        }        public DialogAnnotation getAnnotation()        {            return this.annnotation;        }        public DialogAnnotationController getController()        {            return this.controller;        }        @SuppressWarnings({"StringEquality"})        public void actionPerformed(ActionEvent e)        {            if (e == null)                return;            if (e.getActionCommand() == AVKey.CLOSE)            {                this.getAppFrame().closeResource(this);            }        }        public void detach()        {            this.getController().setEnabled(false);            RenderableLayer layer = this.getAppFrame().getContentLayer();            layer.removeRenderable(this.getAnnotation());        }        public void attach()        {            this.getController().setEnabled(true);            RenderableLayer layer = this.appFrame.getContentLayer();            layer.removeRenderable(this.getAnnotation());            layer.addRenderable(this.getAnnotation());        }    }    public static class AudioContentAnnotation extends ContentAnnotation    {        protected Clip clip;        protected Object source;        protected Thread readThread;        public AudioContentAnnotation(AppFrame appFrame, AudioPlayerAnnotation annnotation,            AudioPlayerAnnotationController controller, Object source)        {            super(appFrame, annnotation, controller);            this.source = source;            this.retrieveAndSetClip(source);        }        public Object getSource()        {            return this.source;        }        public void detach()        {            super.detach();            // Stop any threads or timers the controller may be actively running.            AudioPlayerAnnotationController controller = (AudioPlayerAnnotationController) this.getController();            if (controller != null)            {                this.stopController(controller);            }            // Stop any threads that may be reading the audio source.            this.stopClipRetrieval();        }        @SuppressWarnings({"StringEquality"})        protected void stopController(AudioPlayerAnnotationController controller)        {            String status = controller.getClipStatus();            if (status == AVKey.PLAY)            {                controller.stopClip();            }        }        protected void retrieveAndSetClip(Object source)        {            this.startClipRetrieval(source);        }        protected void doRetrieveAndSetClip(final Object source)        {            javax.swing.SwingUtilities.invokeLater(new Runnable()            {                public void run()                {                    getAnnotation().setBusy(true);                    appFrame.getWwd().redraw();                }            });            final Clip clip = this.readClip(source);            SwingUtilities.invokeLater(new Runnable()            {                public void run()                {                    AudioPlayerAnnotationController controller = (AudioPlayerAnnotationController) getController();                    if (controller != null)                    {                        controller.setClip(clip);                    }                    AudioPlayerAnnotation annotation = (AudioPlayerAnnotation) getAnnotation();                    if (annotation != null)                    {                        if (clip == null)                        {                            annotation.getTitleLabel().setText(createErrorTitle(source.toString()));                        }                    }                    getAnnotation().setBusy(false);                    appFrame.getWwd().redraw();                }            });        }        protected Clip readClip(Object source)        {            try            {                java.net.URL url = new java.net.URL(source.toString());                return openAudioURL(url);            }            catch (Exception e)            {                e.printStackTrace();            }            return null;        }        protected void startClipRetrieval(final Object source)        {            this.readThread = new Thread(new Runnable()            {                public void run()                {                    doRetrieveAndSetClip(source);                }            });            this.readThread.start();        }        protected void stopClipRetrieval()        {            if (this.readThread != null)            {                if (this.readThread.isAlive())                {                    this.readThread.interrupt();                }            }            this.readThread = null;        }    }    public static class ImageContentAnnotation extends ContentAnnotation    {        public ImageContentAnnotation(AppFrame appFrame, SlideShowAnnotation annnotation,            SlideShowAnnotationController controller)        {            super(appFrame, annnotation, controller);        }

⌨️ 快捷键说明

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