library.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  4. <title>Classe Library</title>
  5. </head>
  6. <body bgcolor="FFFFFF">
  7. <h1>Class Library</h1>
  8. <p> O ponto de acesso para uma biblioteca JAR é uma classe derivada que estende a
  9. classe original <code> Library </code>. O trabalho principal da biblioteca é
  10. listar as ferramentas que estão disponíveis através da biblioteca, na maioria das vezes,
  11. as ferramentas são todas aquelas necessárias para se adicionar os vários componentes
  12. definidos - ou seja, instâncias da classe <code> AddTool </code> ao se trabalhar
  13. com diferentes fábricas de componentes.
  14. </p>
  15. <h2>Components</h2>
  16. <pre>
  17. package com.cburch.gray;
  18. import java.util.Arrays;
  19. import java.util.List;
  20. import com.cburch.logisim.tools.AddTool;
  21. import com.cburch.logisim.tools.Library;
  22. /** The library of components that the user can access. */
  23. public class Components extends Library {
  24. /** The list of all tools contained in this library. Technically,
  25. * libraries contain tools, which is a slightly more general concept
  26. * than components; practically speaking, though, you'll most often want
  27. * to create AddTools for new components that can be added into the circuit.
  28. */
  29. private List&lt;AddTool&gt; tools;
  30. /** Constructs an instance of this library. This constructor is how
  31. * Logisim accesses first when it opens the JAR file: It looks for
  32. * a no-arguments constructor method of the user-designated class.
  33. */
  34. public Components() {
  35. tools = Arrays.asList(new AddTool[] {
  36. new AddTool(new GrayIncrementer()),
  37. new AddTool(new SimpleGrayCounter()),
  38. new AddTool(new GrayCounter()),
  39. });
  40. }
  41. /** Returns the name of the library that the user will see. */
  42. public String getDisplayName() {
  43. return "Gray Tools";
  44. }
  45. /** Returns a list of all the tools available in this library. */
  46. public List&lt;AddTool&gt; getTools() {
  47. return tools;
  48. }
  49. }
  50. </pre>
  51. <p><strong>Próximo:</strong> <a href="simpctr.html">Contador simples em código de Gray</a>.</p>
  52. </body>
  53. </html>