public class TLcdOverlayLayout extends Object implements LayoutManager2
Container
panel overlaying a map. For
JavaFX views, see TLcdOverlayPane
.
You can add components to 10 distinct locations, and specify what should happen if multiple components are added to the same location.
To arrange components, use one of the following methods:
Container.add(Component, Object)
method. You can pass a TLcdOverlayLayout.Location
as constraints object.
The default ResolveClash
is TLcdOverlayLayout.ResolveClash.HORIZONTAL
.
putConstraint(java.awt.Component, com.luciad.gui.swing.TLcdOverlayLayout.Location, com.luciad.gui.swing.TLcdOverlayLayout.ResolveClash)
methods before adding the component to the container
using an Container#add
method without constraints parameter.
Note: The implementation depends on the preferredSize
of the Component
. When this is not set,
it will use a default Dimension equal to (50, 50). So it's important that
getPreferredSize
returns an appropriate value for any component you wish to add to a container with this
LayoutManager
.
TLcdOverlayLayout.Location
,
TLcdOverlayLayout.ResolveClash
Modifier and Type | Class and Description |
---|---|
static class |
TLcdOverlayLayout.Location
This enumeration identifies the different locations where components can be placed when
added to the container.
|
static class |
TLcdOverlayLayout.ResolveClash
This enumeration can be used to indicate how the LayoutManager should handle multiple
components added to the same location.
|
Constructor and Description |
---|
TLcdOverlayLayout()
Default Constructor for
TLcdOverlayLayout . |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(Component aComponent,
Object aConstraints) |
void |
addLayoutComponent(String aName,
Component aComponent)
This implementation simply adds the component to the
Location.NORTH_EAST . |
float |
getLayoutAlignmentX(Container aTarget) |
float |
getLayoutAlignmentY(Container aTarget) |
void |
invalidateLayout(Container aTarget) |
void |
layoutContainer(Container aParent) |
Dimension |
maximumLayoutSize(Container aTarget) |
Dimension |
minimumLayoutSize(Container aParent) |
Dimension |
preferredLayoutSize(Container aParent) |
void |
putConstraint(Component aComponent,
TLcdOverlayLayout.Location aLocation,
TLcdOverlayLayout.ResolveClash aResolveClash)
Specifies the location and clash resolution for the given object.
|
void |
putConstraint(Component aComponent,
TLcdOverlayLayout.Location aLocation,
TLcdOverlayLayout.ResolveClash aResolveClash,
int aXOffset,
int aYOffset)
Specifies the location, clash resolution, and padding offsets for the given object.
|
void |
removeLayoutComponent(Component aComponent) |
public TLcdOverlayLayout()
TLcdOverlayLayout
.public void putConstraint(Component aComponent, TLcdOverlayLayout.Location aLocation, TLcdOverlayLayout.ResolveClash aResolveClash)
If you call this method, do it before adding the object to the container, without specifying a constraint.
When resolving a clash at a specific location, the ResolveClash
of the last component
(according the container's child order) at the Location
is used, .
aComponent
- The component to be constrained.aLocation
- The location of the component.aResolveClash
- The ResolveClash
constraint for the component.putConstraint(java.awt.Component, com.luciad.gui.swing.TLcdOverlayLayout.Location, com.luciad.gui.swing.TLcdOverlayLayout.ResolveClash, int, int)
public void putConstraint(Component aComponent, TLcdOverlayLayout.Location aLocation, TLcdOverlayLayout.ResolveClash aResolveClash, int aXOffset, int aYOffset)
If you call this method, do it before adding the object to the container, without specifying a constraint.
When resolving a clash at a specific location, the ResolveClash
of the last component
(according the container's child order) at the Location
is used, .
aComponent
- The component to be constrained.aLocation
- The location of the component.aResolveClash
- The ResolveClash
constraint for the component.aXOffset
- The distance in pixels between the component and its left/right
(depending on the Location) neighbour or the East/West edge of the container.aYOffset
- The distance in pixels between the component and its upper/lower
(depending on the Location) neighbour or the North/South edge of the container.public void addLayoutComponent(String aName, Component aComponent)
Location.NORTH_EAST
.
Use the method Container.add(java.awt.Component, Object)
in order to specify the location.addLayoutComponent
in interface LayoutManager
UnsupportedOperationException
- alwaysaddLayoutComponent(java.awt.Component, Object)
public void addLayoutComponent(Component aComponent, Object aConstraints)
This method will be called when you add a component to a container using the
Container.add(java.awt.Component, Object)
method. The constraints should be an instance
of the TLcdOverlayLayout.Location
Enumeration. If the passed object is null, NORTH_EAST
will be set as the default Location
. If the passed object is not an instance of Location
,
an IllegalArgumentException
will be thrown. To set other constraints (ResolveClash
, offsets) use the methods
putConstraint(java.awt.Component, com.luciad.gui.swing.TLcdOverlayLayout.Location, com.luciad.gui.swing.TLcdOverlayLayout.ResolveClash)
or
putConstraint(java.awt.Component, com.luciad.gui.swing.TLcdOverlayLayout.Location, com.luciad.gui.swing.TLcdOverlayLayout.ResolveClash, int, int)
.
addLayoutComponent
in interface LayoutManager2
aComponent
- The component to be addedaConstraints
- An instance of TLcdOverlayLayout.Location
that
specifies the location of the component.public void removeLayoutComponent(Component aComponent)
removeLayoutComponent
in interface LayoutManager
public Dimension maximumLayoutSize(Container aTarget)
maximumLayoutSize
in interface LayoutManager2
public float getLayoutAlignmentX(Container aTarget)
getLayoutAlignmentX
in interface LayoutManager2
public float getLayoutAlignmentY(Container aTarget)
getLayoutAlignmentY
in interface LayoutManager2
public void invalidateLayout(Container aTarget)
invalidateLayout
in interface LayoutManager2
public Dimension preferredLayoutSize(Container aParent)
preferredLayoutSize
in interface LayoutManager
public Dimension minimumLayoutSize(Container aParent)
minimumLayoutSize
in interface LayoutManager
public void layoutContainer(Container aParent)
layoutContainer
in interface LayoutManager