Class TiledImageViewer
- All Implemented Interfaces:
ComponentListener,HierarchyListener,MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,Cloneable,EventListener,TileListener
The tiles are provided by tile providers. The tiles are requested asynchronously on multiple
threads and are cached. This means that tile providers have to do no caching themselves and are free to calculate or
generate each tile on request, even if that is relatively slow.
The tile providers are ordered on numbered layers. The numbering does not have to be continuous, and only one tile provider can be configured per layer. Lower numbered layers are rendered below higher numbered layers.
When zooming in, this viewer performs all the scaling itself. When zooming out, for tile providers which indicate that they support zooming, the scaling is delegated to the tile providers.
This class does not provide scrollbars, however it can be encapsulated in a TiledImageViewerContainer
which will surround it with scrollbars, with support for the tile providers' extents.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic interfaceA listener for changes to aTiledImageViewerview.Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.pepsoft.util.IntegerAttributeKeyprotected intThe image coordindates of the marker (if any) to paint as a red crosshair.protected intThe image coordindates of the marker (if any) to paint as a red crosshair.protected intThe previously displayed location in scaled coordinates.protected intThe previously displayed location in scaled coordinates.static final intstatic final intstatic final intprotected intThe currently displayed location in scaled coordinates.protected intThe currently displayed location in scaled coordinates.protected intThe offset to apply to the image so that the view coordinates are displayed in the centre of the view.protected intThe offset to apply to the image so that the view coordinates are displayed in the centre of the view.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new tiled image viewer which allows panning by dragging with the left mouse button and which paints the central crosshair.TiledImageViewer(boolean leftClickDrags, boolean paintCentre) Create a new tiled image viewer.TiledImageViewer(boolean leftClickDrags, boolean paintCentre, int tileProviderZoomCutoff) Create a new tiled image viewer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOverlay(String key, int x, Component componentToTrack, BufferedImage overlay) Add an overlay.clone()Create clone of this tiled image viewer with a copy of the current tile providers and tile provider caches, so that it can immediately display the same content, but then behave independently with regard to zooming and panning.voidvoidvoidvoidGet the combined and zoom-corrected extent or main area of interest of all the tile providers, in component coordinates.Get the colour in which the grid is painted.intGet the current size in image coordinates of the grid.intGet the coordinates in image coordinates of the marker (displayed as a red crosshair), if configured.protected final RectanglegetTileBounds(int x, int y) Get the bounds of a tile in component coordinates, taking the current zoom level into account.protected final RectanglegetTileBounds(int x, int y, int effectiveZoom) Get the bounds of a tile in component coordinates, taking a specific zoom level into account.protected final RectanglegetTileBounds(int x, int y, int width, int height, int effectiveZoom) Get the bounds of a rectangular area of tiles in component coordinates, taking a specific zoom level into account.intGet the number of currently configured tile providers.Get an unmodifiable view of the currently configured list of tile providers.Get the view listener.Get the coordinate in image coordinates of the centre of the view.intgetViewX()Get the X coordinate in image coordinates of the centre of the view.intgetViewY()Get the Y coordinate in image coordinates of the centre of the view.Get the currently visible area in world coordinates.intgetZoom()Get the current zoom level in powers of two.voidhierarchyChanged(HierarchyEvent event) booleanbooleanDetermine whether the grid is currently painted.protected final booleanisTileVisible(int x, int y, int effectiveZoom) Determine whether a tile is currently visible in the viewport.voidvoidvoidvoidvoidvoidvoidvoidmoveBy(int dx, int dy) Move the view by a number of pixels.voidmoveTo(int x, int y) Centre the view on a particular location in image coordinates.voidCentre the view on a particular location in image coordinates.voidCentre the view on the currently configured marker.voidCentre the view on the image origin (coordinates 0,0).protected voidvoidrefresh()Immediately throws away and refreshes all tiles of all tile providers.voidrefresh(boolean keepDirtyTiles) Refreshes all tiles of all tile providers.voidrefresh(TileProvider tileProvider, int x, int y) Refresh a single tile for a single tile provider.voidrefresh(TileProvider tileProvider, Set<Point> tiles) Refresh a number of tiles for a single tile provider.voidRemove all tile providers.voidremoveOverlay(String key) Remove a previously added overlay.voidremoveTileProvider(int layer) Remove a tile provider.voidreset()Deprecated.voidvoidsetBackgroundImage(BufferedImage backgroundImage) voidsetBackgroundImageMode(TiledImageViewer.BackgroundImageMode backgroundImageMode) voidsetGridColour(Color gridColour) Set the colour in which to paint the grid.voidsetGridSize(int gridSize) Set the size in image coordinates at which the grid should be painted.voidsetInhibitUpdates(boolean inhibitUpdates) voidsetLabelScale(int labelScale) voidsetMarkerCoords(Point markerCoords) Set the coordinates in image coordinates where a red crosshair marker should be displayed, if any.voidsetPaintGrid(boolean paintGrid) Set whether the gid should be painted.voidsetTileProvider(int layer, TileProvider tileProvider) Set or replace a tile provider on a specific layer and reuse the existing provider's cached tile images as stale tile images for the new provider.voidsetTileProvider(TileProvider tileProvider) Set or replace a tile provider on layer 0 and reuse the existing provider's cached tile images as stale tile images for the new provider.voidsetTileProviderZoom(TileProvider tileProvider, int zoom) voidsetViewListener(TiledImageViewer.ViewListener viewListener) Get the currently configured view listener, if any.voidsetZoom(int zoom) Set the zoom level in powers of two.voidsetZoom(int zoom, int locusX, int locusY) Set the zoom level in powers of two.voidtileChanged(TileProvider source, int x, int y) Invoked when the contents of a tile have changed and the tile should be retrieved again.voidtilesChanged(TileProvider source, Set<Point> tiles) Invoked when the contents of one or more tiles have changed and the tile(s) should be retrieved again.protected final floatApply translation and scaling to a graphics canvas according to the current location and zoom settings such that it can be painted using image coordinates.final PointviewToWorld(int x, int y) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account.final PointviewToWorld(int x, int y, int effectiveZoom) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, using a specific zoom level.final RectangleviewToWorld(int x, int y, int width, int height) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account.final PointviewToWorld(Point coords) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account.final PointviewToWorld(Point coords, int effectiveZoom) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, using a specific zoom level.final RectangleviewToWorld(Rectangle coords) Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account.final PointworldToView(int x, int y) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account.final RectangleworldToView(int x, int y, int width, int height) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account.final RectangleworldToView(int x, int y, int width, int height, int effectiveZoom) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, using a specific zoom level.final PointworldToView(Point coords) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account.final RectangleworldToView(Rectangle coords) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account.final RectangleworldToView(Rectangle coords, int effectiveZoom) Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, using a specific zoom level.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, getBaseline, getBaselineResizeBehavior, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUIMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
viewX
protected int viewXThe currently displayed location in scaled coordinates. -
viewY
protected int viewYThe currently displayed location in scaled coordinates. -
previousX
protected int previousXThe previously displayed location in scaled coordinates. Used during mouse drag operations. -
previousY
protected int previousYThe previously displayed location in scaled coordinates. Used during mouse drag operations. -
markerX
protected int markerXThe image coordindates of the marker (if any) to paint as a red crosshair. -
markerY
protected int markerYThe image coordindates of the marker (if any) to paint as a red crosshair. -
xOffset
protected int xOffsetThe offset to apply to the image so that the view coordinates are displayed in the centre of the view. -
yOffset
protected int yOffsetThe offset to apply to the image so that the view coordinates are displayed in the centre of the view. -
TILE_SIZE
public static final int TILE_SIZE- See Also:
-
TILE_SIZE_BITS
public static final int TILE_SIZE_BITS- See Also:
-
TILE_SIZE_MASK
public static final int TILE_SIZE_MASK- See Also:
-
ADVANCED_SETTING_MAX_TILE_RENDER_THREADS
public static final org.pepsoft.util.IntegerAttributeKey ADVANCED_SETTING_MAX_TILE_RENDER_THREADS
-
-
Constructor Details
-
TiledImageViewer
public TiledImageViewer()Create a new tiled image viewer which allows panning by dragging with the left mouse button and which paints the central crosshair. -
TiledImageViewer
public TiledImageViewer(boolean leftClickDrags, boolean paintCentre) Create a new tiled image viewer.- Parameters:
leftClickDrags- Whether dragging with the left mouse button should pan the image.paintCentre- Whether the central crosshair indicating the current location should be painted.
-
TiledImageViewer
public TiledImageViewer(boolean leftClickDrags, boolean paintCentre, int tileProviderZoomCutoff) Create a new tiled image viewer.- Parameters:
leftClickDrags- Whether dragging with the left mouse button should pan the image.paintCentre- Whether the central crosshair indicating the current location should be painted.tileProviderZoomCutoff- The zoom level below which zooming should be delegated to the tile providers that support it.
-
-
Method Details
-
getTileProviders
Get an unmodifiable view of the currently configured list of tile providers.- Returns:
- An unmodifyable view of the currently configured list of tile providers.
-
getTileProviderCount
public int getTileProviderCount()Get the number of currently configured tile providers.- Returns:
- The number of currently configured tile providers.
-
setTileProvider
Set or replace a tile provider on layer 0 and reuse the existing provider's cached tile images as stale tile images for the new provider. Mainly meant as a convenience method for clients that will only ever use one tile provider at a time.- Parameters:
tileProvider- The tile provider to place at the specified layer.
-
setTileProvider
Set or replace a tile provider on a specific layer and reuse the existing provider's cached tile images as stale tile images for the new provider.- Parameters:
layer- The layer at which to place the tile provider.tileProvider- The tile provider to place at the specified layer.
-
removeTileProvider
public void removeTileProvider(int layer) Remove a tile provider.- Parameters:
layer- The layer on the tile provider to remove is placed.
-
removeAllTileProviders
public void removeAllTileProviders()Remove all tile providers. -
getViewX
public int getViewX()Get the X coordinate in image coordinates of the centre of the view.- Returns:
- The X coordinate in image coordinates of the centre of the view.
-
getViewY
public int getViewY()Get the Y coordinate in image coordinates of the centre of the view.- Returns:
- The Y coordinate in image coordinates of the centre of the view.
-
getExtent
Get the combined and zoom-corrected extent or main area of interest of all the tile providers, in component coordinates.- Returns:
- The combined and zoom-corrected extent or main area of interest
of all the tile providers, or
nullif there are no tile providers configured, or none of them indicate an extent. - See Also:
-
getViewLocation
Get the coordinate in image coordinates of the centre of the view.- Returns:
- The coordinate in image coordinates of the centre of the view.
-
getZoom
public int getZoom()Get the current zoom level in powers of two.- Returns:
- The current zoom level as a power of two. The scale is 2zoom.
-
setZoom
public void setZoom(int zoom) Set the zoom level in powers of two. 0 means "native size"; positive numbers zoom in (result in a larger scale); negative numbers zoom out (result in a smaller scale).- Parameters:
zoom- The new zoom level as a power of two. The scale will be 2zoom.
-
setZoom
public void setZoom(int zoom, int locusX, int locusY) Set the zoom level in powers of two. 0 means "native size"; positive numbers zoom in (result in a larger scale); negative numbers zoom out (result in a smaller scale).- Parameters:
zoom- The new zoom level as a power of two. The scale will be 2zoom.
-
resetZoom
public void resetZoom() -
getMarkerCoords
Get the coordinates in image coordinates of the marker (displayed as a red crosshair), if configured.- Returns:
- The coordinates in image coordinates of the marker, or
nullif no marker is configured.
-
setMarkerCoords
Set the coordinates in image coordinates where a red crosshair marker should be displayed, if any.- Parameters:
markerCoords- The coordinates in image coordinates where a red crosshair marker should be displayed, ornullif no marker should be displayed.
-
isPaintGrid
public boolean isPaintGrid()Determine whether the grid is currently painted.- Returns:
trueif the grid is currently painted.
-
setPaintGrid
public void setPaintGrid(boolean paintGrid) Set whether the gid should be painted.- Parameters:
paintGrid-trueif the grid should be painted.
-
getGridSize
public int getGridSize()Get the current size in image coordinates of the grid.- Returns:
- The current size in image coordinates of the grid.
-
setGridSize
public void setGridSize(int gridSize) Set the size in image coordinates at which the grid should be painted.- Parameters:
gridSize- The size in image coordinates at which the grid should be painted.
-
moveTo
Centre the view on a particular location in image coordinates.- Parameters:
coords- The coordinates in image coordinates of the location to centre.
-
moveTo
public void moveTo(int x, int y) Centre the view on a particular location in image coordinates.- Parameters:
x- The X coordinate in image coordinates of the location to centre.y- The Y coordinate in image coordinates of the location to centre.
-
moveToMarker
public void moveToMarker()Centre the view on the currently configured marker. Does nothing if no marker is configured. -
moveToOrigin
public void moveToOrigin()Centre the view on the image origin (coordinates 0,0). -
moveBy
public void moveBy(int dx, int dy) Move the view by a number of pixels. The actual movement in image coordinates may be different if the zoom level is not zero.- Parameters:
dx- The number of pixels to move the view right.dy- The number of pixels to move the view down.
-
refresh
public void refresh()Immediately throws away and refreshes all tiles of all tile providers. -
refresh
public void refresh(boolean keepDirtyTiles) Refreshes all tiles of all tile providers.- Parameters:
keepDirtyTiles- Whether to keep displaying the old tiles while the new ones are being rendered.
-
refresh
Refresh a single tile for a single tile provider. If the tile is visible it will immediately be scheduled for background rendering. Otherwise it will be scheduled when it next becomes visible. If there is a fresh tile image in the cache that will be used as a stale tile image until it has been re-rendered.- Parameters:
tileProvider- The tile provider.x- The X coordinate of the tile in tiles relative to the image origin.y- The Y coordinate of the tile in tiles relative to the image origin.
-
refresh
Refresh a number of tiles for a single tile provider. Tiles that are currently visible will immediately be scheduled for background rendering. Otherwise they will be scheduled when they next become visible. Any fresh tile images in the cache will be used as stale tile images until the tiles are re-rendered.- Parameters:
tileProvider- The tile provider.tiles- A set of tile coordinates of the tiles to refresh, in tiles relative to the image origin.
-
reset
Deprecated.Reset the location to the origin, and the zoom level to -2. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account. This version does not take tile-provider-specific offset into acount. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, using a specific zoom level. This version does not take per-tile-provider offsets into account. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, using a specific zoom level. This version does not take per-tile-provider offsets into account. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, taking the current zoom level into account. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, using a specific zoom level. -
worldToView
Transform coordinates from image (world) coordinates to component (pixels relative to the top left corner) coordinates, using a specific zoom level. This version does not take tile-provider-specific offsets into account. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account. -
viewToWorld
Transform coordinates from component (pixels relative to the top left corner) coordinates to image (world) coordinates, taking the current zoom level into account. -
getViewListener
Get the view listener.- Returns:
- The currently configured view listener, or
nullif none is configured.
-
setViewListener
Get the currently configured view listener, if any.- Parameters:
viewListener- The currently configured view listener, ornullif there is none.
-
addOverlay
Add an overlay. An overlay is an image which is overlaid on the viewport, on the left or right edge of the view, vertically tracking some other component. The image may be partially transparent.- Parameters:
key- The unique key of the overlay to add.x- The horizontal distance from the left edge to paint the overlay, or if negative: the horizontal distance from the right edge.componentToTrack- The component of which the height should be tracked.overlay- The image to overlay on the view.
-
removeOverlay
Remove a previously added overlay.- Parameters:
key- The unique key of the overlay to remove.
-
getGridColour
Get the colour in which the grid is painted.- Returns:
- The colour in which the grid is painted.
-
setGridColour
Set the colour in which to paint the grid.- Parameters:
gridColour- The colour in which to paint the grid.
-
getBackgroundImage
-
setBackgroundImage
-
getBackgroundImageMode
-
setBackgroundImageMode
-
isInhibitUpdates
public boolean isInhibitUpdates() -
setInhibitUpdates
public void setInhibitUpdates(boolean inhibitUpdates) -
getLabelScale
public int getLabelScale() -
setLabelScale
public void setLabelScale(int labelScale) -
setTileProviderZoom
-
getVisibleArea
Get the currently visible area in world coordinates.- Returns:
- The currently visible area in world coordinates.
-
clone
Create clone of this tiled image viewer with a copy of the current tile providers and tile provider caches, so that it can immediately display the same content, but then behave independently with regard to zooming and panning. -
isTileVisible
protected final boolean isTileVisible(int x, int y, int effectiveZoom) Determine whether a tile is currently visible in the viewport.- Parameters:
x- The X coordinate of the tile to check for visibility.y- The Y coordinate of the tile to check for visibility.effectiveZoom- The zoom level to take into account.- Returns:
trueif any part of the specified tile intersects the viewport.
-
getTileBounds
Get the bounds of a tile in component coordinates, taking the current zoom level into account.- Parameters:
x- The X coordinate of the tile for which to determine the bounds.y- The X coordinate of the tile for which to determine the bounds.- Returns:
- The area in component coordinates taken up by the specified tile.
-
getTileBounds
Get the bounds of a tile in component coordinates, taking a specific zoom level into account. This version does not take per-tile-provider offsets into account.- Parameters:
x- The X coordinate of the tile for which to determine the bounds.y- The X coordinate of the tile for which to determine the bounds.effectiveZoom- The zoom level to take into account.- Returns:
- The area in component coordinates taken up by the specified tile.
-
getTileBounds
Get the bounds of a rectangular area of tiles in component coordinates, taking a specific zoom level into account. This version does not take tile-provider-specific offsets into account.- Parameters:
x- The X coordinate of the top left tile of the area for which to determine the bounds.y- The X coordinate of the top left tile of the area for which to determine the bounds.width- The width in tiles of the area for which to determine the bounds.height- The height in tiles of the area for which to determine the bounds.effectiveZoom- The zoom level to take into account.- Returns:
- The area in component coordinates taken up by the specified rectangle of tiles.
-
transformGraphics
Apply translation and scaling to a graphics canvas according to the current location and zoom settings such that it can be painted using image coordinates.- Parameters:
g2- The graphics canvas to which to apply the transforms.- Returns:
- The scaling factor to apply to image coordinates to account for the zoom level.
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
componentResized
- Specified by:
componentResizedin interfaceComponentListener
-
componentShown
- Specified by:
componentShownin interfaceComponentListener
-
componentMoved
- Specified by:
componentMovedin interfaceComponentListener
-
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener
-
tileChanged
Description copied from interface:TileListenerInvoked when the contents of a tile have changed and the tile should be retrieved again.- Specified by:
tileChangedin interfaceTileListener- Parameters:
source- The tile provider from which the changed tile should be retrieved.x- The X coordinate (in tiles) of the changed tile.y- The Y coordinate (in tiles) of the changed tile.
-
tilesChanged
Description copied from interface:TileListenerInvoked when the contents of one or more tiles have changed and the tile(s) should be retrieved again.- Specified by:
tilesChangedin interfaceTileListener- Parameters:
source- The tile provider from which the changed tile(s) should be retrieved.tiles- The set of coordinates of the changed tile(s).
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
hierarchyChanged
- Specified by:
hierarchyChangedin interfaceHierarchyListener
-