NASA World Wind

gov.nasa.worldwind.render
Class AbstractBrowserBalloon

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.AbstractBalloon
              extended by gov.nasa.worldwind.render.AbstractBrowserBalloon
All Implemented Interfaces:
AVList, Disposable, MessageListener, SelectListener, Balloon, Highlightable, OrderedRenderable, Renderable, HotSpot, WWObject, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, PropertyChangeListener, EventListener
Direct Known Subclasses:
GlobeBrowserBalloon, ScreenBrowserBalloon

public abstract class AbstractBrowserBalloon
extends AbstractBalloon
implements OrderedRenderable, HotSpot, Disposable

A Balloon that displays HTML, JavaScript, and Flash content using the system's native browser. The balloon's HTML content is specified by calling setText with an HTML formatted string. A browser balloon resolves relative URLs in the HTML content by consulting its resource resolver. The resource resolver converts a relative URL to an absolute URL that the browser can load. The resource resolver is specified by calling setResourceResolver, and may be one of the following: a WebResourceResolver, a URL, or a String containing a valid URL description. If a browser balloon's resource resolver is null or is an unrecognized type, the browser interprets relative URLs as unresolved references.

Browser Controls

Browser balloons display three default browser controls that enable users to navigate the browser's history back and forward, and to close the balloon. When the user selects one of these controls, a SelectEvent is generated with the PickedObject's AVKey.ACTION value set to one of AVKey.CLOSE, AVKey.BACK, or AVKey.FORWARD. These controls may be enabled or disabled by calling setDrawBrowserControls (they are enabled by default), and may be customized by adding or removing controls from the browser balloon. See getBrowserControls, addBrowserControl, and removeBrowserControl.

Resize Control

Browser balloons provide a default resize control that is activated by dragging the balloon's border. When the user drags the border, a SelectEvent is generated with the PickedObject's AVKey.ACTION value set to AVKey.RESIZE. The PickedObject's AVKey.BOUNDS value holds the Balloon's screen bounds in AWT coordinates (origin at the upper left corner) as a java.awt.Rectangle. The resize control may be enabled or disabled by calling setDrawResizeControl (it is enabled by default).

Balloon Size

The browser balloon's screen width and height are specified as a Size object in its BalloonAttributes. This size may configured in one of the following three modes:

The balloon's width and height may be configured independently, enabling any combination of these three modes. The balloon's width and height are limited by its maximum size, which is also specified as a Size object in its BalloonAttributes. If the maximum size is null, the balloon's width and height are unlimited. The space provided for the balloon's HTML content equal to the balloon's screen width and height minus the balloon's insets, also specified in its BalloonAttributes

The balloon's width or height (or both) may be configured to fit to the balloon's HTML content by configuring its BalloonAttributes with a Size who's width or height mode is Size.NATIVE_DIMENSION or Size.MAINTAIN_ASPECT_RATIO. When configured in this mode, the browser balloon's size always fits the HTML content specified at construction or by calling setText. If a user action causes the balloon to navigate to another page, the balloon continues to fit to its current HTML content.

The balloon frame's corner radius and leader width specified in its BalloonAttributes are limited by the balloon's size. The corner radius is first limited by the balloon's width and height, then the leader width is limited by the balloon's width and height minus space taken by rounded corners. For example, if the corner radius is 100 and the width and height are 50 and 100, the actual corner radius used is 25 - half of the rectangle's smallest dimension. Similarly, if the leader is attached to the rectangle's bottom, its width is limited by the rectangle's width minus any space used by the balloon's rounded corners.

Hiding the balloon

The balloon can be made visible or invisible by calling setVisible. The balloon's visibilityAction determines what happens to the native web browser when the balloon is invisible. The balloon can either release its native web browser, preventing the native browser from consuming system resources while the balloon is invisible, or it can retain the native browser. Possible values of visibilityAction are:


Nested Class Summary
static class AbstractBrowserBalloon.BrowserControl
           
protected static class AbstractBrowserBalloon.FrameGeometryInfo
          Holds the vertex data and the defining properties of a balloon's frame and leader geometry.
 
Field Summary
protected  List<AbstractBrowserBalloon.BrowserControl> browserControls
           
protected static Dimension DEFAULT_NATIVE_SIZE
          The browser balloon's default native size: 400x300.
protected static int DEFAULT_OUTLINE_PICK_WIDTH
          The default outline pick width in pixels.
protected static String DEFAULT_WEB_VIEW_FACTORY
          The class name of the default WebViewFactory used to create the balloon's internal WebView.
protected  boolean drawBrowserControls
           
protected  boolean drawResizeControl
           
protected  boolean drawTitleBar
           
protected  double eyeDistance
          Used to order the balloon as an ordered renderable.
protected static int FRAME_GEOMETRY_ELLIPSE_SLICES
          The number of slices used to display a balloon frame as an ellipse: 64.
protected static int FRAME_GEOMETRY_RECTANGLE_CORNER_SLICES
          The number of slices used to display each of a rectangular balloon frame's rounded corners: 16.
protected  AbstractBrowserBalloon.FrameGeometryInfo frameInfo
          The balloon geometry vertices passed to OpenGL.
protected  long frameTimeStamp
          Identifies the frame used to calculate the balloon's active attributes and points.
protected  long geomTimeStamp
          Identifies the frame used to calculate the balloon's geometry.
protected  Point lastPickPoint
          The screen coordinate of the last SelectEvent sent to this balloon's select method.
protected  OGLStackHandler osh
          Support for setting up and restoring OpenGL state during rendering.
protected  int outlinePickWidth
          The line width used to draw the the balloon's outline during picking.
protected  Layer pickLayer
          The layer active during the most recent pick pass.
protected  PickSupport pickSupport
          Support for setting up and restoring picking state, and resolving the picked object.
protected  Object resourceResolver
          Indicates the object used to resolve relative resource paths in this browser balloon's HTML content.
protected  Rectangle screenExtent
          The extent of the balloon's geometry in the viewport (on the screen).
protected  Point screenOffset
          The location of the balloon's content frame relative to the balloon's screen point in the viewport.
protected  Rectangle screenPickExtent
          The extend of the balloon's pickable geometry in the viewport (on the screen).
protected  Rectangle screenRect
          The location and size of the balloon's content frame in the viewport (on the screen).
protected  long textUpdateTime
          Identifies the time when the balloon text was updated.
protected  String visibilityAction
          Action that will occur when the balloon is made invisible.
protected  WebView webView
          Interface for interacting with the operating system's web browser control.
protected  Dimension webViewContentSize
          The size of the WebView's HTML content size, in pixels.
protected  boolean webViewCreationFailed
          Denotes whether or not an attempt at WebView creation failed.
protected  Rectangle webViewRect
          The location and size of the WebView's content frame in the viewport (on the screen).
protected  long webViewTimeStamp
          Identifies the frame used to update the WebView's state.
 
Fields inherited from class gov.nasa.worldwind.render.AbstractBalloon
activeAttributes, alwaysOnTop, attributes, defaultAttributes, delegateOwner, highlightAttributes, highlighted, maxActiveAltitude, minActiveAltitude, pickEnabled, text, textDecoder, visible
 
Constructor Summary
protected AbstractBrowserBalloon(String text)
           
 
Method Summary
 void addAllBrowserControls(Iterable<? extends AbstractBrowserBalloon.BrowserControl> iterable)
           
 void addBrowserControl(AbstractBrowserBalloon.BrowserControl browserControl)
           
 AbstractBrowserBalloon.BrowserControl addBrowserControl(String action, Offset offset, Object imageSource)
           
 AbstractBrowserBalloon.BrowserControl addBrowserControl(String action, Offset offset, Size size, Object imageSource)
           
protected  void beginDrawing(DrawContext dc)
           
protected  boolean bindWebViewTexture(DrawContext dc)
           
protected abstract  void computeBalloonPoints(DrawContext dc)
          Computes and stores the balloon's model-coordinate and screen-coordinate points.
protected  Rectangle computeFramePickRect(Rectangle frameRect)
           
protected  Rectangle computeFrameRectForWebViewRect(BalloonAttributes activeAttrs, Rectangle webViewRect)
           
protected  void computeGeometry()
          Updates the balloon's screen-coordinate geometry in frameInfo according to the current screen bounds, screen offset, and active attributes.
protected  Point computeOffset(DrawContext dc, BalloonAttributes activeAttrs, int width, int height)
           
protected  double computeOutlinePickWidth()
          Computes the line width to use during picking (in pixels).
protected  Dimension computeSize(DrawContext dc, BalloonAttributes activeAttrs)
          Computes the size of this balloon's frame in the viewport (on the screen).
protected  Rectangle computeWebViewRectForFrameRect(BalloonAttributes activeAttrs, Rectangle frameRect)
           
protected  Point convertToWebView(Object context, Point point)
          Converts the specified screen point from AWT coordinates to local WebView coordinates.
protected static List<AbstractBrowserBalloon.BrowserControl> createDefaultBrowserControls()
          Returns a list containing the browser balloon's three default browser controls, configured as follows:

ControlActionOffsetSizeImage Source CloseAVKey.CLOSE(30, 25) pixels inset from the balloon's upper right cornerImage source's native size in pixels (16x16)images/browser-close-16x16.gif BackAVKey.BACK(15, 25) pixels inset from the balloon's upper left cornerImage source's native size in pixels (16x16)images/browser-back-16x16.gif ForwardAVKey.FORWARD(35, 25) pixels inset from the balloon's upper left cornerImage source's native size in pixels (16x16)images/browser-forward-16x16.gif

protected  FloatBuffer createFrameVertices()
          Creates the balloon's frame vertex buffer according to the active attributes.
protected  PickedObject createLinkPickedObject(DrawContext dc, Color pickColor, AVList linkParams)
           
protected  PickedObject createPickedObject(DrawContext dc, Color pickColor)
           
protected  void determineWebViewContentSize()
           
 void dispose()
          Disposes the balloon's internal WebView.
protected  void disposeWebView()
           
protected  void doDrawOrderedRenderable(DrawContext dc)
           
protected  void drawBrowserControl(DrawContext dc, AbstractBrowserBalloon.BrowserControl control)
           
protected  void drawBrowserControls(DrawContext dc)
           
protected  void drawFrame(DrawContext dc)
           
protected  void drawFrameInterior(DrawContext dc)
          Draws this browser balloon's interior geometry in screen-coordinates, with the WebView's texture representation applied as an OpenGL decal.
protected  void drawFrameOutline(DrawContext dc)
           
protected  void drawLinks(DrawContext dc)
           
protected  void drawOrderedRenderable(DrawContext dc)
           
protected  void drawResizeControl(DrawContext dc)
          Draw pickable regions for the resize controls.
protected  void drawTitleBar(DrawContext dc)
           
protected  void drawWebViewLinks(DrawContext dc)
           
protected  void endDrawing(DrawContext dc)
           
 Rectangle getBounds(DrawContext dc)
          Get the balloon bounding Rectangle using OGL coordinates - bottom-left corner x and y relative to the WorldWindow bottom-left corner, and the balloon callout width and height.
 Iterable<AbstractBrowserBalloon.BrowserControl> getBrowserControls()
           
 Cursor getCursor()
          Returns a null Cursor, indicating the default cursor should be used when the BrowserBalloon is active.
 double getDistanceFromEye()
          Returns the ordered renderable's distance from the current view's eye point.
 int getOutlinePickWidth()
          Indicates the outline line width (in pixels) used during picking.
 Object getResourceResolver()
          Indicates the object used to resolve relative resource paths in this browser balloon's HTML content.
 String getVisibilityAction()
          Indicates the the action that occurs when the BrowserBalloon is set to invisible.
 void goBack()
          Navigate the browser to the previous page in the browsing history.
 void goForward()
          Navigate the browser to the next page in the browsing history.
protected  void handleKeyEvent(KeyEvent event)
          Sends the specified KeyEvent to the balloon's internal WebView.
protected  void handleMouseEvent(MouseEvent event)
          Sends the specified MouseEvent to the balloon's internal WebView.
protected  void handleSelectEvent(SelectEvent event)
          Sends the specified SelectEvent to the balloon's internal WebView.
protected  boolean intersectsFrustum(DrawContext dc)
          Determines whether the balloon intersects the view frustum.
 boolean isActive()
          Indicates whether or not this HotSpot is active.
 boolean isDrawBrowserControls()
           
protected  boolean isDrawBrowserControls(DrawContext dc)
           
protected  boolean isDrawInterior(DrawContext dc)
           
protected  boolean isDrawLinks(DrawContext dc)
           
protected  boolean isDrawOutline(DrawContext dc)
           
 boolean isDrawResizeControl()
           
protected  boolean isDrawResizeControl(DrawContext dc)
           
 boolean isDrawTitleBar()
           
protected  boolean isDrawTitleBar(DrawContext dc)
           
 void keyPressed(KeyEvent event)
          Forwards the key pressed event to the balloon's internal WebView and consumes the event.
 void keyReleased(KeyEvent event)
          Forwards the key released event to the balloon's internal WebView and consumes the event.
 void keyTyped(KeyEvent event)
          Forwards the key typed event to the balloon's internal WebView and consumes the event.
protected  FloatBuffer makeDefaultFrameVertices()
           
protected  FloatBuffer makeEllipseFrameVertices()
           
protected  void makeOrderedRenderable(DrawContext dc)
          Updates the balloon's per-frame rendering state, and determines whether to queue an ordered renderable for the balloon.
protected  FloatBuffer makeRectangleFrameVertices()
           
protected  void makeWebView(DrawContext dc, Dimension frameSize)
           
 void mouseClicked(MouseEvent event)
          Does nothing; BrowserBalloon handles mouse clicked events in selected.
 void mouseDragged(MouseEvent event)
          Does nothing; BrowserBalloon handles mouse dragged events in selected.
 void mouseEntered(MouseEvent event)
          Does nothing; BrowserBalloon does not handle mouse entered events.
 void mouseExited(MouseEvent event)
          Does nothing; BrowserBalloon does not handle mouse exited events.
 void mouseMoved(MouseEvent event)
          Forwards the mouse moved event to the balloon's internal WebView.
 void mousePressed(MouseEvent event)
          Does nothing; BrowserBalloon handles mouse pressed events in selected.
 void mouseReleased(MouseEvent event)
          Does nothing; BrowserBalloon handles mouse released events in selected.
 void mouseWheelMoved(MouseWheelEvent event)
          Forwards the mouse wheel event to the balloon's internal WebView and consumes the event.
protected  boolean mustRegenerateGeometry()
          Indicates whether this balloon's screen-coordinate geometry must be recomputed as a result of a balloon attribute changing.
 void pick(DrawContext dc, Point pickPoint)
          Executes a pick of the ordered renderable.
protected  void prepareToDrawInterior(DrawContext dc)
           
protected  void prepareToDrawOutline(DrawContext dc)
           
 void propertyChange(PropertyChangeEvent propertyChangeEvent)
          The property change listener for this instance.
 void removeAllBrowserControls()
           
 void removeBrowserControl(AbstractBrowserBalloon.BrowserControl browserControl)
           
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void selected(SelectEvent event)
          Forwards the MouseEvent associated with the specified event to the balloon's internal WebView.
 void setActive(boolean active)
          Called when this HotSpot is activated or deactivated.
 void setDrawBrowserControls(boolean draw)
           
 void setDrawResizeControl(boolean draw)
           
 void setDrawTitleBar(boolean draw)
           
 void setOutlinePickWidth(int width)
          Specifies the outline line width (in pixels) to use during picking.
 void setResourceResolver(Object resourceResolver)
          Specifies a the object to use when resolving relative resource paths in this browser balloon's HTML content.
protected abstract  void setupDepthTest(DrawContext dc)
           
 void setVisibilityAction(String visibilityAction)
          Specifies the action that occurs when this balloon is set to invisible.
 void setVisible(boolean visible)
          Set whether the balloon is visible and should be rendered.
protected  void setWebViewContent()
           
protected  void updateRenderState(DrawContext dc)
           
protected  void updateRenderStateIfNeeded(DrawContext dc)
          Update the balloon's active attributes and points, if that hasn't already been done this frame.
protected  void updateWebView(DrawContext dc)
           
 
Methods inherited from class gov.nasa.worldwind.render.AbstractBalloon
determineActiveAttributes, getActiveAttributes, getAttributes, getDecodedText, getDelegateOwner, getHighlightAttributes, getMaxActiveAltitude, getMinActiveAltitude, getText, getTextDecoder, isAlwaysOnTop, isHighlighted, isPickEnabled, isVisible, setAlwaysOnTop, setAttributes, setDelegateOwner, setHighlightAttributes, setHighlighted, setMaxActiveAltitude, setMinActiveAltitude, setPickEnabled, setText, setTextDecoder
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

browserControls

protected List<AbstractBrowserBalloon.BrowserControl> browserControls

DEFAULT_NATIVE_SIZE

protected static final Dimension DEFAULT_NATIVE_SIZE
The browser balloon's default native size: 400x300. This default size is used when a balloon's size is configured to use a native dimension, but the WebView either has not been created or its content size is not known. This default chosen to minimize the popping effect when the balloon's size switches from the default to the WebView's content size.


DEFAULT_OUTLINE_PICK_WIDTH

protected static final int DEFAULT_OUTLINE_PICK_WIDTH
The default outline pick width in pixels. The default is 10 pixels, the maximum OpenGL line width supported by most graphics cards.

See Also:
Constant Field Values

DEFAULT_WEB_VIEW_FACTORY

protected static final String DEFAULT_WEB_VIEW_FACTORY
The class name of the default WebViewFactory used to create the balloon's internal WebView. This factory is used when the configuration does not specify a WebView factory.


drawBrowserControls

protected boolean drawBrowserControls

drawResizeControl

protected boolean drawResizeControl

drawTitleBar

protected boolean drawTitleBar

eyeDistance

protected double eyeDistance
Used to order the balloon as an ordered renderable.


FRAME_GEOMETRY_ELLIPSE_SLICES

protected static final int FRAME_GEOMETRY_ELLIPSE_SLICES
The number of slices used to display a balloon frame as an ellipse: 64.

See Also:
Constant Field Values

FRAME_GEOMETRY_RECTANGLE_CORNER_SLICES

protected static final int FRAME_GEOMETRY_RECTANGLE_CORNER_SLICES
The number of slices used to display each of a rectangular balloon frame's rounded corners: 16.

See Also:
Constant Field Values

frameInfo

protected AbstractBrowserBalloon.FrameGeometryInfo frameInfo
The balloon geometry vertices passed to OpenGL.


frameTimeStamp

protected long frameTimeStamp
Identifies the frame used to calculate the balloon's active attributes and points.


geomTimeStamp

protected long geomTimeStamp
Identifies the frame used to calculate the balloon's geometry.


lastPickPoint

protected Point lastPickPoint
The screen coordinate of the last SelectEvent sent to this balloon's select method.


osh

protected OGLStackHandler osh
Support for setting up and restoring OpenGL state during rendering.


outlinePickWidth

protected int outlinePickWidth
The line width used to draw the the balloon's outline during picking. Initially set to DEFAULT_OUTLINE_PICK_WIDTH.


pickLayer

protected Layer pickLayer
The layer active during the most recent pick pass.


pickSupport

protected PickSupport pickSupport
Support for setting up and restoring picking state, and resolving the picked object.


resourceResolver

protected Object resourceResolver
Indicates the object used to resolve relative resource paths in this browser balloon's HTML content. May be one of the following: WebResourceResolver, URL, String containing a valid URL description, or null to specify that relative paths should be interpreted as unresolved references. Initially null.


screenExtent

protected Rectangle screenExtent
The extent of the balloon's geometry in the viewport (on the screen).


screenOffset

protected Point screenOffset
The location of the balloon's content frame relative to the balloon's screen point in the viewport.


screenPickExtent

protected Rectangle screenPickExtent
The extend of the balloon's pickable geometry in the viewport (on the screen). Includes this balloon's outline where it exceeds the screen extent.


screenRect

protected Rectangle screenRect
The location and size of the balloon's content frame in the viewport (on the screen).


textUpdateTime

protected long textUpdateTime
Identifies the time when the balloon text was updated. Initially -1.


visibilityAction

protected String visibilityAction
Action that will occur when the balloon is made invisible.


webView

protected WebView webView
Interface for interacting with the operating system's web browser control. Initially null.


webViewContentSize

protected Dimension webViewContentSize
The size of the WebView's HTML content size, in pixels. This is the size that the WebView can be displayed at without the need for scroll bars. May be null or (0, 0), indicating that the WebView's HTML content size is unknown. Initially null.


webViewCreationFailed

protected boolean webViewCreationFailed
Denotes whether or not an attempt at WebView creation failed. When true the balloon does not perform subsequent attempts to create the WebView. Initially false.


webViewRect

protected Rectangle webViewRect
The location and size of the WebView's content frame in the viewport (on the screen).


webViewTimeStamp

protected long webViewTimeStamp
Identifies the frame used to update the WebView's state.

Constructor Detail

AbstractBrowserBalloon

protected AbstractBrowserBalloon(String text)
Method Detail

addAllBrowserControls

public void addAllBrowserControls(Iterable<? extends AbstractBrowserBalloon.BrowserControl> iterable)

addBrowserControl

public void addBrowserControl(AbstractBrowserBalloon.BrowserControl browserControl)

addBrowserControl

public AbstractBrowserBalloon.BrowserControl addBrowserControl(String action,
                                                               Offset offset,
                                                               Object imageSource)

addBrowserControl

public AbstractBrowserBalloon.BrowserControl addBrowserControl(String action,
                                                               Offset offset,
                                                               Size size,
                                                               Object imageSource)

beginDrawing

protected void beginDrawing(DrawContext dc)

bindWebViewTexture

protected boolean bindWebViewTexture(DrawContext dc)

computeBalloonPoints

protected abstract void computeBalloonPoints(DrawContext dc)
Computes and stores the balloon's model-coordinate and screen-coordinate points.

Parameters:
dc - the current draw context.

computeFramePickRect

protected Rectangle computeFramePickRect(Rectangle frameRect)

computeFrameRectForWebViewRect

protected Rectangle computeFrameRectForWebViewRect(BalloonAttributes activeAttrs,
                                                   Rectangle webViewRect)

computeGeometry

protected void computeGeometry()
Updates the balloon's screen-coordinate geometry in frameInfo according to the current screen bounds, screen offset, and active attributes.


computeOffset

protected Point computeOffset(DrawContext dc,
                              BalloonAttributes activeAttrs,
                              int width,
                              int height)

computeOutlinePickWidth

protected double computeOutlinePickWidth()
Computes the line width to use during picking (in pixels). Returns the larger of this balloon's outline width and its outlinePickWidth.

Returns:
the line width to use during picking, in pixels.

computeSize

protected Dimension computeSize(DrawContext dc,
                                BalloonAttributes activeAttrs)
Computes the size of this balloon's frame in the viewport (on the screen). If this balloon's maximum size is not null, the returned size is no larger than the maximum size.

Parameters:
dc - the current draw context.
activeAttrs - the attributes used to compute the balloon's size.
Returns:
this balloon frame's screen size, in pixels.

computeWebViewRectForFrameRect

protected Rectangle computeWebViewRectForFrameRect(BalloonAttributes activeAttrs,
                                                   Rectangle frameRect)

convertToWebView

protected Point convertToWebView(Object context,
                                 Point point)
Converts the specified screen point from AWT coordinates to local WebView coordinates.

Parameters:
point - The point to convert.
context - the component who's coordinate system the point is in.
Returns:
A new Point in the WebView's local coordinate system.

createDefaultBrowserControls

protected static List<AbstractBrowserBalloon.BrowserControl> createDefaultBrowserControls()
Returns a list containing the browser balloon's three default browser controls, configured as follows:

ControlActionOffsetSizeImage Source
CloseAVKey.CLOSE(30, 25) pixels inset from the balloon's upper right cornerImage source's native size in pixels (16x16)images/browser-close-16x16.gif
BackAVKey.BACK(15, 25) pixels inset from the balloon's upper left cornerImage source's native size in pixels (16x16)images/browser-back-16x16.gif
ForwardAVKey.FORWARD(35, 25) pixels inset from the balloon's upper left cornerImage source's native size in pixels (16x16)images/browser-forward-16x16.gif

Returns:
a list containing the browser balloon's default browser controls.

createFrameVertices

protected FloatBuffer createFrameVertices()
Creates the balloon's frame vertex buffer according to the active attributes.

Returns:
a buffer containing the frame's x and y locations.

createLinkPickedObject

protected PickedObject createLinkPickedObject(DrawContext dc,
                                              Color pickColor,
                                              AVList linkParams)

createPickedObject

protected PickedObject createPickedObject(DrawContext dc,
                                          Color pickColor)

determineWebViewContentSize

protected void determineWebViewContentSize()

dispose

public void dispose()
Disposes the balloon's internal WebView. This does nothing if the balloon is already disposed.

Specified by:
dispose in interface Disposable

disposeWebView

protected void disposeWebView()

doDrawOrderedRenderable

protected void doDrawOrderedRenderable(DrawContext dc)

drawBrowserControl

protected void drawBrowserControl(DrawContext dc,
                                  AbstractBrowserBalloon.BrowserControl control)

drawBrowserControls

protected void drawBrowserControls(DrawContext dc)

drawFrame

protected void drawFrame(DrawContext dc)

drawFrameInterior

protected void drawFrameInterior(DrawContext dc)
Draws this browser balloon's interior geometry in screen-coordinates, with the WebView's texture representation applied as an OpenGL decal. OpenGL's texture decal mode uses the texture color where the texture's alpha is 1, and uses the balloon's background color where it's 0. The texture's internal format must be RGBA to work correctly, and this assumes that the WebView's texture format is RGBA.

If the WebView's texture cannot be created or cannot be applied for any reason, this displays the balloon's interior geometry in the balloon's background color without applying the WebView's texture.

If the specified draw context is in picking mode, this draws the balloon's interior geometry in the current color and does not apply the WebView's texture.

Parameters:
dc - the current draw context.

drawFrameOutline

protected void drawFrameOutline(DrawContext dc)

drawLinks

protected void drawLinks(DrawContext dc)

drawOrderedRenderable

protected void drawOrderedRenderable(DrawContext dc)

drawResizeControl

protected void drawResizeControl(DrawContext dc)
Draw pickable regions for the resize controls. A pickable region is drawn along the frame outline.

Parameters:
dc - Draw context.

drawTitleBar

protected void drawTitleBar(DrawContext dc)

drawWebViewLinks

protected void drawWebViewLinks(DrawContext dc)

endDrawing

protected void endDrawing(DrawContext dc)

getBounds

public Rectangle getBounds(DrawContext dc)
Get the balloon bounding Rectangle using OGL coordinates - bottom-left corner x and y relative to the WorldWindow bottom-left corner, and the balloon callout width and height.

The balloon offset from it's reference point is factored in such that the callout leader shape and reference point are included in the bounding rectangle.

Specified by:
getBounds in interface Balloon
Parameters:
dc - the current DrawContext.
Returns:
the balloon bounding Rectangle using OGL viewport coordinates.

getBrowserControls

public Iterable<AbstractBrowserBalloon.BrowserControl> getBrowserControls()

getCursor

public Cursor getCursor()
Returns a null Cursor, indicating the default cursor should be used when the BrowserBalloon is active. The Cursor is set by the WebView in response to mouse moved events.

Specified by:
getCursor in interface HotSpot
Returns:
A null Cursor.

getDistanceFromEye

public double getDistanceFromEye()
Description copied from interface: OrderedRenderable
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.

Specified by:
getDistanceFromEye in interface OrderedRenderable
Returns:
the distance of the ordered renderable from the current view's eye point.

getOutlinePickWidth

public int getOutlinePickWidth()
Indicates the outline line width (in pixels) used during picking. A larger width than normal typically makes the outline easier to pick.

Returns:
the outline line width (in pixels) used during picking.
See Also:
setOutlinePickWidth(int)

getResourceResolver

public Object getResourceResolver()
Indicates the object used to resolve relative resource paths in this browser balloon's HTML content.

Returns:
the object used to resolve relative resource paths in HTML content. One of the following: WebResourceResolver, URL, String containing a valid URL description, or null to indicate that relative paths are interpreted as unresolved references.
See Also:
setResourceResolver(Object)

getVisibilityAction

public String getVisibilityAction()
Indicates the the action that occurs when the BrowserBalloon is set to invisible. See setVisibilityAction for a description of the possible actions.

Returns:
A string that indicates the action that will occur when the balloon is set to invisible.
See Also:
setVisibilityAction(String), setVisible(boolean)

goBack

public void goBack()
Navigate the browser to the previous page in the browsing history. Has no effect if there is previous page.


goForward

public void goForward()
Navigate the browser to the next page in the browsing history. Has no effect if there is no next page.


handleKeyEvent

protected void handleKeyEvent(KeyEvent event)
Sends the specified KeyEvent to the balloon's internal WebView.

This does nothing if the balloon's internal WebView is uninitialized.

Parameters:
event - the event to send.

handleMouseEvent

protected void handleMouseEvent(MouseEvent event)
Sends the specified MouseEvent to the balloon's internal WebView. The event's point is converted from AWT coordinates to the WebView's local coordinate system.

This does nothing if the balloon's internal WebView is uninitialized.

Parameters:
event - the event to send.

handleSelectEvent

protected void handleSelectEvent(SelectEvent event)
Sends the specified SelectEvent to the balloon's internal WebView. The event's pickPoint is converted from AWT coordinates to the WebView's local coordinate system.

Parameters:
event - the event to send.

intersectsFrustum

protected boolean intersectsFrustum(DrawContext dc)
Determines whether the balloon intersects the view frustum.

Parameters:
dc - the current draw context.
Returns:
true If the balloon intersects the frustum, otherwise false.

isActive

public boolean isActive()
Indicates whether or not this HotSpot is active.

Specified by:
isActive in interface HotSpot
Returns:
true if this HotSpot is active, false if not.

isDrawBrowserControls

public boolean isDrawBrowserControls()

isDrawBrowserControls

protected boolean isDrawBrowserControls(DrawContext dc)

isDrawInterior

protected boolean isDrawInterior(DrawContext dc)

isDrawLinks

protected boolean isDrawLinks(DrawContext dc)

isDrawOutline

protected boolean isDrawOutline(DrawContext dc)

isDrawResizeControl

public boolean isDrawResizeControl()

isDrawResizeControl

protected boolean isDrawResizeControl(DrawContext dc)

isDrawTitleBar

public boolean isDrawTitleBar()

isDrawTitleBar

protected boolean isDrawTitleBar(DrawContext dc)

keyPressed

public void keyPressed(KeyEvent event)
Forwards the key pressed event to the balloon's internal WebView and consumes the event. This consumes the event so the View doesn't respond to it. The

Specified by:
keyPressed in interface HotSpot
Specified by:
keyPressed in interface KeyListener
Parameters:
event - The event to forward.

keyReleased

public void keyReleased(KeyEvent event)
Forwards the key released event to the balloon's internal WebView and consumes the event. This consumes the event so the View doesn't respond to it.

Specified by:
keyReleased in interface HotSpot
Specified by:
keyReleased in interface KeyListener
Parameters:
event - The event to forward.

keyTyped

public void keyTyped(KeyEvent event)
Forwards the key typed event to the balloon's internal WebView and consumes the event. This consumes the event so the View doesn't respond to it.

Specified by:
keyTyped in interface HotSpot
Specified by:
keyTyped in interface KeyListener
Parameters:
event - The event to forward.

makeDefaultFrameVertices

protected FloatBuffer makeDefaultFrameVertices()

makeEllipseFrameVertices

protected FloatBuffer makeEllipseFrameVertices()

makeOrderedRenderable

protected void makeOrderedRenderable(DrawContext dc)
Updates the balloon's per-frame rendering state, and determines whether to queue an ordered renderable for the balloon. This queues an ordered renderable if the balloon intersects the current viewing frustum, and if the balloon's internal rendering state can be computed. This updates the balloon's rendering state by calling updateRenderStateIfNeeded, and updates its geometry by calling computeGeometry.

BrowserBalloon separates render state updates from geometry updates for two reasons:

Parameters:
dc - the current draw context.

makeRectangleFrameVertices

protected FloatBuffer makeRectangleFrameVertices()

makeWebView

protected void makeWebView(DrawContext dc,
                           Dimension frameSize)

mouseClicked

public void mouseClicked(MouseEvent event)
Does nothing; BrowserBalloon handles mouse clicked events in selected.

Specified by:
mouseClicked in interface HotSpot
Specified by:
mouseClicked in interface MouseListener
Parameters:
event - The event to handle.

mouseDragged

public void mouseDragged(MouseEvent event)
Does nothing; BrowserBalloon handles mouse dragged events in selected.

Specified by:
mouseDragged in interface HotSpot
Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
event - The event to handle.

mouseEntered

public void mouseEntered(MouseEvent event)
Does nothing; BrowserBalloon does not handle mouse entered events.

Specified by:
mouseEntered in interface HotSpot
Specified by:
mouseEntered in interface MouseListener
Parameters:
event - The event to handle.

mouseExited

public void mouseExited(MouseEvent event)
Does nothing; BrowserBalloon does not handle mouse exited events.

Specified by:
mouseExited in interface HotSpot
Specified by:
mouseExited in interface MouseListener
Parameters:
event - The event to handle.

mouseMoved

public void mouseMoved(MouseEvent event)
Forwards the mouse moved event to the balloon's internal WebView. This does not consume the event, because the InputHandler implements the policy for consuming or forwarding mouse moved events to other objects.

Unlike mouse clicked, mouse pressed, and mouse dragged events, mouse move events cannot be forwarded to the WebView via SelectEvents in selected, because mouse movement events are not selection events.

Specified by:
mouseMoved in interface HotSpot
Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
event - The event to forward.

mousePressed

public void mousePressed(MouseEvent event)
Does nothing; BrowserBalloon handles mouse pressed events in selected.

Specified by:
mousePressed in interface HotSpot
Specified by:
mousePressed in interface MouseListener
Parameters:
event - The event to handle.

mouseReleased

public void mouseReleased(MouseEvent event)
Does nothing; BrowserBalloon handles mouse released events in selected.

Specified by:
mouseReleased in interface HotSpot
Specified by:
mouseReleased in interface MouseListener
Parameters:
event - The event to handle.

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent event)
Forwards the mouse wheel event to the balloon's internal WebView and consumes the event. This consumes the event so the View doesn't respond to it.

Unlike mouse clicked, mouse pressed, and mouse dragged events, mouse wheel events cannot be forwarded to the WebView via SelectEvents in selected, because mouse wheel events are not selection events.

Specified by:
mouseWheelMoved in interface HotSpot
Specified by:
mouseWheelMoved in interface MouseWheelListener
Parameters:
event - The event to forward.

mustRegenerateGeometry

protected boolean mustRegenerateGeometry()
Indicates whether this balloon's screen-coordinate geometry must be recomputed as a result of a balloon attribute changing.

Returns:
true if this balloon's geometry must be recomputed, otherwise false.

pick

public void pick(DrawContext dc,
                 Point pickPoint)
Description copied from interface: OrderedRenderable
Executes a pick of the ordered renderable.

Specified by:
pick in interface OrderedRenderable
Parameters:
dc - the current draw context.
pickPoint - the pick point.

prepareToDrawInterior

protected void prepareToDrawInterior(DrawContext dc)

prepareToDrawOutline

protected void prepareToDrawOutline(DrawContext dc)

propertyChange

public void propertyChange(PropertyChangeEvent propertyChangeEvent)
The property change listener for this instance. Receives property change notifications that this instance has registered with other property change notifiers.

Overridden to suppress AVKey.REPAINT property change events sent by the balloon's internal WebView when isVisible returns false.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class WWObjectImpl
Parameters:
propertyChangeEvent - the event

removeAllBrowserControls

public void removeAllBrowserControls()

removeBrowserControl

public void removeBrowserControl(AbstractBrowserBalloon.BrowserControl browserControl)

render

public void render(DrawContext dc)
Description copied from interface: Renderable
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

selected

public void selected(SelectEvent event)
Forwards the MouseEvent associated with the specified event to the balloon's internal WebView. This does not consume the event, because the InputHandler implements the policy for consuming or forwarding mouse clicked events to other objects.

Specified by:
selected in interface SelectListener
Specified by:
selected in interface HotSpot
Parameters:
event - The event to handle.

setActive

public void setActive(boolean active)
Called when this HotSpot is activated or deactivated. The HotSpot only receives input events when it is active.

Specified by:
setActive in interface HotSpot
Parameters:
active - true if this HotSpot is being activated. false if this HotSpot is being deactivated.

setDrawBrowserControls

public void setDrawBrowserControls(boolean draw)

setDrawResizeControl

public void setDrawResizeControl(boolean draw)

setDrawTitleBar

public void setDrawTitleBar(boolean draw)

setOutlinePickWidth

public void setOutlinePickWidth(int width)
Specifies the outline line width (in pixels) to use during picking. The specified width must be zero or a positive integer. Specifying a pick width of zero effectively disables the picking of the balloon's outline and its resize control. A larger width than normal typically makes the outline easier to pick.

When the the balloon's resize control is enabled, the outline becomes the resize control and is drawn in the specified width. Therefore this value also controls the balloon's resize control width. If the resize control is disabled by calling setDrawResizeControl(boolean) with a value of false, this has no effect on the balloon's resize control until it is enabled.

Parameters:
width - the outline line width (in pixels) to use during picking.
Throws:
IllegalArgumentException - if width is less than zero.
See Also:
getOutlinePickWidth(), setDrawResizeControl(boolean)

setResourceResolver

public void setResourceResolver(Object resourceResolver)
Specifies a the object to use when resolving relative resource paths in this browser balloon's HTML content. The resourceResolver may be one of the following:

If the resourceResolver is null or is not one of the recognized types, this browser balloon interprets relative resource paths as unresolved references.

Parameters:
resourceResolver - the object to use when resolving relative resource paths in HTML content. May be one of the following: WebResourceResolver, URL, String containing a valid URL description, or null to specify that relative paths should be interpreted as unresolved references.
See Also:
getResourceResolver()

setupDepthTest

protected abstract void setupDepthTest(DrawContext dc)

setVisibilityAction

public void setVisibilityAction(String visibilityAction)
Specifies the action that occurs when this balloon is set to invisible. Possible actions are:

Parameters:
visibilityAction - Either AVKey.VISIBILITY_ACTION_RELEASE or AVKey.VISIBILITY_ACTION_RETAIN.

setVisible

public void setVisible(boolean visible)
Set whether the balloon is visible and should be rendered.

When this balloon is set to invisible, the visibilityAction determines what happens to the native web browser that backs the balloon. By default, the browser resources are released when the balloon is not visible.

Specified by:
setVisible in interface Balloon
Overrides:
setVisible in class AbstractBalloon
Parameters:
visible - true if the balloon is visible and should be rendered.
See Also:
setVisibilityAction(String)

setWebViewContent

protected void setWebViewContent()

updateRenderState

protected void updateRenderState(DrawContext dc)

updateRenderStateIfNeeded

protected void updateRenderStateIfNeeded(DrawContext dc)
Update the balloon's active attributes and points, if that hasn't already been done this frame. This updates the balloon's rendering state as follows:

Parameters:
dc - the current draw context.

updateWebView

protected void updateWebView(DrawContext dc)

NASA World Wind