home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 6.8 KB | 246 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.
-
-
- @(#)PortView.java 0.00 01-Jan-96
-
- A DividerView for the Portfolio section.
-
- Authors:
-
- jlee James Lee
- rphall Rick Hall
-
- Version Ident:
-
- $Header: /PjJavaClient/src/pj/awt/PortView.java 13 3/22/96 11:13p Jlee $
-
- History:
-
-
- 0.00 15-Jan-96 rphall Initial Creation
- 0.01 23-Jan-96 jlee Added PjAdSpec parameter in PortView constructor and
- modified ad. view panel layout.
- 0.02 1-Mar-96 Ted S. Added portfolio Icon to make it more PJish.
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.ArrayFormatter;
- import pj.awt.Column;
- import pj.awt.DividerView;
- import pj.awt.PjAdSpec;
- import pj.awt.PjAdView;
- import pj.awt.PjImages;
- import pj.awt.PjListLayout;
- import pj.awt.PjPageSpec;
- import pj.awt.PjFinals;
- 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.FlowLayout;
- import java.awt.Font;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Label;
- import java.awt.Panel;
-
-
- /**
- * A DividerView for the Portfolio section.
- *
- * @see DividerView
- * @version 0.00 01-Jan-96
- * @author rphall
- */
- public class PortView extends DividerView implements Assertable
- {
-
- // --- Class variables
-
- private static final String strPort="Quotes (Delayed at least 15 minutes)";
-
- // --- Instance variables
-
- private Component cPageTitle;
- private Column colPort;
- private PjAdView pjav;
- private Paper paper;
-
- private Label lblPort;
-
-
-
- // --- Public constructors
-
- /**
- * A general-purpose constructor that uses preassembled
- * components.
- * @param t A title component.
- * @param port A Portfolio column.
- * @param pagespec A specification for the page.
- * @param pas A specification for the Portfolio ad.
- * @param paper The paper being observed.
- */
- public PortView( Component t, Column port,
- PjPageSpec pagespec, PjAdSpec pas, Paper p)
- {
- super(pagespec.tabspec);
-
- cPageTitle = t;
- colPort = port;
- pjav = new PjAdView(pas);
- paper = p;
-
- initialLayout();
-
- } // PortView constructor
-
- /**
- * A specialized constructor for a PortView that uses
- * a page specification.
- * @param pagespec A page specification, either for the
- * Front Page headlines or the ThisJustIn headlines.
- * @param pas A specification for the Portfolio ad.
- * @param p The paper being observed.
- */
- public PortView(PjPageSpec pagespec, PjAdSpec pas, Paper p)
- {
- super(pagespec.tabspec);
- paper = p;
-
- if ( pagespec.strPageName.equals(PjStr.pagePort) )
- {
- // Create Portfolio Page components
- cPageTitle = new Label("Portfolio");
- cPageTitle.setFont( PjFinals.fntSectionBigTitle );
-
- colPort = new Column(Paper.idPortQuote,paper);
- colPort.setStoryFormatter( new ArrayFormatter(Paper.idPortQuote) );
- colPort.setFont( PjFinals.fntFormattedColumn );
- pjav = new PjAdView(pas);
- }
-
- else
- {
- // Bad page specification
- assert(false);
- }
-
- initialLayout();
- System.out.println("Debug-PortView:constructed");
- } // PortView constructor
-
- // --- Public operations
-
- /**
- * @return The number (one) of views in a PortView.
- */
- 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();
- lblPort = new Label(strPort);
- lblPort.setFont( PjFinals.fntColumnLabel );
-
- layoutArrayPanel(pnlTopData,lblPort,colPort);
-
- layoutPanels(pnlTop,pnlTopData,pjav);
-
- } // 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 portfolio icon
- pnl.add( new GifCanvas(Imgs.imagespecs()[ PjImages.idxPortfolio ].getImage() ));
-
- // add the page title "Portfolio"
- pnl.add(cPageTitle);
- }
-
- private void layoutArrayPanel(Panel pnl, Component lbl, Component col)
- {
- PjListLayout listLayout = new PjListLayout();
- pnl.setLayout(listLayout);
-
- // Components should added in following order.
- pnl.add(lbl);
- pnl.add(col);
-
- } // layoutArrayPanel
-
- private void layoutAdPanel(Panel pnl, PjAdView pjav)
- {
- pnl.add("Center", pjav );
- } // 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.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
-
-
-
- } // PortView
-