Newbie help: Setting width/height on the fly

From: Joshua Trutwin <Joshua.Trutwin@udlp.com>
Date: Tue Oct 08 2002 - 13:46:55 EDT

I am new to the OpenMap API, and somewhat new to Swing so please bear
with me!

I want to integrate OpenMap into an existing application where we model
a crew interface to an Army vehicle. Depending on the screen the crew
member is looking at, they may have a different sized view of the map
(e.g. full screen, 1/4 screen, etc.).

Our architecture currently requires our GUI components to extend
JComponent or JPanel, basically a viewport that shows only the map and
none of the controls for zoom, pan, etc.

I am to the point where I can load the map in a JPanel and I can change
the height and width of the JPanel, but the openmap bean does not
respond to these changes.

I am curious what would be the best solution to this problem. I tried
to play with projections, but I cannot seem to set any of the properties
for width/height on a projection object. I looked over the examples in
com/bbn/openmap/examples/simple and it seems like it should just work on
it's own. (Except those examples use a JFrame instead of a JPanel).

Here is some sample code:

public class NGMapViewport extends JPanel {
   private int width = 400;
   private int height = 600;

   public NGMapViewport () {
     MapHandler mapHandler = new MapHandler();
      bufferedMapBean = new BufferedMapBean();

     // set center, scale, layers, etc.

     super.add(bufferedMapBean);
     setWidth(width);
     setHeight(height);
     setVisible(true);
   }

   public void setHeight (int height) {
      this.height = height;
      setPreferredSize(new Dimension(width, height));
      setMaximumSize(new Dimension(width, height));
      setMinimumSize(new Dimension(width, height));
      setSize(new Dimension(width, height));
      revalidate();
      repaint();
   }

   // setWidth pretty much the same
}

Thanks in advance.

Josh

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Oct 8 13:48:51 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT