public class DefaultImageCanvas extends Object implements ImageCanvas
The canvas sends a PanZoomEvent whenever it is panned or zoomed. It
sends a MouseCursorEvent whenever the mouse cursor changes.
| Constructor and Description |
|---|
DefaultImageCanvas(ImageDisplay display) |
| Modifier and Type | Method and Description |
|---|---|
IntCoords |
dataToPanelCoords(RealCoords dataCoords)
Converts the given data coordinates into panel
coordinates.
|
double |
getBestZoomLevel(double fractionalScale)
Gets the closest step-wise zoom factor below the given scale.
|
MouseCursor |
getCursor()
Gets the current mouse cursor.
|
ImageDisplay |
getDisplay()
Gets the canvas's display.
|
double |
getInitialScale()
Gets the scale to use when reverting after zooming.
|
RealCoords |
getPanCenter()
Gets the coordinates of the data space point currently displayed
in the center of the viewport.
|
IntCoords |
getPanOffset()
Gets the absolute offset of the viewport in pixels from the top left.
|
int |
getViewportHeight()
Gets the current height of the canvas viewport in panel
coordinates.
|
int |
getViewportWidth()
Gets the current width of the canvas viewport in panel
coordinates.
|
double |
getZoomFactor()
Gets the current zoom level.
|
boolean |
isInImage(IntCoords point)
Tests whether a given point in the panel falls within the boundaries of the
display space.
|
void |
pan(IntCoords delta)
Adjusts the pan by the given (X, Y) amount in panel space.
|
void |
pan(RealCoords delta)
Adjusts the pan by the given (X, Y) amount.
|
RealCoords |
panelToDataCoords(IntCoords panelCoords)
Converts the given panel coordinates into data
coordinates.
|
void |
panReset()
Resets the pan origin to the center of the display.
|
void |
setCursor(MouseCursor cursor)
Sets the mouse to the given
MouseCursor type. |
void |
setInitialScale(double zoomFactor)
Sets the scale to use when reverting after zooming.
|
void |
setPanCenter(IntCoords center)
Pans to the given absolute (X, Y) position in panel coordinate
space.
|
void |
setPanCenter(RealCoords center)
Pans to the given absolute (X, Y) position in data coordinate
space.
|
void |
setViewportSize(int width,
int height)
Sets the dimensions of the viewport in panel coordinates.
|
void |
setZoom(double factor)
Zooms to the given scale factor, without changing the viewport's center.
|
void |
setZoomAndCenter(double factor)
Zooms to the given scale factor, recentering the viewport at the center of
the data space.
|
void |
setZoomAndCenter(double factor,
RealCoords center)
Zooms to the given scale factor, recentering the viewport at the specified
data coordinates.
|
void |
setZoomAtPoint(double factor,
IntCoords pos)
Zooms to the given scale factor, such that the specified position in
panel coordinates remains at the same place in the viewport.
|
void |
setZoomAtPoint(double factor,
RealCoords pos)
Zooms to the given scale factor, such that the specified position in
data coordinates remains at the same place in the viewport.
|
void |
zoomIn()
Zooms in by the default amount, without changing the viewport's center.
|
void |
zoomIn(IntCoords pos)
Zooms in by the default amount, such that the specified position in
panel coordinates remains at the same place in the viewport.
|
void |
zoomIn(RealCoords pos)
Zooms in by the default amount, such that the specified position in
data coordinates remains at the same place in the viewport.
|
void |
zoomOut()
Zooms out by the default amount, without changing the viewport's center.
|
void |
zoomOut(IntCoords pos)
Zooms out by the default amount, such that the specified position in
panel coordinates remains at the same place in the viewport.
|
void |
zoomOut(RealCoords pos)
Zooms out by the default amount, such that the specified position in
data coordinates remains at the same place in the viewport.
|
void |
zoomToFit(IntRect viewportBox)
Zooms the viewport to fit the given bounding box in panel
coordinates.
|
void |
zoomToFit(RealRect viewportBox)
Zoom the viewport to fit the given bounding box in data
coordinates.
|
public DefaultImageCanvas(ImageDisplay display)
public ImageDisplay getDisplay()
ImageCanvasgetDisplay in interface ImageCanvaspublic int getViewportWidth()
ImageCanvasgetViewportWidth in interface ImageCanvaspublic int getViewportHeight()
ImageCanvasgetViewportHeight in interface ImageCanvaspublic void setViewportSize(int width,
int height)
ImageCanvassetViewportSize in interface ImageCanvaspublic boolean isInImage(IntCoords point)
ImageCanvasisInImage in interface ImageCanvaspoint - The point to check, in panel coordinates.public RealCoords panelToDataCoords(IntCoords panelCoords)
ImageCanvaspanelToDataCoords in interface ImageCanvaspublic IntCoords dataToPanelCoords(RealCoords dataCoords)
ImageCanvasdataToPanelCoords in interface ImageCanvaspublic MouseCursor getCursor()
ImageCanvasgetCursor in interface ImageCanvaspublic void setCursor(MouseCursor cursor)
ImageCanvasMouseCursor type.setCursor in interface ImageCanvaspublic RealCoords getPanCenter()
PannablegetPanCenter in interface Pannablepublic IntCoords getPanOffset()
PannablegetPanOffset in interface Pannablepublic void setPanCenter(RealCoords center)
PannablesetPanCenter in interface Pannablecenter - Absolute coordinates, in data coordinate space.public void setPanCenter(IntCoords center)
PannablesetPanCenter in interface Pannablecenter - Absolute coordinates, in panel coordinate space.public void pan(RealCoords delta)
Pannablepublic void pan(IntCoords delta)
Pannablepublic void panReset()
Pannablepublic void setZoom(double factor)
Zoomablepublic void setZoomAtPoint(double factor,
RealCoords pos)
ZoomableThis is useful for repeatedly zooming at a chosen point in the data.
setZoomAtPoint in interface Zoomablefactor - The new scale factor.pos - The data coordinates to keep in the same place within
the viewport.public void setZoomAtPoint(double factor,
IntCoords pos)
ZoomableThis is useful for repeatedly zooming at a clicked point.
setZoomAtPoint in interface Zoomablefactor - The new scale factor.pos - The panel coordinates to keep in the same place within
the viewport.public void setZoomAndCenter(double factor)
ZoomablesetZoomAndCenter in interface Zoomablefactor - The new scale factor.public void setZoomAndCenter(double factor,
RealCoords center)
ZoomablesetZoomAndCenter in interface Zoomablefactor - The new scale factor.center - Absolute coordinates, in data coordinate space.public void zoomIn()
Zoomablepublic void zoomIn(RealCoords pos)
Zoomablepublic void zoomIn(IntCoords pos)
Zoomablepublic void zoomOut()
Zoomablepublic void zoomOut(RealCoords pos)
Zoomablepublic void zoomOut(IntCoords pos)
Zoomablepublic void zoomToFit(IntRect viewportBox)
Zoomablepublic void zoomToFit(RealRect viewportBox)
Zoomablepublic double getZoomFactor()
ZoomablegetZoomFactor in interface Zoomablepublic double getInitialScale()
ZoomablegetInitialScale in interface Zoomablepublic void setInitialScale(double zoomFactor)
ZoomablesetInitialScale in interface Zoomablepublic double getBestZoomLevel(double fractionalScale)
ZoomablegetBestZoomLevel in interface ZoomableCopyright © 2014–2022 ImageJ. All rights reserved.