home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 7.5 KB | 256 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)WeatherView.java 0.00 01-Jan-96
-
- A WeatherView for the Weather section.
-
- Authors:
-
- jlee James Lee
-
- Version Ident:
-
- $Header: /PjJavaClient/src/pj/awt/WeatherView.java 7 3/22/96 11:13p Jlee $
-
- History:
-
- 0.00 24-Jan-96 jlee Initial Creation
- 0.01 1-Mar-96 Ted S. Added weather icon.
- 0.02 27-Mar-96 Ted S. Added copyright and some instructional text.
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
-
- import pj.awt.PageView;
- import pj.awt.PjAdSpec;
- import pj.awt.PjAdView;
- import pj.awt.PjImages;
- import pj.awt.WeatherImageMap;
- import pj.io.Paper;
- import pj.net.RemoteImage;
-
-
- import collections.Assertable;
- import collections.ImplementationError;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Color;
- import java.awt.Label;
- import java.awt.Panel;
-
- /**
- * A PageView for the Weather section.
- *
- * @see PageView
- * @version 0.00 24-Jan-96
- * @author jlee
- */
- public class WeatherView extends PageView implements Assertable
- {
-
- // --- Instance variables
-
- private Component cPageTitle;
- private PjAdView pjav;
- private WeatherImageMap WeatherImageMap;
-
- // --- Public constructors
-
- /**
- * A general-purpose constructor that uses preassembled
- * components.
- * @param t A title component.
- * @param pas A specification for the Portfolio ad.
- * @param ri The Weather GIF remote image.
- */
- public WeatherView( Component t, PjAdSpec pas, RemoteImage riWeatherMap)
- {
- cPageTitle = t;
- WeatherImageMap WeatherImageMap = new WeatherImageMap( riWeatherMap.getImage() );
- pjav = new PjAdView(pas);
-
- initialLayout();
-
- } // WeatherView constructor
-
- /**
- * A specialized constructor for a PortView that uses
- * a page specification.
- *
- * @param pas A specification for the Portfolio ad.
- * @param ri The Weather GIF remote image.
- */
- public WeatherView(String pagename, PjAdSpec pas, RemoteImage riWeatherMap)
- {
- super(pagename);
-
- WeatherImageMap = new WeatherImageMap( riWeatherMap.getImage() );
-
- // Create weather section title
- cPageTitle = new Label("Weather");
- cPageTitle.setFont( PjFinals.fntSectionBigTitle );
-
- pjav = new PjAdView(pas);
-
- initialLayout();
-
- System.out.println("Debug-WeatherView:constructed");
- } // WeatherView constructor
-
- // --- Public operations
-
- /**
- * @return The number (one) of views in a WeatherView.
- */
- public int countViews()
- {
- return 1;
- }
-
- /**
- * Raise an exception if predicate is false.
- * @see collections.Assertable
- */
- public void assert(boolean predicate) throws ImplementationError
- {
- ImplementationError.assert(this, predicate);
- }
-
- // --- Private operations
-
- private void initialLayout()
- {
- Panel pnlTop = new Panel();//default FlowLayout
- layoutTopPanel(pnlTop);
-
- Panel pnlWthMap = new Panel();//default FlowLayout
- layoutWthMapPanel(pnlWthMap);
-
- Panel pnlAd = new Panel();
- pnlAd.setLayout( new BorderLayout() );
- layoutAdPanel(pnlAd, pjav);
-
- layoutPanels(pnlTop,pnlWthMap,pnlAd);
-
- } // initialLayout
-
- private void layoutTopPanel(Panel pnl)
- {
- PjImages Imgs;
- Imgs = new PjImages();
-
- // allign evrything to the left like in VB PJ.
- pnl.setLayout( new FlowLayout( FlowLayout.LEFT ) );
-
- // Add the little umbrella icon
- pnl.add( new GifCanvas(Imgs.imagespecs()[ PjImages.idxWeather ].getImage() ));
-
- // add the page title "Weather"
- pnl.add(cPageTitle);
- }
-
- private void layoutWthMapPanel(Panel pnl)
- {
- // Create the labels to add to the panel
- Label lblCopyRight = new Label( "(c) 1996 Accu-Weather Inc. All Rights Reserved.", Label.CENTER);
- lblCopyRight.setForeground( Color.darkGray );
- Label lblInstructions = new Label( "Select the region for which you wish to view weather.", Label.CENTER);
-
- // Place all items vertically, and centered, one on top of the other.
- GridBagLayout gridbag = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- pnl.setLayout(gridbag);
-
- // Add each item, from top to bottom
- gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.VERTICAL;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(lblCopyRight, gbc);
- pnl.add( lblCopyRight);
-
- gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.VERTICAL;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(lblInstructions, gbc);
- pnl.add( lblInstructions );
-
- gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.VERTICAL;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(WeatherImageMap, gbc);
- pnl.add(WeatherImageMap);
- }
-
- private void layoutAdPanel(Panel pnl, PjAdView pjav)
- {
- pnl.add("Center", pjav );
- }
-
- private void layoutPanels( Panel pnlTop, Panel pnlWthMap, Panel pnlAd)
- {
- GridBagLayout gridbag = new GridBagLayout();
- setLayout(gridbag);
-
- // Top panel
- GridBagConstraints gbc = new GridBagConstraints();
-
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlTop, gbc);
- add(pnlTop);
-
- // Top panel of Weather Image Map
- gbc = new GridBagConstraints();
- //gbc.weightx = 1.0;
-
- gbc.fill = GridBagConstraints.NONE;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlWthMap, gbc);
- add(pnlWthMap);
-
- // Empty panel to fill the gap between Weather panel and Ad panel.
- Panel pnlGap = new Panel();
- gbc = new GridBagConstraints();
- gbc.weighty = 1.0;
-
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlGap, gbc);
- add(pnlGap);
-
- // Ad panel
- gbc = new GridBagConstraints();
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
-
- gbc.fill = GridBagConstraints.NONE;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlAd, gbc);
- add(pnlAd);
-
- } // layoutPanels
-
-
- } // WeatherView
-
-