# Class Region

java.lang.Object
com.codename1.gaming.level.Region

public class Region extends Object
A loadable area of a large world: its own streaming `Terrain`, placed `GameElement`s and a world-space origin (`#getOriginX()`,`#getOriginZ()` in tile units). Regions are linked to neighbours by named edges (`#link(String,String)`, e.g. "east" -> "desert-2"), so a `GameWorld` can stream the adjacent regions in and out for seamless transitions as the player crosses a boundary. A region serializes independently as its own document.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Region()`
  `Region(String id, String name)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(double worldX, double worldZ)`
  Returns true if the world point (tile units) falls inside this region's bounds; an unbounded region (width/depth 0) contains everything at/after its origin only loosely (callers use neighbor links for transitions instead).
  `List<GameElement>`
  `elements()`
  `static Region`
  `fromJson(String json)`
  `double`
  `getDepth()`
  `String`
  `getId()`
  `String`
  `getName()`
  `double`
  `getOriginX()`
  `double`
  `getOriginZ()`
  `double`
  `getWidth()`
  `Region`
  `link(String edge, String neighborRegionId)`
  Links a named edge of this region to a neighbouring region id.
  `Map<String,String>`
  `neighbors()`
  `Map<String,Object>`
  `props()`
  `Region`
  `setId(String id)`
  `Region`
  `setName(String name)`
  `Region`
  `setOrigin(double x, double z)`
  `Region`
  `setSpan(double width, double depth)`
  `Region`
  `setTerrain(StreamingTerrain terrain)`
  `StreamingTerrain`
  `terrain()`
  The region's streaming terrain (created lazily; chunk-paged so a region can be huge).
  `String`
  `toJson()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Region

    public Region()

  - ### Region

    public Region(String id, String name)

- ## Method Details

  - ### getId

    public String getId()

  - ### setId

    public Region setId(String id)

  - ### getName

    public String getName()

  - ### setName

    public Region setName(String name)

  - ### getOriginX

    public double getOriginX()

  - ### getOriginZ

    public double getOriginZ()

  - ### setOrigin

    public Region setOrigin(double x, double z)

  - ### getWidth

    public double getWidth()

  - ### getDepth

    public double getDepth()

  - ### setSpan

    public Region setSpan(double width, double depth)

  - ### terrain

    public StreamingTerrain terrain()
    The region's streaming terrain (created lazily; chunk-paged so a region can be huge).

  - ### setTerrain

    public Region setTerrain(StreamingTerrain terrain)

  - ### elements

    public List<GameElement> elements()

  - ### contains

    public boolean contains(double worldX, double worldZ)
    Returns true if the world point (tile units) falls inside this region's bounds; an unbounded region (width/depth 0) contains everything at/after its origin only loosely (callers use neighbor links for transitions instead).

  - ### link

    public Region link(String edge, String neighborRegionId)
    Links a named edge of this region to a neighbouring region id.

  - ### neighbors

    public Map<String,String> neighbors()

  - ### props

    public Map<String,Object> props()

  - ### toJson

    public String toJson()

  - ### fromJson

    public static Region fromJson(String json)