Class DefaultRegionChecker
- java.lang.Object
-
- org.flexdock.docking.defaults.DefaultRegionChecker
-
- All Implemented Interfaces:
DockingConstants,RegionChecker
public class DefaultRegionChecker extends java.lang.Object implements RegionChecker, DockingConstants
- 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_REGION
-
Fields 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 Constructor Description DefaultRegionChecker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.RectanglecalculateRegionalBounds(java.awt.Component c, java.lang.String region, float size)protected static floatcheckBounds(float val, float max, float min)protected static floatgetDockingInset(java.lang.Float value, float defaultVal, float max, float min)java.awt.RectanglegetEastRegion(java.awt.Component c)Returns the rectangular bounds within the specified component that represent it'sDockingConstants.EAST_REGION.java.awt.RectanglegetNorthRegion(java.awt.Component c)Returns the rectangular bounds within the specified component that represent it'sDockingConstants.NORTH_REGION.java.lang.StringgetRegion(java.awt.Component comp, java.awt.Point point)Returns the docking region of the suppliedComponentthat contains the coordinates of the specifiedPoint.java.awt.RectanglegetRegionBounds(java.awt.Component c, java.lang.String region)Returns the boundingRectanglewithin the specified component that represents the specified region.static floatgetRegionPreference(Dockable d, java.lang.String region)Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedDockable.floatgetRegionSize(java.awt.Component c, java.lang.String region)Returns a percentage (0.0F through 1.0F) representing the amount of space allotted for the specified region within the specifiedComponent.java.awt.RectanglegetSiblingBounds(java.awt.Component c, java.lang.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, java.lang.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(java.awt.Component c, java.lang.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.java.awt.RectanglegetSouthRegion(java.awt.Component c)Returns the rectangular bounds within the specified component that represent it'sDockingConstants.SOUTH_REGION.java.awt.RectanglegetWestRegion(java.awt.Component c)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.
-
-
-
Method Detail
-
getRegion
public java.lang.String getRegion(java.awt.Component comp, java.awt.Point point)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:
RegionChecker.getRegion(Component, Point),getNorthRegion(Component),getSouthRegion(Component),getEastRegion(Component),getWestRegion(Component)
-
getNorthRegion
public java.awt.Rectangle getNorthRegion(java.awt.Component c)
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:
RegionChecker.getNorthRegion(Component),getRegionBounds(Component, String)
-
getSouthRegion
public java.awt.Rectangle getSouthRegion(java.awt.Component c)
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:
RegionChecker.getSouthRegion(Component),getRegionBounds(Component, String)
-
getEastRegion
public java.awt.Rectangle getEastRegion(java.awt.Component c)
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:
RegionChecker.getEastRegion(Component),getRegionBounds(Component, String)
-
getWestRegion
public java.awt.Rectangle getWestRegion(java.awt.Component c)
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:
RegionChecker.getWestRegion(Component),getRegionBounds(Component, String)
-
getRegionBounds
public java.awt.Rectangle getRegionBounds(java.awt.Component c, java.lang.String region)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:
RegionChecker.getRegionBounds(Component, String),getRegionSize(Component, String)
-
getSiblingBounds
public java.awt.Rectangle getSiblingBounds(java.awt.Component c, java.lang.String region)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:
RegionChecker.getSiblingBounds(Component, String),getSiblingSize(Component, String)
-
calculateRegionalBounds
protected java.awt.Rectangle calculateRegionalBounds(java.awt.Component c, java.lang.String region, float size)
-
getRegionSize
public float getRegionSize(java.awt.Component c, java.lang.String region)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:
RegionChecker.getRegionSize(Component, String),DockingManager.getDockable(Component),getRegionPreference(Dockable, String),Dockable.getDockingProperties()
-
getSiblingSize
public float getSiblingSize(java.awt.Component c, java.lang.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.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:
DockingManager.getDockable(Component),getSiblingPreference(Dockable, String),Dockable.getDockingProperties()
-
getDockingInset
protected static float getDockingInset(java.lang.Float value, float defaultVal, float max, float min)
-
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
public static float getRegionPreference(Dockable d, java.lang.String region)
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:
Dockable.getDockingProperties(),RegionChecker.DEFAULT_REGION_SIZE,validateRegionSize(float)
-
getSiblingPreference
public static float getSiblingPreference(Dockable d, java.lang.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.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:
Dockable.getDockingProperties(),RegionChecker.DEFAULT_SIBLING_SIZE,validateSiblingSize(float)
-
-