public class TableBody extends ContainerBox implements TextLines
Modifier and Type | Class and Description |
---|---|
static class |
TableBody.Cell |
protected static class |
TableBody.CellImpl |
static class |
TableBody.CellInfo |
protected static class |
TableBody.LayoutInfo |
GadgetContainer.Side
Modifier and Type | Field and Description |
---|---|
protected boolean |
addColRowLabels |
protected int[] |
columnConstrainedWidth |
protected int |
horizontalSpacing |
protected static int |
LABEL_MARGIN_HEIGHT |
protected static int |
LABEL_MARGIN_WIDTH |
protected TableBody.LayoutInfo |
layoutInfo |
protected TableBody.CellImpl[][] |
rows |
protected int |
verticalSpacing |
style
children, NO_GADGETS
Modifier and Type | Method and Description |
---|---|
void |
addRow() |
void |
addRow(TableBody.Cell[] cells) |
protected static void |
drawColumnRowLabel(Graphics g,
int index,
boolean column,
int rx,
int ry,
int rw,
int rh,
FontMetrics labelMetrics,
int labelA,
int labelD,
Color bg,
Color bg2,
Color fg,
Color fg2) |
TableBody.CellInfo |
findCell(Gadget gadget) |
boolean |
findCell(TableBody.CellInfo info) |
TableBody.CellInfo |
getCell(int rowIndex,
int cellIndex) |
void |
getCell(TableBody.CellInfo info) |
int |
getCellCount(int rowIndex) |
int |
getFirstBaseLine()
Returns the baseline of first text line if any and -1 otherwise.
|
int |
getHorizontalCellSpacing() |
int |
getLastBaseLine()
Returns the baseline of last text line if any and -1 otherwise.
|
TableBody.Cell[] |
getRow(int rowIndex) |
int |
getRowCount() |
void |
getSizeConstraints(Gadget child,
Dimension constraints)
Invoked by a child gadget before layouting itself to know what are the
constraints for its width and height.
|
int |
getVerticalCellSpacing() |
void |
insertCell(int rowIndex,
int cellIndex,
TableBody.Cell cell) |
void |
insertCell(int childIndex,
TableBody.Cell cell) |
void |
insertChild(int childIndex,
Gadget gadget)
Insert specified gadget in this contained at specified index.
|
void |
insertRow(int rowIndex) |
void |
insertRow(int rowIndex,
TableBody.Cell[] cells) |
boolean |
isAddingColumnRowLabels() |
protected void |
layoutContent(int constrainedWidth,
int constrainedHeight,
boolean recursive) |
protected void |
layoutEmptyContent(int constrainedWidth,
int constrainedHeight) |
protected static String |
numberToLabel(int number) |
protected void |
paintContent(Graphics g) |
void |
paintRelayout(Gadget child,
int prevWidth,
int prevHeight,
GadgetContainer.Side damagedSide,
int damagedLength)
Invoked by a child gadget when its geometry (width, height, but also
for some gadgets baseline, reference point, etc) has changed.
|
protected void |
printContent(Graphics g) |
void |
removeCell(int rowIndex,
int cellIndex) |
void |
removeChild(Gadget gadget)
Remove specified gadget from this container.
|
void |
removeChild(int childIndex)
Remove child gadget at specified index from this container.
|
void |
removeRow(int rowIndex) |
void |
replaceCell(int rowIndex,
int cellIndex,
TableBody.Cell newCell) |
void |
replaceChild(Gadget oldGadget,
Gadget newGadget)
Replace specified gadget in this container.
|
void |
replaceChild(int childIndex,
Gadget newGadget)
Replace specified gadget in this container.
|
void |
setAddingColumnRowLabels(boolean addColRowLabels) |
void |
setHorizontalCellSpacing(int spacing) |
void |
setVerticalCellSpacing(int spacing) |
getMarginBottom, getMarginTop, getStyle, hasDynamicVerticalMargins, layout, paint, paintEmptyContent, print, printEmptyContent, setStyle
addChild, findGadgetAt, getChild, getChildCount, getChildren, getNonBreakableVerticalRanges, indexOfChild, indexOfChildAt, isAncestorOf, paintRelayout, removeAllChildren
focusGained, focusLost, gadgetToPanel, gadgetToRoot, getAncestors, getBounds, getBounds, getCursor, getEventDispatcher, getFontMetrics, getGadgetPanel, getGraphics, getLocation, getLocation, getRoot, getSize, getSize, getToolkit, getToolTip, grabsMouseButton, handleAppEvent, handleKeyEvent, handleMouseEvent, hasFocus, isAppEventHandler, layout, makeRectangleVisible, makeRectangleVisible, panelToGadget, refresh, relayout, relayout, repaint, repaint, requestFocus
protected static int LABEL_MARGIN_WIDTH
protected static int LABEL_MARGIN_HEIGHT
protected int horizontalSpacing
protected int verticalSpacing
protected boolean addColRowLabels
protected TableBody.CellImpl[][] rows
protected int[] columnConstrainedWidth
protected TableBody.LayoutInfo layoutInfo
public TableBody()
public TableBody(Style style)
public void setHorizontalCellSpacing(int spacing)
public int getHorizontalCellSpacing()
public void setVerticalCellSpacing(int spacing)
public int getVerticalCellSpacing()
public void setAddingColumnRowLabels(boolean addColRowLabels)
public boolean isAddingColumnRowLabels()
public void addRow()
public void addRow(TableBody.Cell[] cells)
public void insertRow(int rowIndex)
public void insertRow(int rowIndex, TableBody.Cell[] cells)
public void removeRow(int rowIndex)
public TableBody.Cell[] getRow(int rowIndex)
public int getRowCount()
public int getCellCount(int rowIndex)
public void insertChild(int childIndex, Gadget gadget)
GadgetContainer
insertChild
in class GadgetContainer
public void insertCell(int childIndex, TableBody.Cell cell)
public void insertCell(int rowIndex, int cellIndex, TableBody.Cell cell)
public void removeChild(Gadget gadget)
GadgetContainer
removeChild
in class GadgetContainer
public void removeChild(int childIndex)
GadgetContainer
removeChild
in class GadgetContainer
public void removeCell(int rowIndex, int cellIndex)
public void replaceChild(Gadget oldGadget, Gadget newGadget)
GadgetContainer
replaceChild
in class GadgetContainer
oldGadget
- replaced gadgetnewGadget
- replacement gadgetpublic void replaceChild(int childIndex, Gadget newGadget)
GadgetContainer
replaceChild
in class GadgetContainer
childIndex
- index of replaced gadget within this containernewGadget
- replacement gadgetpublic void replaceCell(int rowIndex, int cellIndex, TableBody.Cell newCell)
public TableBody.CellInfo getCell(int rowIndex, int cellIndex)
public void getCell(TableBody.CellInfo info)
public TableBody.CellInfo findCell(Gadget gadget)
public boolean findCell(TableBody.CellInfo info)
protected void layoutEmptyContent(int constrainedWidth, int constrainedHeight)
layoutEmptyContent
in class ContainerBox
protected void layoutContent(int constrainedWidth, int constrainedHeight, boolean recursive)
layoutContent
in class ContainerBox
public void getSizeConstraints(Gadget child, Dimension constraints)
GadgetContainer
getSizeConstraints
in class GadgetContainer
child
- the child that invoked this methodconstraints
- this Dimension object is updated to reflect the
contraints on the child size. A negative or null width or height means
not constrained.public void paintRelayout(Gadget child, int prevWidth, int prevHeight, GadgetContainer.Side damagedSide, int damagedLength)
GadgetContainer
This parent gadget must at least respond by repainting its child but generally this parent gadget has to ``refresh'' itself.
This default implementation is a kind of light-weight Gadget.refresh()
where the relayout is not recursive. It should be redefined
by a faster, more container specific, version.
This default implementation assumes that if, after the relayout, this container has not changed its width and height, a repaint is sufficient and its own parent doesn't need to be notified.
paintRelayout
in class GadgetContainer
child
- the child that invoked this methodprevWidth
- child width before the relayoutprevHeight
- child height before the relayoutdamagedSide
- the side, if any, that was expanded or shrinkeddamagedLength
- If damagedSide is GadgetContainer.Side.TOP
, it is
sufficient to repaint (0, 0, width, damagedLength).
If damagedSide is GadgetContainer.Side.BOTTOM
, it is sufficient to repaint
(0, height-damagedLength, width, damagedLength).
If damagedSide is GadgetContainer.Side.LEFT
, it is sufficient to repaint
(0, 0, damagedLength, height).
If damagedSide is GadgetContainer.Side.RIGHT
, it is sufficient to repaint
(width-damagedLength, 0, damagedLength, height).
If damagedSide is GadgetContainer.Side.NONE
, (damagedLength is meaningless)
repaint the whole child.
protected void paintContent(Graphics g)
paintContent
in class ContainerBox
protected static final void drawColumnRowLabel(Graphics g, int index, boolean column, int rx, int ry, int rw, int rh, FontMetrics labelMetrics, int labelA, int labelD, Color bg, Color bg2, Color fg, Color fg2)
protected static final String numberToLabel(int number)
protected void printContent(Graphics g)
printContent
in class ContainerBox
public int getFirstBaseLine()
TextLines
getFirstBaseLine
in interface TextLines
public int getLastBaseLine()
TextLines
getLastBaseLine
in interface TextLines