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()
ImageCanvas
getDisplay
in interface ImageCanvas
public int getViewportWidth()
ImageCanvas
getViewportWidth
in interface ImageCanvas
public int getViewportHeight()
ImageCanvas
getViewportHeight
in interface ImageCanvas
public void setViewportSize(int width, int height)
ImageCanvas
setViewportSize
in interface ImageCanvas
public boolean isInImage(IntCoords point)
ImageCanvas
isInImage
in interface ImageCanvas
point
- The point to check, in panel coordinates.public RealCoords panelToDataCoords(IntCoords panelCoords)
ImageCanvas
panelToDataCoords
in interface ImageCanvas
public IntCoords dataToPanelCoords(RealCoords dataCoords)
ImageCanvas
dataToPanelCoords
in interface ImageCanvas
public MouseCursor getCursor()
ImageCanvas
getCursor
in interface ImageCanvas
public void setCursor(MouseCursor cursor)
ImageCanvas
MouseCursor
type.setCursor
in interface ImageCanvas
public RealCoords getPanCenter()
Pannable
getPanCenter
in interface Pannable
public IntCoords getPanOffset()
Pannable
getPanOffset
in interface Pannable
public void setPanCenter(RealCoords center)
Pannable
setPanCenter
in interface Pannable
center
- Absolute coordinates, in data coordinate space.public void setPanCenter(IntCoords center)
Pannable
setPanCenter
in interface Pannable
center
- Absolute coordinates, in panel coordinate space.public void pan(RealCoords delta)
Pannable
public void pan(IntCoords delta)
Pannable
public void panReset()
Pannable
public void setZoom(double factor)
Zoomable
public void setZoomAtPoint(double factor, RealCoords pos)
Zoomable
This is useful for repeatedly zooming at a chosen point in the data.
setZoomAtPoint
in interface Zoomable
factor
- The new scale factor.pos
- The data coordinates to keep in the same place within
the viewport.public void setZoomAtPoint(double factor, IntCoords pos)
Zoomable
This is useful for repeatedly zooming at a clicked point.
setZoomAtPoint
in interface Zoomable
factor
- The new scale factor.pos
- The panel coordinates to keep in the same place within
the viewport.public void setZoomAndCenter(double factor)
Zoomable
setZoomAndCenter
in interface Zoomable
factor
- The new scale factor.public void setZoomAndCenter(double factor, RealCoords center)
Zoomable
setZoomAndCenter
in interface Zoomable
factor
- The new scale factor.center
- Absolute coordinates, in data coordinate space.public void zoomIn()
Zoomable
public void zoomIn(RealCoords pos)
Zoomable
public void zoomIn(IntCoords pos)
Zoomable
public void zoomOut()
Zoomable
public void zoomOut(RealCoords pos)
Zoomable
public void zoomOut(IntCoords pos)
Zoomable
public void zoomToFit(IntRect viewportBox)
Zoomable
public void zoomToFit(RealRect viewportBox)
Zoomable
public double getZoomFactor()
Zoomable
getZoomFactor
in interface Zoomable
public double getInitialScale()
Zoomable
getInitialScale
in interface Zoomable
public void setInitialScale(double zoomFactor)
Zoomable
setInitialScale
in interface Zoomable
public double getBestZoomLevel(double fractionalScale)
Zoomable
getBestZoomLevel
in interface Zoomable
Copyright © 2014–2022 ImageJ. All rights reserved.