Search in sources :

Example 1 with Panorama

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;
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Component(org.apache.pivot.wtk.Component)

Example 2 with Panorama

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;
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Component(org.apache.pivot.wtk.Component)

Example 3 with Panorama

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;
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 4 with Panorama

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;
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Component(org.apache.pivot.wtk.Component)

Example 5 with Panorama

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;
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Component(org.apache.pivot.wtk.Component)

Aggregations

Panorama (org.apache.pivot.wtk.Panorama)10 Component (org.apache.pivot.wtk.Component)8 Dimensions (org.apache.pivot.wtk.Dimensions)2 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 Frame (org.apache.pivot.wtk.Frame)1 ImageView (org.apache.pivot.wtk.ImageView)1