home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / J_AUTHOR / Mojo / data.2 / docs / microline / examples / tree3.java < prev    next >
Encoding:
Java Source  |  1996-05-27  |  4.9 KB  |  145 lines

  1. // (c) Copyright 1994-1996 Microline Software, Inc. ALL RIGHTS RESERVED
  2. //
  3. // THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE COPIED AND USED
  4. // ONLY IN ACCORDANCE WITH THE TERMS OF THAT LICENSE AND WITH THE INCLUSION
  5. // OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE AND DOCUMENTATION, AND ITS
  6. // COPYRIGHTS ARE OWNED BY MICROLINE SOFTWARE AND ARE PROTECTED BY UNITED
  7. // STATES COPYRIGHT LAWS AND INTERNATIONAL TREATY PROVISIONS.
  8. //
  9. // THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
  10. // AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY MICROLINE SOFTWARE.
  11. //
  12. // THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT
  13. // WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY
  14. // PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT.  MICROLINE SOFTWARE
  15. // ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS
  16. // SOFTWARE.
  17. //
  18. // MICROLINE SOFTWARE SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR
  19. // CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SOME
  20. // STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
  21. // CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATIONS MIGHT NOT APPLY TO
  22. // YOU.
  23. //
  24. // MICROLINE SOFTWARE SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE
  25. // ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES
  26. // RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE
  27. // TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY
  28. // MICROLINE SOFTWARE.
  29. //
  30. // U.S. GOVERNMENT RESTRICTED RIGHTS
  31. // This Software and documentation are provided with RESTRICTED RIGHTS.
  32. // Use, duplication or disclosure by the Government is subject to
  33. // restrictions as set forth in subparagraph (c)(1) of the Rights in
  34. // Technical Data and Computer Software Clause at DFARS 252.227-7013 or
  35. // subparagraphs (c)(1)(ii) and (2) of Commercial Computer Software -
  36. // Restricted Rights at 48 CFR 52.227-19, as applicable, supplier is
  37. // Microline Software, 41 Sutter St Suite 1374, San Francisco, CA 94104.
  38.  
  39. import java.awt.*;
  40. import java.util.*;
  41. import java.mct.*;
  42. import java.applet.Applet;
  43.  
  44. public class tree3 extends Applet
  45. {
  46. MlTree tree;
  47. static boolean expands[] = { true, true, true, false, false,
  48.         false, true, false, false, true };
  49. static int levels[] = { 0, 1, 2, 3, 2, 2, 1, 2, 2, 2 };
  50. Image dotImage, winImage;
  51.  
  52. public void init()
  53.     {
  54.     MlResources res;
  55.     MlTreeRowDefinition rows[];
  56.     int i, n;
  57.  
  58.     setLayout(new BorderLayout());
  59.     res = new MlResources();
  60.  
  61.     makeIcons();
  62.  
  63.     tree = new MlTree();
  64.  
  65.     res.add("selectionPolicy", "SELECT_MULTIPLE_ROW");
  66.     res.add("globalImageWidth", 16);
  67.     res.add("globalImageHeight", 16);
  68.     tree.setValues(res);
  69.  
  70.     n = 100;
  71.     rows = new MlTreeRowDefinition[n];
  72.     for (i = 0; i < n; i++)
  73.         {
  74.         rows[i] = new MlTreeRowDefinition();
  75.         rows[i].level = levels[i % 10];
  76.         if (i % 30 >= 10)
  77.             rows[i].level += 3;
  78.         if (i % 30 >= 20)
  79.             rows[i].level += 3;
  80.         rows[i].expands = expands[i % 10];
  81.         if (rows[i].expands)
  82.             rows[i].image = dotImage;
  83.         else
  84.             rows[i].image = winImage;
  85.         rows[i].isExpanded = true;
  86.         if (rows[i].expands)
  87.             rows[i].string = "Sector Number " + rows[i].level + "-" +
  88.                 (i % 2) + (i + 413);
  89.         else
  90.             rows[i].string = "Item Number " + (i % 12) + (i % 3) + (i % 2);
  91.         }
  92.     tree.addRows(rows, 0);
  93.  
  94.     add("Center", tree);
  95.     }
  96.  
  97. public void makeIcons()
  98.     {
  99.     MlIconMaker im;
  100.  
  101.     im = new MlIconMaker();
  102.     im.setDimensions(16, 16);
  103.     im.setColor('B', 0xff000080);
  104.     im.setColor('K', 0xff000000);
  105.     im.setColor('G', 0xff808080);
  106.  
  107.     im.setPixels("                ");
  108.     im.setPixels("                ");
  109.     im.setPixels("                ");
  110.     im.setPixels("                ");
  111.     im.setPixels("      BBBBB     ");
  112.     im.setPixels("     BBBBBBB    ");
  113.     im.setPixels("    BBBBBBBBB   ");
  114.     im.setPixels("   BBB  BBBBBB  ");
  115.     im.setPixels("   BBB BBBBBBB  ");
  116.     im.setPixels("   BBBBBBBBBBB  ");
  117.     im.setPixels("   BBBBBBBBBBB  ");
  118.     im.setPixels("   BBBBBBBBBBB  ");
  119.     im.setPixels("    BBBBBBBBB   ");
  120.     im.setPixels("     BBBBBBB    ");
  121.     im.setPixels("      BBBBB     ");
  122.     im.setPixels("                ");
  123.     dotImage = im.createImage(this);
  124.  
  125.     im.clear();
  126.     im.setPixels("                ");
  127.     im.setPixels("                ");
  128.     im.setPixels("   KKKKKKKKKKK  ");
  129.     im.setPixels("   KGGGGGGGGGK  ");
  130.     im.setPixels("   KG       GK  ");
  131.     im.setPixels("   KG G GGG GK  ");
  132.     im.setPixels("   KG       GK  ");
  133.     im.setPixels("   KG G GGG GK  ");
  134.     im.setPixels("   KG       GK  ");
  135.     im.setPixels("   KGGGGGGGGGK  ");
  136.     im.setPixels("   KKKKKKKKKKK  ");
  137.     im.setPixels("       KGK      ");
  138.     im.setPixels("       KGK      ");
  139.     im.setPixels("    KKKKKKKKK   ");
  140.     im.setPixels("    KKKKKKKKK   ");
  141.     im.setPixels("                ");
  142.     winImage = im.createImage(this);
  143.     }
  144. }
  145.