library.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <html>
  2. <head>
  3. <title>Library Class</title>
  4. </head>
  5. <body bgcolor="FFFFFF">
  6. <h1>Library Class</h1>
  7. <p>The access point for the JAR library is a class that extends the
  8. <code>Library</code> class. The library's main job is to list the tools that are
  9. available through the library; most often, the tools are all tools
  10. to add the various components defined - that is, instances of the
  11. <code>AddTool</code> class working with different component factories.</p>
  12. <h2>Components</h2>
  13. <pre>
  14. package com.cburch.gray;
  15. import java.util.Arrays;
  16. import java.util.List;
  17. import com.cburch.logisim.tools.AddTool;
  18. import com.cburch.logisim.tools.Library;
  19. /** The library of components that the user can access. */
  20. public class Components extends Library {
  21. /** The list of all tools contained in this library. Technically,
  22. * libraries contain tools, which is a slightly more general concept
  23. * than components; practically speaking, though, you'll most often want
  24. * to create AddTools for new components that can be added into the circuit.
  25. */
  26. private List&lt;AddTool&gt; tools;
  27. /** Constructs an instance of this library. This constructor is how
  28. * Logisim accesses first when it opens the JAR file: It looks for
  29. * a no-arguments constructor method of the user-designated class.
  30. */
  31. public Components() {
  32. tools = Arrays.asList(new AddTool[] {
  33. new AddTool(new GrayIncrementer()),
  34. new AddTool(new SimpleGrayCounter()),
  35. new AddTool(new GrayCounter()),
  36. });
  37. }
  38. /** Returns the name of the library that the user will see. */
  39. public String getDisplayName() {
  40. return "Gray Tools";
  41. }
  42. /** Returns a list of all the tools available in this library. */
  43. public List&lt;AddTool&gt; getTools() {
  44. return tools;
  45. }
  46. }
  47. </pre>
  48. <p><strong>Next:</strong> <a href="simpctr.html">Simple Gray Code Counter</a>.</p>
  49. </body>
  50. </html>