use of org.apache.pivot.wtk.ComponentMouseWheelListener in project pivot by apache.
the class ScaleDecoratorDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
scaleWindow = (Window) bxmlSerializer.readObject(DecoratorDemo.class, "scale_window.bxml");
bxmlSerializer.bind(this);
imageView.getComponentMouseWheelListeners().add(new ComponentMouseWheelListener() {
@Override
public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y) {
// Note: both scale values are the same
float currentScale = scaleDecorator.getScaleX();
if (wheelRotation < 0) {
// UP == zoom in, make scale larger
scaleDecorator.setScale(currentScale * 2.0f);
} else {
// DOWN == zoom out, make scale smaller
scaleDecorator.setScale(currentScale / 2.0f);
}
component.repaint();
return true;
}
});
scaleWindow.open(display);
}
Aggregations