home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / ed8n1t2i / buffer.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  3.2 KB  |  84 lines

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // Buffer.java           v 1.00 b1
  5. // Written by:           I. van Rienen / E-mail ivr@bart.nl
  6. // URL:                  http://www/bart.nl/~ivr
  7. // Initial release:
  8. // Released in public domain:
  9. //
  10. // ---- Description ----
  11. // Java class containing methods for a Buffer
  12. //
  13. // This program and the Java source is in the public domain.
  14. // Permission to use, copy, modify, and distribute this software
  15. // and its documentation for NON-COMMERCIAL purposes and
  16. // without fee is hereby granted.
  17. //
  18. //    Copyright 1996
  19. //
  20. //    Iwan van Rienen
  21. //    Joan Maetsuyckerstr. 145
  22. //    2593 ZG  The Hague
  23. //    The Netherlands
  24. //
  25. // I am not responsible for any bugs in this program and
  26. // possible damage to hard- or software when using this program.
  27. //****************************************************************************
  28. import java.applet.Applet;
  29. import java.awt.*;
  30. import java.util.Vector;
  31.  
  32. class Buffer extends LogicPort {
  33.  
  34. //----------------------------------------------------------------------------
  35. // The constructor of a buffer
  36. //----------------------------------------------------------------------------
  37.     public Buffer(Pin PinGrid[][], int x, int y) {
  38.         super(1, x, y, ComponentPin.PIN_TEXT_INVISIBLE);
  39.         ComponentName = "buffer";
  40.         ClassName = "Buffer";
  41.         IPin[0] = new InputPin("A", 1, 3, 2, 0, 0, 0, ComponentPin.PIN_TEXT_INVISIBLE);
  42.         RegisterPins (PinGrid, x, y);
  43.     }
  44.  
  45. //----------------------------------------------------------------------------
  46. // The constructor of a new buffer, which is a copy of CompToCopy
  47. //----------------------------------------------------------------------------
  48.     public Buffer (ElectronicComponent CompToCopy, int xo, int yo) {
  49.         super (CompToCopy, xo, yo);
  50.     }
  51.  
  52. //----------------------------------------------------------------------------
  53. // Method for copying this component.
  54. //----------------------------------------------------------------------------
  55.     public ElectronicComponent Copy(int xo, int yo) {
  56.         Buffer NewComponent = new Buffer(this, xo, yo);
  57.         return NewComponent;
  58.     }
  59.  
  60. //----------------------------------------------------------------------------
  61. // Method for drawing this buffer
  62. //----------------------------------------------------------------------------
  63.     public void draw(Graphics g, int xp, int yp, int gs) {
  64.         super.draw (g, xp, yp, gs);
  65.         int x = Pos.x - xp;
  66.         int y = Pos.y - yp;
  67.  
  68.         // Draw HitBox
  69.         // DrawHitBox(g, x, y, gs);
  70.  
  71.         // Draw the body
  72.         g.setColor (ComponentColor);
  73.         g.drawLine((x + 3) * gs, (y + 1) * gs, (x + 3) * gs, (y + 5) * gs);
  74.         g.drawLine((x + 3) * gs, (y + 1) * gs, (x + 7) * gs, (y + 3) * gs);
  75.         g.drawLine((x + 3) * gs, (y + 5) * gs, (x + 7) * gs, (y + 3) * gs);
  76.     }
  77.  
  78. //----------------------------------------------------------------------------
  79. // This method is simulating the component
  80. //----------------------------------------------------------------------------
  81.     public void SimulateLogic() {
  82.         OPin[0].Level = IPin[0].getLevel();
  83.     }
  84. }