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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // Vcc.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 Vcc
  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.  
  29. import java.applet.Applet;
  30. import java.awt.*;
  31. import java.util.Vector;
  32.  
  33. class Vcc extends ElectronicComponent {
  34.  
  35. //----------------------------------------------------------------------------
  36. // The constructor of a new Vcc Pin.
  37. //----------------------------------------------------------------------------
  38.     public Vcc(Pin PinGrid[][], int x, int y) {
  39.         super (x, y, 4, 6, 1, 1, 2, 4, 0, 1);      // x,y,w,h HitBox x,y,w,h, I,O
  40.         OPin[0] = new OutputPin("Vcc", 2, 5, 0, -2, 0, 0, ComponentPin.PIN_TEXT_INVISIBLE); // name, x, y, w, h, Flags
  41.         OPin[0].Level = 5;
  42.         ComponentName = "Vcc";
  43.         ClassName = "Vcc";
  44.         RegisterPins (PinGrid, x, y);
  45.     }
  46.  
  47. //----------------------------------------------------------------------------
  48. // The constructor of a new Vcc pin, which is a copy of CompToCopy
  49. //----------------------------------------------------------------------------
  50.     public Vcc (ElectronicComponent CompToCopy, int xo, int yo) {
  51.         super (CompToCopy, xo, yo);
  52.     }
  53.  
  54. //----------------------------------------------------------------------------
  55. // Method for copying this component.
  56. //----------------------------------------------------------------------------
  57.     public ElectronicComponent Copy(int xo, int yo) {
  58.         Vcc NewComponent = new Vcc(this, xo, yo);
  59.         NewComponent.OPin[0].Level = 5;
  60.         return NewComponent;
  61.     }
  62.  
  63. //----------------------------------------------------------------------------
  64. // Method for drawing this component.
  65. //----------------------------------------------------------------------------
  66.     public void draw(Graphics g, int xp, int yp, int gs) {
  67.         super.draw (g, xp, yp, gs);
  68.         int x = Pos.x - xp;
  69.         int y = Pos.y - yp;
  70.  
  71.         // Draw HitBox and Dimension
  72.         // DrawHitBox(g, x, y, gs);
  73.  
  74.         // Draw The OutputPin
  75.         DrawOutputPins(g, x, y, gs);
  76.  
  77.         // Draw the body
  78.         g.setColor (ComponentColor);
  79.         g.drawOval ((int)((x + 1.5) * gs) , (y + 2) * gs, gs, gs);
  80.         g.drawLine ((int)((x + 1.5) * gs), (y + 3) * gs,
  81.                     (int)((x + 2.5) * gs), (y + 2) * gs );
  82.  
  83.         // Draw plus sign
  84.         g.setColor (Color.red);
  85.         g.drawLine ((int)((x + 1.75) * gs), (int)((y + 1.5) * gs),
  86.                     (int)((x + 2.25) * gs), (int)((y + 1.5) * gs));
  87.         g.drawLine ((int)((x + 2) * gs), (int)((y + 1.25) * gs),
  88.                     (int)((x + 2) * gs), (int)((y + 1.75) * gs));
  89.     }
  90.  
  91. //----------------------------------------------------------------------------
  92. // Here is the code that's simulating the component
  93. // All connected components to this Vcc pin will be informed
  94. //----------------------------------------------------------------------------
  95.     public void Simulate(int id) {
  96. //      System.out.println ("Vcc Simulate() ID= " + id);
  97.         InformConnectedComponents(id);
  98.     }
  99.  
  100. }