home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / awt / pjimages.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  8.4 KB  |  277 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.         Written by the Personal Journal developers of Dow Jones & Company, Inc.
  4.  
  5.     Dow Jones makes no representations or warranties about 
  6.     the suitability of this software, either express or 
  7.     implied, including but not limited to the implied warranties 
  8.     of merchantability, fitness for a particular purpose, 
  9.     or non-infringement.  Dow Jones will not be liable for 
  10.     any damages suffered by a user as a result of using, 
  11.     modifying or distributing this software or its derivatives.
  12.  
  13.  
  14.         @(#)PjImages.java  0.00 16-Jan-96
  15.  
  16.         A specification of images in the Personal Journal notebook.
  17.  
  18.         Authors:
  19.  
  20.                 jts                             Ted Skolnick
  21.         rphall          Rick Hall
  22.  
  23.         Version Ident:
  24.  
  25.         $Header: /PjJavaClient/src/pj/awt/PjImages.java 3     1/23/96 10:53p Rphall $
  26.  
  27.         History:
  28.  
  29.         16-Jan-96 rphall     Initial Creation
  30.         13-Feb-96 Ted S.     Adding images for DogEar
  31.         28-Feb-96 Ted S.     Added icons that go on the tops of the pages
  32.                                 like the umbrella, or the bull.
  33.         1-Mar-96  Ted S.     Added portfolio icon.
  34.         26-Mar-96 Ted S.     Added PJ Logo bitmap. and "This Just In"
  35.                                 and "What's news".
  36.  
  37. ---------------------------------------------------------------------------*/
  38.  
  39. package pj.awt;
  40.  
  41. import collections.Assertable;
  42. import collections.ImplementationCheckable;
  43. import collections.ImplementationError;
  44. import java.net.MalformedURLException;
  45. import java.net.URL;
  46. import pj.net.RemoteImage;
  47.  
  48. /**
  49.  * A specification of images in the Personal Journal notebook.
  50.  *
  51.  * @version 0.00 16-Jan-96
  52.  * @author  rphall
  53. */
  54. public class PjImages implements Assertable, ImplementationCheckable
  55.     {
  56.  
  57.     // --- Class variables
  58.  
  59.     /** Index of the Weather map within imagespecs() */
  60.     public static final int idxWthMap = 0;
  61.  
  62.     /** Index of dogear image with both pages up */
  63.     public static final int idxDogEarBothUp = 1;
  64.  
  65.     /** Index of dogear image with left page down */
  66.     public static final int idxDogEarLeftDown = 2;
  67.  
  68.     /** Index of dogear image with right page down */
  69.     public static final int idxDogEarRightDown = 3;
  70.  
  71.     /** Index of Bear image */
  72.     public static final int idxBear = 4;
  73.  
  74.     /** Index of FrontPage image */
  75.     public static final int idxFrontPage = 5;
  76.  
  77.     /** Index of Sports image  */
  78.     public static final int idxSports = 6;
  79.  
  80.     /** Index of TJI image */
  81.     public static final int idxTJI = 7;
  82.  
  83.     /** Index of Scores image  */
  84.     public static final int idxScores = 8;
  85.  
  86.     /** Index of Weather image */
  87.     public static final int idxWeather = 9;
  88.  
  89.     /** Index of Market image  */
  90.     public static final int idxMarket = 10;
  91.  
  92.     /** Index of bull image w */
  93.     public static final int idxBull = 10;
  94.  
  95.     /** Index of Portfolio image  */
  96.     public static final int idxPortfolio = 11;
  97.  
  98.     /** Index of PJ Logo image  */
  99.     public static final int idxPjLogo = 12;
  100.  
  101.     /** Index of "This just In..." image  */
  102.     public static final int idxThisJustInText = 13;
  103.  
  104.     /** Index of "Whats News" image  */
  105.     public static final int idxWhatsNewsText = 14;
  106.  
  107.     
  108.     private static RemoteImage[] imagespec;
  109.  
  110.     /** A relative URL to the Weather map */
  111.     private static final String strUrlWthMap = "WeatherMap.gif";
  112.  
  113.     /** A relative URL to the DogEar bothUp image */
  114.     private static final String strUrlbothUp = "pjwdebo.gif";
  115.  
  116.     /** A relative URL to the DogEar leftDown image */
  117.     private static final String strUrlleftDown = "pjwdebld.gif";
  118.  
  119.     /** A relative URL to the DogEar rightDown image */
  120.     private static final String strUrlrightDown = "pjwdebrd.gif";
  121.  
  122.  
  123.     /** Relative URLs for all the icons on each PJ screen ( like the bear, or umbrella ) */
  124.     private static final String strBear = "bear.gif";
  125.  
  126.     private static final String strFrontPage = "front.gif";
  127.  
  128.     private static final String strSports = "sports.gif";
  129.  
  130.     private static final String strTJI = "tji.gif";
  131.  
  132.     private static final String strScores = "scores.gif";
  133.  
  134.     private static final String strWeather = "weathico.gif";
  135.  
  136.     private static final String strMarket = "market.gif";
  137.  
  138.     private static final String strBull = "bull.gif";
  139.  
  140.     private static final String strPortfolio = "port.gif";
  141.  
  142.     private static final String strPjLogo = "pj_logo.gif";
  143.  
  144.     private static final String strThisJustInText = "thisjustin.gif";
  145.  
  146.     private static final String strWhatsNewsText = "whatsnews.gif";
  147.  
  148.     
  149.  
  150.     // --- Public constructors
  151.  
  152.     /**
  153.      * Constructs an advertisement specification.
  154.      * @param base A base URL from which relative image URL's are calculated.
  155.     */
  156.     public PjImages(URL base)
  157.         {
  158.         RemoteImage  ri;
  159.  
  160.         if (imagespec == null)
  161.             {
  162.             imagespec = new RemoteImage[15];
  163.  
  164.             try {
  165.  
  166.                 // Weather map
  167.                 ri = new RemoteImage( new URL(base,strUrlWthMap) );
  168.                 imagespec[idxWthMap] = ri;
  169.  
  170.                 // Add images for the DogaEar
  171.                 ri = new RemoteImage( new URL(base,strUrlbothUp) );
  172.                 imagespec[idxDogEarBothUp] = ri;
  173.  
  174.                 ri = new RemoteImage( new URL(base,strUrlleftDown) );
  175.                 imagespec[idxDogEarLeftDown] = ri;
  176.  
  177.                 ri = new RemoteImage( new URL(base,strUrlrightDown) );
  178.                 imagespec[idxDogEarRightDown] = ri;
  179.  
  180.  
  181.  
  182.                 ri = new RemoteImage( new URL(base,strBear) );
  183.                 imagespec[idxBear] = ri;
  184.  
  185.                 ri = new RemoteImage( new URL(base,strFrontPage) );
  186.                 imagespec[idxFrontPage] = ri;
  187.  
  188.                 ri = new RemoteImage( new URL(base,strSports) );
  189.                 imagespec[idxSports] = ri;
  190.  
  191.                 ri = new RemoteImage( new URL(base,strTJI) );
  192.                 imagespec[idxTJI] = ri;
  193.  
  194.                 ri = new RemoteImage( new URL(base,strScores) );
  195.                 imagespec[idxScores] = ri;
  196.  
  197.                 ri = new RemoteImage( new URL(base,strWeather) );
  198.                 imagespec[idxWeather] = ri;
  199.  
  200.                 ri = new RemoteImage( new URL(base,strMarket) );
  201.                 imagespec[idxMarket] = ri;
  202.  
  203.                 ri = new RemoteImage( new URL(base,strBull) );
  204.                 imagespec[idxBull] = ri;
  205.  
  206.                 ri = new RemoteImage( new URL(base,strPortfolio) );
  207.                 imagespec[idxPortfolio] = ri;
  208.  
  209.                 ri = new RemoteImage( new URL(base,strPjLogo) );
  210.                 imagespec[idxPjLogo] = ri;
  211.  
  212.                 ri = new RemoteImage( new URL(base,strThisJustInText) );
  213.                 imagespec[idxThisJustInText] = ri;
  214.  
  215.                 ri = new RemoteImage( new URL(base,strWhatsNewsText) );
  216.                 imagespec[idxWhatsNewsText] = ri;
  217.  
  218.                 
  219.  
  220.                 } // try
  221.             catch(MalformedURLException e)
  222.                 { 
  223.                 assert(false); 
  224.                 }
  225.  
  226.             } // if imagespec null
  227.  
  228.         // Postconditions
  229.         checkImplementation();
  230.  
  231.         System.out.println("Debug-PjImages:constructed");
  232.         } // PjImages()
  233.  
  234.  
  235.  
  236. /**
  237.      * A null constructor handy for anyone who wants to use this to get an image
  238.      *  after PJ has been initialised. So, somebody must first construct a PjImages
  239.      *  with the URL constructor before this one has any value.  Static members are what
  240.      *  makes this possible.
  241.     */
  242.     public PjImages( )
  243.         {
  244.         } // PjImages()
  245.  
  246.  
  247.     // --- Public operations
  248.     /**
  249.      * Check the internal consistency of the a PjImages.
  250.      * Currently a NOP.
  251.      * @exception ImplementationError currently never thrown.
  252.     */
  253.     public void checkImplementation() throws ImplementationError
  254.         {
  255.         } // checkImplementation()
  256.  
  257.     /**
  258.      * Raise an exception if predicate is false.
  259.      * @see collections.Assertable
  260.      * @exception ImplementationError thrown if predicate is false.
  261.     */
  262.     public void assert(boolean predicate) throws ImplementationError
  263.         { 
  264.         ImplementationError.assert(this, predicate); 
  265.         }
  266.  
  267.     /**
  268.      * @return An array of ad specifications.
  269.     */
  270.     public RemoteImage[] imagespecs()
  271.         { 
  272.         return imagespec; 
  273.         }
  274.  
  275.     
  276.     } // PjImages
  277.