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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // OrPort.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 Or port
  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 OrPort extends LogicPort {
  33.  
  34. //----------------------------------------------------------------------------
  35. // The constructor of a new OR port
  36. //----------------------------------------------------------------------------
  37.     public OrPort(int i, int x, int y, int fl) {
  38.         super(i, x, y, fl);
  39.     }
  40.  
  41. //----------------------------------------------------------------------------
  42. // The constructor of a new OR port, which is a copy of CompToCopy
  43. //----------------------------------------------------------------------------
  44.     public OrPort (ElectronicComponent CompToCopy, int xo, int yo) {
  45.         super (CompToCopy, xo, yo);
  46.     }
  47.  
  48. //----------------------------------------------------------------------------
  49. // Method for copying this component.
  50. //----------------------------------------------------------------------------
  51.     public ElectronicComponent Copy(int xo, int yo) {
  52.         return this; // Should not occure, But return <this> to avoid problems
  53.     }
  54.  
  55. //----------------------------------------------------------------------------
  56. // Method for drawing this OR port
  57. //----------------------------------------------------------------------------
  58.     public void draw(Graphics g, int xp, int yp, int gs) {
  59.         super.draw (g, xp, yp, gs);
  60.         int x = Pos.x - xp;
  61.         int y = Pos.y - yp;
  62.  
  63.         // Draw the body
  64.         g.setColor (ComponentColor);
  65.         g.drawArc ((x + 2) * gs, (y + 1) * gs, gs * 1, gs * 4 , -90, 180);
  66.         g.drawArc ((x - 3) * gs, (y + 1) * gs, (int)(gs * 11.5), gs * 12 , 42, 49);
  67.         g.drawArc ((x - 3) * gs, (y - 7) * gs, (int)(gs * 11.5), gs * 12 , -42, -49);
  68.     }
  69.  
  70. //----------------------------------------------------------------------------
  71. // This method is simulating the component
  72. //----------------------------------------------------------------------------
  73.     public void SimulateLogic() {
  74.         int ix = 0;
  75.         int Result = 0;
  76.         for (ix = 0; ix < Inputs; ix++) {
  77.             if (IPin[ix].getLevel() == 5) {
  78.                 Result = 5;
  79.             }
  80.         }
  81.         OPin[0].Level = Result;
  82.     }
  83. }