RE: Newbie help: Setting width/height on the fly

From: Joshua Trutwin <Joshua.Trutwin@udlp.com>
Date: Tue Oct 08 2002 - 15:22:06 EDT

Thanks, Don's email had the solution. Here is the modified code if
anyone's curious:

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.

     this.setLayout(new BorderLayout());
     this.add(bufferedMapBean, BorderLayout.CENTER);
     setSize(width, height);
     setVisible(true);
   }

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

Josh

>>> "Lonnie D. Goad" <LGoad@OptiMetrics.org> 10/08/02 02:16PM >>>
Never tried this before but you may want to try to set the map in a
JScrollPane then add the scrollPane to your Panel

-----Original Message-----
From: owner-openmap-users@bbn.com [mailto:owner-openmap-users@bbn.com]

On Behalf Of Joshua Trutwin
Sent: Tuesday, October 08, 2002 1:47 PM
To: openmap-users@bbn.com
Subject: Newbie help: Setting width/height on the fly

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"]
--
[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 15:23:06 2002

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