Example usage for javax.swing JViewport getHeight

List of usage examples for javax.swing JViewport getHeight

Introduction

In this page you can find the example usage for javax.swing JViewport getHeight.

Prototype

@BeanProperty(bound = false)
public int getHeight() 

Source Link

Document

Returns the current height of this component.

Usage

From source file:cn.pholance.datamanager.common.components.JRViewer.java

/**
 *
 *///  ww w  .j a v  a 2 s  . co  m
public void gotoHyperlink(JRPrintHyperlink hyperlink) {
    switch (hyperlink.getHyperlinkTypeValue()) {
    case REFERENCE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case LOCAL_ANCHOR: {
        if (hyperlink.getHyperlinkAnchor() != null) {
            Map<String, JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes();
            JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor());
            if (anchorIndex.getPageIndex() != pageIndex) {
                setPageIndex(anchorIndex.getPageIndex());
                refreshPage();
            }
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;

                int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom);
                int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom);

                int maxX = pnlInScroll.getWidth() - viewport.getWidth();
                int maxY = pnlInScroll.getHeight() - viewport.getHeight();

                if (newX < 0) {
                    newX = 0;
                }
                if (newX > maxX) {
                    newX = maxX;
                }
                if (newY < 0) {
                    newY = 0;
                }
                if (newY > maxY) {
                    newY = maxY;
                }

                viewport.setViewPosition(new Point(newX, newY));
            }
        }

        break;
    }
    case LOCAL_PAGE: {
        int page = pageIndex + 1;
        if (hyperlink.getHyperlinkPage() != null) {
            page = hyperlink.getHyperlinkPage().intValue();
        }

        if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) {
            setPageIndex(page - 1);
            refreshPage();
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;
                viewport.setViewPosition(new Point(0, 0));
            }
        }

        break;
    }
    case REMOTE_ANCHOR: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink anchor    : " + hyperlink.getHyperlinkAnchor());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case REMOTE_PAGE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink page      : " + hyperlink.getHyperlinkPage());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case CUSTOM: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink of type " + hyperlink.getLinkType());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case NONE:
    default: {
        break;
    }
    }
}

From source file:ireport_5_6_0.view.JRViewer.java

/**
 *
 *///  w  ww.  j  a v  a  2 s .  com
public void gotoHyperlink(JRPrintHyperlink hyperlink) {
    switch (hyperlink.getHyperlinkTypeValue()) {
    case REFERENCE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case LOCAL_ANCHOR: {
        if (hyperlink.getHyperlinkAnchor() != null) {
            Map<String, JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes();
            JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor());
            if (anchorIndex.getPageIndex() != pageIndex) {
                setPageIndex(anchorIndex.getPageIndex());
                refreshPage();
            }
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;

                int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom);
                int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom);

                int maxX = pnlInScroll.getWidth() - viewport.getWidth();
                int maxY = pnlInScroll.getHeight() - viewport.getHeight();

                if (newX < 0) {
                    newX = 0;
                }
                if (newX > maxX) {
                    newX = maxX;
                }
                if (newY < 0) {
                    newY = 0;
                }
                if (newY > maxY) {
                    newY = maxY;
                }

                viewport.setViewPosition(new Point(newX, newY));
            }
        }
        break;
    }
    case LOCAL_PAGE: {
        int page = pageIndex + 1;
        if (hyperlink.getHyperlinkPage() != null) {
            page = hyperlink.getHyperlinkPage().intValue();
        }

        if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) {
            setPageIndex(page - 1);
            refreshPage();
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;
                viewport.setViewPosition(new Point(0, 0));
            }
        }
        break;
    }
    case REMOTE_ANCHOR: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink anchor    : " + hyperlink.getHyperlinkAnchor());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case REMOTE_PAGE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink page      : " + hyperlink.getHyperlinkPage());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case CUSTOM: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink of type " + hyperlink.getLinkType());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case NONE:
    default: {
        break;
    }
    }
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Returns buffered image of current viewport in provided JScrollPane.
 * //w  ww .  j  av  a  2  s.  c  om
 * @param pane
 * @return Graph image.
 */
private BufferedImage createImage(JScrollPane pane) {
    JViewport jVPort = pane.getViewport();
    jVPort.getWidth();
    int w = jVPort.getWidth();
    int h = jVPort.getHeight();
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics();
    jVPort.paint(g);
    return bi;
}