home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 7.6 KB | 279 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.
-
-
- @(#)SpHiliteView.java 0.00 01-Jan-96
-
- A DividerView for the Sports Highlights section.
-
- Authors:
-
- rphall Rick Hall
- jlee James Lee
-
- Version Ident:
-
- $Header$
-
- History:
-
- 0.00 15-Jan-96 rphall Initial Creation
- 27-Mar-96 jlee Got rid of & from "Sc&ores"
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.Column;
- import pj.awt.DividerView;
- import pj.awt.PjPageSpec;
- import pj.awt.PjStr;
- import pj.io.Paper;
-
- import collections.Assertable;
- import collections.ImplementationError;
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.Insets;
-
-
- /**
- * A DividerView for the Sports Highlights section.
- *
- * @see DividerView
- * @version 0.00 01-Jan-96
- * @author rphall
- */
- public class SpHiliteView extends DividerView implements Assertable
- {
- // --- Class variables
-
- private static final String strSpHilite ="Highlights";
- private static final String strSpScore ="Scores";
-
- // FIXME
- //private static final URL strAdImageParam = "data/SpHiliteAdImage.gif";
- //private static final URL strAdCopyParam = "data/SpHiliteAdCopy.txt";
-
- // --- Instance variables
-
- private Component cPageTitle;
- private Column colSpHilite;
- private Component cAdImage;
- private Component cAdCopy;
- private Paper paper;
-
- private Label lblSpHilite;
- private Button btnSpScore;
-
-
- // --- Public constructors
-
- /**
- * A general-purpose constructor that uses preassembled
- * components.
- * @param t A title component.
- * @param port A Sports Highlights column.
- * @param pagespec A specification for the page.
- * @param paper The paper being observed.
- */
- public SpHiliteView(Component t,Column port,PjPageSpec pagespec,Paper p)
- {
- super(pagespec.tabspec);
-
- cPageTitle = t;
- colSpHilite = port;
- paper = p;
-
- initialLayout();
-
- } // SpHiliteView constructor
-
- /**
- * A specialized constructor for a SpHiliteView that uses
- * a page specification.
- * @param pagespec A page specification, either for the
- * Front Page headlines or the ThisJustIn headlines.
- * @param paper The paper being observed.
- */
- public SpHiliteView(PjPageSpec pagespec, Paper paper)
- {
- super(pagespec.tabspec);
-
- if ( pagespec.strPageName.equals(PjStr.pageSpHilite) )
- {
- // Create Sports Highlights Page components
- cPageTitle = new Label("Sports");
-
- Font lblFont = new Font("MS Sans Serif", Font.BOLD, 25 );
- cPageTitle.setFont( lblFont );
-
- colSpHilite = new Column(Paper.idSpHilite,paper);
- }
-
- else
- {
- // Bad page specification
- assert(false);
- }
-
- initialLayout();
-
- } // SpHiliteView constructor
-
- // --- Public operations
-
- /**
- * @return The number (one) of views in a SpHiliteView.
- */
- 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()
- {
- Font lblFont = new Font("MS Sans Serif", Font.BOLD, 8 );
-
- Panel pnlTop = new Panel();
- layoutTopPanel(pnlTop);
-
- Panel pnlTopData = new Panel();
- lblSpHilite = new Label(strSpHilite);
- btnSpScore = new Button(strSpScore);
-
- lblSpHilite.setFont( lblFont );
- btnSpScore.setFont( lblFont );
-
- layoutArrayPanel(pnlTopData,lblSpHilite,btnSpScore,colSpHilite);
-
- Panel pnlAd = null;
- /*
- Panel pnlAd = new Panel();
- btnWrap = new Button(strWrap);
- btnExTrs = new Button(strExTrs);
- layoutAdPanel(pnlAd,btnWrap,btnExTrs);
- */
-
- layoutPanels(pnlTop,pnlTopData,pnlAd);
-
- } // initialLayout
-
- private void layoutTopPanel(Panel pnl)
- {
- pnl.add(cPageTitle);
- }
-
- private void layoutArrayPanel(Panel pnl, Component lbl, Component btn, Component col)
- {
- GridBagLayout gridbag = new GridBagLayout();
- pnl.setLayout(gridbag);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
-
- gbc.insets = new Insets( 20, 7, 2, 7 );
- gridbag.setConstraints(lbl, gbc);
- pnl.add(lbl);
-
- gbc.weightx = 0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(btn, gbc);
- pnl.add(btn);
-
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.insets = new Insets( 0, 7, 2, 7 );
-
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(col, gbc);
- pnl.add(col);
-
- } // layoutArrayPanel
-
- private void layoutAdPanel(Panel pnl, Component cImage, Component cCopy)
- {
- GridBagLayout gridbag = new GridBagLayout();
- pnl.setLayout(gridbag);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
-
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
-
- gridbag.setConstraints(cImage, gbc);
- pnl.add(cImage);
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(cCopy, gbc);
- pnl.add(cCopy);
-
- } // layoutAdPanel
-
- private void layoutPanels( Panel pnlTop, Panel pnlTopData, Panel pnlAd)
- {
- GridBagLayout gridbag = new GridBagLayout();
- setLayout(gridbag);
-
- // Top panel
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlTop, gbc);
- add(pnlTop);
-
- // Top panel of data
- gbc = new GridBagConstraints();
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
-
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlTopData, gbc);
- add(pnlTopData);
-
- /*
- // Ad panel
- gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(pnlAd, gbc);
- add(pnlAd);
- */
-
- } // layoutPanels
-
-
-
- } // SpHiliteView
-