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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // InputPin.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 Input Pin
  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.  
  31. class InputPin extends ComponentPin {
  32.     boolean AlreadyInformed = false;
  33.     int ReceivedSimulationCycleID;
  34.     int LevelChanged = 0;
  35.     boolean Looping = false;
  36.  
  37. //-----------------------------------------------------------------------------
  38. // Constuct a new pin with the data of PinToCopy
  39. //-----------------------------------------------------------------------------
  40.     public InputPin (InputPin PinToCopy) {
  41.         super(PinToCopy);
  42.     }
  43.  
  44. //-----------------------------------------------------------------------------
  45. // Construct a new InputPin.
  46. //-----------------------------------------------------------------------------
  47.     public InputPin (String name, int x, int y, int w, int h, int txo, int tyo, int fl) {
  48.         super (name, x, y, w, h, txo, tyo, fl);
  49.     }
  50.  
  51. //-----------------------------------------------------------------------------
  52. // Initialize the Pin before simulating
  53. //-----------------------------------------------------------------------------
  54.     public void InitBeforeSimulate() {
  55.         ReceivedSimulationCycleID = -1;
  56.         LevelChanged = 0;
  57.         Looping = false;
  58.     }
  59.  
  60. //-----------------------------------------------------------------------------
  61. // Draw the pin. Mostly of the drawing is done by the parent, ComponentPin,
  62. // But draw a loop-symbool if this pin is looping.
  63. //-----------------------------------------------------------------------------
  64.    public void draw (Graphics g, int x, int y, int gs) {
  65.         super.draw (g, x, y, gs);
  66.         if (Looping) {
  67.             int xp = PinPos.x + x;
  68.             int yp = PinPos.y + y;
  69.  
  70.             g.setColor (Color.yellow);
  71.             g.drawArc ((xp - 2) * gs, (int)((yp - 1.5) * gs), gs * 2, gs * 2, 0, 270);
  72.             g.drawLine (xp * gs, (int)((yp - 0.5) * gs), (int)((xp + 0.5) * gs), (yp - 1 ) * gs);
  73.             g.drawLine (xp * gs, (int)((yp - 0.5) * gs), (int)((xp - 0.5) * gs), (yp - 1 ) * gs);
  74.         }
  75.     }
  76. }