/** * Gets a Region instance bounded by the given dimensions. The given bounds will be restricted * to the given bounds of this GestureRegionDirector, and null may be returned if suitable * bounds are not found or a conflicting region was already defined on this * GestureRegionDirector. */ public GestureDirector getRegion (IRectangle bounds) { if (!_bounds.intersects(bounds)) { Log.log.warning("Supplied region is not within our defined bounds", "_bounds", _bounds, "bounds", bounds); return null; } Rectangle regionBounds = _bounds.intersection(bounds); GestureDirector region = _regions.get(regionBounds); if (region != null) return region; // make sure we don't intersect any other defined regions for (Rectangle existingRegionBounds : _regions.keySet()) { if (existingRegionBounds.intersects(regionBounds)) { Log.log.warning("New region intersects existing region", "existing", existingRegionBounds, "new", regionBounds); return null; } } // new region! region = new GestureDirector(_plat, regionBounds, _timer); _regions.put(regionBounds, region); return region; }