@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
// apply a hover styling on moving the mouse over a NatTable
uiBindingRegistry.registerFirstMouseMoveBinding(
new IMouseEventMatcher() {
@Override
public boolean matches(NatTable natTable, MouseEvent event,
LabelStack regionLabels) {
int width = layer.getPreferredWidth();
int height = layer.getPreferredHeight();
return ((event.x > 0 && event.x < width) && (event.y > 0 && event.y < height));
}
}, new HoverStylingAction(layer));
// clear any hover styling if the mouse is moved out of the region area
uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {
@Override
public boolean matches(NatTable natTable, MouseEvent event,
LabelStack regionLabels) {
int width = layer.getPreferredWidth();
int height = layer.getPreferredHeight();
return ((event.x < 0 || event.x > width) || (event.y < 0 || event.y > height));
}
}, new ClearHoverStylingAction());
// clear any hover styling if the mouse is moved out of a NatTable
// region
uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {
@Override
public boolean matches(NatTable natTable, MouseEvent event,
LabelStack regionLabels) {
return (natTable != null && regionLabels == null);
}
}, new ClearHoverStylingAction());
// clear any hover styling if the mouse is moved out of the NatTable
// area
uiBindingRegistry.registerMouseExitBinding(new IMouseEventMatcher() {
@Override
public boolean matches(NatTable natTable, MouseEvent event,
LabelStack regionLabels) {
// always return true because this matcher is only asked in case
// the mouse