Class DefaultRegionChecker
- All Implemented Interfaces:
DockingConstants,RegionChecker
- Author:
- Christopher Butler
-
Field Summary
Fields inherited from interface org.flexdock.docking.DockingConstants
ACTIVE_WINDOW, BOTTOM, CENTER, CENTER_REGION, CLOSE_ACTION, DEFAULT_PERSISTENCE_KEY, DOCKING_ID, EAST_REGION, HEAVYWEIGHT_DOCKABLES, HORIZONTAL, LEFT, MOUSE_PRESSED, NORTH_REGION, PERMANENT_FOCUS_OWNER, PIN_ACTION, REGION, RIGHT, SOUTH_REGION, TOP, UNINITIALIZED, UNINITIALIZED_RATIO, UNKNOWN_REGION, UNSPECIFIED_SIBLING_PREF, VERTICAL, WEST_REGIONFields inherited from interface org.flexdock.docking.RegionChecker
DEFAULT_REGION_SIZE, DEFAULT_SIBLING_SIZE, DEFAULT_SIBLING_SIZE_KEY, MAX_REGION_SIZE, MAX_SIBILNG_SIZE, MIN_REGION_SIZE, MIN_SIBILNG_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RectanglecalculateRegionalBounds(Component c, String region, float size) protected static floatcheckBounds(float val, float max, float min) protected static floatgetDockingInset(Float value, float defaultVal, float max, float min) Returns the rectangular bounds within the specified component that represent it'sDockingConstants.EAST_REGION.Returns the rectangular bounds within the specified component that represent it'sDockingConstants.NORTH_REGION.Returns the docking region of the suppliedComponentthat contains the coordinates of the specifiedPoint.getRegionBounds(Component c, String region) Returns the boundingRectanglewithin the specified component that represents the specified region.static floatgetRegionPreference(Dockable d, String region) Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedDockable.floatgetRegionSize(Component c, String region) Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedComponent.getSiblingBounds(Component c, String region) Returns the boundingRectanglewithin the specified component that represents the desired area to be allotted for siblingComponentsin the specified region.static floatgetSiblingPreference(Dockable d, String region) Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for siblingComponentsdocked to the specified region within the specifiedDockable.floatgetSiblingSize(Component c, String region) Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for siblingComponentdocked to the specified region within the specifiedComponent.Returns the rectangular bounds within the specified component that represent it'sDockingConstants.SOUTH_REGION.Returns the rectangular bounds within the specified component that represent it'sDockingConstants.WEST_REGION.static floatvalidateRegionSize(float size) Returnssizeif it is between the valuesRegionChecker.MIN_REGION_SIZEandRegionChecker.MAX_REGION_SIZE.static floatvalidateSiblingSize(float size) Returnssizeif it is between the valuesRegionChecker.MIN_SIBILNG_SIZEandRegionChecker.MAX_SIBILNG_SIZE.
-
Constructor Details
-
DefaultRegionChecker
public DefaultRegionChecker()
-
-
Method Details
-
getRegion
Returns the docking region of the suppliedComponentthat contains the coordinates of the specifiedPoint. If eithercomporpointisnull, thenUNKNOWN_REGIONis returned. If the specifiedComponentbounds do not contain the suppliedPoint, thenUNKNOWN_REGIONis returned.This implementation assumes that
compis aComponentembedded within aDockingPort. Ifcompis itself aDockingPort, thenCENTER_REGIONis returned. Otherwise, the returned region is based upon a section of the bounds of the specifiedComponentrelative to the containingDockingPort.This method divides the specified
Component'sbounds into fourRectanglesdetermined bygetNorthRegion(Component c),getSouthRegion(Component c),getEastRegion(Component c), andgetWestRegion(Component c), respectively. EachRectangleis then checked to see if it contains the specifiedPoint. The order of precedence is NORTH, SOUTH, EAST, and then WEST. If the specifiedPointis contained by theComponentbounds but none of the sub-Rectangles, thenCENTER_REGIONis returned.For NORTH and SOUTH
Rectangles, the distance is checked between the top/bottom and left or right edge of the regional bounds. If the horizontal distance to the regional edge is smaller than the vertical distance, then EAST or WEST takes precendence of NORTH or SOUTH. This allows for proper determination between "northeast", "northwest", "southeast", and "southwest" cases.- Specified by:
getRegionin interfaceRegionChecker- Parameters:
comp- theComponentwhose region is to be examined.point- the coordinates whose region is to be determined.- Returns:
- the docking region containing the specified
Point. - See Also:
-
getNorthRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.NORTH_REGION. This method dispatches togetRegionBounds(Component c, String region), passing an argument ofDockingConstants.NORTH_REGIONfor the region parameter. If the specifiedComponentisnull, then anullreference is returned.- Specified by:
getNorthRegionin interfaceRegionChecker- Parameters:
c- theComponentwhose north region is to be returned.- Returns:
- the bounds containing the north region of the specified
Component. - See Also:
-
getSouthRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.SOUTH_REGION. This method dispatches togetRegionBounds(Component c, String region), passing an argument ofDockingConstants.SOUTH_REGIONfor the region parameter. If the specifiedComponentisnull, then anullreference is returned.- Specified by:
getSouthRegionin interfaceRegionChecker- Parameters:
c- theComponentwhose south region is to be returned.- Returns:
- the bounds containing the north region of the specified
Component. - See Also:
-
getEastRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.EAST_REGION. This method dispatches togetRegionBounds(Component c, String region), passing an argument ofDockingConstants.EAST_REGIONfor the region parameter. If the specifiedComponentisnull, then anullreference is returned.- Specified by:
getEastRegionin interfaceRegionChecker- Parameters:
c- theComponentwhose east region is to be returned.- Returns:
- the bounds containing the north region of the specified
Component. - See Also:
-
getWestRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.WEST_REGION. This method dispatches togetRegionBounds(Component c, String region), passing an argument ofDockingConstants.WEST_REGIONfor the region parameter. If the specifiedComponentisnull, then anullreference is returned.- Specified by:
getWestRegionin interfaceRegionChecker- Parameters:
c- theComponentwhose west region is to be returned.- Returns:
- the bounds containing the north region of the specified
Component. - See Also:
-
getRegionBounds
Returns the boundingRectanglewithin the specified component that represents the specified region. Ifcorregionare null, then this method returns anullreference.This method dispatches to
getRegionSize(Component c, String region)to determine the proportional size of the specifiedComponentdedicated to the specified region. It then multiplies this value by the relevantComponentdimension (widthfor east/west,heightfor north/south) and returns aRectanglewith the resulting dimension, spanning theComponentedge for the specified region.- Specified by:
getRegionBoundsin interfaceRegionChecker- Parameters:
c- theComponentwhose region bounds are to be returned.region- the specified region that is to be examined.- Returns:
- the bounds containing the supplied region of the specified
Component. - See Also:
-
getSiblingBounds
Returns the boundingRectanglewithin the specified component that represents the desired area to be allotted for siblingComponentsin the specified region. Ifcorregionare null, then this method returns anullreference.This method dispatches to
getSiblingSize(Component c, String region)to determine the proportional size of the specifiedComponentdedicated to siblings in the specified region. It then multiplies this value by the relevantComponentdimension (widthfor east/west,heightfor north/south) and returns aRectanglewith the resulting dimension, spanning theComponentedge for the specified region.- Specified by:
getSiblingBoundsin interfaceRegionChecker- Parameters:
c- theComponentwhose sibling bounds are to be returned.region- the specified region that is to be examined.- Returns:
- the bounds representing the allotted sibling area for the
supplied region of the specified
Component. - See Also:
-
calculateRegionalBounds
-
getRegionSize
Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedComponent.This method resolves the
Dockableassociated with the specifiedComponentand dispatches togetRegionPreference(Dockable d, String region).getRegionPreference(Dockable d, String region)attempts to invokegetDockingProperties()on theDockableto resolve aDockablePropertySetinstance and return from itsgetRegionInset(String region)method.If the specified
Componentisnull, noDockablecan be resolved, or no value is specified in theDockable'sassociatedDockingPropsinstance, then the default value ofRegionChecker.DEFAULT_REGION_SIZEis returned.- Specified by:
getRegionSizein interfaceRegionChecker- Parameters:
c- theComponentwhose region is to be examined.region- the specified region that is to be examined.- Returns:
- the percentage of the specified
Componentallotted for the specified region. - See Also:
-
getSiblingSize
Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for siblingComponentdocked to the specified region within the specifiedComponent.This method resolves the
Dockableassociated with the specifiedComponentand dispatches togetSiblingPreference(Dockable d, String region).getSiblingPreference(Dockable d, String region)attempts to invokegetDockingProperties()on theDockableto resolve aDockablePropertySetinstance and return from itsgetSiblingSize(String region)method.If the specified
Componentisnull, noDockablecan be resolved, or no value is specified in theDockable'sassociatedDockingPropsinstance, then the default value ofRegionChecker.DEFAULT_SIBLING_SIZEis returned.- Specified by:
getSiblingSizein interfaceRegionChecker- Parameters:
c- theComponentwhose sibling size is to be examined.region- the specified region that is to be examined.- Returns:
- the percentage of the specified
Componentallotted for the siblings within the specified region. - See Also:
-
getDockingInset
-
checkBounds
protected static float checkBounds(float val, float max, float min) -
validateRegionSize
public static float validateRegionSize(float size) Returnssizeif it is between the valuesRegionChecker.MIN_REGION_SIZEandRegionChecker.MAX_REGION_SIZE. Ifsizeis less thanRegionChecker.MIN_REGION_SIZE, thenRegionChecker.MIN_REGION_SIZEis returned. Ifsizeis greater thanRegionChecker.MAX_REGION_SIZE, thenRegionChecker.MAX_REGION_SIZEis returned.- Returns:
- a valid
sizevalue betweenRegionChecker.MIN_REGION_SIZEandRegionChecker.MAX_REGION_SIZE, inclusive.
-
validateSiblingSize
public static float validateSiblingSize(float size) Returnssizeif it is between the valuesRegionChecker.MIN_SIBILNG_SIZEandRegionChecker.MAX_SIBILNG_SIZE. Ifsizeis less thanRegionChecker.MIN_SIBILNG_SIZE, thenRegionChecker.MIN_SIBILNG_SIZEis returned. Ifsizeis greater thanRegionChecker.MAX_SIBILNG_SIZE, thenRegionChecker.MAX_SIBILNG_SIZEis returned.- Returns:
- a valid
sizevalue betweenRegionChecker.MIN_SIBILNG_SIZEandRegionChecker.MAX_SIBILNG_SIZE, inclusive.
-
getRegionPreference
Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedDockable.This method calls
getDockingProperties()on theDockableto resolve aDockablePropertySetinstance. It then invokesgetRegionInset(String region)on theDockablePropertySetto retrieve the preferred region size. If theDockableisnullor no region preference can be found, then the default value ofRegionChecker.DEFAULT_REGION_SIZEis returned. Otherwise, the retrieved region preference is passed throughvalidateRegionSize(float size)and returned.- Parameters:
d- theDockablewhose region is to be checkedregion- the region of the specifiedDockableto be checked- Returns:
- a percentage (0.0F through 1.0F) representing the amount of space
allotted for the specified region within the specified
Dockable. - See Also:
-
getSiblingPreference
Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for siblingComponentsdocked to the specified region within the specifiedDockable.This method calls
getDockingProperties()on theDockableto resolve aDockablePropertySetinstance. It then invokesgetSiblingSize(String region)on theDockablePropertySetto retrieve the preferred sibling size. If theDockableisnullor no sibling preference can be found, then the default value ofRegionChecker.DEFAULT_SIBLING_SIZEis returned. Otherwise, the retrieved region preference is passed throughvalidateSiblingSize(float size)and returned.- Parameters:
d- theDockablewhose sibling size is to be checkedregion- the region of the specifiedDockableto be checked- Returns:
- a percentage (0.0F through 1.0F) representing the amount of space
allotted for sibling
Componentsdocked to the specified region within the specifiedDockable. - See Also:
-