edu.mines.jtk.mosaic
Class Tile

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.Tile
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Tile
extends IPanel

A tile in a mosaic contains a list of tiled views. A tile coordinates changes to its tiled views and its view rectangle with other tiles in its mosaic.

Each tile has a horizontal projector and a vertical projector. These map world coordinates to and from normalized coordinates. The mosaic aligns its tiles such that all tiles in the same column share the same horizontal projector, and all tiles in the same row share the same vertical projector.

A tile's view rectangle represents a subset of a unit square; i.e., the view rectangle is in normalized coordinates. Setting the view rectangle of a tile causes the view rectangle to be set accordingly in all tiles in the same column and row of the mosaic. To zoom or scroll a tile, change its view rectangle.

A tile's transcaler maps normalized coordinates to and from device coordinates. When unzoomed (by default), the tile's transcaler maps normalized coordinates (0.0,0.0) to device coordinates (0,0) and normalized coordinates (1.0,1.0) to device coordinates (width-1,height-1), where width and height represent the size of the tile. The transcaler changes when either its size or its view rectangle is changed.

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

Nested Class Summary
 
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
 
Method Summary
 boolean addTiledView(TiledView tv)
          Adds the specified tiled view to this tile.
 int countTiledViews()
          Returns the number of tiled views in this this.
 int getColumnIndex()
          Gets the column index of this tile.
 Projector getHorizontalProjector()
          Gets the horizontal projector for this tile.
 Mosaic getMosaic()
          Gets the mosaic that contains this tile.
 int getRowIndex()
          Gets the row index of this tile.
 TileAxis getTileAxisBottom()
          Gets the bottom tile axis for this tile.
 TileAxis getTileAxisLeft()
          Gets the left tile axis for this tile.
 TileAxis getTileAxisRight()
          Gets the right tile axis for this tile.
 TileAxis getTileAxisTop()
          Gets the top tile axis for this tile.
 TiledView getTiledView(int index)
          Gets the tiled view with specified index.
 java.util.Iterator<TiledView> getTiledViews()
          Gets an iterator for the tiled views in this tile.
 Transcaler getTranscaler()
          Gets the transcaler for this tile.
 Projector getVerticalProjector()
          Gets the vertical projector for this tile.
 DRectangle getViewRectangle()
          Gets the view rectangle for this tile.
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.
 double pixelToWorldHorizontal(int x)
          Transforms a pixel x coordinate to a horizontal world coordinate.
 double pixelToWorldVertical(int y)
          Transforms a pixel y coordinate to a vertical world coordinate.
 boolean removeTiledView(TiledView tv)
          Removes the specified tiled view from this tile.
 void setBestHorizontalProjector(Projector bhp)
          Sets the best horizontal projector for this tile.
 void setBestVerticalProjector(Projector bvp)
          Sets the best vertical projector for this tile.
 void setBounds(int x, int y, int width, int height)
           
 void setViewRectangle(DRectangle vr)
          Sets the view rectangle for this tile.
 
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, 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, doLayout, 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, 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
 

Method Detail

getMosaic

public Mosaic getMosaic()
Gets the mosaic that contains this tile.

Returns:
the mosaic.

getRowIndex

public int getRowIndex()
Gets the row index of this tile.

Returns:
the row index.

getColumnIndex

public int getColumnIndex()
Gets the column index of this tile.

Returns:
the column index.

setBestHorizontalProjector

public void setBestHorizontalProjector(Projector bhp)
Sets the best horizontal projector for this tile. If null, this tile will compute its best horizontal projector by merging those of its tiled views. If not null, the specified projector is best. In either case, this tile's horizontal projector may be adjusted by it's mosaic during alignment with other tiles in the same column.

Parameters:
bhp - the best horizontal projector.

setBestVerticalProjector

public void setBestVerticalProjector(Projector bvp)
Sets the best vertical projector for this tile. If null, this tile will compute its best vertical projector by merging those of its tiled views. If not null, the specified projector is best. In either case, this tile's vertical projector may be adjusted by it's mosaic during alignment with other tiles in the same row.

Parameters:
bvp - the best vertical projector.

getHorizontalProjector

public Projector getHorizontalProjector()
Gets the horizontal projector for this tile.

Returns:
the horizontal projector.

getVerticalProjector

public Projector getVerticalProjector()
Gets the vertical projector for this tile.

Returns:
the vertical projector.

getTranscaler

public Transcaler getTranscaler()
Gets the transcaler for this tile.

Returns:
the transcaler.

pixelToWorldHorizontal

public double pixelToWorldHorizontal(int x)
Transforms a pixel x coordinate to a horizontal world coordinate.

Parameters:
x - the pixel x coordinate.
Returns:
the horizontal world coordinate.

pixelToWorldVertical

public double pixelToWorldVertical(int y)
Transforms a pixel y coordinate to a vertical world coordinate.

Parameters:
y - the pixel y coordinate.
Returns:
the vertical world coordinate.

addTiledView

public boolean addTiledView(TiledView tv)
Adds the specified tiled view to this tile. If the tiled view is already in this tile, it is first removed, before adding it again.

Parameters:
tv - the tiled view.
Returns:
true, if this tile did not already contain the specified tiled view; false, otherwise.

removeTiledView

public boolean removeTiledView(TiledView tv)
Removes the specified tiled view from this tile. If the tiled view is not in this tile, this method does nothing.

Parameters:
tv - the tiled view.
Returns:
true, if this tile contained the specified tiled view; false, otherwise.

countTiledViews

public int countTiledViews()
Returns the number of tiled views in this this.

Returns:
the number of tiled views.

getTiledView

public TiledView getTiledView(int index)
Gets the tiled view with specified index.

Parameters:
index - the index.
Returns:
the tiled view.

getTiledViews

public java.util.Iterator<TiledView> getTiledViews()
Gets an iterator for the tiled views in this tile.

Returns:
the iterator.

getViewRectangle

public DRectangle getViewRectangle()
Gets the view rectangle for this tile. The view rectangle represents the subset of normalized coordinate space that is displayed in this tile.

Returns:
the view rectangle.

setViewRectangle

public void setViewRectangle(DRectangle vr)
Sets the view rectangle for this tile. The view rectangle represents the subset of normalized coordinate space that is displayed in this tile. Setting the view rectangle may zoom or scroll this tile.

Parameters:
vr - the view rectangle.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class java.awt.Component

getTileAxisTop

public TileAxis getTileAxisTop()
Gets the top tile axis for this tile.

Returns:
the axis; null, if none.

getTileAxisLeft

public TileAxis getTileAxisLeft()
Gets the left tile axis for this tile.

Returns:
the axis; null, if none.

getTileAxisBottom

public TileAxis getTileAxisBottom()
Gets the bottom tile axis for this tile.

Returns:
the axis; null, if none.

getTileAxisRight

public TileAxis getTileAxisRight()
Gets the right tile axis for this tile.

Returns:
the axis; null, if none.

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