Package org.flexdock.docking
Interface RegionChecker
- All Known Implementing Classes:
DefaultRegionChecker
public interface RegionChecker
This interface provides an API for determining the desired regional bounds
for a
Dockable
component. Implementing classes are responsible for
determining the bounds and proportional sizes for both docking regions and
sibling components.
As a Dockable
is dragged across a DockingPort
containing
another embedded Dockable
, a determination must be made as to where
the dragged Dockable
will be docked within the target
DockingPort
based upon the current mouse position relative to
the embedded Dockable
underneath the mouse. Classes that implement
this interface are responsible for making such determinations.
For example, if a Dockable
is dragged over another Dockable
embedded within a DockingPort
, and the current mouse position is
near the top edge of the embedded Dockable
, the current
RegionChecker
is responsible for determining whether the user is
attempting to dock in the north
, east
, west
, or
center
of the embedded Dockable
. The visual
DragPreview
displayed to the end user should reflect this
determination.
Once the docking operation is complete and the layout has been split between
both Dockables
, the actual percentage of space allotted to the new
Dockable
in the layout, referred to as the "sibling", is also
determined by the current RegionChecker
implementation.- Author:
- Christopher Butler, Mateusz Szczap
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final float
Default region size.static final float
Default sibling size.static final String
A key to find a system property that will override the default sibling size in this interface.static final float
Default maximum region size.static final float
Default maximum sibling size.static final float
Default minimum region size.static final float
Default minimum sibling size. -
Method Summary
Modifier and TypeMethodDescriptiongetEastRegion
(Component component) Returns the rectangular bounds within the specified component that represent it'sDockingConstants.EAST_REGION
.getNorthRegion
(Component component) Returns the rectangular bounds within the specified component that represent it'sDockingConstants.NORTH_REGION
.Returns the docking region of the suppliedComponent
that contains the coordinates of the specifiedPoint
.getRegionBounds
(Component component, String region) Returns the rectangular bounds within the specified component that represent the specified region.float
getRegionSize
(Component component, String region) Returns a percentage representing the amount of space allotted for the specified region within the specifiedComponent
.getSiblingBounds
(Component component, String region) ARectangle
representing the actual amount of space to allot for siblingComponents
should they be docked into the specified region.float
getSiblingSize
(Component component, String region) Returns a percentage representing the amount of space allotted for siblingComponents
to be docked within the specified region of the suppliedComponent
.getSouthRegion
(Component component) Returns the rectangular bounds within the specified component that represent it'sDockingConstants.SOUTH_REGION
.getWestRegion
(Component component) Returns the rectangular bounds within the specified component that represent it'sDockingConstants.WEST_REGION
.
-
Field Details
-
MAX_REGION_SIZE
static final float MAX_REGION_SIZEDefault maximum region size.- See Also:
-
MIN_REGION_SIZE
static final float MIN_REGION_SIZEDefault minimum region size.- See Also:
-
MAX_SIBILNG_SIZE
static final float MAX_SIBILNG_SIZEDefault maximum sibling size.- See Also:
-
MIN_SIBILNG_SIZE
static final float MIN_SIBILNG_SIZEDefault minimum sibling size.- See Also:
-
DEFAULT_REGION_SIZE
static final float DEFAULT_REGION_SIZEDefault region size.- See Also:
-
DEFAULT_SIBLING_SIZE
static final float DEFAULT_SIBLING_SIZEDefault sibling size.- See Also:
-
DEFAULT_SIBLING_SIZE_KEY
A key to find a system property that will override the default sibling size in this interface.- See Also:
-
-
Method Details
-
getRegion
Returns the docking region of the suppliedComponent
that contains the coordinates of the specifiedPoint
. Valid return values are those regions defined inDockingConstants
and includeCENTER_REGION
,NORTH_REGION
,SOUTH_REGION
,EAST_REGION
,WEST_REGION
, orUNKNOWN_REGION
.- Parameters:
component
- theComponent
whose region is to be examined.point
- the coordinates whose region is to be determined.- Returns:
- the docking region containing the specified
Point
.
-
getNorthRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.NORTH_REGION
.- Parameters:
component
- theComponent
whose north region is to be returned.- Returns:
- the bounds containing the north region of the specified
Component
.
-
getSouthRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.SOUTH_REGION
.- Parameters:
component
- theComponent
whose south region is to be returned.- Returns:
- the bounds containing the south region of the specified
Component
.
-
getEastRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.EAST_REGION
.- Parameters:
component
- theComponent
whose east region is to be returned.- Returns:
- the bounds containing the east region of the specified
Component
.
-
getWestRegion
Returns the rectangular bounds within the specified component that represent it'sDockingConstants.WEST_REGION
.- Parameters:
component
- theComponent
whose west region is to be returned.- Returns:
- the bounds containing the west region of the specified
Component
.
-
getRegionBounds
Returns the rectangular bounds within the specified component that represent the specified region. Valid values for theregion
parameter are those regions defined inDockingConstants
and includeNORTH_REGION
,SOUTH_REGION
,EAST_REGION
, andWEST_REGION
. All other region values should result in this method returning anull
reference.- Parameters:
component
- theComponent
whose 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
.
-
getRegionSize
Returns a percentage representing the amount of space allotted for the specified region within the specifiedComponent
. For example, a return value of 0.25F for NORTH_REGION implies that the top 25% of the suppliedComponent's
bounds rectangle is to be interpreted as theComponent's
northern region. Valid values for theregion
parameter are those regions defined inDockingConstants
and includeNORTH_REGION
,SOUTH_REGION
,EAST_REGION
, andWEST_REGION
. All other region values should result in this method returning the constantDEFAULT_SIBLING_SIZE
.- Parameters:
component
- theComponent
whose region is to be examined.region
- the specified region that is to be examined.- Returns:
- the percentage of the specified
Component
allotted for the specified region.
-
getSiblingBounds
ARectangle
representing the actual amount of space to allot for siblingComponents
should they be docked into the specified region. This method differs fromgetRegionBounds(Component c, String region)
in thatgetRegionBounds()
determines the amount to space used to check whether aComponent's
docking will intersect with a particular region, whereas this method returns the actual amount of space saidComponent
will take up after docking has been completed. Valid values for theregion
parameter are those regions defined inDockingConstants
and includeNORTH_REGION
,SOUTH_REGION
,EAST_REGION
, andWEST_REGION
. All other region values should result in this method returning the constantDEFAULT_SIBLING_SIZE
.- Parameters:
component
- theComponent
whose sibling bounds are to be returned.region
- the specified region that is to be examined.- Returns:
- the bounds containing the sibling bounds desired for
Components
docked into the specified region of the of the specifiedComponent
.
-
getSiblingSize
Returns a percentage representing the amount of space allotted for siblingComponents
to be docked within the specified region of the suppliedComponent
. This method differs fromgetRegionSize(Component c, String region)
in thatgetRegionSize()
determines the proportional space used to check whether aComponent's
docking will intersect with a particular region, whereas this method returns the proportional space saidComponent
will take up after docking has been completed. Valid values for theregion
parameter are those regions defined inDockingConstants
and includeNORTH_REGION
,SOUTH_REGION
,EAST_REGION
, andWEST_REGION
. All other region values should result in this method returning the constantDEFAULT_SIBLING_SIZE
.- Parameters:
component
- theComponent
whose sibling proportions are to be returned.region
- the specified region that is to be examined.- Returns:
- the percentage of the specified
Component
allotted for siblingComponents
that are to be docked into the specified region.
-