org.flexdock.docking.defaults
public class DefaultRegionChecker extends java.lang.Object implements RegionChecker, DockingConstants
DEFAULT_REGION_SIZE, DEFAULT_SIBLING_SIZE, DEFAULT_SIBLING_SIZE_KEY, MAX_REGION_SIZE, MAX_SIBILNG_SIZE, MIN_REGION_SIZE, MIN_SIBILNG_SIZE
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
Constructor and Description |
---|
DefaultRegionChecker() |
Modifier and Type | Method and Description |
---|---|
protected java.awt.Rectangle |
calculateRegionalBounds(java.awt.Component c,
java.lang.String region,
float size) |
protected static float |
checkBounds(float val,
float max,
float min) |
protected static float |
getDockingInset(java.lang.Float value,
float defaultVal,
float max,
float min) |
java.awt.Rectangle |
getEastRegion(java.awt.Component c)
Returns the rectangular bounds within the specified component that
represent it's
DockingConstants.EAST_REGION . |
java.awt.Rectangle |
getNorthRegion(java.awt.Component c)
Returns the rectangular bounds within the specified component that
represent it's
DockingConstants.NORTH_REGION . |
java.lang.String |
getRegion(java.awt.Component comp,
java.awt.Point point)
Returns the docking region of the supplied
Component that
contains the coordinates of the specified Point . |
java.awt.Rectangle |
getRegionBounds(java.awt.Component c,
java.lang.String region)
Returns the bounding
Rectangle within the specified component
that represents the specified region. |
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 specified
Dockable . |
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 specified
Component . |
java.awt.Rectangle |
getSiblingBounds(java.awt.Component c,
java.lang.String region)
Returns the bounding
Rectangle within the specified component
that represents the desired area to be allotted for sibling
Components in the specified region. |
static float |
getSiblingPreference(Dockable d,
java.lang.String region)
Returns a percentage (0.0F through 1.0F) representing the amount of space
allotted for sibling
Components docked to the specified region
within the specified Dockable . |
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 sibling
Component docked to the specified region
within the specified Component . |
java.awt.Rectangle |
getSouthRegion(java.awt.Component c)
Returns the rectangular bounds within the specified component that
represent it's
DockingConstants.SOUTH_REGION . |
java.awt.Rectangle |
getWestRegion(java.awt.Component c)
Returns the rectangular bounds within the specified component that
represent it's
DockingConstants.WEST_REGION . |
static float |
validateRegionSize(float size)
Returns
size if it is between the values
RegionChecker.MIN_REGION_SIZE and
RegionChecker.MAX_REGION_SIZE . |
static float |
validateSiblingSize(float size)
Returns
size if it is between the values
RegionChecker.MIN_SIBILNG_SIZE and
RegionChecker.MAX_SIBILNG_SIZE . |
public java.lang.String getRegion(java.awt.Component comp, java.awt.Point point)
Component
that
contains the coordinates of the specified Point
. If either
comp
or point
is null
, then
UNKNOWN_REGION
is returned. If the specified Component
bounds do not contain the supplied Point
, then
UNKNOWN_REGION
is returned.
This implementation assumes that comp
is a Component
embedded within a DockingPort
. If comp
is itself a
DockingPort
, then CENTER_REGION
is returned. Otherwise,
the returned region is based upon a section of the bounds of the
specified Component
relative to the containing
DockingPort
.
This method divides the specified Component's
bounds into four
Rectangles
determined by getNorthRegion(Component c)
,
getSouthRegion(Component c)
, getEastRegion(Component c)
,
and getWestRegion(Component c)
, respectively. Each
Rectangle
is then checked to see if it contains the specified
Point
. The order of precedence is NORTH, SOUTH, EAST, and then
WEST. If the specified Point
is contained by the
Component
bounds but none of the sub-Rectangles
, then
CENTER_REGION
is 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.
getRegion
in interface RegionChecker
comp
- the Component
whose region is to be examined.point
- the coordinates whose region is to be determined.Point
.RegionChecker.getRegion(Component, Point)
,
getNorthRegion(Component)
,
getSouthRegion(Component)
,
getEastRegion(Component)
,
getWestRegion(Component)
public java.awt.Rectangle getNorthRegion(java.awt.Component c)
DockingConstants.NORTH_REGION
. This method
dispatches to getRegionBounds(Component c, String region)
,
passing an argument of DockingConstants.NORTH_REGION
for the
region parameter. If the specified Component
is null
,
then a null
reference is returned.getNorthRegion
in interface RegionChecker
c
- the Component
whose north region is to be returned.Component
.RegionChecker.getNorthRegion(Component)
,
getRegionBounds(Component, String)
public java.awt.Rectangle getSouthRegion(java.awt.Component c)
DockingConstants.SOUTH_REGION
. This method
dispatches to getRegionBounds(Component c, String region)
,
passing an argument of DockingConstants.SOUTH_REGION
for the
region parameter. If the specified Component
is null
,
then a null
reference is returned.getSouthRegion
in interface RegionChecker
c
- the Component
whose south region is to be returned.Component
.RegionChecker.getSouthRegion(Component)
,
getRegionBounds(Component, String)
public java.awt.Rectangle getEastRegion(java.awt.Component c)
DockingConstants.EAST_REGION
. This method
dispatches to getRegionBounds(Component c, String region)
,
passing an argument of DockingConstants.EAST_REGION
for the
region parameter. If the specified Component
is null
,
then a null
reference is returned.getEastRegion
in interface RegionChecker
c
- the Component
whose east region is to be returned.Component
.RegionChecker.getEastRegion(Component)
,
getRegionBounds(Component, String)
public java.awt.Rectangle getWestRegion(java.awt.Component c)
DockingConstants.WEST_REGION
. This method
dispatches to getRegionBounds(Component c, String region)
,
passing an argument of DockingConstants.WEST_REGION
for the
region parameter. If the specified Component
is null
,
then a null
reference is returned.getWestRegion
in interface RegionChecker
c
- the Component
whose west region is to be returned.Component
.RegionChecker.getWestRegion(Component)
,
getRegionBounds(Component, String)
public java.awt.Rectangle getRegionBounds(java.awt.Component c, java.lang.String region)
Rectangle
within the specified component
that represents the specified region. If c
or region
are
null, then this method returns a null
reference.
This method dispatches to
getRegionSize(Component c, String region)
to determine the
proportional size of the specified Component
dedicated to the
specified region. It then multiplies this value by the relevant
Component
dimension (width
for east/west,
height
for north/south) and returns a Rectangle
with
the resulting dimension, spanning the Component
edge for the
specified region.
getRegionBounds
in interface RegionChecker
c
- the Component
whose region bounds are to be returned.region
- the specified region that is to be examined.Component
.RegionChecker.getRegionBounds(Component, String)
,
getRegionSize(Component, String)
public java.awt.Rectangle getSiblingBounds(java.awt.Component c, java.lang.String region)
Rectangle
within the specified component
that represents the desired area to be allotted for sibling
Components
in the specified region. If c
or
region
are null, then this method returns a null
reference.
This method dispatches to
getSiblingSize(Component c, String region)
to determine the
proportional size of the specified Component
dedicated to
siblings in the specified region. It then multiplies this value by the
relevant Component
dimension (width
for east/west,
height
for north/south) and returns a Rectangle
with
the resulting dimension, spanning the Component
edge for the
specified region.
getSiblingBounds
in interface RegionChecker
c
- the Component
whose sibling bounds are to be returned.region
- the specified region that is to be examined.Component
.RegionChecker.getSiblingBounds(Component, String)
,
getSiblingSize(Component, String)
protected java.awt.Rectangle calculateRegionalBounds(java.awt.Component c, java.lang.String region, float size)
public float getRegionSize(java.awt.Component c, java.lang.String region)
Component
.
This method resolves the Dockable
associated with the specified
Component
and dispatches to
getRegionPreference(Dockable d, String region)
.
getRegionPreference(Dockable d, String region)
attempts to invoke
getDockingProperties()
on the Dockable
to resolve a
DockablePropertySet
instance and return from its
getRegionInset(String region)
method.
If the specified Component
is null
, no Dockable
can be resolved, or no value is specified in the Dockable's
associated DockingProps
instance, then the default value of
RegionChecker.DEFAULT_REGION_SIZE
is returned.
getRegionSize
in interface RegionChecker
c
- the Component
whose region is to be examined.region
- the specified region that is to be examined.Component
allotted for
the specified region.RegionChecker.getRegionSize(Component, String)
,
DockingManager.getDockable(Component)
,
getRegionPreference(Dockable, String)
,
Dockable.getDockingProperties()
public float getSiblingSize(java.awt.Component c, java.lang.String region)
Component
docked to the specified region
within the specified Component
.
This method resolves the Dockable
associated with the specified
Component
and dispatches to
getSiblingPreference(Dockable d, String region)
.
getSiblingPreference(Dockable d, String region)
attempts to
invoke getDockingProperties()
on the Dockable
to resolve
a DockablePropertySet
instance and return from its
getSiblingSize(String region)
method.
If the specified Component
is null
, no Dockable
can be resolved, or no value is specified in the Dockable's
associated DockingProps
instance, then the default value of
RegionChecker.DEFAULT_SIBLING_SIZE
is returned.
getSiblingSize
in interface RegionChecker
c
- the Component
whose sibling size is to be examined.region
- the specified region that is to be examined.Component
allotted for
the siblings within the specified region.DockingManager.getDockable(Component)
,
getSiblingPreference(Dockable, String)
,
Dockable.getDockingProperties()
protected static float getDockingInset(java.lang.Float value, float defaultVal, float max, float min)
protected static float checkBounds(float val, float max, float min)
public static float validateRegionSize(float size)
size
if it is between the values
RegionChecker.MIN_REGION_SIZE
and
RegionChecker.MAX_REGION_SIZE
. If size
is less than
RegionChecker.MIN_REGION_SIZE
, then
RegionChecker.MIN_REGION_SIZE
is returned. If size
is
greater than RegionChecker.MAX_REGION_SIZE
, then
RegionChecker.MAX_REGION_SIZE
is returned.size
value between
RegionChecker.MIN_REGION_SIZE
and
RegionChecker.MAX_REGION_SIZE
, inclusive.public static float validateSiblingSize(float size)
size
if it is between the values
RegionChecker.MIN_SIBILNG_SIZE
and
RegionChecker.MAX_SIBILNG_SIZE
. If size
is less than
RegionChecker.MIN_SIBILNG_SIZE
, then
RegionChecker.MIN_SIBILNG_SIZE
is returned. If size
is
greater than RegionChecker.MAX_SIBILNG_SIZE
, then
RegionChecker.MAX_SIBILNG_SIZE
is returned.size
value between
RegionChecker.MIN_SIBILNG_SIZE
and
RegionChecker.MAX_SIBILNG_SIZE
, inclusive.public static float getRegionPreference(Dockable d, java.lang.String region)
Dockable
.
This method calls getDockingProperties()
on the Dockable
to resolve a DockablePropertySet
instance. It then invokes
getRegionInset(String region)
on the DockablePropertySet
to retrieve the preferred region size. If the Dockable
is
null
or no region preference can be found, then the default value
of RegionChecker.DEFAULT_REGION_SIZE
is returned. Otherwise, the
retrieved region preference is passed through
validateRegionSize(float size)
and returned.
d
- the Dockable
whose region is to be checkedregion
- the region of the specified Dockable
to be checkedDockable
.Dockable.getDockingProperties()
,
RegionChecker.DEFAULT_REGION_SIZE
,
validateRegionSize(float)
public static float getSiblingPreference(Dockable d, java.lang.String region)
Components
docked to the specified region
within the specified Dockable
.
This method calls getDockingProperties()
on the Dockable
to resolve a DockablePropertySet
instance. It then invokes
getSiblingSize(String region)
on the DockablePropertySet
to retrieve the preferred sibling size. If the Dockable
is
null
or no sibling preference can be found, then the default
value of RegionChecker.DEFAULT_SIBLING_SIZE
is returned.
Otherwise, the retrieved region preference is passed through
validateSiblingSize(float size)
and returned.
d
- the Dockable
whose sibling size is to be checkedregion
- the region of the specified Dockable
to be checkedComponents
docked to the specified
region within the specified Dockable
.Dockable.getDockingProperties()
,
RegionChecker.DEFAULT_SIBLING_SIZE
,
validateSiblingSize(float)