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

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // Probe.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 Logic Analyzer Probe
  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. import java.io.PrintStream;
  32.  
  33. class Probe extends ElectronicComponent {
  34.     Point ChannelPos;
  35.     Dimension ChannelDim;
  36.     int LevelHistory[];
  37.     static final int MAX_HISTORY = 100;
  38.     boolean clockup_probe = false;
  39.     boolean clockdn_probe = false;
  40.     int OldLevel;
  41.  
  42. //----------------------------------------------------------------------------
  43. // The constructor of a new analyzer probe
  44. //----------------------------------------------------------------------------
  45.     public Probe (Pin PinGrid[][], int x, int y) {
  46.         super (x, y, 4, 6, 1, 1, 2, 4, 1, 0);      // x,y,w,h HitBox x,y,w,h, I,O
  47.         ChannelPos = new Point(0, 0);
  48.         ChannelDim = new Dimension(0, 0);
  49.         LevelHistory = new int[MAX_HISTORY];
  50.         ComponentName = "Probe";
  51.         ClassName = "Probe";
  52.         IPin[0] = new InputPin("Probe", 2, 5, 0, -2, 0, -1, ComponentPin.PIN_NORMAL); // name, x, y, w, h, txo, tyo, flags
  53.         RegisterPins (PinGrid, x, y);
  54.     }
  55.  
  56. //----------------------------------------------------------------------------
  57. // The constructor of a new analyzer probe with the specified variables
  58. //----------------------------------------------------------------------------
  59.     public Probe (Pin PinGrid[][], int x, int y, String text, boolean up, boolean dn) {
  60.         super (x, y, 4, 6, 1, 1, 2, 4, 1, 0);      // x,y,w,h HitBox x,y,w,h, I,O
  61.         clockup_probe = up;
  62.         clockdn_probe = dn;
  63.         ChannelPos = new Point(0, 0);
  64.         ChannelDim = new Dimension(0, 0);
  65.         LevelHistory = new int[MAX_HISTORY];
  66.         ComponentName = "Probe";
  67.         ClassName = "Probe";
  68.         IPin[0] = new InputPin(text, 2, 5, 0, -2, 0, -1, ComponentPin.PIN_NORMAL); // name, x, y, w, h, txo, tyo, flags
  69.         RegisterPins (PinGrid, x, y);
  70.     }
  71.  
  72. //----------------------------------------------------------------------------
  73. // The constructor of a new Probe, which is a copy of CompToCopy
  74. //----------------------------------------------------------------------------
  75.     public Probe (ElectronicComponent CompToCopy, int xo, int yo) {
  76.         super (CompToCopy, xo, yo);
  77.         ChannelPos = new Point(0, 0);
  78.         ChannelDim = new Dimension(0, 0);
  79.         LevelHistory = new int[MAX_HISTORY];
  80.     }
  81.  
  82. //----------------------------------------------------------------------------
  83. // Method for copying this component.
  84. //----------------------------------------------------------------------------
  85.     public ElectronicComponent Copy(int xo, int yo) {
  86.         Probe NewComponent = new Probe(this, xo, yo);
  87.         return NewComponent;
  88.     }
  89.  
  90. //----------------------------------------------------------------------------
  91. // Method for Drawing this probe in the schematic
  92. //----------------------------------------------------------------------------
  93.     public void draw(Graphics g, int xp, int yp, int gs) {
  94.         super.draw (g, xp, yp, gs);
  95.         int x = Pos.x - xp;
  96.         int y = Pos.y - yp;
  97.  
  98.         // Draw HitBox and Dimension
  99.         // DrawHitBox(g, x, y, gs);
  100.  
  101.         // Draw all I Pins
  102.         DrawInputPins(g, x, y, gs);
  103.  
  104.         // Draw the body
  105.         g.setColor (ComponentColor);
  106.         g.drawOval ((int)((x + 1.5) * gs) , (y + 2) * gs, gs, gs);
  107.         g.drawLine ((int)((x + 1.5) * gs), (y + 3) * gs,
  108.                     (int)((x + 2.5) * gs), (y + 2) * gs );
  109.  
  110.     }
  111.  
  112. //----------------------------------------------------------------------------
  113. // Method for saving the probe
  114. //----------------------------------------------------------------------------
  115.    public void Save (PrintStream myPrintStream) {
  116.         if (clockup_probe) {
  117.             myPrintStream.println ("describe component ProbeUp");
  118.         } else if (clockdn_probe) {
  119.             myPrintStream.println ("describe component ProbeDn");
  120.         } else  {
  121.             myPrintStream.println ("describe component Probe");
  122.         }
  123.  
  124.         myPrintStream.println (" pos " + Pos.x + " " + Pos.y);
  125.         myPrintStream.println (" Text " + IPin[0].getName());
  126.         myPrintStream.println ("end describe");
  127.     }
  128. }