com.threerings.miso.tile
Class AutoFringer

java.lang.Object
  extended by com.threerings.miso.tile.AutoFringer

public class AutoFringer
extends Object

Automatically fringes a scene according to the rules in the supplied fringe configuration.


Nested Class Summary
protected static class AutoFringer.FringerRec
          A record for holding information about a particular fringe as we're computing what it will look like.
static class AutoFringer.FringeTile
           
 
Field Summary
protected  FringeConfiguration _fringeconf
           
protected  CheapIntMap _fringers
           
protected  ImageManager _imgr
           
protected  TileManager _tmgr
           
protected static int[] BITS_TO_INDEX
           
protected static int EAST
           
protected static int[][] FLAGMATRIX
           
protected static int[] FRINGETILES
          The fringe tiles we use.
protected static int NORTH
           
protected static int NORTHEAST
           
protected static int NORTHWEST
           
protected static int NUM_FRINGEBITS
           
protected static int SOUTH
           
protected static int SOUTHEAST
           
protected static int SOUTHWEST
           
protected static int WEST
           
 
Constructor Summary
AutoFringer(FringeConfiguration fringeconf, ImageManager imgr, TileManager tmgr)
          Constructs an instance that will fringe according to the rules in the supplied fringe configuration.
 
Method Summary
protected  int adjustTileSetId(int tileSetId)
          Allow subclasses to apply arbitrary modifications to tileset ids for whatever nefarious purposes they may have.
protected  AutoFringer.FringeTile composeFringeTile(AutoFringer.FringerRec[] fringers, Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> fringes, int hashValue, boolean passable, Map<Long,BufferedImage> masks)
          Compose a FringeTile out of the various fringe images needed.
 FringeConfiguration getFringeConf()
          Returns the fringe configuration used by this fringer.
protected  int[] getFringeIndexes(int bits)
          Get the fringe index specified by the fringebits.
 BaseTile getFringeTile(MisoSceneModel scene, int col, int row, Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> fringes, Map<Long,BufferedImage> masks)
          Compute and return the fringe tile to be inserted at the specified location.
protected  BufferedImage getTileImage(BufferedImage img, FringeConfiguration.FringeTileSetRecord tsr, int baseset, int index, int hashValue, Map<Long,BufferedImage> masks)
          Retrieve or compose an image for the specified fringe.
protected  BufferedImage stampTileImage(Object stamp, BufferedImage ftimg, int width, int height)
          Helper function for getTileImage(java.awt.image.BufferedImage, com.threerings.miso.tile.FringeConfiguration.FringeTileSetRecord, int, int, int, java.util.Map).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

protected static final int NORTH
See Also:
Constant Field Values

NORTHEAST

protected static final int NORTHEAST
See Also:
Constant Field Values

EAST

protected static final int EAST
See Also:
Constant Field Values

SOUTHEAST

protected static final int SOUTHEAST
See Also:
Constant Field Values

SOUTH

protected static final int SOUTH
See Also:
Constant Field Values

SOUTHWEST

protected static final int SOUTHWEST
See Also:
Constant Field Values

WEST

protected static final int WEST
See Also:
Constant Field Values

NORTHWEST

protected static final int NORTHWEST
See Also:
Constant Field Values

NUM_FRINGEBITS

protected static final int NUM_FRINGEBITS
See Also:
Constant Field Values

FLAGMATRIX

protected static final int[][] FLAGMATRIX

FRINGETILES

protected static final int[] FRINGETILES
The fringe tiles we use. These are the 17 possible tiles made up of continuous fringebits sections. Huh? see docs/miso/fringebits.png


BITS_TO_INDEX

protected static final int[] BITS_TO_INDEX

_imgr

protected ImageManager _imgr

_tmgr

protected TileManager _tmgr

_fringeconf

protected FringeConfiguration _fringeconf

_fringers

protected CheapIntMap _fringers
Constructor Detail

AutoFringer

public AutoFringer(FringeConfiguration fringeconf,
                   ImageManager imgr,
                   TileManager tmgr)
Constructs an instance that will fringe according to the rules in the supplied fringe configuration.

Method Detail

getFringeConf

public FringeConfiguration getFringeConf()
Returns the fringe configuration used by this fringer.


getFringeTile

public BaseTile getFringeTile(MisoSceneModel scene,
                              int col,
                              int row,
                              Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> fringes,
                              Map<Long,BufferedImage> masks)
Compute and return the fringe tile to be inserted at the specified location.


composeFringeTile

protected AutoFringer.FringeTile composeFringeTile(AutoFringer.FringerRec[] fringers,
                                                   Map<AutoFringer.FringeTile,WeakReference<AutoFringer.FringeTile>> fringes,
                                                   int hashValue,
                                                   boolean passable,
                                                   Map<Long,BufferedImage> masks)
Compose a FringeTile out of the various fringe images needed.


getTileImage

protected BufferedImage getTileImage(BufferedImage img,
                                     FringeConfiguration.FringeTileSetRecord tsr,
                                     int baseset,
                                     int index,
                                     int hashValue,
                                     Map<Long,BufferedImage> masks)
                              throws NoSuchTileSetException
Retrieve or compose an image for the specified fringe.

Throws:
NoSuchTileSetException

stampTileImage

protected BufferedImage stampTileImage(Object stamp,
                                       BufferedImage ftimg,
                                       int width,
                                       int height)
Helper function for getTileImage(java.awt.image.BufferedImage, com.threerings.miso.tile.FringeConfiguration.FringeTileSetRecord, int, int, int, java.util.Map).


getFringeIndexes

protected int[] getFringeIndexes(int bits)
Get the fringe index specified by the fringebits. If no index is available, try breaking down the bits into contiguous regions of bits and look for indexes for those.


adjustTileSetId

protected int adjustTileSetId(int tileSetId)
Allow subclasses to apply arbitrary modifications to tileset ids for whatever nefarious purposes they may have.