|
|||||||||
| Home >> All >> cgsuite >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
cgsuite.plugin
Class GridEditorPanel

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
cgsuite.plugin.EditorPanel
cgsuite.plugin.GridEditorPanel
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
- public class GridEditorPanel
- extends EditorPanel
A generalized, reusable grid-based EditorPanel. A
GridEditorPanel displays a cgsuite.util.Grid in a
rectangular array, mapping the Grid's integer values to
images using a user-specified list of icons. Entries in the grid can be
modified using a variety of user input methods.
Custom Editors may create and populate instances of
GridEditorPanel directly; a variety of methods are provided
for customizing the grid's behavior and display. If additional flexibility
is needed, GridEditorPanel can be subclassed, or a new
EditorPanel written from scratch.
- Version:
- $Revision: 1.14 $ $Date: 2003/10/14 05:30:39 $
| Nested Class Summary | |
protected class |
GridEditorPanel.GridEditorListener
|
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private javax.swing.JMenuItem |
addColumn
|
private javax.swing.JMenuItem |
addRow
|
static int |
ALLOW_ALL
Indicates that all methods of modifying the grid are permitted. |
static int |
ALLOW_CYCLE_ENTRIES
Indicates that the user may cycle among the available grid entries by left-clicking the grid. |
static int |
ALLOW_DRAG_ENTRIES
Indicates that the user may drag the grid entries to new locations. |
static int |
ALLOW_RESIZE_HORIZONTAL
Indicates that the user may resize this GridEditorPanel
horizontally. |
static int |
ALLOW_RESIZE_VERTICAL
Indicates that the user may resize this GridEditorPanel
vertically. |
static int |
ALLOW_SET_ENTRIES
Indicates that the user may set the values of the grid entries by selecting from a popup menu. |
private int |
borderHeight
|
private int |
borderWidth
|
private java.awt.Dimension |
cellSize
|
private javax.swing.JMenu |
changeBoardSizeMenu
|
private int |
defaultEmptyCell
|
private java.awt.Dimension |
draggingCell
|
private int |
gap
|
private cgsuite.util.Grid |
grid
|
private javax.swing.Icon[] |
icons
|
private java.awt.image.BufferedImage |
image
|
private int |
lineThickness
|
private GridEditorPanel.GridEditorListener |
listener
|
private int |
originalDraggingCellValue
|
private int |
originalSelectedCellValue
|
private int |
permissions
|
protected javax.swing.JPopupMenu |
popupMenu
|
private javax.swing.JMenuItem |
removeColumn
|
private javax.swing.JMenuItem |
removeRow
|
private java.awt.Dimension |
selectedCell
|
private javax.swing.JMenu |
setCellMenu
|
| Fields inherited from class cgsuite.plugin.EditorPanel |
EDIT_STATE_PROPERTY |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
GridEditorPanel()
Constructs a new GridEditorPanel with an empty list of
icons and an empty 1x1 grid, allowing all methods of modifying the
grid. |
|
GridEditorPanel(javax.swing.Icon[] icons)
Constructs a new GridEditorPanel with the specified list
of icons and an empty 1x1 grid, allowing all methods of modifying the
grid. |
|
GridEditorPanel(javax.swing.Icon[] icons,
cgsuite.util.Grid grid)
Constructs a new GridEditorPanel with the specified list
of icons and initial entries, and allowing all forms of modifying the
grid. |
|
GridEditorPanel(javax.swing.Icon[] icons,
cgsuite.util.Grid grid,
int permissions)
Constructs a new GridEditorPanel with the specified list
of icons, initial entries, and permissions. |
|
| Method Summary | |
void |
addColumn(java.awt.Point p)
Add a column at the selected position. |
void |
addRow(java.awt.Point p)
Add a row at the selected position. |
protected void |
createMenus()
Create all menus and link them to the event listener. |
protected void |
cycleCell(java.awt.Dimension d)
Cycle the value at the given cell one step through the allowable values, then repaint. |
java.awt.Dimension |
getBorderSize()
Get the size of the blank borders between the board and the edges of the panel. |
protected java.awt.Dimension |
getCell(java.awt.Point p)
Return the array reference for the cell containing p. |
int |
getGap()
Get the minimum gap within each square between the edges of the icon and the gridlines. |
cgsuite.util.Grid |
getGrid()
Returns a copy of the Grid stored in this editor panel. |
javax.swing.Icon[] |
getIcons()
|
int |
getLineThickness()
Get the thickness of the gridlines. |
int |
getPermissions()
|
java.awt.Dimension |
getPreferredSize()
Get the preferred size (so the component will be correctly displayed in a scrollpane). |
void |
paintComponent(java.awt.Graphics g)
Paint the grid with entries. |
void |
removeColumn(int col)
Remove the selected column (counting from 0 at the left hand edge). |
void |
removeRow(int row)
Remove the requested row (counting from 0 as the top row). |
protected void |
replaceImage()
Rerender the image. |
protected void |
replaceImage(int row,
int column)
Rerender the given cell in the image. |
void |
setBorderSize(int width,
int height)
Set the blank borders between the board and the edge of the panel. |
protected void |
setCell(java.awt.Dimension d,
int newValue)
Set the entry at the given gell to the given value, then repaint. |
void |
setGap(int newGap)
Set the minimum gap within each square between the edges of the icon and the gridlines. |
void |
setGrid(cgsuite.util.Grid grid)
|
void |
setIcons(javax.swing.Icon[] icons)
|
void |
setLineThickness(int newThickness)
Set the thickness of the gridlines. |
void |
setPermissions(int permissions)
|
private void |
setUnitGrid()
|
private GridEditorPanel |
thisComponent()
Needed to get a reference from within the listener class (since this refers to the listener). |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
ALLOW_RESIZE_HORIZONTAL
public static final int ALLOW_RESIZE_HORIZONTAL
- Indicates that the user may resize this
GridEditorPanelhorizontally.- See Also:
- Constant Field Values
ALLOW_RESIZE_VERTICAL
public static final int ALLOW_RESIZE_VERTICAL
- Indicates that the user may resize this
GridEditorPanelvertically.- See Also:
- Constant Field Values
ALLOW_CYCLE_ENTRIES
public static final int ALLOW_CYCLE_ENTRIES
- Indicates that the user may cycle among the available grid entries by
left-clicking the grid.
- See Also:
- Constant Field Values
ALLOW_SET_ENTRIES
public static final int ALLOW_SET_ENTRIES
- Indicates that the user may set the values of the grid entries by
selecting from a popup menu.
- See Also:
- Constant Field Values
ALLOW_DRAG_ENTRIES
public static final int ALLOW_DRAG_ENTRIES
- Indicates that the user may drag the grid entries to new locations.
- See Also:
- Constant Field Values
ALLOW_ALL
public static final int ALLOW_ALL
- Indicates that all methods of modifying the grid are permitted.
- See Also:
- Constant Field Values
icons
private javax.swing.Icon[] icons
grid
private cgsuite.util.Grid grid
image
private java.awt.image.BufferedImage image
borderWidth
private int borderWidth
borderHeight
private int borderHeight
gap
private int gap
lineThickness
private int lineThickness
cellSize
private java.awt.Dimension cellSize
defaultEmptyCell
private int defaultEmptyCell
permissions
private int permissions
selectedCell
private java.awt.Dimension selectedCell
draggingCell
private java.awt.Dimension draggingCell
originalSelectedCellValue
private int originalSelectedCellValue
originalDraggingCellValue
private int originalDraggingCellValue
popupMenu
protected javax.swing.JPopupMenu popupMenu
setCellMenu
private javax.swing.JMenu setCellMenu
changeBoardSizeMenu
private javax.swing.JMenu changeBoardSizeMenu
addRow
private javax.swing.JMenuItem addRow
addColumn
private javax.swing.JMenuItem addColumn
removeRow
private javax.swing.JMenuItem removeRow
removeColumn
private javax.swing.JMenuItem removeColumn
listener
private GridEditorPanel.GridEditorListener listener
| Constructor Detail |
GridEditorPanel
public GridEditorPanel()
- Constructs a new
GridEditorPanelwith an empty list of icons and an empty 1x1 grid, allowing all methods of modifying the grid.
GridEditorPanel
public GridEditorPanel(javax.swing.Icon[] icons)
- Constructs a new
GridEditorPanelwith the specified list of icons and an empty 1x1 grid, allowing all methods of modifying the grid.
GridEditorPanel
public GridEditorPanel(javax.swing.Icon[] icons, cgsuite.util.Grid grid)
- Constructs a new
GridEditorPanelwith the specified list of icons and initial entries, and allowing all forms of modifying the grid.
GridEditorPanel
public GridEditorPanel(javax.swing.Icon[] icons, cgsuite.util.Grid grid, int permissions)
- Constructs a new
GridEditorPanelwith the specified list of icons, initial entries, and permissions.
| Method Detail |
getIcons
public javax.swing.Icon[] getIcons()
setIcons
public void setIcons(javax.swing.Icon[] icons)
getGrid
public cgsuite.util.Grid getGrid()
- Returns a copy of the Grid stored in this editor panel.
setGrid
public void setGrid(cgsuite.util.Grid grid)
setUnitGrid
private void setUnitGrid()
getBorderSize
public java.awt.Dimension getBorderSize()
- Get the size of the blank borders between the board and the
edges of the panel.
setBorderSize
public void setBorderSize(int width,
int height)
- Set the blank borders between the board and the edge of the
panel.
getGap
public int getGap()
- Get the minimum gap within each square between the edges of
the icon and the gridlines.
setGap
public void setGap(int newGap)
- Set the minimum gap within each square between the edges of
the icon and the gridlines.
getLineThickness
public int getLineThickness()
- Get the thickness of the gridlines.
setLineThickness
public void setLineThickness(int newThickness)
- Set the thickness of the gridlines.
getPermissions
public int getPermissions()
setPermissions
public void setPermissions(int permissions)
removeRow
public void removeRow(int row)
- Remove the requested row (counting from 0 as the top
row). Cannot remove the row if there is only one, since this
would leave the array smaller than 1x1.
removeColumn
public void removeColumn(int col)
- Remove the selected column (counting from 0 at the left hand
edge). Cannot remove the column if there is only one, since
this would leave the board smaller than 1x1.
addRow
public void addRow(java.awt.Point p)
- Add a row at the selected position. If the selected position
lies above or below the board, add a row on that edge.
addColumn
public void addColumn(java.awt.Point p)
- Add a column at the selected position. If the selected
position lies to left or right of the board, add a column on
that edge.
replaceImage
protected void replaceImage()
- Rerender the image. Call this method when more than one entry
in the grid array has changed.
replaceImage
protected void replaceImage(int row,
int column)
- Rerender the given cell in the image. Call this method when
only one cell in the grid array has changed. You will
generally need to call
repaint()as well.
paintComponent
public void paintComponent(java.awt.Graphics g)
- Paint the grid with entries.
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Get the preferred size (so the component will be correctly
displayed in a scrollpane). The preferred size is the image
size plus borders.
getCell
protected java.awt.Dimension getCell(java.awt.Point p)
- Return the array reference for the cell containing p. If p is
outside the board, return null. The reference is in Screen cell
coordinates
(width, height), with the origin at top-left, not in array coordinates[row][column]
cycleCell
protected void cycleCell(java.awt.Dimension d)
- Cycle the value at the given cell one step through the
allowable values, then repaint.
setCell
protected void setCell(java.awt.Dimension d, int newValue)
- Set the entry at the given gell to the given value, then repaint.
createMenus
protected void createMenus()
- Create all menus and link them to the event listener.
thisComponent
private GridEditorPanel thisComponent()
- Needed to get a reference from within the listener class
(since
thisrefers to the listener).
|
|||||||||
| Home >> All >> cgsuite >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC