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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // Pin.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 Pin, used in PinGrid and contains ElectronicComponent
  12. // Used to make a PinGrid[][]
  13. //
  14. // This program and the Java source is in the public domain.
  15. // Permission to use, copy, modify, and distribute this software
  16. // and its documentation for NON-COMMERCIAL purposes and
  17. // without fee is hereby granted.
  18. //
  19. //    Copyright 1996
  20. //
  21. //    Iwan van Rienen
  22. //    Joan Maetsuyckerstr. 145
  23. //    2593 ZG  The Hague
  24. //    The Netherlands
  25. //
  26. // I am not responsible for any bugs in this program and
  27. // possible damage to hard- or software when using this program.
  28. //****************************************************************************
  29. import java.applet.Applet;
  30. import java.awt.*;
  31. import java.util.Vector;
  32.  
  33. class Pin {
  34.     Vector Components;
  35.  
  36. // ---------------------------------------------------------------------------
  37. // The constructor of the Pin class.
  38. // ---------------------------------------------------------------------------
  39.     public Pin () {
  40.         Components = new Vector();
  41.     }
  42.  
  43. // ---------------------------------------------------------------------------
  44. // add Components to this Pin
  45. // ---------------------------------------------------------------------------
  46.     public void AddComponent (ElectronicComponent ActComponent) {
  47.         Components.addElement(ActComponent);
  48.     }
  49.  
  50. // ---------------------------------------------------------------------------
  51. // Remove components from this Pin
  52. // ---------------------------------------------------------------------------
  53.     public void RemoveComponent (ElectronicComponent ActComponent) {
  54.         for (int ix = 0; ix < Components.size(); ix++) {
  55.             if (Components.elementAt(ix) == ActComponent) {
  56.                 Components.removeElementAt(ix);
  57.                 // System.out.println ("Component found and removed from grid.");
  58.                 return;
  59.             }
  60.         }
  61.     // System.out.println ("**** Error - can't remove component from grid");
  62.     }
  63.  
  64. // ---------------------------------------------------------------------------
  65. // Set all components up before simulating. this is done once
  66. // before simulating and will set up the linked-lists between the components
  67. // ---------------------------------------------------------------------------
  68.     public void SimulateSetUp(int x, int y) {
  69.         int ix;
  70.         ElectronicComponent ActComponent;
  71.  
  72.         for (ix = 0; ix < Components.size(); ix++) {
  73.             ActComponent = (ElectronicComponent)Components.elementAt(ix);
  74.             ActComponent.SimulateSetUp(x, y, Components);
  75.         }
  76.     }
  77.  
  78. }