Package net.sf.paperclips
Class DefaultGridLook
java.lang.Object
net.sf.paperclips.DefaultGridLook
- All Implemented Interfaces:
GridLook
A GridLook which draws a border around grid cells, with configurable
background colors for body, header, and footer cells.
- Author:
- Matthew Hall
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant cell spacing value indicating that the borders of adjacent cells should overlap so the appear continuous. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a DefaultGridLook with no border, no cell spacing, and no background colors.DefaultGridLook(int horizontalSpacing, int verticalSpacing) Constructs a DefaultGridLook with the given cell spacing, and no border or background colors. -
Method Summary
Modifier and TypeMethodDescriptionbooleanorg.eclipse.swt.graphics.RGBReturns the body background color.Returns the body background color provider.Returns the cell border.org.eclipse.swt.graphics.RectangleReturns a rectangle whose public fields denote the left (x), top (y), right (width) and bottom (height) cell padding, expressed in points.org.eclipse.swt.graphics.PointReturns the border spacing, in points, between adjacent grid cells.org.eclipse.swt.graphics.RGBReturns the footer background color.Returns the footer background color provider.intReturns the vertical gap between the body and footer cells.org.eclipse.swt.graphics.RGBReturns the header background color.Returns the header background color provider.intReturns the vertical gap between the header and body cells.getPainter(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc) Returns a GridLookPainter for painting the GridLook.inthashCode()voidsetBodyBackground(org.eclipse.swt.graphics.RGB bodyBackground) Sets the body background color.voidsetBodyBackgroundProvider(CellBackgroundProvider bodyBackgroundProvider) Sets the body background color provider.voidsetCellBorder(Border border) Sets the cell border.voidsetCellPadding(int horizontalPadding, int verticalPadding) Sets the cell padding to the given horizontal and vertical values.voidsetCellPadding(int left, int top, int right, int bottom) Sets the cell padding to the specified values.voidsetCellPadding(org.eclipse.swt.graphics.Rectangle cellPadding) Sets the cell padding to the values in the public fields of the argument.voidsetCellSpacing(int horizontal, int vertical) Sets the border spacing, in points, between adjacent grid cells.voidsetCellSpacing(org.eclipse.swt.graphics.Point cellSpacing) Sets the border spacing, in points, between adjacent grid cells.voidsetFooterBackground(org.eclipse.swt.graphics.RGB footerBackground) Sets the footer background color.voidsetFooterBackgroundProvider(CellBackgroundProvider footerBackgroundProvider) Sets the footer background color provider.voidsetFooterGap(int footerGap) Sets the vertical gap between the header and body cells.voidsetHeaderBackground(org.eclipse.swt.graphics.RGB headerBackground) Sets the header background color.voidsetHeaderBackgroundProvider(CellBackgroundProvider headerBackgroundProvider) Sets the header background color provider.voidsetHeaderGap(int headerGap) Sets the vertical gap between the header and body cells.
-
Field Details
-
BORDER_OVERLAP
public static final int BORDER_OVERLAPConstant cell spacing value indicating that the borders of adjacent cells should overlap so the appear continuous.- See Also:
-
-
Constructor Details
-
DefaultGridLook
public DefaultGridLook()Constructs a DefaultGridLook with no border, no cell spacing, and no background colors. -
DefaultGridLook
public DefaultGridLook(int horizontalSpacing, int verticalSpacing) Constructs a DefaultGridLook with the given cell spacing, and no border or background colors.- Parameters:
horizontalSpacing- the horizontal cell spacing.verticalSpacing- the vertical cell spacing.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getCellBorder
Returns the cell border. Default is an empty border with no margins.- Returns:
- the cell border.
-
setCellBorder
Sets the cell border.- Parameters:
border- the cell border.
-
getCellSpacing
public org.eclipse.swt.graphics.Point getCellSpacing()Returns the border spacing, in points, between adjacent grid cells. Default is (x=BORDER_OVERLAP, y=BORDER_OVERLAP).- Returns:
- the border spacing, in points, between adjacent grid cells.
-
setCellSpacing
public void setCellSpacing(org.eclipse.swt.graphics.Point cellSpacing) Sets the border spacing, in points, between adjacent grid cells. A value ofBORDER_OVERLAPcauses the borders to overlap, making the border appear continuous throughout the grid. A value of 0 or more causes the cell borders to be spaced that many points apart. 72 points = 1".- Parameters:
cellSpacing- a point whose x and y elements indicate the horizontal and vertical spacing between grid cells.
-
setCellSpacing
public void setCellSpacing(int horizontal, int vertical) Sets the border spacing, in points, between adjacent grid cells. A value ofBORDER_OVERLAPcauses the borders to overlap, making the border appear continuous throughout the grid. A value of 0 or more causes the cell borders to be spaced that many points apart. 72 points = 1".- Parameters:
horizontal- the horizontal cell spacing.vertical- the vertical cell spacing.
-
getCellPadding
public org.eclipse.swt.graphics.Rectangle getCellPadding()Returns a rectangle whose public fields denote the left (x), top (y), right (width) and bottom (height) cell padding, expressed in points. 72 points = 1" = 2.54cm.- Returns:
- a rectangle whose public fields denote the cell padding at each edge.
-
setCellPadding
public void setCellPadding(org.eclipse.swt.graphics.Rectangle cellPadding) Sets the cell padding to the values in the public fields of the argument.- Parameters:
cellPadding- the new cell padding.
-
setCellPadding
public void setCellPadding(int horizontalPadding, int verticalPadding) Sets the cell padding to the given horizontal and vertical values. This is equivalent to calling setCellPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding).- Parameters:
horizontalPadding- the amount of padding to add to the left and right of each cell, in points.verticalPadding- the amount padding to add to the top and bottom each cell, in points.
-
setCellPadding
public void setCellPadding(int left, int top, int right, int bottom) Sets the cell padding to the specified values.- Parameters:
left- the left cell padding, in points.top- the top cell padding, in points.right- the right cell padding, in points.bottom- the bottom cell padding, in points.
-
getHeaderBackground
public org.eclipse.swt.graphics.RGB getHeaderBackground()Returns the header background color. If null, the body background color is used. Default is null.- Returns:
- the header background color.
-
setHeaderBackground
public void setHeaderBackground(org.eclipse.swt.graphics.RGB headerBackground) Sets the header background color. Calls to this method override any previous calls to setHeaderBackgroundProvider(...).- Parameters:
headerBackground- the new background color. If null, the body background color will be used.
-
getHeaderBackgroundProvider
Returns the header background color provider.- Returns:
- the header background color provider.
-
setHeaderBackgroundProvider
Sets the header background color provider. Calls to this method override any previous calls to setHeaderBackground(RGB). Setting this property to null restores the default background provider.- Parameters:
headerBackgroundProvider- the new background color provider.
-
getHeaderGap
public int getHeaderGap()Returns the vertical gap between the header and body cells. Default is BORDER_OVERLAP.- Returns:
- the vertical gap between the header and body cells.
-
setHeaderGap
public void setHeaderGap(int headerGap) Sets the vertical gap between the header and body cells. A value ofBORDER_OVERLAPcauses the borders to overlap, making the border appear continuous in the transition from the header cells to the body cells.- Parameters:
headerGap- the new header gap.
-
getBodyBackground
public org.eclipse.swt.graphics.RGB getBodyBackground()Returns the body background color. Default is null (no background color).- Returns:
- the body background color.
-
setBodyBackground
public void setBodyBackground(org.eclipse.swt.graphics.RGB bodyBackground) Sets the body background color. Calls to this method override any previous calls to setBodyBackgroundProvider(...).- Parameters:
bodyBackground- the new background color.
-
getBodyBackgroundProvider
Returns the body background color provider.- Returns:
- the body background color provider.
-
setBodyBackgroundProvider
Sets the body background color provider. Calls to this method override any previous calls to setBodyBackground(RGB). Setting this property to null restores the default background provider.- Parameters:
bodyBackgroundProvider- the new background color provider.
-
getPainter
public GridLookPainter getPainter(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc) Description copied from interface:GridLookReturns a GridLookPainter for painting the GridLook.- Specified by:
getPainterin interfaceGridLook- Parameters:
device- the device to paint on.gc- the graphics context for painting.- Returns:
- a GridLookPainter for painting the GridLook.
-