home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.io.InputStream;
- import java.net.URL;
-
- public class DigSim extends Applet implements Runnable {
- DigSimFrame frame;
- ControlPanel MyControlPanel;
- StatusPanel MyStatusPanel;
- SchematicPanel MySchematicPanel;
- Button displayb;
- Button disposeb;
- Thread killme;
- String SchematicName;
- Schematic MySchematic;
- Pin[][] PinGrid;
- String message;
- static final int MaxXPoints = 100;
- static final int MaxYPoints = 100;
- Image GridImage;
- Image ImageBuffer;
- Graphics ibg;
- int OffScreenWidth;
- int OffScreenHeight;
- static final Color BackGroundColor;
- static final Color GridColor;
- static final int GridStep = 8;
- static final int hgs = 4;
- boolean SchematicPanelPainted = false;
- boolean HelpWanted = false;
- String TextFileRequested;
- boolean EnableFileOperations = false;
- ExamplesFrame MyExamplesFrame;
- String RequestedText;
- boolean RequestedTextFileRead = false;
- boolean RequestedTextFileError = false;
- OptionsFrame MyOptionsFrame;
- AnalyzerFrame MyAnalyzerFrame;
- int SimulationSpeed = 10;
- boolean StopAtShortCircuit = true;
- boolean StopAtLoop = true;
- boolean AnalyzerAutoPopUp = true;
-
- public void init() {
- ((Container)this).setLayout(new FlowLayout());
- ((Container)this).add(this.displayb = new Button("Display simulator"));
- ((Container)this).add(this.disposeb = new Button("Dispose simulator"));
- this.OffScreenWidth = 400;
- this.OffScreenHeight = 300;
- this.SchematicName = ((Applet)this).getParameter("schematic");
- String var1 = ((Applet)this).getParameter("fileop");
- if (var1 != null) {
- if (var1.equals("true")) {
- this.EnableFileOperations = true;
- } else {
- this.EnableFileOperations = false;
- }
- } else {
- this.EnableFileOperations = false;
- }
-
- this.PinGrid = new Pin[100][100];
- this.InitPinGrids();
- this.SetUpImages();
- this.doFrame();
- this.StatusMessage("Please wait.");
- }
-
- public void start() {
- if (this.killme == null) {
- this.killme = new Thread(this);
- this.killme.start();
- }
-
- }
-
- public void stop() {
- this.killme = null;
- }
-
- public void run() {
- InputStream var1 = null;
- Object var2 = null;
- byte var3 = 100;
- int var5 = 0;
- char[] var4 = new char[var3];
-
- try {
- Thread.currentThread().setPriority(1);
- if (this.SchematicName != null) {
- var1 = (new URL(((Applet)this).getDocumentBase(), this.SchematicName)).openStream();
- this.MySchematic = new Schematic(this.PinGrid, var1);
- }
- } catch (Exception var13) {
- String var15 = ((Throwable)var13).toString();
- String[] var9 = new String[]{"OK"};
- new SimpleDialog(this.frame, "Reading inital schematic", var15, var9, 1, 0, 0, 1);
- }
-
- try {
- if (var1 != null) {
- var1.close();
- }
- } catch (Exception var12) {
- }
-
- ((Component)this).repaint();
- if (this.MySchematic == null) {
- this.MySchematic = new Schematic();
- this.frame.setTitle("Digital Simulator [untitled]");
- } else {
- this.frame.setTitle("Digital Simulator [" + this.SchematicName + "]");
- this.MySchematic.FileDir = "";
- this.MySchematic.FileName = this.SchematicName;
- }
-
- while(this.killme != null) {
- try {
- Thread.sleep((long)this.SimulationSpeed);
- } catch (InterruptedException var11) {
- }
-
- if (this.TextFileRequested != null) {
- var5 = 0;
- String var7 = "";
-
- try {
- Thread.currentThread().setPriority(1);
- var1 = (new URL(((Applet)this).getDocumentBase(), this.TextFileRequested)).openStream();
-
- int var6;
- while((var6 = var1.read()) != -1) {
- var4[var5++] = (char)var6;
- if (var5 >= var3) {
- var7 = var7 + new String(var4, 0, var3);
- var5 = 0;
- }
- }
-
- var7 = var7 + new String(var4, 0, var5);
- } catch (Exception var14) {
- var7 = var7 + ((Throwable)var14).toString();
- this.RequestedText = var7;
- this.RequestedTextFileError = true;
- }
-
- try {
- if (var1 != null) {
- var1.close();
- }
- } catch (Exception var10) {
- var7 = var7 + ((Throwable)var10).toString();
- this.RequestedText = var7;
- this.RequestedTextFileError = true;
- }
-
- if (!this.RequestedTextFileError) {
- this.RequestedText = var7;
- this.RequestedTextFileRead = true;
- }
- }
-
- if (!this.SchematicPanelPainted && this.ImagesReady()) {
- this.SchematicPanelPainted = true;
- this.MySchematicPanel.repaint();
- if (this.MyControlPanel != null) {
- this.MyControlPanel.EnableAllButtons();
- this.frame.EnableAllMenus();
- this.StatusMessage("DigSim initialized. Make a choice or select a component.");
- }
- }
-
- if (this.MyStatusPanel.SimulationRunning) {
- this.SimulateCycle();
- }
- }
-
- this.killme = null;
- }
-
- public void InitPinGrids() {
- for(int var1 = 0; var1 < 100; ++var1) {
- for(int var2 = 0; var2 < 100; ++var2) {
- this.PinGrid[var1][var2] = new Pin();
- }
- }
-
- }
-
- public void SetUpImages() {
- this.ImageBuffer = ((Component)this).createImage(this.OffScreenWidth, this.OffScreenHeight);
- this.ibg = this.ImageBuffer.getGraphics();
- this.GridImage = ((Component)this).createImage(this.OffScreenWidth, this.OffScreenHeight);
- Graphics var3 = this.GridImage.getGraphics();
- var3.setColor(BackGroundColor);
- var3.fillRect(0, 0, this.OffScreenWidth, this.OffScreenHeight);
- var3.setColor(GridColor);
-
- for(int var1 = 1; var1 <= 100; ++var1) {
- for(int var2 = 1; var2 <= 100; ++var2) {
- var3.drawLine(var1 * 8, var2 * 8, var1 * 8, var2 * 8);
- }
- }
-
- }
-
- public void destroyFrame() {
- if (this.SimulateRunning()) {
- this.SimulateStop();
- }
-
- if (this.MyAnalyzerFrame != null) {
- this.MyAnalyzerFrame.dispose();
- this.MyAnalyzerFrame = null;
- }
-
- if (this.MyExamplesFrame != null) {
- this.MyExamplesFrame.dispose();
- this.MyExamplesFrame = null;
- }
-
- if (this.MyOptionsFrame != null) {
- this.MyOptionsFrame.dispose();
- this.MyOptionsFrame = null;
- }
-
- if (this.frame != null) {
- this.frame.dispose();
- this.frame = null;
- this.displayb.enable(true);
- this.disposeb.enable(false);
- }
-
- }
-
- void doFrame() {
- this.displayb.enable(false);
- this.disposeb.enable(true);
- this.frame = new DigSimFrame(this);
- this.frame.EnableAllMenus();
- }
-
- public boolean action(Event var1, Object var2) {
- if (var1.target instanceof Button) {
- String var3 = (String)var2;
- if (var3.equals("Display simulator")) {
- this.doFrame();
- this.MyControlPanel.EnableAllButtons();
- } else if (var3.equals("Dispose simulator")) {
- this.destroyFrame();
- }
-
- return true;
- } else {
- return false;
- }
- }
-
- public void SimulateSetUp() {
- for(int var1 = 0; var1 < 100; ++var1) {
- for(int var2 = 0; var2 < 100; ++var2) {
- if (this.PinGrid[var1][var2] != null) {
- this.PinGrid[var1][var2].SimulateSetUp(var1, var2);
- }
- }
- }
-
- }
-
- public void SimulateStart() {
- this.StatusMessage("Please wait. Initializing simulation.");
- this.MyStatusPanel.repaint();
- if (!this.MyStatusPanel.SimulationInitializeInProgress) {
- if (this.AnalyzerAutoPopUp && this.MyAnalyzerFrame == null && this.MySchematic.ProbesInSchematic()) {
- this.MyAnalyzerFrame = new AnalyzerFrame(this);
- }
-
- this.MySchematicPanel.SelectSchematic.RemoveAllComponents();
- this.MyStatusPanel.SimulationInitializeInProgress = true;
- this.MyStatusPanel.repaint();
- this.SimulateSetUp();
- this.MyStatusPanel.SimulationInitializeInProgress = false;
- this.MyStatusPanel.SimulationRunning = true;
- this.StatusMessage("Simulation running. press 'Simulate' button again to stop or press a component in the schematic");
- }
- }
-
- public void SimulateStop() {
- this.MyStatusPanel.SimulationRunning = false;
- this.StatusMessage("Simulation stoppped. Make a choice above or change the schematic.");
- this.MyStatusPanel.repaint();
- }
-
- public boolean IsSimulating() {
- return this.MyStatusPanel.SimulationRunning || this.MyStatusPanel.SimulationInitializeInProgress;
- }
-
- public void SimulateCycle() {
- this.MySchematic.InitBeforeSimulate();
-
- for(int var2 = 0; var2 < 4; ++var2) {
- this.MySchematic.Simulate();
- }
-
- if (this.StopAtShortCircuit) {
- ElectronicComponent var1 = this.MySchematic.TestShortCircuit();
- if (var1 != null) {
- String[] var6 = new String[]{"OK"};
- String var7 = "Short circuit detected at " + var1.getName() + " pos. " + var1.Pos.x + ", " + var1.Pos.y;
- new SimpleDialog(this.frame, "Short circuit detected", var7, var6, 1, 0, 0, 1);
- this.UserWantsSimulate();
- this.MySchematicPanel.repaint();
- this.MyStatusPanel.repaint();
- return;
- }
- }
-
- if (this.StopAtLoop) {
- ElectronicComponent var5 = this.MySchematic.TestLoop();
- if (var5 != null) {
- String[] var3 = new String[]{"OK"};
- String var4 = "Loop detected at " + var5.getName() + " pos. " + var5.Pos.x + ", " + var5.Pos.y;
- new SimpleDialog(this.frame, "Loop detected", var4, var3, 1, 0, 0, 1);
- this.UserWantsSimulate();
- this.MySchematicPanel.repaint();
- this.MyStatusPanel.repaint();
- return;
- }
- }
-
- if (this.MyAnalyzerFrame != null && this.MyAnalyzerFrame.MyAnalyzerPanel != null) {
- this.MyAnalyzerFrame.MyAnalyzerPanel.update();
- }
-
- this.MySchematicPanel.repaint();
- this.MyStatusPanel.repaint();
- }
-
- public void addComponent(ElectronicComponent var1) {
- if (this.MySchematic != null) {
- this.MySchematicPanel.SelectSchematic.RemoveAllComponents();
- this.MySchematic.addComponent(var1);
- if (!(var1 instanceof Wire)) {
- this.UserWantsPointer();
- }
-
- this.MySchematicPanel.repaint();
- }
- }
-
- public void addComponent(String var1) {
- if (this.MySchematicPanel != null) {
- if ("Wire".equals(var1)) {
- this.UserWantsWireDrawing();
- } else if ("Junction".equals(var1)) {
- this.UserWantsJunctionDrawing();
- } else {
- if ("Vcc".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Vcc(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("GND".equals(var1)) {
- this.addComponent((ElectronicComponent)(new GND(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Switch".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Switch(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Push button".equals(var1)) {
- this.addComponent((ElectronicComponent)(new PushButton(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Buffer".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Buffer(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Inverter".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Inverter(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input AND port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoAndPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("3-input AND port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new ThreeAndPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input OR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoOrPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("3-input OR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new ThreeOrPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input XOR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoXorPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input NAND port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoNandPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("3-input NAND port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new ThreeNandPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input NOR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoNorPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("3-input NOR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new ThreeNorPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("2-input XNOR port".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TwoXnorPort(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("SR-latch".equals(var1)) {
- this.addComponent((ElectronicComponent)(new SRLatch(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Gated SR-latch".equals(var1)) {
- this.addComponent((ElectronicComponent)(new GatedSRLatch(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("D-latch".equals(var1)) {
- this.addComponent((ElectronicComponent)(new DLatch(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("D-flipflop".equals(var1)) {
- this.addComponent((ElectronicComponent)(new DFlipFlop(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("JK-flipflop".equals(var1)) {
- this.addComponent((ElectronicComponent)(new JKFlipFlop(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Edge-triggered T-flipflop".equals(var1)) {
- this.addComponent((ElectronicComponent)(new EdgeTriggeredTFlipFlop(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("T-flipflop".equals(var1)) {
- this.addComponent((ElectronicComponent)(new TFlipFlop(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Octal D-flipflop".equals(var1)) {
- this.addComponent((ElectronicComponent)(new OctalDFlipFlop(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Octal latch".equals(var1)) {
- this.addComponent((ElectronicComponent)(new OctalLatch(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Red LED".equals(var1)) {
- this.addComponent((ElectronicComponent)(new LED(this.PinGrid, Color.red, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Green LED".equals(var1)) {
- this.addComponent((ElectronicComponent)(new LED(this.PinGrid, Color.green, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Yellow LED".equals(var1)) {
- this.addComponent((ElectronicComponent)(new LED(this.PinGrid, Color.yellow, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Bi-color LED".equals(var1)) {
- this.addComponent((ElectronicComponent)(new BiColorLED(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("7-segment display".equals(var1)) {
- this.addComponent((ElectronicComponent)(new SevenSegmentDisplay(this.PinGrid, Color.red, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Oscilator".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Oscilator(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("Analyzer probe".equals(var1)) {
- this.addComponent((ElectronicComponent)(new Probe(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- this.updateAnalyzer();
- } else if ("BCD to 7-segment decoder".equals(var1)) {
- this.addComponent((ElectronicComponent)(new BCDToSevenSegDecoder(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("3- to 8-line decoder".equals(var1)) {
- this.addComponent((ElectronicComponent)(new ThreeToEightLineDecoder(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("4-bit binary counter".equals(var1)) {
- this.addComponent((ElectronicComponent)(new FourBitBinaryCounter(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("8-bit serial in shift register".equals(var1)) {
- this.addComponent((ElectronicComponent)(new EightBitSerInShiftReg(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- } else if ("8-bit parallel in shift register".equals(var1)) {
- this.addComponent((ElectronicComponent)(new EightBitParInShiftReg(this.PinGrid, this.MySchematicPanel.GridXOffset, this.MySchematicPanel.GridYOffset)));
- }
-
- this.MySchematicPanel.WireDrawing = false;
- this.MySchematicPanel.JunctionDrawing = false;
- this.StatusMessage("Click and hold the mouse button in the body of the new " + var1 + " to move it.");
- }
- }
- }
-
- public boolean ImagesReady() {
- return this.ibg != null && this.GridImage != null && this.ImageBuffer != null && this.MySchematic != null;
- }
-
- public void StatusMessage(String var1) {
- this.MyStatusPanel.StatusMessage(var1);
- }
-
- public boolean SimulateRunning() {
- return this.MyStatusPanel.SimulateRunning();
- }
-
- public String getAppletInfo() {
- return "DigSim v 0.01 (c) 1996 Iwan van Rienen\nE-mail: ivr@bart.nl\nHomepage: http://www.bart.nl/~ivr/";
- }
-
- public String[][] getParameterInfo() {
- String[][] var1 = new String[][]{{"schematic", "String", "Initial schematic to load"}, {"fileop", "Boolean", "Local file operations enable"}};
- return var1;
- }
-
- public void UserWantsPointer() {
- this.HelpWanted = false;
- if (this.MyControlPanel != null) {
- this.MyControlPanel.SelectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.MySchematicPanel != null) {
- this.MySchematicPanel.WireDrawing = false;
- this.MySchematicPanel.JunctionDrawing = false;
- this.StatusMessage("Move the cursor to a component body or wire-end and press a mouse button.");
- }
-
- }
-
- public void UserWantsWireDrawing() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Wire");
- this.UserWantsPointer();
- } else {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.SelectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.MySchematicPanel != null) {
- this.StatusMessage("Move the mouse to the desired position, click and hold the mouse button to draw a wire.");
- this.MySchematicPanel.WireDrawing = true;
- this.MySchematicPanel.JunctionDrawing = false;
- this.MySchematicPanel.SelectSchematic.RemoveAllComponents();
- this.MySchematicPanel.repaint();
- }
-
- }
- }
-
- public void UserWantsJunctionDrawing() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Junction");
- this.UserWantsPointer();
- } else {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.SelectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.MySchematicPanel != null) {
- this.MySchematicPanel.WireDrawing = false;
- this.MySchematicPanel.JunctionDrawing = true;
- this.StatusMessage("Move the mouse to the desired position, and click the mouse button to add a junction.");
- this.MySchematicPanel.SelectSchematic.RemoveAllComponents();
- this.MySchematicPanel.repaint();
- }
-
- }
- }
-
- public void UserWantsTextDrawing() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Text");
- this.UserWantsPointer();
- } else {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.SelectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.frame != null) {
- if (this.frame.MyTextDialog == null) {
- this.frame.MyTextDialog = new TextDialog(this.frame, "", 5);
- }
-
- this.StatusMessage("Please type a new text.");
- this.UserWantsPointer();
- }
-
- }
- }
-
- public void UserWantsHelp() {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.SelectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Help");
- } else {
- this.StatusMessage("Choose a component, menu or button to get help about it.");
- this.HelpWanted = true;
- }
- }
-
- public void UserWantsSimulate() {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.SelectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Simulate");
- this.UserWantsPointer();
- } else if (!this.IsSimulating()) {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.DisableButton("Pointer");
- this.MyControlPanel.DisableButton("Wire");
- this.MyControlPanel.DisableButton("Junction");
- this.MyControlPanel.DisableButton("Text");
- this.MyControlPanel.DisableButton("New");
- this.MyControlPanel.DisableButton("Open");
- this.MyControlPanel.DisableButton("Save");
- }
-
- this.frame.DisableAllMenus();
- this.frame.StartMenuItem.disable();
- this.frame.StopMenuItem.enable();
- this.SimulateStart();
- ((Component)this).repaint();
- } else {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.EnableButton("Pointer");
- this.MyControlPanel.EnableButton("Wire");
- this.MyControlPanel.EnableButton("Junction");
- this.MyControlPanel.EnableButton("Text");
- this.MyControlPanel.EnableButton("New");
- if (this.EnableFileOperations) {
- this.MyControlPanel.EnableButton("Open");
- this.MyControlPanel.EnableButton("Save");
- }
- }
-
- this.frame.EnableAllMenus();
- this.frame.StopMenuItem.disable();
- this.frame.StartMenuItem.enable();
- this.SimulateStop();
- this.UserWantsPointer();
- ((Component)this).repaint();
- }
- }
-
- public void UserWantsNewSchematic() {
- if (this.MySchematic != null) {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.SelectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "New");
- this.UserWantsPointer();
- } else {
- if (this.MySchematic.Modified) {
- if (this.frame.NewDialog == null) {
- String[] var1 = new String[]{"OK", "Cancel"};
- this.frame.NewDialog = new SimpleDialog(this.frame, "New schematic", "Discard changes?", var1, 2, 1, 2, 2);
- this.UserWantsPointer();
- return;
- }
- } else {
- this.MySchematic.DestroyComponents(this.PinGrid);
- this.frame.setTitle("Digital Simulator [untitled]");
- this.MySchematic.FileName = null;
- this.MySchematic.Modified = false;
- this.MySchematicPanel.repaint();
- this.UserWantsPointer();
- this.updateAnalyzer();
- }
-
- }
- }
- }
-
- public void UserWantsOpenSchematic() {
- if (this.MySchematic != null) {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.SelectButton("Open");
- this.MyControlPanel.UnselectButton("Save");
- }
-
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Open");
- this.UserWantsPointer();
- } else {
- if (this.MySchematic.Modified) {
- if (this.frame.OpenDialog == null) {
- String[] var2 = new String[]{"OK", "Cancel"};
- this.frame.OpenDialog = new SimpleDialog(this.frame, "Open schematic", "Discard changes?", var2, 2, 1, 3, 2);
- this.UserWantsPointer();
- return;
- }
- } else {
- Schematic var1 = this.frame.DoFileOpenDialog(this.PinGrid, "Open schematic");
- if (var1 != null) {
- this.MySchematic = var1;
- this.frame.setTitle("Digital Simulator [" + this.MySchematic.FileName + "]");
- this.MySchematicPanel.repaint();
- }
-
- this.UserWantsPointer();
- }
-
- }
- }
- }
-
- public void UserWantsOpenExample(String var1) {
- if (this.MySchematic != null) {
- if (this.MySchematic.Modified) {
- if (this.frame.OpenExampleDialog == null) {
- String[] var2 = new String[]{"OK", "Cancel"};
- this.frame.ExampleFileName = var1;
- this.frame.OpenExampleDialog = new SimpleDialog(this.frame, "Open example", "Discard changes?", var2, 2, 1, 7, 2);
- this.UserWantsPointer();
- return;
- }
- } else {
- this.frame.LoadExample(var1);
- this.UserWantsPointer();
- }
-
- }
- }
-
- public void UserWantsSaveSchematic() {
- if (this.MySchematic != null) {
- if (this.MyControlPanel != null) {
- this.MyControlPanel.UnselectButton("Pointer");
- this.MyControlPanel.UnselectButton("Wire");
- this.MyControlPanel.UnselectButton("Junction");
- this.MyControlPanel.UnselectButton("Text");
- this.MyControlPanel.UnselectButton("Help");
- this.MyControlPanel.UnselectButton("Simulate");
- this.MyControlPanel.UnselectButton("New");
- this.MyControlPanel.UnselectButton("Open");
- this.MyControlPanel.SelectButton("Save");
- }
-
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Save");
- this.UserWantsPointer();
- } else {
- if (this.MySchematic.FileName != null && this.MySchematic.FileDir != null) {
- this.frame.DoFileSaveDialog(this.MySchematic, false, "Save schematic");
- } else {
- this.frame.DoFileSaveDialog(this.MySchematic, false, "Save schematic as");
- }
-
- this.frame.setTitle("Digital Simulator [" + this.MySchematic.FileName + "]");
- this.MySchematicPanel.repaint();
- this.UserWantsPointer();
- }
- }
- }
-
- public void UserWantsCopySchematic() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Copy");
- } else {
- this.MySchematicPanel.Copy();
- this.frame.PasteMenuItem.enable();
- this.MyControlPanel.EnableButton("Paste");
- }
-
- this.MyControlPanel.UnselectButton("Copy");
- this.UserWantsPointer();
- }
-
- public void UserWantsPasteSchematic() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Paste");
- } else {
- this.MySchematicPanel.Paste();
- }
-
- this.MyControlPanel.UnselectButton("Paste");
- this.UserWantsPointer();
- }
-
- public void UserWantsCutSchematic() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Cut");
- } else {
- this.MySchematicPanel.Cut();
- this.frame.CutMenuItem.disable();
- this.frame.CopyMenuItem.disable();
- this.frame.PasteMenuItem.enable();
- this.MyControlPanel.DisableButton("Cut");
- this.MyControlPanel.DisableButton("Copy");
- this.MyControlPanel.EnableButton("Paste");
- }
-
- this.MyControlPanel.UnselectButton("Cut");
- this.UserWantsPointer();
- }
-
- public void UserWantsOpenExample() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Open example");
- } else {
- if (this.MyExamplesFrame == null) {
- this.MyExamplesFrame = new ExamplesFrame(this);
- }
-
- }
- }
-
- public void UserWantsCopyToSchematic() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "CopyTo");
- } else {
- this.MySchematicPanel.CopyTo();
- this.frame.PasteMenuItem.enable();
- this.MyControlPanel.EnableButton("Paste");
- }
-
- this.UserWantsPointer();
- }
-
- public void UserWantsPasteFromSchematic() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "PasteFrom");
- } else {
- this.MySchematicPanel.PasteFrom();
- }
-
- this.UserWantsPointer();
- }
-
- public void UserWantsOptions() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Options");
- } else if (this.MyOptionsFrame == null) {
- this.MyOptionsFrame = new OptionsFrame(this);
- }
-
- this.UserWantsPointer();
- }
-
- public void UserWantsAnalyzer() {
- if (this.HelpWanted) {
- new HelpDialog(this.frame, "Analyzer");
- } else {
- if (this.MyAnalyzerFrame == null) {
- this.MyAnalyzerFrame = new AnalyzerFrame(this);
- }
-
- }
- }
-
- public void updateAnalyzer() {
- if (this.MyAnalyzerFrame != null) {
- this.MyAnalyzerFrame.repaint();
- }
-
- }
-
- static {
- BackGroundColor = Color.black;
- GridColor = Color.green;
- }
- }
-