edu.mines.jtk.mosaic
Class Mosaic

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by edu.mines.jtk.mosaic.IPanel
                      extended by edu.mines.jtk.mosaic.Mosaic
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Mosaic
extends IPanel

A mosaic of tiles and tile axes. A mosaic lays out its tiles in a matrix, with a specified number of rows and columns. It manages the world and normalized coordinate systems of those tiles, so that tiles zoom and scroll consistently.

For example, when the the view rectangle (in normalized coordinates) of a tile is set, perhaps while zooming or scrolling, then that tile's mosaic changes the view rectangles of any other tiles in the same row or column accordingly, so that they all zoom and scroll together.

A mosaic can also manage axes at the top, left, bottom, and/or right sides of its matrix of tiles. These axes annotate the adjacent tiles, and mosaic ensures that they too zoom and scroll consistent with any changes to the view rectangles of those tiles.

A mosaic also manages a horizontal scrollbar for each column and a vertical scrollbar for each row. The mosaic shows scrollbars for only those dimensions of view rectangles that are zoomed. In other words, scrollbars are visible and consume space only when they are needed.

Version:
2004.12.27, 2005.12.23
Author:
Dave Hale, Colorado School of Mines
See Also:
Serialized Form

Nested Class Summary
static class Mosaic.AxesPlacement
          Placement of axes.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
Mosaic(int nrow, int ncol, java.util.Set<Mosaic.AxesPlacement> axesPlacement)
          Constructs a mosaic with the specified number of rows and columns.
 
Method Summary
 int countColumns()
          Returns the number of columns of tiles in this mosaic.
 int countRows()
          Returns the number of rows of tiles in this mosaic.
 void doLayout()
           
 java.awt.Dimension getMinimumSize()
           
 ModeManager getModeManager()
          Gets the mode manager for this mosaic.
 java.awt.Dimension getPreferredSize()
           
 Tile getTile(int irow, int icol)
          Gets the tile with specified row and column indices.
 TileAxis getTileAxisBottom(int icol)
          Gets the bottom tile axis with specified column index.
 TileAxis getTileAxisLeft(int irow)
          Gets the left tile axis with specified row index.
 TileAxis getTileAxisRight(int irow)
          Gets the right tile axis with specified row index.
 TileAxis getTileAxisTop(int icol)
          Gets the top tile axis with specified column index.
protected  void paintComponent(java.awt.Graphics g)
           
 void paintToRect(java.awt.Graphics2D g2d, int x, int y, int w, int h)
          Paints this panel to a specified rectangle of a graphics context.
 void setBackground(java.awt.Color color)
           
 void setFont(java.awt.Font font)
           
 void setForeground(java.awt.Color color)
           
 void setHeightElastic(int irow, int heightElastic)
          Sets the height elastic for the specified row.
 void setHeightMinimum(int irow, int heightMinimum)
          Sets the height minimum for the specified row.
 void setModeManager(ModeManager modeManager)
          Sets the mode manager for this mosaic.
 void setWidthElastic(int icol, int widthElastic)
          Sets the width elastic for the specified column.
 void setWidthMinimum(int icol, int widthMinimum)
          Sets the width minimum for the specified column.
 
Methods inherited from class edu.mines.jtk.mosaic.IPanel
computeScale, createGraphics, getLineWidth, paintToImage, paintToImage, paintToPng, scaleLineWidth
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 

Constructor Detail

Mosaic

public Mosaic(int nrow,
              int ncol,
              java.util.Set<Mosaic.AxesPlacement> axesPlacement)
Constructs a mosaic with the specified number of rows and columns.

Parameters:
nrow - the number of rows.
ncol - the number of columns.
axesPlacement - the placement of axes.
Method Detail

setModeManager

public void setModeManager(ModeManager modeManager)
Sets the mode manager for this mosaic. By default, a mosaic constructs a unique mode manager when it is constructed. This default may be overridden, for example, when two or more mosaics must share modes.

Parameters:
modeManager - the mode manager.

countRows

public int countRows()
Returns the number of rows of tiles in this mosaic.

Returns:
the number of rows.

countColumns

public int countColumns()
Returns the number of columns of tiles in this mosaic.

Returns:
the number of columns.

getTile

public Tile getTile(int irow,
                    int icol)
Gets the tile with specified row and column indices.

Parameters:
irow - the row index.
icol - the column index.
Returns:
the tile.

getTileAxisTop

public TileAxis getTileAxisTop(int icol)
Gets the top tile axis with specified column index.

Parameters:
icol - the column index.
Returns:
the axis; null, if none.

getTileAxisLeft

public TileAxis getTileAxisLeft(int irow)
Gets the left tile axis with specified row index.

Parameters:
irow - the row index.
Returns:
the axis; null, if none.

getTileAxisBottom

public TileAxis getTileAxisBottom(int icol)
Gets the bottom tile axis with specified column index.

Parameters:
icol - the column index.
Returns:
the axis; null, if none.

getTileAxisRight

public TileAxis getTileAxisRight(int irow)
Gets the right tile axis with specified row index.

Parameters:
irow - the row index.
Returns:
the axis; null, if none.

setWidthMinimum

public void setWidthMinimum(int icol,
                            int widthMinimum)
Sets the width minimum for the specified column. All tiles in the specified column will have width not less than the specified minimum. Width minimums are used to compute the preferred width of this mosaic. The default width minimum is 100.

Parameters:
icol - the column index.
widthMinimum - the width minimum.

setWidthElastic

public void setWidthElastic(int icol,
                            int widthElastic)
Sets the width elastic for the specified column. If extra width is available in this mosaic, it is allocated to the specified column of tiles in proportion to the specified width elastic. For fixed-width columns, the width elastic should be zero. The default width elastic is 100.

Parameters:
icol - the column index.
widthElastic - the width elastic.

setHeightMinimum

public void setHeightMinimum(int irow,
                             int heightMinimum)
Sets the height minimum for the specified row. All tiles in the specified row will have height not less than the specified minimum. Height minimums are used to compute the preferred height of this mosaic. The default height minimum is 100.

Parameters:
irow - the row index.
heightMinimum - the height minimum.

setHeightElastic

public void setHeightElastic(int irow,
                             int heightElastic)
Sets the height elastic for the specified row. If extra height is available in this mosaic, it is allocated to the specified row of tiles in proportion to the specified height elastic. For fixed-height rows, the height elastic should be zero. The default height elastic is 100.

Parameters:
irow - the row index.
heightElastic - the height elastic.

getModeManager

public ModeManager getModeManager()
Gets the mode manager for this mosaic.

Returns:
the mode manager.

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class javax.swing.JComponent

setForeground

public void setForeground(java.awt.Color color)
Overrides:
setForeground in class javax.swing.JComponent

setBackground

public void setBackground(java.awt.Color color)
Overrides:
setBackground in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

doLayout

public void doLayout()
Overrides:
doLayout in class java.awt.Container

paintToRect

public void paintToRect(java.awt.Graphics2D g2d,
                        int x,
                        int y,
                        int w,
                        int h)
Description copied from class: IPanel
Paints this panel to a specified rectangle of a graphics context. This implementation simply paints any IPanel children of this panel. It ignores and does not draw any children that are not IPanels.

Classes that extend this base class typically override this method to draw something besides children of this panel. When appropriate, those extensions may also call this method.

Overrides:
paintToRect in class IPanel
Parameters:
g2d - the graphics context.
x - the x-coordinate of the graphics rectangle.
y - the y-coordinate of the graphics rectangle.
w - the width of the graphics rectangle.
h - the height of the graphics rectangle.

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent