use of org.apache.pivot.wtk.Panorama in project pivot by apache.
the class TerraPanoramaSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
// The panorama's preferred height is the preferred height of the view
Panorama panorama = (Panorama) getComponent();
Component view = panorama.getView();
if (view != null) {
preferredHeight = view.getPreferredHeight(width);
}
return preferredHeight;
}
use of org.apache.pivot.wtk.Panorama in project pivot by apache.
the class TerraPanoramaSkin method getMaxScrollLeft.
protected int getMaxScrollLeft() {
int maxScrollLeft = 0;
Panorama panorama = (Panorama) getComponent();
int width = getWidth();
Component view = panorama.getView();
if (view != null) {
maxScrollLeft = Math.max(view.getWidth() - width, 0);
}
return maxScrollLeft;
}
use of org.apache.pivot.wtk.Panorama in project pivot by apache.
the class TerraPanoramaSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
Dimensions preferredSize = null;
// The panorama's preferred size is the preferred size of the view
Panorama panorama = (Panorama) getComponent();
Component view = panorama.getView();
if (view == null) {
preferredSize = Dimensions.ZERO;
} else {
preferredSize = view.getPreferredSize();
}
return preferredSize;
}
use of org.apache.pivot.wtk.Panorama in project pivot by apache.
the class TerraPanoramaSkin method mouseWheel.
@Override
public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y) {
boolean consumed = false;
Panorama panorama = (Panorama) getComponent();
Component view = panorama.getView();
if (view != null) {
// presssed while the mouse wheel was scrolled
if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
// Treat the mouse wheel as a horizontal scroll event
int previousScrollLeft = panorama.getScrollLeft();
int newScrollLeft = previousScrollLeft + (scrollAmount * wheelRotation * (int) INITIAL_SCROLL_DISTANCE);
if (wheelRotation > 0) {
int maxScrollLeft = getMaxScrollLeft();
newScrollLeft = Math.min(newScrollLeft, maxScrollLeft);
if (previousScrollLeft < maxScrollLeft) {
consumed = true;
}
} else {
newScrollLeft = Math.max(newScrollLeft, 0);
if (previousScrollLeft > 0) {
consumed = true;
}
}
panorama.setScrollLeft(newScrollLeft);
} else {
// Treat the mouse wheel as a vertical scroll event
int previousScrollTop = panorama.getScrollTop();
int newScrollTop = previousScrollTop + (scrollAmount * wheelRotation * (int) INITIAL_SCROLL_DISTANCE);
if (wheelRotation > 0) {
int maxScrollTop = getMaxScrollTop();
newScrollTop = Math.min(newScrollTop, maxScrollTop);
if (previousScrollTop < maxScrollTop) {
consumed = true;
}
} else {
newScrollTop = Math.max(newScrollTop, 0);
if (previousScrollTop > 0) {
consumed = true;
}
}
panorama.setScrollTop(newScrollTop);
}
}
return consumed;
}
use of org.apache.pivot.wtk.Panorama in project pivot by apache.
the class TerraPanoramaSkin method getMaxScrollTop.
protected int getMaxScrollTop() {
int maxScrollTop = 0;
Panorama panorama = (Panorama) getComponent();
int height = getHeight();
Component view = panorama.getView();
if (view != null) {
maxScrollTop = Math.max(view.getHeight() - height, 0);
}
return maxScrollTop;
}
Aggregations