- All Known Subinterfaces:
ContainerWrapper
- All Known Implementing Classes:
SwingComponentWrapper,SwingContainerWrapper
NOTE!.equals() and .hashcode() should be shunted to the wrapped component. E.g.
public int hashCode()
{
return getComponent().hashCode();
}
public final boolean equals(Object o)
{
if (o instanceof ComponentWrapper == false)
return false;
return getComponent().equals(((ComponentWrapper) o).getComponent());
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionintgetBaseline(int width, int height) Returns the baseline for the component given the suggested height.Returns the actual object that this wrapper is aggregating.intgetComponetType(boolean disregardScrollPane) Returns the type of component that this wrapper is wrapping.intReturns the current height for this component.intReturns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.intReturns a hash code that should be reasonably different for anything that might change the layout.Returns a String id that can be used to reference the component in link constraints.intgetMaximumHeight(int wHint) Returns the maximum height of the component.intgetMaximumWidth(int hHint) Returns the maximum width of the component.intgetMinimumHeight(int wHint) Returns the minimum height of the component.intgetMinimumWidth(int hHint) Returns the minimum width of the component.Returns the container for this component.floatgetPixelUnitFactor(boolean isHor) Returns the pixel unit factor for the horizontal or vertical dimension.intgetPreferredHeight(int wHint) Returns the preferred height of the component.intgetPreferredWidth(int hHint) Returns the preferred width of the component.intReturns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible ornull.intReturns the screen x-coordinate for the upper left coordinate of the component layout-able bounds.intReturns the screen y-coordinate for the upper left coordinate of the component layout-able bounds.intReturns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible ornull.intReturns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.int[]Returns the padding on a component by component basis.intgetWidth()Returns the current width for this component.intgetX()Returns the current x coordinate for this component.intgetY()Returns the current y coordinate for this component.booleanReturns if the component has a baseline and if it can be retrieved.booleanReturns if the component's visibility is set totrue.voidPaints component outline to indicate where it is.voidsetBounds(int x, int y, int width, int height) Sets the component's bounds.
-
Field Details
-
TYPE_UNSET
static final int TYPE_UNSET- See Also:
-
TYPE_UNKNOWN
static final int TYPE_UNKNOWN- See Also:
-
TYPE_CONTAINER
static final int TYPE_CONTAINER- See Also:
-
TYPE_LABEL
static final int TYPE_LABEL- See Also:
-
TYPE_TEXT_FIELD
static final int TYPE_TEXT_FIELD- See Also:
-
TYPE_TEXT_AREA
static final int TYPE_TEXT_AREA- See Also:
-
TYPE_BUTTON
static final int TYPE_BUTTON- See Also:
-
TYPE_LIST
static final int TYPE_LIST- See Also:
-
TYPE_TABLE
static final int TYPE_TABLE- See Also:
-
TYPE_SCROLL_PANE
static final int TYPE_SCROLL_PANE- See Also:
-
TYPE_IMAGE
static final int TYPE_IMAGE- See Also:
-
TYPE_PANEL
static final int TYPE_PANEL- See Also:
-
TYPE_COMBO_BOX
static final int TYPE_COMBO_BOX- See Also:
-
TYPE_SLIDER
static final int TYPE_SLIDER- See Also:
-
TYPE_SPINNER
static final int TYPE_SPINNER- See Also:
-
TYPE_PROGRESS_BAR
static final int TYPE_PROGRESS_BAR- See Also:
-
TYPE_TREE
static final int TYPE_TREE- See Also:
-
TYPE_CHECK_BOX
static final int TYPE_CHECK_BOX- See Also:
-
TYPE_SCROLL_BAR
static final int TYPE_SCROLL_BAR- See Also:
-
TYPE_SEPARATOR
static final int TYPE_SEPARATOR- See Also:
-
-
Method Details
-
getComponent
Object getComponent()Returns the actual object that this wrapper is aggregating. This might be needed for getting information about the object that the wrapper interface does not provide.If this is a container the container should be returned instead.
- Returns:
- The actual object that this wrapper is aggregating. Not
null.
-
getX
int getX()Returns the current x coordinate for this component.- Returns:
- The current x coordinate for this component.
-
getY
int getY()Returns the current y coordinate for this component.- Returns:
- The current y coordinate for this component.
-
getWidth
int getWidth()Returns the current width for this component.- Returns:
- The current width for this component.
-
getHeight
int getHeight()Returns the current height for this component.- Returns:
- The current height for this component.
-
getScreenLocationX
int getScreenLocationX()Returns the screen x-coordinate for the upper left coordinate of the component layout-able bounds.- Returns:
- The screen x-coordinate for the upper left coordinate of the component layout-able bounds.
-
getScreenLocationY
int getScreenLocationY()Returns the screen y-coordinate for the upper left coordinate of the component layout-able bounds.- Returns:
- The screen y-coordinate for the upper left coordinate of the component layout-able bounds.
-
getMinimumWidth
int getMinimumWidth(int hHint) Returns the minimum width of the component.- Parameters:
hHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The minimum width of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
getMinimumHeight
int getMinimumHeight(int wHint) Returns the minimum height of the component.- Parameters:
wHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The minimum height of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
getPreferredWidth
int getPreferredWidth(int hHint) Returns the preferred width of the component.- Parameters:
hHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The preferred width of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
getPreferredHeight
int getPreferredHeight(int wHint) Returns the preferred height of the component.- Parameters:
wHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The preferred height of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
getMaximumWidth
int getMaximumWidth(int hHint) Returns the maximum width of the component.- Parameters:
hHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The maximum width of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
getMaximumHeight
int getMaximumHeight(int wHint) Returns the maximum height of the component.- Parameters:
wHint- The Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.- Returns:
- The maximum height of the component.
- Since:
- 3.5. Added the hint as a parameter knowing that a correction and recompilation is necessary for any implementing classes. This change was worth it though.
-
setBounds
void setBounds(int x, int y, int width, int height) Sets the component's bounds.- Parameters:
x- The x coordinate.y- The y coordinate.width- The width.height- The height.
-
isVisible
boolean isVisible()Returns if the component's visibility is set totrue. This should not return if the component is actually visible, but if the visibility is set to true or not.- Returns:
truemeans visible.
-
getBaseline
int getBaseline(int width, int height) Returns the baseline for the component given the suggested height.- Parameters:
width- The width to calculate for if other than the current. If-1the current size should be used.height- The height to calculate for if other than the current. If-1the current size should be used.- Returns:
- The baseline from the top or -1 if not applicable.
-
hasBaseline
boolean hasBaseline()Returns if the component has a baseline and if it can be retrieved. Should for instance returnfalsefor Swing before mustang.- Returns:
- If the component has a baseline and if it can be retrieved.
-
getParent
ContainerWrapper getParent()Returns the container for this component.- Returns:
- The container for this component. Will return
nullif the component has no parent.
-
getPixelUnitFactor
float getPixelUnitFactor(boolean isHor) Returns the pixel unit factor for the horizontal or vertical dimension.The factor is 1 for both dimensions on the normal font in a JPanel on Windows. The factor should increase with a bigger "X".
This is the Swing version:
Rectangle2D r = fm.getStringBounds("X", parent.getGraphics()); wFactor = r.getWidth() / 6; hFactor = r.getHeight() / 13.27734375f;- Parameters:
isHor- If it is the horizontal factor that should be returned.- Returns:
- The factor.
-
getHorizontalScreenDPI
int getHorizontalScreenDPI()Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.If headless mode
PlatformDefaults.getDefaultDPI()will be returned.- Returns:
- The DPI.
-
getVerticalScreenDPI
int getVerticalScreenDPI()Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.If headless mode
PlatformDefaults.getDefaultDPI()will be returned.- Returns:
- The DPI.
-
getScreenWidth
int getScreenWidth()Returns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible ornull.If in headless mode
1024is returned.- Returns:
- The screen size. E.g.
1280.
-
getScreenHeight
int getScreenHeight()Returns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible ornull.If in headless mode
768is returned.- Returns:
- The screen size. E.g.
1024.
-
getLinkId
String getLinkId()Returns a String id that can be used to reference the component in link constraints. This value should return the default id for the component. The id can be set for a component in the constraints and if so the value returned by this method will never be used. If there are no sensible id for the componentnullshould be returned.For instance the Swing implementation returns the string returned from
Component.getName().- Returns:
- The string link id or
null.
-
getLayoutHashCode
int getLayoutHashCode()Returns a hash code that should be reasonably different for anything that might change the layout. This value is used to know if the component layout needs to clear any caches.- Returns:
- A hash code that should be reasonably different for anything that might change the layout. Returns -1 if the widget is disposed.
-
getVisualPadding
int[] getVisualPadding()Returns the padding on a component by component basis. This method can be overridden to return padding to compensate for example for borders that have shadows or where the outer most pixel is not the visual "edge" to align to.Default implementation returns
nullfor all components except for Windows XP's JTabbedPane which will return new Insets(0, 0, 2, 2).NOTE! To reduce generated garbage the returned padding should never be changed so that the same insets can be returned many times.
- Returns:
nullif no padding. NOTE! To reduce generated garbage the returned padding should never be changed so that the same insets can be returned many times. [top, left, bottom, right]
-
paintDebugOutline
void paintDebugOutline()Paints component outline to indicate where it is. -
getComponetType
int getComponetType(boolean disregardScrollPane) Returns the type of component that this wrapper is wrapping.This method can be invoked often so the result should be cached.
NOTE! This is misspelled. Keeping it that way though since this is only used by developers who port MigLayout.
- Parameters:
disregardScrollPane- Istrueany wrapping scroll pane should be disregarded and the type of the scrolled component should be returned.- Returns:
- The type of component that this wrapper is wrapping. E.g.
TYPE_LABEL.
-