Search in sources :

Example 6 with Panorama

use of org.apache.pivot.wtk.Panorama in project pivot by apache.

the class PanoramaTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    frame1 = new Frame();
    frame1.setTitle("Panorama Test 1");
    Panorama panorama = new Panorama();
    frame1.setContent(panorama);
    frame1.setPreferredSize(240, 320);
    ImageView imageView = new ImageView();
    imageView.setImage(getClass().getResource("IMG_0767_2.jpg"));
    panorama.setView(imageView);
    frame1.open(display);
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    frame2 = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("panorama_test.bxml")));
    frame2.setTitle("Panorama Test 2");
    frame2.setPreferredSize(480, 360);
    frame2.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Panorama(org.apache.pivot.wtk.Panorama) ImageView(org.apache.pivot.wtk.ImageView) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 7 with Panorama

use of org.apache.pivot.wtk.Panorama in project pivot by apache.

the class TerraPanoramaSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Panorama panorama = (Panorama) component;
    panorama.getViewportListeners().add(this);
    // Add scroll arrow link buttons and attach mouse listeners
    // to them; the mouse handlers should call setScrollTop() and
    // setScrollLeft() on the panorama as appropriate
    panorama.add(northButton);
    northButton.getComponentMouseListeners().add(buttonMouseListener);
    panorama.add(southButton);
    southButton.getComponentMouseListeners().add(buttonMouseListener);
    panorama.add(eastButton);
    eastButton.getComponentMouseListeners().add(buttonMouseListener);
    panorama.add(westButton);
    westButton.getComponentMouseListeners().add(buttonMouseListener);
    updateScrollButtonVisibility();
}
Also used : Panorama(org.apache.pivot.wtk.Panorama)

Example 8 with Panorama

use of org.apache.pivot.wtk.Panorama in project pivot by apache.

the class TerraPanoramaSkin method updateScrollButtonVisibility.

protected void updateScrollButtonVisibility() {
    Panorama panorama = (Panorama) getComponent();
    boolean mouseOver = panorama.isMouseOver();
    int scrollTop = panorama.getScrollTop();
    int maxScrollTop = getMaxScrollTop();
    northButton.setVisible((alwaysShowScrollButtons || mouseOver) && scrollTop > 0);
    southButton.setVisible((alwaysShowScrollButtons || mouseOver) && scrollTop < maxScrollTop);
    int scrollLeft = panorama.getScrollLeft();
    int maxScrollLeft = getMaxScrollLeft();
    westButton.setVisible((alwaysShowScrollButtons || mouseOver) && scrollLeft > 0);
    eastButton.setVisible((alwaysShowScrollButtons || mouseOver) && scrollLeft < maxScrollLeft);
}
Also used : Panorama(org.apache.pivot.wtk.Panorama)

Example 9 with Panorama

use of org.apache.pivot.wtk.Panorama in project pivot by apache.

the class TerraPanoramaSkin method layout.

@Override
public void layout() {
    Panorama panorama = (Panorama) getComponent();
    int width = getWidth();
    int height = getHeight();
    Component view = panorama.getView();
    if (view != null) {
        Dimensions viewSize = view.getPreferredSize();
        view.setSize(Math.max(width, viewSize.width), Math.max(height, viewSize.height));
        int viewWidth = view.getWidth();
        int viewHeight = view.getHeight();
        int maxScrollTop = getMaxScrollTop();
        if (panorama.getScrollTop() > maxScrollTop) {
            panorama.setScrollTop(maxScrollTop);
        }
        int maxScrollLeft = getMaxScrollLeft();
        if (panorama.getScrollLeft() > maxScrollLeft) {
            panorama.setScrollLeft(maxScrollLeft);
        }
        if (width < viewWidth) {
            // Show east/west buttons
            eastButton.setSize(eastButton.getPreferredWidth(), height);
            eastButton.setLocation(width - eastButton.getWidth(), 0);
            westButton.setSize(westButton.getPreferredWidth(), height);
            westButton.setLocation(0, 0);
        }
        if (height < viewHeight) {
            // Show north/south buttons
            northButton.setSize(width, northButton.getPreferredHeight());
            northButton.setLocation(0, 0);
            southButton.setSize(width, southButton.getPreferredHeight());
            southButton.setLocation(0, height - southButton.getHeight());
        }
    }
    updateScrollButtonVisibility();
}
Also used : Panorama(org.apache.pivot.wtk.Panorama) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 10 with Panorama

use of org.apache.pivot.wtk.Panorama in project pivot by apache.

the class TerraPanoramaSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    int preferredWidth = 0;
    // The panorama's preferred width is the preferred width of the view
    Panorama panorama = (Panorama) getComponent();
    Component view = panorama.getView();
    if (view != null) {
        preferredWidth = view.getPreferredWidth(height);
    }
    return preferredWidth;
}
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