public class Media360View

  1. Object
  2. Component
  3. Container
  4. Media360View

ImplementsAnimation, Editable, Iterable<Component>, StyleListener

A 360 degree panorama viewer: renders an equirectangular image onto the inside of a sphere with drag-to-look navigation and optional gyroscope look. Works everywhere Display#isGpuSupported() is true; on platforms without a GPU backend it degrades to the standard “3D not supported” placeholder without crashing.

Mono mode fills the component; #setStereo(boolean) renders the same viewpoint side by side for cardboard-style viewers. Photo spheres are captured from a single point, so stereo intentionally uses a zero eye separation - there is no parallax information in the image to reproduce.

360 video is not supported directly because the platform has no path from media frames to GPU textures yet; #setTextureSource(TextureSource) is the extension point for dynamic content.

Media360View pano = new Media360View();
pano.setImage(EncodedImage.create("/panorama.jpg"));
form.add(BorderLayout.CENTER, pano);

Constructors

public Media360View()Creates an empty viewer; supply content with #setImage(Image) or #setTextureSource(TextureSource).

Methods

public boolean isSupported()True when the current platform provides a 3D backend.
public void setImage(Image image)Shows an equirectangular panorama image (the format produced by 360 cameras and phone panorama modes: longitude maps to X, latitude to Y).
public void setTextureSource(TextureSource source)Installs a dynamic texture source, replacing any static image.
public void setStereo(boolean stereo)Switches between a full-viewport mono view (the default) and side-by-side stereo for cardboard-style viewers.
public boolean isStereo()True when rendering side-by-side stereo.
public void setHeadTrackingEnabled(boolean enabled)Enables gyroscope look-around, composed with drag navigation.
public boolean isHeadTrackingEnabled()True when gyroscope look-around is enabled.
public float getYaw()The horizontal look angle in degrees; positive turns right.
public void setYaw(float yawDegrees)Sets the horizontal look angle in degrees.
public float getPitch()The vertical look angle in degrees, clamped so the view cannot flip over the poles; positive looks up.
public void setPitch(float pitchDegrees)Sets the vertical look angle in degrees.
public void reset()Resets the view to look straight ahead and recenters the gyroscope.
public RenderView getRenderView()The underlying render view, exposed for advanced integration.
protected void initComponent()Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state
protected void deinitialize()Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
public void pointerPressed(int x, int y)If this Component is focused, the pointer pressed event will call this method
public void pointerDragged(int x, int y)If this Component is focused, the pointer dragged event will call this method
public void pointerReleased(int x, int y)If this Component is focused, the pointer released event will call this method
protected boolean mouseWheel(WheelEvent ev)The wheel looks around, the way dragging does.

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

Media360View

public Media360View()
Creates an empty viewer; supply content with #setImage(Image) or #setTextureSource(TextureSource).

Method details

isSupported

public boolean isSupported()
True when the current platform provides a 3D backend.

setImage

public void setImage(Image image)
Shows an equirectangular panorama image (the format produced by 360 cameras and phone panorama modes: longitude maps to X, latitude to Y). Replaces any previous image or texture source.

Parameters

image Image
the panorama to display

setTextureSource

public void setTextureSource(TextureSource source)
Installs a dynamic texture source, replacing any static image. The extension point for procedural or (future) video content.

Parameters

source TextureSource
the source, or null to remove it

setStereo

public void setStereo(boolean stereo)
Switches between a full-viewport mono view (the default) and side-by-side stereo for cardboard-style viewers.

isStereo

public boolean isStereo()
True when rendering side-by-side stereo.

setHeadTrackingEnabled

public void setHeadTrackingEnabled(boolean enabled)
Enables gyroscope look-around, composed with drag navigation. When the device has no motion sensors this quietly stays drag-only.

isHeadTrackingEnabled

public boolean isHeadTrackingEnabled()
True when gyroscope look-around is enabled.

getYaw

public float getYaw()
The horizontal look angle in degrees; positive turns right.

setYaw

public void setYaw(float yawDegrees)
Sets the horizontal look angle in degrees.

getPitch

public float getPitch()
The vertical look angle in degrees, clamped so the view cannot flip over the poles; positive looks up.

setPitch

public void setPitch(float pitchDegrees)
Sets the vertical look angle in degrees. Clamped to stay off the poles.

reset

public void reset()
Resets the view to look straight ahead and recenters the gyroscope.

getRenderView

public RenderView getRenderView()
The underlying render view, exposed for advanced integration.

initComponent

protected void initComponent()
Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state

deinitialize

protected void deinitialize()
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

pointerPressed

public void pointerPressed(int x, int y)
If this Component is focused, the pointer pressed event will call this method

Parameters

x int
the pointer x coordinate
y int
the pointer y coordinate

pointerDragged

public void pointerDragged(int x, int y)
If this Component is focused, the pointer dragged event will call this method

Parameters

x int
the pointer x coordinate
y int
the pointer y coordinate

pointerReleased

public void pointerReleased(int x, int y)
If this Component is focused, the pointer released event will call this method

Parameters

x int
the pointer x coordinate
y int
the pointer y coordinate

mouseWheel

protected boolean mouseWheel(WheelEvent ev)
The wheel looks around, the way dragging does. This used to come for free: the desktop ports turned a wheel into synthetic drag events, so a panorama followed the trackpad without knowing the wheel existed. Those synthetic events are gone – they pressed and released on whatever was under the cursor – so the gesture is handled here directly, at the scale and in the directions the drag above uses.

Parameters

ev WheelEvent
the wheel event, carrying the scroll deltas in display pixels

Returns

true when this component handled the wheel and nothing else should act on it