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 theGridPanecomponent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classGridPaneSkin.MetadataProvides 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 voidcellInserted(GridPane.Row row, int column)Called when a cell has been inserted into a grid pane.voidcellsRemoved(GridPane.Row row, int column, Sequence<Component> removed)Called when cells have been removed from a grid pane.voidcellUpdated(GridPane.Row row, int column, Component previousComponent)Called when a cell has been updated in a grid pane.voidcolumnCountChanged(GridPane gridPane, int previousColumnCount)Called when a grid pane's column count has changed.intgetBaseline(int width, int height)Should be implemented in every subclass.intgetColumnAt(int x)BoundsgetColumnBounds(int column)java.awt.ColorgetHorizontalGridColor()intgetHorizontalSpacing()InsetsgetPadding()intgetPreferredHeight(int width)Returns the visual's preferred height given the provided width constraint.DimensionsgetPreferredSize()Returns the visual's unconstrained preferred size.intgetPreferredWidth(int height)Returns the visual's preferred width given the provided height constraint.intgetRowAt(int y)BoundsgetRowBounds(int row)booleangetShowHorizontalGridLines()booleangetShowVerticalGridLines()java.awt.ColorgetVerticalGridColor()intgetVerticalSpacing()voidinstall(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.voidlayout()If the component on which the skin is installed is a container, lays out the container's children.voidpaint(java.awt.Graphics2D graphics)Paints the visual.voidrowInserted(GridPane gridPane, int index)Called when a row has been inserted into a grid pane.voidrowsRemoved(GridPane gridPane, int index, Sequence<GridPane.Row> rows)Called when rows have been removed from a grid pane.voidsetHorizontalGridColor(java.awt.Color horizontalGridColor)Sets the color used to paint the grid pane's horizontal grid lines.voidsetHorizontalGridColor(java.lang.String horizontalGridColor)Sets the color used to paint the grid pane's horizontal grid lines.voidsetHorizontalSpacing(int horizontalSpacing)Sets the spacing that will be applied in between the grid pane's columns during layout.voidsetPadding(int padding)Sets the padding that will be reserved around the grid pane during layout.voidsetPadding(java.lang.Number padding)Sets the padding that will be reserved around the grid pane during layout.voidsetPadding(java.lang.String padding)Sets the padding that will be reserved around the grid pane during layout.voidsetPadding(Dictionary<java.lang.String,?> padding)Sets the padding that will be reserved around the grid pane during layout.voidsetPadding(Sequence<?> padding)Sets the padding that will be reserved around the grid pane during layout.voidsetPadding(Insets padding)Sets the padding that will be reserved around the grid pane during layout.voidsetShowHorizontalGridLines(boolean showHorizontalGridLines)Sets whether or not horizontal grid lines will be painted in between the grid pane's rows.voidsetShowVerticalGridLines(boolean showVerticalGridLines)Sets whether or not vertical grid lines will be painted in between the grid pane's columns.voidsetVerticalGridColor(java.awt.Color verticalGridColor)Sets the color used to paint the grid pane's vertical grid lines.voidsetVerticalGridColor(java.lang.String verticalGridColor)Sets the color used to paint the grid pane's vertical grid lines.voidsetVerticalSpacing(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:ComponentSkinMust 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:
installin interfaceSkin- Overrides:
installin classContainerSkin- Parameters:
component- The component to which the skin is being attached.
-
getPreferredWidth
public int getPreferredWidth(int height)
Description copied from interface:ConstrainedVisualReturns the visual's preferred width given the provided height constraint.- Specified by:
getPreferredWidthin interfaceConstrainedVisual- Overrides:
getPreferredWidthin classContainerSkin- Parameters:
height- The height by which to constrain the preferred width, or-1for no constraint.- Returns:
- The preferred width given the height constraint.
-
getPreferredHeight
public int getPreferredHeight(int width)
Description copied from interface:ConstrainedVisualReturns the visual's preferred height given the provided width constraint.- Specified by:
getPreferredHeightin interfaceConstrainedVisual- Overrides:
getPreferredHeightin classContainerSkin- Parameters:
width- The width by which to constrain the preferred height, or-1for no constraint.- Returns:
- The preferred height given the width constraint.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisualReturns the visual's unconstrained preferred size.- Specified by:
getPreferredSizein interfaceConstrainedVisual- Overrides:
getPreferredSizein 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:ComponentSkinShould be implemented in every subclass.The default implementation here simply returns -1 (no baseline).
- Specified by:
getBaselinein interfaceConstrainedVisual- Overrides:
getBaselinein 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
-1if this visual does not have a baseline.
-
layout
public void layout()
Description copied from interface:SkinIf 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:VisualPaints the visual.- Specified by:
paintin interfaceVisual- Overrides:
paintin 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:
getRowAtin interfaceGridPane.Skin
-
getRowBounds
public Bounds getRowBounds(int row)
- Specified by:
getRowBoundsin interfaceGridPane.Skin
-
getColumnAt
public int getColumnAt(int x)
- Specified by:
getColumnAtin interfaceGridPane.Skin
-
getColumnBounds
public Bounds getColumnBounds(int column)
- Specified by:
getColumnBoundsin interfaceGridPane.Skin
-
columnCountChanged
public void columnCountChanged(GridPane gridPane, int previousColumnCount)
Description copied from interface:GridPaneListenerCalled when a grid pane's column count has changed.- Specified by:
columnCountChangedin 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:GridPaneListenerCalled when a row has been inserted into a grid pane.- Specified by:
rowInsertedin 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:GridPaneListenerCalled when rows have been removed from a grid pane.- Specified by:
rowsRemovedin 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:GridPaneListenerCalled when a cell has been inserted into a grid pane.- Specified by:
cellInsertedin 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:GridPaneListenerCalled when cells have been removed from a grid pane.- Specified by:
cellsRemovedin 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:GridPaneListenerCalled when a cell has been updated in a grid pane.- Specified by:
cellUpdatedin 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.
-
-