|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--edu.kzoo.grid.display.ScrollableGridDisplay
Grid Display Package:
A ScrollableGridDisplay is a panel containing a
scrollable graphical display of a grid.
| Field Summary | |
protected GridBackgroundDisplay |
backgroundDisplay
|
protected java.awt.Color |
bgColor
|
static int |
DEFAULT_MIN_CELL_SIZE
|
static int |
DEFAULT_VIEWABLE_SIZE
|
protected int |
gridLineWidth
|
protected static int |
LOCATION_TOOL_TIPS
|
protected int |
minCellSize
|
protected int |
numCols
|
protected int |
numRows
|
protected static int |
OBJECT_STRING_TOOL_TIPS
|
static java.awt.Color |
OCEAN_BLUE
|
protected int |
originCol
|
protected int |
originRow
|
protected int |
outerCellSize
|
protected java.awt.Dimension |
preferredVPSize
|
protected Grid |
theGrid
|
protected boolean |
toolTipsEnabledFlag
|
protected int |
toolTipsType
|
| 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.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 | |
ScrollableGridDisplay()
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(java.awt.Color backgroundColor)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int minimumCellSize)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int minimumCellSize,
java.awt.Color backgroundColor)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int width,
int height)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int width,
int height,
java.awt.Color backgroundColor)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int width,
int height,
int minimumCellSize)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
ScrollableGridDisplay(int viewingWidth,
int viewingHeight,
int minimumCellSize,
java.awt.Color backgroundColor)
Constructs a new ScrollableGridDisplay object with no grid and an empty view. |
|
| Method Summary | |
java.awt.Color |
backgroundColor()
Gets the background color for displaying the grid. |
protected int |
calculateGridLineWidth()
Returns the width of each grid line. |
int |
colToXCoord(int col)
Returns X-coordinate of left side of given column. |
void |
drawBackground(java.awt.Graphics2D g2)
Draws the grid background. |
protected void |
drawGridlines(java.awt.Graphics2D g2)
Draws the gridlines for the grid. |
protected void |
drawGridObject(java.awt.Graphics2D g2,
GridObject obj)
Draws one GridObject instance. |
protected int |
extraHeight()
|
protected int |
extraWidth()
|
void |
fillBackground(java.awt.Graphics2D g2,
java.awt.Color fillColor)
Fills the grid background with the specified color. |
javax.swing.JViewport |
getEnclosingViewport()
Gets our parent viewport, if we are in one. |
java.awt.Dimension |
getMinimumSize()
Returns the minimum size of the display, for use by layout manager. |
java.lang.String |
getPannableTipText()
|
java.awt.Dimension |
getPreferredScrollableViewportSize()
|
java.awt.Dimension |
getPreferredSize()
Returns the desired size of the display, for use by layout manager. |
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
boolean |
getScrollableTracksViewportHeight()
|
boolean |
getScrollableTracksViewportWidth()
|
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
java.lang.String |
getToolTipText(java.awt.event.MouseEvent evt)
Given a MouseEvent, determines what text to place in the floating tool tip when the the mouse hovers over this location. |
Grid |
grid()
Gets the grid. |
boolean |
gridLinesAreVisible()
Returns true if the grid lines are visible,
false otherwise. |
int |
innerCellSize()
Returns the size of each cell, not including the width of a grid line. |
boolean |
isPannableUnbounded()
|
Location |
locationForPoint(java.awt.Point p)
Given a Point, determines which grid location (if any) is under the mouse. |
void |
makeGridLinesVisible(boolean visible)
Makes the gridlines visible or invisible, depending on the value of the visible parameter. |
void |
makeToolTipsReportLocation()
Sets tool tips to provide information about the locations of cells in the grid. |
void |
makeToolTipsReportObject()
Sets tool tips to provide information about the contents of cells in the grid. |
int |
minimumCellSize()
Gets the minimum cell size. |
void |
paintComponent(java.awt.Graphics g)
Paints this component. |
void |
panBy(int hDelta,
int vDelta)
|
void |
reactToNewGrid(Grid newGrid)
Reacts to a change in grids being used. |
protected void |
recalculateCellSize()
Calculates the cell size to use given the current viewable region and the number of rows and columns in the grid. |
void |
recenterOnOrigin()
Pans the display back to the origin, so that 0, 0 is at the the upper left of the visible viewport. |
int |
rowToYCoord(int row)
Returns Y-coordinate of top of given row. |
void |
setBackgroundColor(java.awt.Color newBackgroundColor)
Sets the background color for displaying the grid. |
void |
setBackgroundDisplay(GridBackgroundDisplay bgDisplay)
Sets the object used to draw the background. |
void |
setGrid(Grid grid)
Sets the Grid being displayed. |
void |
setToolTipsEnabled(boolean flag)
Enables/disables showing of tooltip giving information about the grid object beneath the mouse. |
void |
showGrid()
Shows the grid. |
boolean |
toolTipsEnabled()
Indicates whether tool tips have been enabled. |
void |
updateLocation(Location loc)
Updates the display of just a single location on the grid. |
protected int |
xCoordToCol(int xCoord)
Returns column corresponding to given X-coordinate. |
protected int |
yCoordToRow(int yCoord)
Returns row corresponding to given Y-coordinate. |
void |
zoomIn()
Zooms in the display by doubling the current cell size. |
void |
zoomOut()
Zooms out the display by halving the current cell size. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_MIN_CELL_SIZE
public static final int DEFAULT_VIEWABLE_SIZE
public static final java.awt.Color OCEAN_BLUE
protected static final int LOCATION_TOOL_TIPS
protected static final int OBJECT_STRING_TOOL_TIPS
protected Grid theGrid
protected java.awt.Dimension preferredVPSize
protected int gridLineWidth
protected int minCellSize
protected int outerCellSize
protected int numRows
protected int numCols
protected int originRow
protected int originCol
protected GridBackgroundDisplay backgroundDisplay
protected java.awt.Color bgColor
protected boolean toolTipsEnabledFlag
protected int toolTipsType
| Constructor Detail |
public ScrollableGridDisplay()
public ScrollableGridDisplay(int width,
int height)
width and height must be
at least as large as the default minimum cell size.)
width - the width of the viewing areaheight - the height of the viewing areapublic ScrollableGridDisplay(int minimumCellSize)
minimumCellSize - minimum cell side length
public ScrollableGridDisplay(int width,
int height,
int minimumCellSize)
width and height must be
at least as large as minimumCellSize.)
width - the width of the viewing areaheight - the height of the viewing areaminimumCellSize - minimum cell side lengthpublic ScrollableGridDisplay(java.awt.Color backgroundColor)
backgroundColor - color to paint background of grid
public ScrollableGridDisplay(int width,
int height,
java.awt.Color backgroundColor)
width and height must be
at least as large as the default minimum cell size.)
width - the width of the viewing areaheight - the height of the viewing areabackgroundColor - color to paint background of grid
public ScrollableGridDisplay(int minimumCellSize,
java.awt.Color backgroundColor)
minimumCellSize - minimum cell side lengthbackgroundColor - color to paint background of grid
public ScrollableGridDisplay(int viewingWidth,
int viewingHeight,
int minimumCellSize,
java.awt.Color backgroundColor)
width and height must be
at least as large as minimumCellSize.)
viewingWidth - the width of the viewing areaviewingHeight - the height of the viewing areaminimumCellSize - minimum cell side lengthbackgroundColor - color to paint background of grid| Method Detail |
public void setGrid(Grid grid)
setGrid in interface GridDisplaygrid - the Grid to displaypublic void reactToNewGrid(Grid newGrid)
GridChangeListener
reactToNewGrid in interface GridChangeListenernewGrid - the new grid being usedpublic javax.swing.JViewport getEnclosingViewport()
protected void recalculateCellSize()
protected int calculateGridLineWidth()
public int innerCellSize()
public Grid grid()
public int minimumCellSize()
public void setBackgroundDisplay(GridBackgroundDisplay bgDisplay)
public java.awt.Color backgroundColor()
public void setBackgroundColor(java.awt.Color newBackgroundColor)
public void makeGridLinesVisible(boolean visible)
visible parameter. The gridlines are visible
by default.
visible - whether to make the gridlines visible (true)
or invisible (false)public boolean gridLinesAreVisible()
true if the grid lines are visible,
false otherwise.
public void showGrid()
repaint method is the standard way to ask a
Swing component to redraw itself. This eventually turns into a call
back to our version of the standard paintComponent
method where we do the actual drawing.
showGrid in interface GridDisplaypublic void updateLocation(Location loc)
public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentg - the Graphics object to use to render this componentpublic void drawBackground(java.awt.Graphics2D g2)
drawBackground in interface GridBackgroundDisplayg2 - the Graphics2 object to use to render
public void fillBackground(java.awt.Graphics2D g2,
java.awt.Color fillColor)
g2 - the Graphics2 object to use to renderfillColor - the color with which to fill the backgroundprotected void drawGridlines(java.awt.Graphics2D g2)
g2 - the Graphics2 object to use to render
protected void drawGridObject(java.awt.Graphics2D g2,
GridObject obj)
g2 - the Graphics2D object to use to renderobj - the GridObject object to draw
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
getScrollableUnitIncrement in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
getScrollableBlockIncrement in interface javax.swing.Scrollablepublic boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth in interface javax.swing.Scrollablepublic boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight in interface javax.swing.Scrollablepublic java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize in interface javax.swing.Scrollablepublic void zoomIn()
public void zoomOut()
public void recenterOnOrigin()
public void panBy(int hDelta,
int vDelta)
panBy in interface PseudoInfiniteViewport.Pannablepublic boolean isPannableUnbounded()
isPannableUnbounded in interface PseudoInfiniteViewport.Pannablepublic java.lang.String getPannableTipText()
getPannableTipText in interface PseudoInfiniteViewport.Pannablepublic void setToolTipsEnabled(boolean flag)
flag - whether to enable/disable tool tipspublic boolean toolTipsEnabled()
true if tool tips are enabled;
false otherwisepublic void makeToolTipsReportLocation()
public void makeToolTipsReportObject()
public java.lang.String getToolTipText(java.awt.event.MouseEvent evt)
getToolTipText in class javax.swing.JComponentevt - the MouseEvent in question
public Location locationForPoint(java.awt.Point p)
p - the Point in question (in display's coordinate system)
protected int xCoordToCol(int xCoord)
protected int yCoordToRow(int yCoord)
public int colToXCoord(int col)
public int rowToYCoord(int row)
public java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JComponentpublic java.awt.Dimension getMinimumSize()
getMinimumSize in class javax.swing.JComponentprotected int extraWidth()
protected int extraHeight()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||