Package org.apache.pivot.wtk.skin
Class GridPaneSkin
- java.lang.Object
-
- org.apache.pivot.wtk.skin.ComponentSkin
-
- org.apache.pivot.wtk.skin.ContainerSkin
-
- org.apache.pivot.wtk.skin.GridPaneSkin
-
- All Implemented Interfaces:
ComponentKeyListener
,ComponentListener
,ComponentMouseButtonListener
,ComponentMouseListener
,ComponentMouseWheelListener
,ComponentStateListener
,ComponentTooltipListener
,ConstrainedVisual
,ContainerListener
,ContainerMouseListener
,GridPane.Skin
,GridPaneListener
,Skin
,Visual
- Direct Known Subclasses:
TerraGridPaneSkin
public class GridPaneSkin extends ContainerSkin implements GridPane.Skin, GridPaneListener
Theme-independent skin for theGridPane
component.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
GridPaneSkin.Metadata
Provides metadata about the grid pane that skins use in performing preferred size calculations and layout.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.skin.ContainerSkin
ContainerSkin.IndexFocusTraversalPolicy
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentKeyListener
ComponentKeyListener.Adapter, ComponentKeyListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentListener
ComponentListener.Adapter, ComponentListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
ComponentMouseButtonListener.Adapter, ComponentMouseButtonListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
ComponentMouseListener.Adapter, ComponentMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseWheelListener
ComponentMouseWheelListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentStateListener
ComponentStateListener.Adapter, ComponentStateListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentTooltipListener
ComponentTooltipListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerListener
ContainerListener.Adapter, ContainerListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerMouseListener
ContainerMouseListener.Adapter, ContainerMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.GridPaneListener
GridPaneListener.Adapter, GridPaneListener.Listeners
-
-
Constructor Summary
Constructors Constructor Description GridPaneSkin()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cellInserted(GridPane.Row row, int column)
Called when a cell has been inserted into a grid pane.void
cellsRemoved(GridPane.Row row, int column, Sequence<Component> removed)
Called when cells have been removed from a grid pane.void
cellUpdated(GridPane.Row row, int column, Component previousComponent)
Called when a cell has been updated in a grid pane.void
columnCountChanged(GridPane gridPane, int previousColumnCount)
Called when a grid pane's column count has changed.int
getBaseline(int width, int height)
Should be implemented in every subclass.int
getColumnAt(int x)
Bounds
getColumnBounds(int column)
java.awt.Color
getHorizontalGridColor()
int
getHorizontalSpacing()
Insets
getPadding()
int
getPreferredHeight(int width)
Returns the visual's preferred height given the provided width constraint.Dimensions
getPreferredSize()
Returns the visual's unconstrained preferred size.int
getPreferredWidth(int height)
Returns the visual's preferred width given the provided height constraint.int
getRowAt(int y)
Bounds
getRowBounds(int row)
boolean
getShowHorizontalGridLines()
boolean
getShowVerticalGridLines()
java.awt.Color
getVerticalGridColor()
int
getVerticalSpacing()
void
install(Component component)
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.void
layout()
If the component on which the skin is installed is a container, lays out the container's children.void
paint(java.awt.Graphics2D graphics)
Paints the visual.void
rowInserted(GridPane gridPane, int index)
Called when a row has been inserted into a grid pane.void
rowsRemoved(GridPane gridPane, int index, Sequence<GridPane.Row> rows)
Called when rows have been removed from a grid pane.void
setHorizontalGridColor(java.awt.Color horizontalGridColor)
Sets the color used to paint the grid pane's horizontal grid lines.void
setHorizontalGridColor(java.lang.String horizontalGridColor)
Sets the color used to paint the grid pane's horizontal grid lines.void
setHorizontalSpacing(int horizontalSpacing)
Sets the spacing that will be applied in between the grid pane's columns during layout.void
setPadding(int padding)
Sets the padding that will be reserved around the grid pane during layout.void
setPadding(java.lang.Number padding)
Sets the padding that will be reserved around the grid pane during layout.void
setPadding(java.lang.String padding)
Sets the padding that will be reserved around the grid pane during layout.void
setPadding(Dictionary<java.lang.String,?> padding)
Sets the padding that will be reserved around the grid pane during layout.void
setPadding(Sequence<?> padding)
Sets the padding that will be reserved around the grid pane during layout.void
setPadding(Insets padding)
Sets the padding that will be reserved around the grid pane during layout.void
setShowHorizontalGridLines(boolean showHorizontalGridLines)
Sets whether or not horizontal grid lines will be painted in between the grid pane's rows.void
setShowVerticalGridLines(boolean showVerticalGridLines)
Sets whether or not vertical grid lines will be painted in between the grid pane's columns.void
setVerticalGridColor(java.awt.Color verticalGridColor)
Sets the color used to paint the grid pane's vertical grid lines.void
setVerticalGridColor(java.lang.String verticalGridColor)
Sets the color used to paint the grid pane's vertical grid lines.void
setVerticalSpacing(int verticalSpacing)
Sets the spacing that will be applied in between the grid pane's rows during layout.-
Methods inherited from class org.apache.pivot.wtk.skin.ContainerSkin
componentInserted, componentMoved, componentsRemoved, focusTraversalPolicyChanged, getBackgroundColor, getBackgroundPaint, isFocusable, isOpaque, mouseDown, mouseMove, mouseUp, mouseWheel, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundPaint, setBackgroundPaint, setBackgroundPaint
-
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
colorFromObject, colorFromObject, colorFromObject, colorFromObject, currentTheme, cursorChanged, decodeFont, defaultBackgroundColor, defaultForegroundColor, dragSourceChanged, dropTargetChanged, enabledChanged, focusedChanged, fontFromObject, getBaseline, getColor, getComponent, getFocusRectangleStroke, getHeight, getSize, getTextInputMethodListener, getThemeFont, getWidth, heightLimitsChanged, invalidateComponent, keyPressed, keyReleased, keyTyped, locationChanged, menuHandlerChanged, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setDefaultStyles, setSize, sizeChanged, themeHasThickFocusRectangle, themeHasTransitionEnabled, themeIsDark, themeIsFlat, tooltipDelayChanged, tooltipTextChanged, tooltipTriggered, visibleChanged, widthLimitsChanged
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pivot.wtk.ConstrainedVisual
setSize
-
-
-
-
Method Detail
-
install
public void install(Component component)
Description copied from class:ComponentSkin
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.- Specified by:
install
in interfaceSkin
- Overrides:
install
in classContainerSkin
- Parameters:
component
- The component to which the skin is being attached.
-
getPreferredWidth
public int getPreferredWidth(int height)
Description copied from interface:ConstrainedVisual
Returns the visual's preferred width given the provided height constraint.- Specified by:
getPreferredWidth
in interfaceConstrainedVisual
- Overrides:
getPreferredWidth
in classContainerSkin
- Parameters:
height
- The height by which to constrain the preferred width, or-1
for no constraint.- Returns:
- The preferred width given the height constraint.
-
getPreferredHeight
public int getPreferredHeight(int width)
Description copied from interface:ConstrainedVisual
Returns the visual's preferred height given the provided width constraint.- Specified by:
getPreferredHeight
in interfaceConstrainedVisual
- Overrides:
getPreferredHeight
in classContainerSkin
- Parameters:
width
- The width by which to constrain the preferred height, or-1
for no constraint.- Returns:
- The preferred height given the width constraint.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisual
Returns the visual's unconstrained preferred size.- Specified by:
getPreferredSize
in interfaceConstrainedVisual
- Overrides:
getPreferredSize
in classComponentSkin
- Returns:
- The preferred size (width and height) of this component.
Depending on the component this can be a static value or derived (as for a container) from its subcomponents, etc.
The default implementation simply calls
ConstrainedVisual.getPreferredWidth(int)
andConstrainedVisual.getPreferredHeight(int)
.
-
getBaseline
public int getBaseline(int width, int height)
Description copied from class:ComponentSkin
Should be implemented in every subclass.The default implementation here simply returns -1 (no baseline).
- Specified by:
getBaseline
in interfaceConstrainedVisual
- Overrides:
getBaseline
in classComponentSkin
- Parameters:
width
- Constrained width to compute the baseline for.height
- Constrained height to compute the baseline for.- Returns:
- The baseline relative to the origin of this visual, or
-1
if this visual does not have a baseline.
-
layout
public void layout()
Description copied from interface:Skin
If the component on which the skin is installed is a container, lays out the container's children.
-
paint
public void paint(java.awt.Graphics2D graphics)
Description copied from interface:Visual
Paints the visual.- Specified by:
paint
in interfaceVisual
- Overrides:
paint
in classContainerSkin
- Parameters:
graphics
- The graphics context in which to paint the visual.
-
getPadding
public final Insets getPadding()
- Returns:
- The padding that will be reserved around the grid pane during layout.
-
setPadding
public final void setPadding(Insets padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- The individual padding values for each side.
-
setPadding
public final void setPadding(int padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- The single value to use for all sides.
-
setPadding
public final void setPadding(Dictionary<java.lang.String,?> padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- The dictionary of padding values, containing"top"
,"bottom"
,"left
, and"right"
entries.
-
setPadding
public final void setPadding(Sequence<?> padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- A sequence with values in the order {top, left, bottom, right}.
-
setPadding
public final void setPadding(java.lang.Number padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- The single value to use for all sides.
-
setPadding
public final void setPadding(java.lang.String padding)
Sets the padding that will be reserved around the grid pane during layout.- Parameters:
padding
- A JSON-format string containing the padding values.
-
getHorizontalSpacing
public final int getHorizontalSpacing()
- Returns:
- The spacing that will be applied in between the grid pane's columns during layout.
-
setHorizontalSpacing
public final void setHorizontalSpacing(int horizontalSpacing)
Sets the spacing that will be applied in between the grid pane's columns during layout.- Parameters:
horizontalSpacing
- The non-negative spacing value between columns.
-
getVerticalSpacing
public final int getVerticalSpacing()
- Returns:
- The spacing that will be applied in between the grid pane's rows during layout.
-
setVerticalSpacing
public final void setVerticalSpacing(int verticalSpacing)
Sets the spacing that will be applied in between the grid pane's rows during layout.- Parameters:
verticalSpacing
- The non-negative spacing value between rows.
-
getShowHorizontalGridLines
public final boolean getShowHorizontalGridLines()
- Returns:
- Whether or not horizontal grid lines will be painted in between the grid pane's rows.
-
setShowHorizontalGridLines
public final void setShowHorizontalGridLines(boolean showHorizontalGridLines)
Sets whether or not horizontal grid lines will be painted in between the grid pane's rows.- Parameters:
showHorizontalGridLines
- Whether to show horizontal grid lines.
-
getShowVerticalGridLines
public final boolean getShowVerticalGridLines()
- Returns:
- Whether or not vertical grid lines will be painted in between the grid pane's columns.
-
setShowVerticalGridLines
public final void setShowVerticalGridLines(boolean showVerticalGridLines)
Sets whether or not vertical grid lines will be painted in between the grid pane's columns.- Parameters:
showVerticalGridLines
- Whether to show the vertical grid lines.
-
getHorizontalGridColor
public final java.awt.Color getHorizontalGridColor()
- Returns:
- The color used to paint the grid pane's horizontal grid lines.
-
setHorizontalGridColor
public final void setHorizontalGridColor(java.awt.Color horizontalGridColor)
Sets the color used to paint the grid pane's horizontal grid lines.- Parameters:
horizontalGridColor
- The new color for the horizontal grid lines.
-
setHorizontalGridColor
public final void setHorizontalGridColor(java.lang.String horizontalGridColor)
Sets the color used to paint the grid pane's horizontal grid lines.- Parameters:
horizontalGridColor
- Any of the color values recognized by Pivot.
-
getVerticalGridColor
public final java.awt.Color getVerticalGridColor()
- Returns:
- The color used to paint the grid pane's vertical grid lines.
-
setVerticalGridColor
public final void setVerticalGridColor(java.awt.Color verticalGridColor)
Sets the color used to paint the grid pane's vertical grid lines.- Parameters:
verticalGridColor
- The new color for vertical grid lines.
-
setVerticalGridColor
public final void setVerticalGridColor(java.lang.String verticalGridColor)
Sets the color used to paint the grid pane's vertical grid lines.- Parameters:
verticalGridColor
- Any of the color values recognized by Pivot.
-
getRowAt
public int getRowAt(int y)
- Specified by:
getRowAt
in interfaceGridPane.Skin
-
getRowBounds
public Bounds getRowBounds(int row)
- Specified by:
getRowBounds
in interfaceGridPane.Skin
-
getColumnAt
public int getColumnAt(int x)
- Specified by:
getColumnAt
in interfaceGridPane.Skin
-
getColumnBounds
public Bounds getColumnBounds(int column)
- Specified by:
getColumnBounds
in interfaceGridPane.Skin
-
columnCountChanged
public void columnCountChanged(GridPane gridPane, int previousColumnCount)
Description copied from interface:GridPaneListener
Called when a grid pane's column count has changed.- Specified by:
columnCountChanged
in interfaceGridPaneListener
- Parameters:
gridPane
- The grid pane that has changed.previousColumnCount
- The previous column count for the grid.
-
rowInserted
public void rowInserted(GridPane gridPane, int index)
Description copied from interface:GridPaneListener
Called when a row has been inserted into a grid pane.- Specified by:
rowInserted
in interfaceGridPaneListener
- Parameters:
gridPane
- The grid pane that has changed.index
- The index of the row that was just inserted.
-
rowsRemoved
public void rowsRemoved(GridPane gridPane, int index, Sequence<GridPane.Row> rows)
Description copied from interface:GridPaneListener
Called when rows have been removed from a grid pane.- Specified by:
rowsRemoved
in interfaceGridPaneListener
- Parameters:
gridPane
- The grid pane that has changed.index
- The starting index of the row(s) that were removed.rows
- The complete sequence of removed rows.
-
cellInserted
public void cellInserted(GridPane.Row row, int column)
Description copied from interface:GridPaneListener
Called when a cell has been inserted into a grid pane.- Specified by:
cellInserted
in interfaceGridPaneListener
- Parameters:
row
- The parent row of the cell that was inserted.column
- The column index of the inserted cell.
-
cellsRemoved
public void cellsRemoved(GridPane.Row row, int column, Sequence<Component> removed)
Description copied from interface:GridPaneListener
Called when cells have been removed from a grid pane.- Specified by:
cellsRemoved
in interfaceGridPaneListener
- Parameters:
row
- The parent row of the removed cell(s).column
- The starting column index of the removed cells.removed
- The complete sequence of removed cells.
-
cellUpdated
public void cellUpdated(GridPane.Row row, int column, Component previousComponent)
Description copied from interface:GridPaneListener
Called when a cell has been updated in a grid pane.- Specified by:
cellUpdated
in interfaceGridPaneListener
- Parameters:
row
- The parent row object of the updated cell.column
- The column index of the updated cell.previousComponent
- The previous contents of this cell.
-
-