void resizeMe(int zoomBoxX, int zoomBoxY, int zoomBoxWidth, int zoomBoxHeight) {
    Dimension viewSize = getParent().getSize();
    double windowWidth = viewSize.getWidth();
    double windowHeight = viewSize.getHeight();
    double scaleX = getWidth() / ((double) zoomBoxWidth);
    double scaleY = getHeight() / ((double) zoomBoxHeight);
    int oldWidth = getWidth();
    int oldHeight = getHeight();
    int width = (int) (scaleX * windowWidth);
    int height = (int) (scaleY * windowHeight);
    // this.setPreferredSize(new Dimension(width, height));
    child.resizeMe(width, height);
    // TODO not sure this one is needed
    revalidate();

    // scroll to the new rectangle
    // int scrollX = (int) (zoomBoxX * scaleX);
    // int scrollY = (int) (zoomBoxY * scaleY);
    // int scrollWidth= (int) (zoomBoxWidth * scaleX);
    // int scrollHeight = (int) (zoomBoxHeight * scaleY);
    int scrollX = (int) (zoomBoxX * (width / (double) oldWidth));
    int scrollY = (int) (zoomBoxY * (height / (double) oldHeight));
    int scrollWidth = (int) (zoomBoxWidth * (width / (double) oldWidth));
    int scrollHeight = (int) (zoomBoxHeight * (height / (double) oldHeight));
    Rectangle r = new Rectangle(scrollX, scrollY, scrollWidth, scrollHeight);
    ((JViewport) getParent()).scrollRectToVisible(r);
    repaint();

  }
Created by IntelliJ IDEA. User: dan Date: Oct 28, 2010 Time: 10:30:40 PM To change this template
use File | Settings | File Templates.
geode-core/src/test/java/org/apache/geode/sequence/ZoomingPanel.java