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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // OutputPin.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 an Output 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 OutputPin extends ComponentPin {
  32.     boolean ShortCircuit = false;
  33.  
  34. //-----------------------------------------------------------------------------
  35. // Constuct a new pin with the data of PinToCopy
  36. //-----------------------------------------------------------------------------
  37.     public OutputPin (OutputPin PinToCopy) {
  38.         super(PinToCopy);
  39.     }
  40.  
  41. //-----------------------------------------------------------------------------
  42. // The constructor of OutputPin.
  43. //-----------------------------------------------------------------------------
  44.     public OutputPin (String name, int x, int y, int w, int h, int txo, int tyo, int fl) {
  45.         super (name, x, y, w, h, txo, tyo, fl);
  46.     }
  47.  
  48. //-----------------------------------------------------------------------------
  49. // Draw the output pin.
  50. // Mostly of the drawing is done by ComponentPin,
  51. // But if there is an short circuit it will be drawed by this function.
  52. //-----------------------------------------------------------------------------
  53.     public void draw (Graphics g, int x, int y, int gs) {
  54.         super.draw (g, x, y, gs);
  55.         if (ShortCircuit) {
  56.             int xp = PinPos.x + x;
  57.             int yp = PinPos.y + y;
  58.  
  59.             g.setColor (Color.yellow);
  60.             g.drawLine (xp * gs, yp * gs, (xp + 1) * gs, (yp  - 1) * gs);
  61.             g.drawLine ((xp + 1) * gs, (yp  - 1) * gs, (xp + 1) * gs, (int)((yp  - 0.5) * gs));
  62.             g.drawLine ((xp + 1) * gs, (int)((yp  - 0.5) * gs), (xp + 2) * gs, (int)((yp  - 1.5) * gs));
  63.             g.drawLine (xp * gs, yp * gs, (int)((xp + 0.25) * gs), (yp) * gs);
  64.             g.drawLine (xp * gs, yp * gs, xp * gs, (int)((yp - 0.25) * gs));
  65.         }
  66.     }
  67.  
  68.     public void InitBeforeSimulate() {
  69.         ShortCircuit = false;
  70.     }
  71. }