com.threerings.stage.client
Class StageScenePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.threerings.media.MediaPanel
                  extended by com.threerings.media.VirtualMediaPanel
                      extended by com.threerings.miso.client.MisoScenePanel
                          extended by com.threerings.stage.client.StageScenePanel
All Implemented Interfaces:
ControllerProvider, RadialMenu.Host, PlaceView, com.threerings.media.FrameParticipant, com.threerings.media.MediaConstants, com.threerings.media.MediaHost, com.threerings.media.util.AStarPathUtil.TraversalPred, KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
EditorScenePanel, ViewerScenePanel

public class StageScenePanel
extends com.threerings.miso.client.MisoScenePanel
implements ControllerProvider, KeyListener, PlaceView

Extends the basic Miso scene panel with Stage fun stuff like portals, clusters and locations.

See Also:
Serialized Form

Nested Class Summary
protected  class StageScenePanel.PortalObjectTile
          Used to render portals as objects in a scene.
 
Nested classes/interfaces inherited from class com.threerings.miso.client.MisoScenePanel
com.threerings.miso.client.MisoScenePanel.PaintTileOp
 
Nested classes/interfaces inherited from class com.threerings.media.MediaPanel
com.threerings.media.MediaPanel.ActionSpriteHandler, com.threerings.media.MediaPanel.Obscurer
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Map<Cluster,Shape> _clusters
          Shapes describing the clusters, indexed by cluster.
protected  Map<Cluster,Shape> _clusterWells
          Shapes describing the clusters, indexed by cluster.
protected  Controller _ctrl
          The controller with which we work in tandem.
protected  StageContext _ctx
          A reference to our client context.
protected  List<com.threerings.miso.client.SceneObject> _portobjs
          Contains scene objects for our portals.
protected  SceneColorizer _rizer
          Handles scene object colorization.
protected  StageScene _scene
          Our currently displayed scene.
static String CLUSTER_CLICKED
          An action command generated when a cluster is clicked.
protected static Color CLUSTER_COLOR
          The color used to render clusters.
protected static int CLUSTER_PAD
          The amount the stroke a cluster.
protected static int CLUSTER_SLOP
          The number of pixels outside a cluster when we assume the mouse is "over" that cluster.
protected static Stroke CLUSTER_STROKE
          The width with which to draw the cluster.
protected static Composite HIGHLIGHT_ALPHA
          Alpha level used to hightlight locations or clusters.
protected static Composite INACTIVE_PORTAL_ALPHA
          The alpha with which to render inactive portals.
static String LOCATION_CLICKED
          An action command generated when the user clicks on a location within the scene.
protected static int MAX_LOCATION_DIST
          The distance within which the mouse must be from a location in order to highlight it.
protected static int PORTAL_ICON_HEIGHT
          The height of the portal icons.
protected static int PORTAL_ICON_WIDTH
          The width of the portal icons.
static int SHOW_CLUSTERS
          Show flag that indicates we should show all clusters.
static int SHOW_PLOTS
          Show flag that indicates we should render known land plots (expensive, don't turn this on willy nilly).
protected static Composite SHOWN_ALPHA
          Alpha level used to render clusters when they're not selected.
 
Fields inherited from class com.threerings.miso.client.MisoScenePanel
_activeMenu, _applicator, _armedItem, _blocks, _coordsDebug, _delayRepaint, _dframe, _dirtyItems, _dirtySprites, _dpanel, _fringes, _hcoords, _hitList, _hitSprites, _hobject, _ibounds, _indicators, _indicatorsLaidOut, _masks, _metrics, _model, _paintOp, _pathsDebug, _pendingBlocks, _resolveDebug, _resolver, _resolvers, _rethinkOp, _rsize, _showFlags, _tcoords, _traverseDebug, _ulpos, _vibounds, _visiBlocks, _vizobjs, ALPHA_FILL_TILE, DEF_RADIAL_RECT, DIRTY_RECT_STROKE, SHOW_TIPS
 
Fields inherited from class com.threerings.media.VirtualMediaPanel
_abounds, _background, _dx, _dy, _fmode, _fpath, _nx, _ny, _trackers, _vbounds, CENTER_ON_PATHABLE, ENCLOSE_PATHABLE, TRACK_PATHABLE
 
Fields inherited from class com.threerings.media.MediaPanel
_actionHandler, _actionSpriteCount, _animmgr, _metamgr, _obscurerList, _remgr, _spritemgr, _tickPaintPending
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.threerings.media.MediaConstants
ALL, BACK, FRONT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
StageScenePanel(StageContext ctx, Controller ctrl)
          Constructs a stage scene view panel.
 
Method Summary
protected  void clusterUpdated(Cluster cluster)
          Called when a real cluster is created or updated in the scene.
protected  Object computeOverHover(int mx, int my)
          Gives derived classes a chance to compute a hover object that takes precedence over sprites and actionable objects.
protected  Object computeUnderHover(int mx, int my)
          Gives derived classes a chance to compute a hover object that is used if the mouse is not hovering over a sprite or actionable object.
protected  boolean containsPoint(Cluster cluster, int mx, int my)
          Returns true if the specified cluster contains the supplied screen coordinate.
protected  boolean defaultShowTips()
          Returns true if we should always show the object tooltips by default, false if they should only be shown while the 'Alt' key is depressed.
 void didLeavePlace(PlaceObject plobj)
           
protected  void dirtyCluster(Cluster cluster)
          Dirties the supplied cluster.
protected  void dirtyCluster(Shape shape)
          Dirties the supplied cluster rectangle.
protected  void drawCluster(Graphics2D gfx, Rectangle clip, Cluster cluster)
          Draw the cluster specified by the rectangle.
 SceneColorizer getColorizer()
          Get the tileset colorizer in use in this scene.
protected  com.threerings.media.tile.TileSet.Colorizer getColorizer(com.threerings.miso.data.ObjectInfo oinfo)
           
 Controller getController()
           
 Portal getPortal(int fullX, int fullY)
          Returns the portal at the specified full coordinates or null if no portal exists at said coordinates.
 StageScene getScene()
          Returns the scene being displayed by this panel.
protected  boolean handleMousePressed(Object hobject, MouseEvent event)
           
protected  void hoverObjectChanged(Object oldHover, Object newHover)
          A place for subclasses to react to the hover object changing.
protected  boolean isPortal(Location loc)
          Returns true if the specified location is associated with a portal.
 void keyPressed(KeyEvent e)
           
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
protected  com.threerings.media.tile.UniformTileSet loadPortalTileSet()
          Loads up the tileset used to render the portal arrows.
protected  void paintBaseDecorations(Graphics2D gfx, Rectangle clip)
           
protected  void paintClusters(Graphics2D gfx, Rectangle clip)
          Paints any visible clusters.
protected  void recomputePortals()
          Computes a set of display objects for the portals in this scene.
protected  void recomputeVisible()
           
 boolean removeCluster(int clusterOid)
          Removes the specified cluster from the view.
 void sceneUpdated(SceneUpdate update)
          Called when we have received a scene update from the server.
 void setScene(StageScene scene)
          Sets the scene managed by the panel.
protected  void showFlagsDidChange(int oldflags)
          Called when our show flags have changed.
 void updateCluster(Cluster cluster, Rectangle bounds)
          Adds or updates the specified cluster in the view.
 void willEnterPlace(PlaceObject plobj)
           
 
Methods inherited from class com.threerings.miso.client.MisoScenePanel
addNotify, allBlocksFinished, appendDirtySprite, blockAbandoned, blockFinished, blockResolved, blockResolving, canTraverse, canTraverseUnresolved, centerOnTile, changeHoverObject, checkShowFlag, clearRadialMenu, clearScene, compose, computeFringeTile, computeIndicators, computeInfluentialBounds, computeInfluentialBounds, dirtyIndicator, enumerateResolvedBlocks, fillTile, fireObjectAction, getBaseTile, getBlock, getComponent, getFringeTile, getFullCoords, getHitObjects, getHoverCoords, getHoverObject, getInfluentialBounds, getObjectRadialSize, getPath, getRadialMenuBounds, getSceneMetrics, getSceneModel, getScreenCoords, getTileCoords, getTileManager, getTipIcon, getTipText, getViewBounds, handleObjectPressed, handleSpritePressed, isResponsive, menuDeactivated, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, paintBetween, paintBits, paintDirtyItems, paintExtras, paintIndicator, paintIndicators, paintInFront, paintTiles, pressObject, refreshScene, removeNotify, repaintRect, reportMemoryUsage, rethink, setBounds, setSceneModel, setShowFlags, skipHitObject, updateTileCoords, viewLocationDidChange, warnVisible
 
Methods inherited from class com.threerings.media.VirtualMediaPanel
addObscurerDirtyRegion, addViewTracker, adjustBoundsCenter, clearPathable, constrainToBounds, didTick, dirtyScreenRect, doLayout, findRootBounds, paint, paintBehind, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeViewTracker, setBackground, setFollowsPathable, setViewLocation, trackPathable
 
Methods inherited from class com.threerings.media.MediaPanel
abortAnimation, addAnimation, addObscurer, addObscurerDirtyRegions, addSprite, clearAnimations, clearSprites, clipToDirtyRegion, createActionSpriteHandler, createGraphics, getAnimationManager, getRegionManager, getSpriteManager, getTimeStamp, isManaged, isManaged, needsPaint, paintDirtyRect, removeObscurer, removeSprite, repaint, setOpaque, setPaused, tick, willTick
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCATION_CLICKED

public static final String LOCATION_CLICKED
An action command generated when the user clicks on a location within the scene.

See Also:
Constant Field Values

CLUSTER_CLICKED

public static final String CLUSTER_CLICKED
An action command generated when a cluster is clicked.

See Also:
Constant Field Values

SHOW_CLUSTERS

public static final int SHOW_CLUSTERS
Show flag that indicates we should show all clusters.

See Also:
Constant Field Values

SHOW_PLOTS

public static final int SHOW_PLOTS
Show flag that indicates we should render known land plots (expensive, don't turn this on willy nilly).

See Also:
Constant Field Values

_ctx

protected StageContext _ctx
A reference to our client context.


_ctrl

protected Controller _ctrl
The controller with which we work in tandem.


_scene

protected StageScene _scene
Our currently displayed scene.


_portobjs

protected List<com.threerings.miso.client.SceneObject> _portobjs
Contains scene objects for our portals.


_clusters

protected Map<Cluster,Shape> _clusters
Shapes describing the clusters, indexed by cluster.


_clusterWells

protected Map<Cluster,Shape> _clusterWells
Shapes describing the clusters, indexed by cluster.


_rizer

protected SceneColorizer _rizer
Handles scene object colorization.


PORTAL_ICON_WIDTH

protected static final int PORTAL_ICON_WIDTH
The width of the portal icons.

See Also:
Constant Field Values

PORTAL_ICON_HEIGHT

protected static final int PORTAL_ICON_HEIGHT
The height of the portal icons.

See Also:
Constant Field Values

MAX_LOCATION_DIST

protected static final int MAX_LOCATION_DIST
The distance within which the mouse must be from a location in order to highlight it.

See Also:
Constant Field Values

CLUSTER_PAD

protected static final int CLUSTER_PAD
The amount the stroke a cluster.

See Also:
Constant Field Values

CLUSTER_STROKE

protected static final Stroke CLUSTER_STROKE
The width with which to draw the cluster.


CLUSTER_COLOR

protected static final Color CLUSTER_COLOR
The color used to render clusters.


HIGHLIGHT_ALPHA

protected static final Composite HIGHLIGHT_ALPHA
Alpha level used to hightlight locations or clusters.


SHOWN_ALPHA

protected static final Composite SHOWN_ALPHA
Alpha level used to render clusters when they're not selected.


INACTIVE_PORTAL_ALPHA

protected static final Composite INACTIVE_PORTAL_ALPHA
The alpha with which to render inactive portals.


CLUSTER_SLOP

protected static final int CLUSTER_SLOP
The number of pixels outside a cluster when we assume the mouse is "over" that cluster.

See Also:
Constant Field Values
Constructor Detail

StageScenePanel

public StageScenePanel(StageContext ctx,
                       Controller ctrl)
Constructs a stage scene view panel.

Method Detail

getColorizer

public SceneColorizer getColorizer()
Get the tileset colorizer in use in this scene.


getColorizer

protected com.threerings.media.tile.TileSet.Colorizer getColorizer(com.threerings.miso.data.ObjectInfo oinfo)
Overrides:
getColorizer in class com.threerings.miso.client.MisoScenePanel

getScene

public StageScene getScene()
Returns the scene being displayed by this panel. Do not modify it.


setScene

public void setScene(StageScene scene)
Sets the scene managed by the panel.


sceneUpdated

public void sceneUpdated(SceneUpdate update)
Called when we have received a scene update from the server.


recomputePortals

protected void recomputePortals()
Computes a set of display objects for the portals in this scene.


recomputeVisible

protected void recomputeVisible()
Overrides:
recomputeVisible in class com.threerings.miso.client.MisoScenePanel

getController

public Controller getController()
Specified by:
getController in interface ControllerProvider

keyPressed

public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

willEnterPlace

public void willEnterPlace(PlaceObject plobj)
Specified by:
willEnterPlace in interface PlaceView

didLeavePlace

public void didLeavePlace(PlaceObject plobj)
Specified by:
didLeavePlace in interface PlaceView

defaultShowTips

protected boolean defaultShowTips()
Returns true if we should always show the object tooltips by default, false if they should only be shown while the 'Alt' key is depressed.


keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

handleMousePressed

protected boolean handleMousePressed(Object hobject,
                                     MouseEvent event)
Overrides:
handleMousePressed in class com.threerings.miso.client.MisoScenePanel

showFlagsDidChange

protected void showFlagsDidChange(int oldflags)
Called when our show flags have changed.

Overrides:
showFlagsDidChange in class com.threerings.miso.client.MisoScenePanel

clusterUpdated

protected void clusterUpdated(Cluster cluster)
Called when a real cluster is created or updated in the scene.


updateCluster

public void updateCluster(Cluster cluster,
                          Rectangle bounds)
Adds or updates the specified cluster in the view. Metrics will be created that allow the cluster to be rendered and hovered over.

Parameters:
cluster - the cluster record to be added.
bounds - the screen coordinates that bound the occupants of the cluster.

removeCluster

public boolean removeCluster(int clusterOid)
Removes the specified cluster from the view.

Returns:
true if such a cluster existed and was removed.

hoverObjectChanged

protected void hoverObjectChanged(Object oldHover,
                                  Object newHover)
A place for subclasses to react to the hover object changing. One of the supplied arguments may be null.

Overrides:
hoverObjectChanged in class com.threerings.miso.client.MisoScenePanel

computeOverHover

protected Object computeOverHover(int mx,
                                  int my)
Gives derived classes a chance to compute a hover object that takes precedence over sprites and actionable objects. If this method returns non-null, no sprite or object hover calculations will be performed and the object returned will become the new hover object.

Overrides:
computeOverHover in class com.threerings.miso.client.MisoScenePanel

computeUnderHover

protected Object computeUnderHover(int mx,
                                   int my)
Gives derived classes a chance to compute a hover object that is used if the mouse is not hovering over a sprite or actionable object. If this method is called, it means that there are no sprites or objects under the mouse. Thus if it returns non-null, the object returned will become the new hover object.

Overrides:
computeUnderHover in class com.threerings.miso.client.MisoScenePanel

containsPoint

protected boolean containsPoint(Cluster cluster,
                                int mx,
                                int my)
Returns true if the specified cluster contains the supplied screen coordinate.


dirtyCluster

protected void dirtyCluster(Cluster cluster)
Dirties the supplied cluster.


dirtyCluster

protected void dirtyCluster(Shape shape)
Dirties the supplied cluster rectangle.


getPortal

public Portal getPortal(int fullX,
                        int fullY)
Returns the portal at the specified full coordinates or null if no portal exists at said coordinates.


paintBaseDecorations

protected void paintBaseDecorations(Graphics2D gfx,
                                    Rectangle clip)
Overrides:
paintBaseDecorations in class com.threerings.miso.client.MisoScenePanel

paintClusters

protected void paintClusters(Graphics2D gfx,
                             Rectangle clip)
Paints any visible clusters.


drawCluster

protected void drawCluster(Graphics2D gfx,
                           Rectangle clip,
                           Cluster cluster)
Draw the cluster specified by the rectangle.


isPortal

protected boolean isPortal(Location loc)
Returns true if the specified location is associated with a portal.


loadPortalTileSet

protected com.threerings.media.tile.UniformTileSet loadPortalTileSet()
Loads up the tileset used to render the portal arrows.