com.threerings.miso.client
Class MisoScenePanel

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
All Implemented Interfaces:
RadialMenu.Host, FrameParticipant, MediaConstants, MediaHost, AStarPathUtil.TraversalPred, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener

public class MisoScenePanel
extends VirtualMediaPanel
implements MouseListener, MouseMotionListener, AStarPathUtil.TraversalPred, RadialMenu.Host

Renders a Miso scene for all to see.

See Also:
Serialized Form

Nested Class Summary
protected  class MisoScenePanel.PaintTileOp
          Used by paintTiles(java.awt.Graphics2D, java.awt.Rectangle).
 
Nested classes/interfaces inherited from class com.threerings.media.MediaPanel
MediaPanel.ActionSpriteHandler, 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  RadialMenu _activeMenu
          The active radial menu (or null).
protected  TileOpApplicator _applicator
           
protected  Object _armedItem
          The item that the user has clicked on with the mouse.
protected  ConcurrentHashMap<Integer,SceneBlock> _blocks
          Contains our scene blocks.
protected static RuntimeAdjust.BooleanAdjust _coordsDebug
          A debug hook that toggles debug rendering of tile coordinates.
protected  MisoContext _ctx
          Provides access to a few things.
protected  boolean _delayRepaint
          Used to avoid repaints while we don't yet have resolved all the blocks needed to render the visible view.
protected  JFrame _dframe
           
protected  DirtyItemList _dirtyItems
          The dirty sprites and objects that need to be re-painted.
protected  List<Sprite> _dirtySprites
          The working sprites list used when calculating dirty regions.
protected  ResolutionView _dpanel
           
protected  Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> _fringes
          Map of active fringe tiles.
protected  Point _hcoords
          Used to track the tile coordinates over which the mouse is hovering.
protected  DirtyItemList _hitList
          The list that we use to track and sort the items over which the mouse is hovering.
protected  List<Sprite> _hitSprites
          Used to collect the list of sprites "hit" by a particular mouse location.
protected  Object _hobject
          Info on the object that the mouse is currently hovering over.
protected  Rectangle _ibounds
          Contains the bounds of our "area of influence" in screen coords.
protected  Map<SceneObject,SceneObjectIndicator> _indicators
          Our object indicators, indexed by the object that they indicate.
protected  boolean _indicatorsLaidOut
          Have the indicators been laid out?
protected  Map<Long,BufferedImage> _masks
          Map of the masks used to calculate fringes in this scene.
protected  MisoSceneMetrics _metrics
          Contains basic scene metrics like tile width and height.
protected  MisoSceneModel _model
          The scene model to be displayed.
protected  MisoScenePanel.PaintTileOp _paintOp
          Used to paint tiles.
protected static RuntimeAdjust.BooleanAdjust _pathsDebug
          A debug hook that toggles debug rendering of sprite paths.
protected  int _pendingBlocks
          A count of blocks in the process of being resolved.
protected static RuntimeAdjust.BooleanAdjust _resolveDebug
          A debug hook that toggles the block resolution display.
protected  SceneBlockResolver _resolver
          The scene block resolver for this scene panel's context.
protected static Map<MisoContext,SceneBlockResolver> _resolvers
          Scene block resolvers shared by all scene panels in a context.
protected  RethinkOp _rethinkOp
          Used by rethink().
protected  Dimension _rsize
          Tracks the size at which we were last "rethunk".
protected  int _showFlags
          Flags indicating which features we should show in the scene.
protected  Point _tcoords
          Temporary point used for intermediate calculations.
protected static RuntimeAdjust.BooleanAdjust _traverseDebug
          A debug hook that toggles debug rendering of traversable tiles.
protected  Point _ulpos
          Contains the tile coords of our upper-left view coord.
protected  Rectangle _vibounds
          Contains the bounds of our visible "area of influence" in screen coords.
protected  Set<SceneBlock> _visiBlocks
          Used to track visible blocks that are waiting to be resolved.
protected  List<SceneObject> _vizobjs
          A list of the potentially visible objects in the scene.
protected static Composite ALPHA_FILL_TILE
          The alpha used to fill tiles for debugging purposes.
protected static Dimension DEF_RADIAL_RECT
          The default size of the "box" that defines the size of our radial menu circles.
protected static Stroke DIRTY_RECT_STROKE
          The stroke used to draw dirty rectangles.
static int SHOW_TIPS
          Show flag that indicates we should show all 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
MisoScenePanel(MisoContext ctx, MisoSceneMetrics metrics)
          Creates a blank miso scene display.
 
Method Summary
 void addNotify()
           
protected  void allBlocksFinished()
          Called to handle the proceedings once our last resolving block has been finished.
protected  void appendDirtySprite(DirtyItemList list, Sprite sprite)
          Computes the tile coordinates of the supplied sprite and appends it to the supplied dirty item list.
protected  void blockAbandoned(SceneBlock block)
          Called by the scene block if it has come up for resolution but is no longer influential.
protected  void blockFinished(SceneBlock block)
          Called whenever a block is done resolving, whether it was successfully resolved or if it was abandoned.
protected  void blockResolved(SceneBlock block)
          Called by a scene block when it has completed its resolution process.
protected  void blockResolving(SceneBlock block)
          Called by the scene block when it has started its resolution.
 boolean canTraverse(Object traverser, int tx, int ty)
          Requests to know if the specified traverser (which was provided in the call to AStarPathUtil.getPath(TraversalPred,Object,int,int,int,int,int,boolean)) can traverse the specified tile coordinate.
protected  boolean canTraverseUnresolved(Object traverser, int tx, int ty)
          Derived classes can control whether or not we consider unresolved tiles to be traversable or not.
 void centerOnTile(int tx, int ty)
          Moves the scene such that the specified tile is in the center.
protected  void changeHoverObject(Object newHover)
          Change the hover object to the new object.
 boolean checkShowFlag(int flag)
          Check to see if the specified show flag is on.
 void clearRadialMenu()
          Clears any radial menu being displayed.
protected  void clearScene()
          Clears out our old scene business.
protected static int compose(int x, int y)
          Masks off the lower 16 bits of the supplied integers and composes them into a single int.
protected  BaseTile computeFringeTile(int tx, int ty)
          Computes the fringe tile for the specified coordinate.
 void computeIndicators()
          Compute the indicators for any objects in the scene.
protected  void computeInfluentialBounds()
          Calls through to computeInfluentialBounds(Rectangle, Rectangle, Rectangle) with _vbounds, _ibounds and _vibounds.
static void computeInfluentialBounds(Rectangle visibleBounds, Rectangle influentualBounds, Rectangle visibleBlockBounds)
          Configures influentialBounds to contain the bounds of the potentially "influential" world and visibleBlockBounds to contain bounds that are used to determine which blocks should be resolved before making the view visible.
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  void dirtyIndicator(SceneObjectIndicator indic)
          Dirties the specified indicator.
 Iterator<SceneBlock> enumerateResolvedBlocks()
          Returns an iterator over all resolved SceneBlock instances.
protected  void fillTile(Graphics2D gfx, int tx, int ty, Color color)
          Fills the specified tile with the given color at 50% alpha.
protected  void fireObjectAction(ObjectActionHandler handler, SceneObject scobj, ActionEvent event)
          Called when an object or object menu item has been clicked.
protected  BaseTile getBaseTile(int tx, int ty)
          Returns the base tile for the specified tile coordinate.
 SceneBlock getBlock(int tx, int ty)
          Returns the resolved block that contains the specified tile coordinate or null if no block is resolved for that coordinate.
protected  TileSet.Colorizer getColorizer(ObjectInfo oinfo)
          Derived classes can override this method and provide a colorizer that will be used to colorize the supplied scene object when rendering.
 Component getComponent()
          If a frame participant wishes also to be actively rendered every frame rather than use passive rendering (which for Swing, at least, is hijacked when using the frame manager such that we take care of repainting dirty Swing components every frame into our off-screen buffer), it can return a component here which will have Component.paint(java.awt.Graphics) called on it once per frame with a translated but unclipped graphics object.
protected  BaseTile getFringeTile(int tx, int ty)
          Returns the fringe tile for the specified tile coordinate.
 Point getFullCoords(int x, int y)
          Converts the supplied screen coordinates to full coordinates.
protected  void getHitObjects(DirtyItemList list, int x, int y)
          Adds to the supplied dirty item list, all of the object tiles that are hit by the specified point (meaning the point is contained within their bounds and intersects a non-transparent pixel in the actual object image.
 Point getHoverCoords()
          Returns the tile coordinates of the tile over which the mouse is hovering.
 Object getHoverObject()
          Returns the top-most object over which the mouse is hovering; this may be a sprite or a SceneObject.
protected  Rectangle getInfluentialBounds()
          Returns the bounds for which all intersecting scene blocks are kept resolved.
protected  Dimension getObjectRadialSize()
          Returns the size of the rectangle around which we create an object's radial menu.
 Path getPath(Sprite sprite, int x, int y, boolean loose)
          Computes a path for the specified sprite to the specified tile coordinates.
protected  Rectangle getRadialMenuBounds(SceneObject scobj)
          Returns an appropriate set of menu bounds for the specified object.
 MisoSceneMetrics getSceneMetrics()
          Returns the scene metrics in use by this panel.
 MisoSceneModel getSceneModel()
          Returns the scene model being displayed by this panel.
 Point getScreenCoords(int x, int y)
          Converts the supplied full coordinates to screen coordinates.
 Point getTileCoords(int x, int y)
          Converts the supplied screen coordinates to tile coordinates.
protected  TileManager getTileManager()
          Returns the tile manager from which we load our tiles.
protected  Icon getTipIcon(SceneObject scobj, String action)
          Provides an icon for this tooltip, the default looks up an object action handler for the action and requests the icon from it.
protected  String getTipText(SceneObject scobj, String action)
          Derived classes can provide human readable object tips via this method.
 Rectangle getViewBounds()
          Returns the bounds of the viewport in virtual coordinates.
protected  boolean handleMousePressed(Object hobject, MouseEvent event)
          Called when the mouse is pressed over an unknown or non-existent hover object.
protected  void handleObjectPressed(SceneObject scobj, int mx, int my)
          Called when the user presses the mouse button over an object.
protected  void handleSpritePressed(Sprite sprite, int mx, int my)
          Called when the user presses the mouse button over a sprite.
protected  void hoverObjectChanged(Object oldHover, Object newHover)
          A place for subclasses to react to the hover object changing.
protected  boolean isResponsive()
          Returns true if we're responding to user input.
 void menuDeactivated(RadialMenu menu)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void paint(Graphics g)
           
protected  void paintBaseDecorations(Graphics2D gfx, Rectangle clip)
          A function where derived classes can paint things after the base tiles have been rendered but before anything else has been rendered (so that whatever is painted appears to be on the ground).
protected  void paintBetween(Graphics2D gfx, Rectangle dirty)
          Paints between the front and back layer of sprites and animations.
protected  void paintBits(Graphics2D gfx, int layer, Rectangle dirty)
          We don't want sprites rendered using the standard mechanism because we intersperse them with objects in our scene and need to manage their z-order.
protected  void paintDirtyItems(Graphics2D gfx, Rectangle clip)
          Renders the dirty sprites and objects in the scene to the given graphics context.
protected  void paintExtras(Graphics2D gfx, Rectangle clip)
          A function where derived classes can paint extra stuff while we've got the clipping region set up.
protected  void paintIndicator(Graphics2D gfx, Rectangle clip, SceneObjectIndicator tip)
          Paint the specified indicator if it intersects the clipping rectangle.
protected  void paintIndicators(Graphics2D gfx, Rectangle clip)
          Paint all the appropriate indicators for our scene objects.
protected  void paintInFront(Graphics2D gfx, Rectangle dirty)
          Paints in front of all sprites and animations.
protected  void paintTiles(Graphics2D gfx, Rectangle clip)
          Renders the base and fringe layer tiles that intersect the specified clipping rectangle.
 void pressObject(SceneObject scobj)
          Programmatically "click" a scene object.
protected  void recomputeVisible()
          Recomputes our set of visible objects and their indicators.
 void refreshScene()
          Completely invalidates our current resolved scene and re-resolves it from the ground up.
 void removeNotify()
           
 void repaintRect(int x, int y, int width, int height)
           
 void reportMemoryUsage()
          Reports the memory usage of the resolved tiles in the current scene block.
protected  int rethink()
          This is called when our view position has changed by more than one tile in any direction.
 void setBounds(int x, int y, int width, int height)
           
 void setSceneModel(MisoSceneModel model)
          Configures this display with a scene model which will immediately be resolved and displayed.
 void setShowFlags(int flags, boolean on)
          Set whether or not to highlight object tooltips (and potentially other scene entities).
protected  void showFlagsDidChange(int oldflags)
          Called when our show flags have changed.
protected  boolean skipHitObject(SceneObject scobj)
          Determines whether we should skip the specified object when compiling the list of objects under a specified point using getHitObjects(com.threerings.miso.client.DirtyItemList, int, int).
protected  boolean updateTileCoords(int sx, int sy, Point tpos)
          Converts the supplied screen coordinates into tile coordinates, writing the values into the supplied Point instance and returning true if the screen coordinates translated into a different set of tile coordinates than were already contained in the point (so that the caller can know to update a highlight, for example).
protected  void viewLocationDidChange(int dx, int dy)
          Called during our tick when we have adjusted the view location.
protected  void warnVisible(SceneBlock block, Rectangle sbounds)
          Issues a warning to the error log that the specified block became visible prior to being resolved.
 
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

SHOW_TIPS

public static final int SHOW_TIPS
Show flag that indicates we should show all tips.

See Also:
Constant Field Values

_ctx

protected MisoContext _ctx
Provides access to a few things.


_metrics

protected MisoSceneMetrics _metrics
Contains basic scene metrics like tile width and height.


_model

protected MisoSceneModel _model
The scene model to be displayed.


_rsize

protected Dimension _rsize
Tracks the size at which we were last "rethunk".


_ulpos

protected Point _ulpos
Contains the tile coords of our upper-left view coord.


_ibounds

protected Rectangle _ibounds
Contains the bounds of our "area of influence" in screen coords.


_vibounds

protected Rectangle _vibounds
Contains the bounds of our visible "area of influence" in screen coords.


_rethinkOp

protected RethinkOp _rethinkOp
Used by rethink().


_blocks

protected ConcurrentHashMap<Integer,SceneBlock> _blocks
Contains our scene blocks. See getBlock(int, int) for details.


_pendingBlocks

protected int _pendingBlocks
A count of blocks in the process of being resolved.


_visiBlocks

protected Set<SceneBlock> _visiBlocks
Used to track visible blocks that are waiting to be resolved.


_delayRepaint

protected boolean _delayRepaint
Used to avoid repaints while we don't yet have resolved all the blocks needed to render the visible view.


_vizobjs

protected List<SceneObject> _vizobjs
A list of the potentially visible objects in the scene.


_masks

protected Map<Long,BufferedImage> _masks
Map of the masks used to calculate fringes in this scene.


_fringes

protected Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> _fringes
Map of active fringe tiles. Scene blocks have hard references to fringe tiles in this map for the tiles they're using, so the blocks coming in and out of the influential bounds determines which tiles remain in the map. The map is from FringeTile to FringeTile so a fully created FringeTile can be extracted from the map using a tile that contains only what's needed for hashCode and equals: id and passability.


_dirtyItems

protected DirtyItemList _dirtyItems
The dirty sprites and objects that need to be re-painted.


_dirtySprites

protected List<Sprite> _dirtySprites
The working sprites list used when calculating dirty regions.


_paintOp

protected MisoScenePanel.PaintTileOp _paintOp
Used to paint tiles.


_tcoords

protected Point _tcoords
Temporary point used for intermediate calculations.


_hitSprites

protected List<Sprite> _hitSprites
Used to collect the list of sprites "hit" by a particular mouse location.


_hitList

protected DirtyItemList _hitList
The list that we use to track and sort the items over which the mouse is hovering.


_hobject

protected Object _hobject
Info on the object that the mouse is currently hovering over.


_armedItem

protected Object _armedItem
The item that the user has clicked on with the mouse.


_activeMenu

protected RadialMenu _activeMenu
The active radial menu (or null).


_hcoords

protected Point _hcoords
Used to track the tile coordinates over which the mouse is hovering.


_indicators

protected Map<SceneObject,SceneObjectIndicator> _indicators
Our object indicators, indexed by the object that they indicate.


_indicatorsLaidOut

protected boolean _indicatorsLaidOut
Have the indicators been laid out?


_showFlags

protected int _showFlags
Flags indicating which features we should show in the scene.


_resolver

protected SceneBlockResolver _resolver
The scene block resolver for this scene panel's context.


_resolvers

protected static Map<MisoContext,SceneBlockResolver> _resolvers
Scene block resolvers shared by all scene panels in a context.


_dframe

protected JFrame _dframe

_dpanel

protected ResolutionView _dpanel

_applicator

protected TileOpApplicator _applicator

_traverseDebug

protected static RuntimeAdjust.BooleanAdjust _traverseDebug
A debug hook that toggles debug rendering of traversable tiles.


_coordsDebug

protected static RuntimeAdjust.BooleanAdjust _coordsDebug
A debug hook that toggles debug rendering of tile coordinates.


_pathsDebug

protected static RuntimeAdjust.BooleanAdjust _pathsDebug
A debug hook that toggles debug rendering of sprite paths.


_resolveDebug

protected static RuntimeAdjust.BooleanAdjust _resolveDebug
A debug hook that toggles the block resolution display.


DIRTY_RECT_STROKE

protected static final Stroke DIRTY_RECT_STROKE
The stroke used to draw dirty rectangles.


ALPHA_FILL_TILE

protected static final Composite ALPHA_FILL_TILE
The alpha used to fill tiles for debugging purposes.


DEF_RADIAL_RECT

protected static final Dimension DEF_RADIAL_RECT
The default size of the "box" that defines the size of our radial menu circles.

Constructor Detail

MisoScenePanel

public MisoScenePanel(MisoContext ctx,
                      MisoSceneMetrics metrics)
Creates a blank miso scene display. Configure it with a scene model via setSceneModel(com.threerings.miso.data.MisoSceneModel) to cause it to display something.

Method Detail

setSceneModel

public void setSceneModel(MisoSceneModel model)
Configures this display with a scene model which will immediately be resolved and displayed.


clearScene

protected void clearScene()
Clears out our old scene business.


refreshScene

public void refreshScene()
Completely invalidates our current resolved scene and re-resolves it from the ground up.


centerOnTile

public void centerOnTile(int tx,
                         int ty)
Moves the scene such that the specified tile is in the center.


getSceneModel

public MisoSceneModel getSceneModel()
Returns the scene model being displayed by this panel. Do not modify!


getSceneMetrics

public MisoSceneMetrics getSceneMetrics()
Returns the scene metrics in use by this panel. Do not modify!


setShowFlags

public void setShowFlags(int flags,
                         boolean on)
Set whether or not to highlight object tooltips (and potentially other scene entities).


checkShowFlag

public boolean checkShowFlag(int flag)
Check to see if the specified show flag is on.


showFlagsDidChange

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


getHoverObject

public Object getHoverObject()
Returns the top-most object over which the mouse is hovering; this may be a sprite or a SceneObject.


getHoverCoords

public Point getHoverCoords()
Returns the tile coordinates of the tile over which the mouse is hovering.


enumerateResolvedBlocks

public Iterator<SceneBlock> enumerateResolvedBlocks()
Returns an iterator over all resolved SceneBlock instances.


getBlock

public SceneBlock getBlock(int tx,
                           int ty)
Returns the resolved block that contains the specified tile coordinate or null if no block is resolved for that coordinate.


getPath

public Path getPath(Sprite sprite,
                    int x,
                    int y,
                    boolean loose)
Computes a path for the specified sprite to the specified tile coordinates.

Parameters:
loose - if true, an approximate path will be returned if a complete path cannot be located. This path will navigate the sprite "legally" as far as possible and then walk the sprite in a straight line to its final destination. This is generally only useful if the the path goes "off screen".

getScreenCoords

public Point getScreenCoords(int x,
                             int y)
Converts the supplied full coordinates to screen coordinates.


getFullCoords

public Point getFullCoords(int x,
                           int y)
Converts the supplied screen coordinates to full coordinates.


getTileCoords

public Point getTileCoords(int x,
                           int y)
Converts the supplied screen coordinates to tile coordinates.


clearRadialMenu

public void clearRadialMenu()
Clears any radial menu being displayed.


reportMemoryUsage

public void reportMemoryUsage()
Reports the memory usage of the resolved tiles in the current scene block.


addNotify

public void addNotify()
Overrides:
addNotify in class JComponent

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JComponent

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

pressObject

public void pressObject(SceneObject scobj)
Programmatically "click" a scene object. This results in a call to handleObjectPressed(com.threerings.miso.client.SceneObject, int, int) with click coordinates in the center of the object.


handleSpritePressed

protected void handleSpritePressed(Sprite sprite,
                                   int mx,
                                   int my)
Called when the user presses the mouse button over a sprite.


handleObjectPressed

protected void handleObjectPressed(SceneObject scobj,
                                   int mx,
                                   int my)
Called when the user presses the mouse button over an object.


getRadialMenuBounds

protected Rectangle getRadialMenuBounds(SceneObject scobj)
Returns an appropriate set of menu bounds for the specified object. Returns a rectangle of the size specified by getObjectRadialSize() centered around the object.


getObjectRadialSize

protected Dimension getObjectRadialSize()
Returns the size of the rectangle around which we create an object's radial menu. The default is a sensible size, but derived classes may wish to tune the value to make their menus lay out in a more aestetically pleasing manner.


fireObjectAction

protected void fireObjectAction(ObjectActionHandler handler,
                                SceneObject scobj,
                                ActionEvent event)
Called when an object or object menu item has been clicked.


handleMousePressed

protected boolean handleMousePressed(Object hobject,
                                     MouseEvent event)
Called when the mouse is pressed over an unknown or non-existent hover object.

Parameters:
hobject - the hover object at the time of the mouse press or null if no hover object is active.
Returns:
true if the mouse press was handled, false if not.

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

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.


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.


canTraverse

public boolean canTraverse(Object traverser,
                           int tx,
                           int ty)
Description copied from interface: AStarPathUtil.TraversalPred
Requests to know if the specified traverser (which was provided in the call to AStarPathUtil.getPath(TraversalPred,Object,int,int,int,int,int,boolean)) can traverse the specified tile coordinate.

Specified by:
canTraverse in interface AStarPathUtil.TraversalPred

canTraverseUnresolved

protected boolean canTraverseUnresolved(Object traverser,
                                        int tx,
                                        int ty)
Derived classes can control whether or not we consider unresolved tiles to be traversable or not.


getViewBounds

public Rectangle getViewBounds()
Description copied from class: VirtualMediaPanel
Returns the bounds of the viewport in virtual coordinates. The returned rectangle must not be modified.

Specified by:
getViewBounds in interface RadialMenu.Host
Overrides:
getViewBounds in class VirtualMediaPanel

getComponent

public Component getComponent()
Description copied from interface: FrameParticipant
If a frame participant wishes also to be actively rendered every frame rather than use passive rendering (which for Swing, at least, is hijacked when using the frame manager such that we take care of repainting dirty Swing components every frame into our off-screen buffer), it can return a component here which will have Component.paint(java.awt.Graphics) called on it once per frame with a translated but unclipped graphics object.

Because clipping is expensive in terms of rectangle object allocation, frame participants are given the opportunity to do their own clipping because they are likely to want to clip to a more fine grained region than their entire bounds. If a participant does not wish to be actively rendered, it can safely return null.

Specified by:
getComponent in interface RadialMenu.Host
Specified by:
getComponent in interface FrameParticipant
Overrides:
getComponent in class MediaPanel

repaintRect

public void repaintRect(int x,
                        int y,
                        int width,
                        int height)
Specified by:
repaintRect in interface RadialMenu.Host

menuDeactivated

public void menuDeactivated(RadialMenu menu)
Specified by:
menuDeactivated in interface RadialMenu.Host

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class VirtualMediaPanel

viewLocationDidChange

protected void viewLocationDidChange(int dx,
                                     int dy)
Description copied from class: VirtualMediaPanel
Called during our tick when we have adjusted the view location. The VirtualMediaPanel._vbounds will already have been updated to reflect our new view coordinates.

Overrides:
viewLocationDidChange in class VirtualMediaPanel
Parameters:
dx - the delta scrolled in the x direction (in pixels).
dy - the delta scrolled in the y direction (in pixels).

getColorizer

protected TileSet.Colorizer getColorizer(ObjectInfo oinfo)
Derived classes can override this method and provide a colorizer that will be used to colorize the supplied scene object when rendering.


appendDirtySprite

protected void appendDirtySprite(DirtyItemList list,
                                 Sprite sprite)
Computes the tile coordinates of the supplied sprite and appends it to the supplied dirty item list.


getTileManager

protected TileManager getTileManager()
Returns the tile manager from which we load our tiles.


rethink

protected int rethink()
This is called when our view position has changed by more than one tile in any direction. Herein we do a whole crapload of stuff:

Returns:
the count of blocks pending after this rethink.

computeInfluentialBounds

protected void computeInfluentialBounds()
Calls through to computeInfluentialBounds(Rectangle, Rectangle, Rectangle) with _vbounds, _ibounds and _vibounds.


computeInfluentialBounds

public static void computeInfluentialBounds(Rectangle visibleBounds,
                                            Rectangle influentualBounds,
                                            Rectangle visibleBlockBounds)
Configures influentialBounds to contain the bounds of the potentially "influential" world and visibleBlockBounds to contain bounds that are used to determine which blocks should be resolved before making the view visible.

Everything that intersects the influential area will be resolved on the expectation that it could be scrolled into view at any time. The influential bounds should be large enough that the time between a block becoming influential and the time at which it is resolved is longer than the expected time by which it will be scrolled into view, otherwise the users will see the man behind the curtain.


getInfluentialBounds

protected Rectangle getInfluentialBounds()
Returns the bounds for which all intersecting scene blocks are kept resolved. Do not modify the rectangle returned by this method.


blockResolving

protected void blockResolving(SceneBlock block)
Called by the scene block when it has started its resolution.


blockAbandoned

protected void blockAbandoned(SceneBlock block)
Called by the scene block if it has come up for resolution but is no longer influential.


blockResolved

protected void blockResolved(SceneBlock block)
Called by a scene block when it has completed its resolution process.


blockFinished

protected void blockFinished(SceneBlock block)
Called whenever a block is done resolving, whether it was successfully resolved or if it was abandoned.


allBlocksFinished

protected void allBlocksFinished()
Called to handle the proceedings once our last resolving block has been finished.


warnVisible

protected void warnVisible(SceneBlock block,
                           Rectangle sbounds)
Issues a warning to the error log that the specified block became visible prior to being resolved. Derived classes may wish to augment or inhibit this warning.


recomputeVisible

protected void recomputeVisible()
Recomputes our set of visible objects and their indicators.


compose

protected static int compose(int x,
                             int y)
Masks off the lower 16 bits of the supplied integers and composes them into a single int.


computeIndicators

public void computeIndicators()
Compute the indicators for any objects in the scene.


getTipText

protected String getTipText(SceneObject scobj,
                            String action)
Derived classes can provide human readable object tips via this method.


getTipIcon

protected Icon getTipIcon(SceneObject scobj,
                          String action)
Provides an icon for this tooltip, the default looks up an object action handler for the action and requests the icon from it.


dirtyIndicator

protected void dirtyIndicator(SceneObjectIndicator indic)
Dirties the specified indicator.


changeHoverObject

protected void changeHoverObject(Object newHover)
Change the hover object to the new object.


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.


getHitObjects

protected void getHitObjects(DirtyItemList list,
                             int x,
                             int y)
Adds to the supplied dirty item list, all of the object tiles that are hit by the specified point (meaning the point is contained within their bounds and intersects a non-transparent pixel in the actual object image.


skipHitObject

protected boolean skipHitObject(SceneObject scobj)
Determines whether we should skip the specified object when compiling the list of objects under a specified point using getHitObjects(com.threerings.miso.client.DirtyItemList, int, int). The default implementation returns true if the object has no action.


updateTileCoords

protected boolean updateTileCoords(int sx,
                                   int sy,
                                   Point tpos)
Converts the supplied screen coordinates into tile coordinates, writing the values into the supplied Point instance and returning true if the screen coordinates translated into a different set of tile coordinates than were already contained in the point (so that the caller can know to update a highlight, for example).

Returns:
true if the tile coordinates have changed.

paint

public void paint(Graphics g)
Overrides:
paint in class MediaPanel

paintInFront

protected void paintInFront(Graphics2D gfx,
                            Rectangle dirty)
Description copied from class: MediaPanel
Paints in front of all sprites and animations. The supplied invalid rectangle should be redrawn in the supplied graphics context. Sub-classes should override this method to do the actual rendering for their display.

Overrides:
paintInFront in class MediaPanel

paintBetween

protected void paintBetween(Graphics2D gfx,
                            Rectangle dirty)
Description copied from class: MediaPanel
Paints between the front and back layer of sprites and animations. The supplied invalid rectangle should be redrawn in the supplied graphics context. Sub-classes should override this method to do the actual rendering for their display.

Overrides:
paintBetween in class MediaPanel

paintBits

protected void paintBits(Graphics2D gfx,
                         int layer,
                         Rectangle dirty)
We don't want sprites rendered using the standard mechanism because we intersperse them with objects in our scene and need to manage their z-order.

Overrides:
paintBits in class MediaPanel

paintBaseDecorations

protected void paintBaseDecorations(Graphics2D gfx,
                                    Rectangle clip)
A function where derived classes can paint things after the base tiles have been rendered but before anything else has been rendered (so that whatever is painted appears to be on the ground).


paintDirtyItems

protected void paintDirtyItems(Graphics2D gfx,
                               Rectangle clip)
Renders the dirty sprites and objects in the scene to the given graphics context.


paintExtras

protected void paintExtras(Graphics2D gfx,
                           Rectangle clip)
A function where derived classes can paint extra stuff while we've got the clipping region set up.


paintIndicators

protected void paintIndicators(Graphics2D gfx,
                               Rectangle clip)
Paint all the appropriate indicators for our scene objects.


paintIndicator

protected void paintIndicator(Graphics2D gfx,
                              Rectangle clip,
                              SceneObjectIndicator tip)
Paint the specified indicator if it intersects the clipping rectangle.


paintTiles

protected void paintTiles(Graphics2D gfx,
                          Rectangle clip)
Renders the base and fringe layer tiles that intersect the specified clipping rectangle.


fillTile

protected void fillTile(Graphics2D gfx,
                        int tx,
                        int ty,
                        Color color)
Fills the specified tile with the given color at 50% alpha. Intended for debug-only tile highlighting purposes.


getBaseTile

protected BaseTile getBaseTile(int tx,
                               int ty)
Returns the base tile for the specified tile coordinate.


getFringeTile

protected BaseTile getFringeTile(int tx,
                                 int ty)
Returns the fringe tile for the specified tile coordinate.


computeFringeTile

protected BaseTile computeFringeTile(int tx,
                                     int ty)
Computes the fringe tile for the specified coordinate.


isResponsive

protected boolean isResponsive()
Returns true if we're responding to user input. This is used to control the display of tooltips and other potential user interactions. By default we are always responsive.