Class StatusBar
- All Implemented Interfaces:
EventListener, EventHandler<MouseEvent>, Localized
Since the main StatusBar job is to listen to mouse events for updating coordinates,
this class implements EventHandler directly. StatusBar can be registered as a listener
using the following methods:
Node.setOnMouseEntered(EventHandler)for showing the coordinate values when the mouse enters the region of interest.Node.setOnMouseExited(EventHandler)for hiding the coordinate values when the mouse exits the region of interest.Node.setOnMouseMoved(EventHandler)for updating the coordinate values when the mouse moves inside the region of interest.
setLocalCoordinates(double, double) explicitly instead.- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ObjectProperty<MathTransform> Conversion from local coordinates to geographic or projected coordinates of rendered data.final ObjectProperty<Quantity<Length>> Specifies a minimal uncertainty to append as "± accuracy" after the coordinate values.protected final LabelThe label where to format the cursor position, either as coordinate values or other representations.The reference systems used by the coordinates shown in this status bar.The object providing sample values under cursor position. -
Constructor Summary
ConstructorsConstructorDescriptionStatusBar(RecentReferenceSystems systemChooser) Creates a new status bar for showing coordinates of mouse cursor position in a canvas. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyCanvasGeometry(GridGeometry geometry) Configures this status bar for showing coordinates in the CRS and with the resolution given by the specified grid geometry.voidapplyCanvasGeometry(GridGeometry geometry, GridExtent sliceExtent, int xdim, int ydim) Configures this status bar for showing coordinates of a slice of a grid coverage.Returns the pixel coordinates from which the geospatial coordinates have been computed.Returns the message currently shown.Returns a property for the name of the reference system used by the coordinates.getView()Returns the encapsulated JavaFX component to add in a scene graph for making the status bar visible.final int[]Returns the indices of x and y coordinate values in a grid coordinate tuple.voidhandle(MouseEvent event) Updates the coordinates shown in the status bar with the value given by the mouse event.voidsetDefaultMessage(String text, Tooltip tooltip) Sets the default message to show when there is no error and no operation in progress.voidsetErrorMessage(String text, Throwable details) Shows or hides an error message on the status bar, optionally with a button showing details in a dialog box.voidsetInfoMessage(String text) Deprecated, for removal: This API element is subject to removal in a future version.voidsetLocalCoordinates(double x, double y) Converts and formats the given pixel coordinates.voidsetProgressMessage(String text) Shows or hides a message for an operation in progress.voidtrack(MapCanvas canvas) Registers listeners on the specified canvas for tracking mouse movements.Methods inherited from class Widget
getLocaleModifier and TypeMethodDescriptionReturns the locale for controls and messages.
-
Field Details
-
localToObjectiveCRS
Conversion from local coordinates to geographic or projected coordinates of rendered data. The local coordinates are the coordinates of the JavaFX view, as given for example inMouseEvent. The objective coordinates are the (usually geographic or projected) coordinates of the image shown in theMapCanvasor other control associated with this status bar. Objective coordinates are not necessarily the coordinates shown in the status bar, because another transformation step may happen if the user selected a different CRS in the contextual menu of the status bar.This transform shall never be null. It is initially an identity transform and is modified by
applyCanvasGeometry(GridGeometry). The transform is usually (but not necessarily) affine and should have no inaccuracy (ignoring rounding error). This transform is normally the inverse of the canvas's objective to display transform, but temporary mismatches may exist during gesture events such as pans, zooms and rotations.This transform may change continuously as a result of gesture events such as zooms and pans. It is possible to set explicitly a value to this property, but the specified value may be overwritten by the next gesture event. Therefore, setting an explicit value is more useful when this status bar is not associated with a
MapCanvas. For example, it may be associated with aGridViewinstead).Setting a value explicitly
If this transform is set to a new value, the given transform must have the same number of source and target dimensions as the previous value (if a change in the number of dimensions is desired, useapplyCanvasGeometry(GridGeometry)instead). The status bar is updated as if the specified transform was applied before transformation to the CRS specified through the contextual menu.API note
We do not provide getter/setter for this property. UseWritableObjectValue.set(Object)directly instead. We omit the "Property" suffix for making this operation more natural.- See Also:
-
positionReferenceSystem
The reference systems used by the coordinates shown in this status bar. This is initially the objective CRS, but may become different if the user selects another reference system through contextual menu.API note
We do not provide getter method for this property; useObservableObjectValue.get()directly instead. We omit the "Property" suffix for making this operation more natural.- See Also:
-
lowestAccuracy
Specifies a minimal uncertainty to append as "± accuracy" after the coordinate values. This uncertainty can be caused for example by a coordinate transformation applied on data before rendering in the canvas.Note that
StatusBarmaintains also its own uncertainty, which can be caused by transformation from objective CRS to the reference system used in this status bar. Such transformations happen when users select a CRS on the status bar (e.g. using the contextual menu) which is different than the canvas objective CRS. In such case we have two sources of stochastic errors: one internal to this status bar and one having causes external to this status bar. ThislowestAccuracyproperty is for specifying the latter.The accuracy actually shown by
StatusBarwill be the greatest value between the accuracy specified in this property and the accuracy computed internally byStatusBar. Note that the "± accuracy" text may be shown or hidden depending on the zoom level. If pixels on screen are larger than the accuracy, then the accuracy text is hidden.- Since:
- 1.3
- See Also:
-
position
The label where to format the cursor position, either as coordinate values or other representations. The text is usually the result of formatting coordinate values as numerical values, but may also be other representations such as Military Grid Reference System (MGRS) codes.- See Also:
-
sampleValuesProvider
The object providing sample values under cursor position. The property value may benullif there are no sample values to format. If non-null, the text provided by this object will appear at the right of the coordinates.API note
We do not provide getter/setter for this property; useWritableObjectValue.set(Object)directly instead. We omit the "Property" suffix for making this operation more natural.
-
-
Constructor Details
-
StatusBar
Creates a new status bar for showing coordinates of mouse cursor position in a canvas. Iftrack(Canvas)is invoked, then thisStatusBarwill show coordinates (usually geographic or projected) of mouse cursor position when the mouse is over that canvas. Note that in such case, thelocalToObjectiveCRSproperty value will be overwritten at any time (for example every time that a gesture event such as pan, zoom or rotation happens).If the
systemChooserargument is non-null, user will be able to select different reference systems using the contextual menu on the status bar.Limitations
This constructor registers numerous listeners onsystemChooser. There is currently no unregistration mechanism. TheStatusBarinstance is expected to exist as long as theMapCanvasandRecentReferenceSystemsinstances given to this constructor.- Parameters:
systemChooser- the manager of reference systems chosen by user, ornullif none.
-
-
Method Details
-
track
Registers listeners on the specified canvas for tracking mouse movements. After this method call, thisStatusBarwill show coordinates (usually geographic or projected) of mouse cursor position when the mouse is over that canvas. ThelocalToObjectiveCRSproperty value may be overwritten at any time, for example after each gesture event such as pan, zoom or rotation.Limitations
This constructor registers numerous listeners oncanvas. There is currently no unregistration mechanism. This method can be invoked only once.- Parameters:
canvas- the canvas that this status bar is tracking.- Throws:
IllegalStateException- if this method has already been invoked with another canvas.- Since:
- 1.3
-
getView
Returns the encapsulated JavaFX component to add in a scene graph for making the status bar visible. TheRegionsubclass is implementation dependent and may change in any future SIS version. -
applyCanvasGeometry
Configures this status bar for showing coordinates in the CRS and with the resolution given by the specified grid geometry. The geometry properties are applied as below:GridGeometry.getCoordinateReferenceSystem()defines the CRS of the coordinates to format.GridGeometry.getGridToCRS(PixelInCell.CELL_CENTER)defines the conversion from coordinate values local to the canvas to coordinate values in the CRS (the local to objective CRS conversion).GridGeometry.getExtent()provides the view size in pixels, used for estimating a resolution.GridGeometry.getResolution(boolean)is also used for estimating a resolution.
localToObjectiveCRSproperty.- Parameters:
geometry- geometry of the coverage shown inMapCanvas, ornull.- See Also:
-
applyCanvasGeometry
Configures this status bar for showing coordinates of a slice of a grid coverage. This method is useful for tracking the pixel coordinates of an image obtained by a call toGridCoverage.render(GridExtent). Byrender(GridExtent)contract, theRenderedImagepixel coordinates are relative to the requestedGridExtent. Consequently, we need to translate the grid coordinates so that the request coordinates start at zero. This method handles that translation.- Parameters:
geometry- geometry of the coverage which produced theRenderedImageto track, ornull.sliceExtent- the extent specified in call toGridCoverage.render(GridExtent)(can benull).xdim- the grid dimension where to assign the values of x pixel coordinates.ydim- the grid dimension where to assign the values of y pixel coordinates.- Since:
- 1.3
-
getXYDimensions
public final int[] getXYDimensions()Returns the indices of x and y coordinate values in a grid coordinate tuple. They are the indices where to assign the values of the x and y arguments in calls tosetLocalCoordinates(x,y).The default value is {0,1}, i.e. the 2 first dimensions in a coordinate tuple. The value can be changed by call to
applyCanvasGeometry(GridGeometry, GridExtent, int, int).- Returns:
- indices of x and y coordinate values in a grid coordinate tuple.
- Since:
- 1.3
-
getLocalCoordinates
Returns the pixel coordinates from which the geospatial coordinates have been computed. The returned point contains the coordinates given in the last call tosetLocalCoordinates(double, double). Note that the latter call may have been caused by a user an action such as a mouse displacement, not necessarily an explicit call from the application code. If the coordinates are not currently shown in the status bar, then this method returns an empty value.- Returns:
- the local coordinates which are the sources of the coordinates currently shown in the status bar.
-
setLocalCoordinates
public void setLocalCoordinates(double x, double y) Converts and formats the given pixel coordinates. Those coordinates will be automatically converted to geographic or projected coordinates if a "local to CRS" conversion is available.Supplemental dimensions
If local coordinates have more than 2 dimensions, then the given (x,y) values will be assigned to the dimensions specified bygetXYDimensions(). Coordinates in all other dimensions will have the values given byGridExtent.getPointOfInterest(PixelInCell)from the extent of the grid geometry given toapplyCanvasGeometry(GridGeometry).- Parameters:
x- the x coordinate local to the view.y- the y coordinate local to the view.- See Also:
-
handle
Updates the coordinates shown in the status bar with the value given by the mouse event. This method handles the following events:MouseEvent.MOUSE_ENTERED: show the coordinates.MouseEvent.MOUSE_EXITED: hide the coordinates.MouseEvent.MOUSE_MOVED: delegate tosetLocalCoordinates(double, double).
- Specified by:
handlein interfaceEventHandler<MouseEvent>- Parameters:
event- the enter, exit or move event. For the convenience of programmatic calls, a null value is synonymous to a mouse exit event.
-
getReferenceSystemName
Returns a property for the name of the reference system used by the coordinates. This is the localized name of thepositionReferenceSystemproperty.- Returns:
- a property for the name of the reference system used by the coordinates.
- Since:
- 1.7
- See Also:
-
getMessage
-
setDefaultMessage
Sets the default message to show when there is no error and no operation in progress. IfsetProgressMessage(String)orsetErrorMessage(String, Throwable)is invoked, the informative or error message has precedence over this default message. When the informative and error message are reset tonull, this default message is restored.- Parameters:
text- message to show when there is no other kind of message, ornullif none.tooltip- optional tool tip to show on the default message, ornullif none.- Since:
- 1.7
-
setInfoMessage
Deprecated, for removal: This API element is subject to removal in a future version.RenamedsetProgressMessage(String).Shows or hides an informative message on the status bar. The message should be temporary, for example for telling that a loading is in progress.- Parameters:
text- the message to show, ornullif none.- Since:
- 1.3
-
setProgressMessage
Shows or hides a message for an operation in progress. The given text should be a temporary message, for example for telling that a loading is in progress. Iftextis non-null, it replaces the default message. Iftextis null (typically after completion of the operation which was in progress), the default message is restored.- Parameters:
text- the message to show, ornullfor restoring the default message.- Since:
- 1.7
-
setErrorMessage
Shows or hides an error message on the status bar, optionally with a button showing details in a dialog box. Thetextargument specifies the message to show on the status bar. Iftextis null, the message will be taken from thedetailsif non-null. Ifdetailsis also null, then the error message will be hidden.- Parameters:
text- the error message to show, ornullif none.details- the exception that caused the error, ornullif none.
-
setProgressMessage(String).