home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 7.9 KB | 286 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.
-
-
- @(#)MarketView.java 0.00 01-Jan-96
-
- A DividerView for the Front Page and ThisJustIn headlines.
-
-
- Authors:
-
- rphall Rick Hall
-
-
- Version Ident:
-
- $Header$
-
-
- History:
-
- 0.00 01-Jan-96 rphall Initial Creation
- 0.01 3-Mar-96 Ted S. Added market icons.
- 27-Mar-96 jlee Changed "Currencies && Bonds" to "Currencies and Bonds"
-
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.Column;
- import pj.awt.DividerView;
- import pj.awt.PjImages;
- import pj.awt.PjPageSpec;
- import pj.awt.PjStr;
- import pj.awt.StoryList;
- import pj.io.Paper;
-
- import collections.Assertable;
- import collections.ImplementationError;
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.FlowLayout;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Label;
- import java.awt.Panel;
-
- /**
- * A DividerView for Front Page and ThisJustIn headlines.
- *
- * @see DividerView
- * @version 0.00 01-Jan-96
- * @author rphall
- */
- public class MarketView extends DividerView implements Assertable
- {
-
- // --- Class variables
-
- private static final String strDjia = "Dow Jones Industrial Average";
- private static final String strStkIdx = "Stock Indexes";
- private static final String strWrap = "Market News";
- private static final String strExTrs = "Currencies and Bonds";
-
- // --- Instance variables
-
- private Component cPageTitle;
- private Column colDjia;
- private Column colStkIdx;
- private Paper paper;
-
- private Label lblDjia;
- private Label lblStkIdx;
- private Button btnWrap;
- private Button btnExTrs;
-
-
- // --- Public constructors
-
- /**
- * A general-purpose constructor that uses preassembled
- * components.
- * @param t A title component.
- * @param djia A Dow Jones Industrial Average column.
- * @param stkidx A Stock Indexes column.
- * @param pagespec A specification for the page.
- * @param paper The paper being observed.
- */
- public MarketView( Component t, Column djia, Column stkidx,
- PjPageSpec pagespec, Paper p)
- {
- super(pagespec.tabspec);
-
- cPageTitle = t;
- colDjia = djia;
- colStkIdx = stkidx;
- paper = p;
-
- initialLayout();
-
- } // MarketView constructor
-
- /**
- * A specialized constructor for a MarketView 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 MarketView(PjPageSpec pagespec, Paper paper)
- {
- super(pagespec.tabspec);
-
- if ( pagespec.strPageName.equals(PjStr.pageMrk) )
- {
- // Create Markets Page components
- cPageTitle = new Label("Markets");
- colDjia = new Column(Paper.idMrkDjia,paper);
- colStkIdx = new Column(Paper.idMrkStkIdx,paper);
- }
-
- else
- {
- // Bad page specification
- assert(false);
- }
-
- initialLayout();
-
- } // MarketView constructor
-
- // --- Public operations
-
- /**
- * @return The number (one) of views in a MarketView.
- */
- 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();
- layoutTopPanel(pnlTop);
-
- Panel pnlTopData = new Panel();
- lblDjia = new Label(strDjia);
- layoutArrayPanel(pnlTopData,lblDjia,colDjia);
-
- Panel pnlBtmData = new Panel();
- lblStkIdx = new Label(strStkIdx);
- layoutArrayPanel(pnlBtmData,lblStkIdx,colStkIdx);
-
- Panel pnlBtn = new Panel();
- btnWrap = new Button(strWrap);
- btnExTrs = new Button(strExTrs);
- layoutBtnPanel(pnlBtn,btnWrap,btnExTrs);
-
- layoutPanels(pnlTop,pnlTopData,pnlBtmData,pnlBtn);
-
- } // 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 market icon
- // fixme: Determine if bull or bear should be used.
- pnl.add( new GifCanvas(Imgs.imagespecs()[ PjImages.idxBull ].getImage() ));
- pnl.add( new Label( "hey" ));
-
- // add the page title "Market..."
- pnl.add(cPageTitle);
- }
-
- private void layoutArrayPanel(Panel pnl, Component lbl, Component col)
- {
- 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.REMAINDER;
-
- gridbag.setConstraints(lbl, gbc);
- pnl.add(lbl);
-
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(col, gbc);
- pnl.add(col);
-
- } // layoutArrayPanel
-
- private void layoutBtnPanel(Panel pnl, Component btnLeft, Component btnRight)
- {
- 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(btnLeft, gbc);
- pnl.add(btnLeft);
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints(btnRight, gbc);
- pnl.add(btnRight);
-
- } // layoutBtnPanel
-
- private void layoutPanels( Panel pnlTop,
- Panel pnlTopData, Panel pnlBtmData, Panel pnlBtn)
- {
- 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.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlTopData, gbc);
- add(pnlTopData);
-
- // Bottom panel of data
- gridbag.setConstraints(pnlBtmData, gbc);
- add(pnlBtmData);
-
- // Bottom panel
- gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints(pnlBtn, gbc);
- add(pnlBtn);
-
- } // layoutPanels
-
-
-
- } // MarketView
-