diff --git a/ams.jar b/ams.jar deleted file mode 100644 index 5e7ad24..0000000 Binary files a/ams.jar and /dev/null differ diff --git a/bin/TuringMachine/OTMSExporter$INode.class b/bin/TuringMachine/OTMSExporter$INode.class index 8fe79d3..23a06da 100644 Binary files a/bin/TuringMachine/OTMSExporter$INode.class and b/bin/TuringMachine/OTMSExporter$INode.class differ diff --git a/bin/TuringMachine/OTMSExporter.class b/bin/TuringMachine/OTMSExporter.class index 2de779d..efdf7f2 100644 Binary files a/bin/TuringMachine/OTMSExporter.class and b/bin/TuringMachine/OTMSExporter.class differ diff --git a/bin/TuringMachine/State.class b/bin/TuringMachine/State.class index 3d9341d..85b3ec1 100644 Binary files a/bin/TuringMachine/State.class and b/bin/TuringMachine/State.class differ diff --git a/bin/TuringMachine/Transition.class b/bin/TuringMachine/Transition.class index 6038f77..40997c0 100644 Binary files a/bin/TuringMachine/Transition.class and b/bin/TuringMachine/Transition.class differ diff --git a/bin/abacus/BigIntegerBean.class b/bin/abacus/BigIntegerBean.class index 6c196d7..d42177a 100644 Binary files a/bin/abacus/BigIntegerBean.class and b/bin/abacus/BigIntegerBean.class differ diff --git a/bin/abacus/Comment.class b/bin/abacus/Comment.class index faad6a7..d630c20 100644 Binary files a/bin/abacus/Comment.class and b/bin/abacus/Comment.class differ diff --git a/bin/abacus/EditNodeDialog.class b/bin/abacus/EditNodeDialog.class index defe343..5b57ab0 100644 Binary files a/bin/abacus/EditNodeDialog.class and b/bin/abacus/EditNodeDialog.class differ diff --git a/bin/abacus/FileData.class b/bin/abacus/FileData.class index 13765b1..7f04dfd 100644 Binary files a/bin/abacus/FileData.class and b/bin/abacus/FileData.class differ diff --git a/bin/abacus/InputsFileData.class b/bin/abacus/InputsFileData.class new file mode 100644 index 0000000..9d3d9c8 Binary files /dev/null and b/bin/abacus/InputsFileData.class differ diff --git a/bin/abacus/MachinePanel$MouseAction.class b/bin/abacus/MachinePanel$MouseAction.class index a959fc9..652025d 100644 Binary files a/bin/abacus/MachinePanel$MouseAction.class and b/bin/abacus/MachinePanel$MouseAction.class differ diff --git a/bin/abacus/MachinePanel.class b/bin/abacus/MachinePanel.class index a0b72d6..8f60130 100644 Binary files a/bin/abacus/MachinePanel.class and b/bin/abacus/MachinePanel.class differ diff --git a/bin/abacus/Main.class b/bin/abacus/Main.class index 9883aa1..8bd4126 100644 Binary files a/bin/abacus/Main.class and b/bin/abacus/Main.class differ diff --git a/bin/abacus/Node.class b/bin/abacus/Node.class index fb30bec..6986c30 100644 Binary files a/bin/abacus/Node.class and b/bin/abacus/Node.class differ diff --git a/bin/abacus/NodeEditor$1.class b/bin/abacus/NodeEditor$1.class index ef5255b..5562726 100644 Binary files a/bin/abacus/NodeEditor$1.class and b/bin/abacus/NodeEditor$1.class differ diff --git a/bin/abacus/NodeEditor.class b/bin/abacus/NodeEditor.class index f3785a6..2e9c108 100644 Binary files a/bin/abacus/NodeEditor.class and b/bin/abacus/NodeEditor.class differ diff --git a/bin/abacus/RegisterEditor$RegisterPanel$RegTimer.class b/bin/abacus/RegisterEditor$RegisterPanel$RegTimer.class index a854fe4..0d95913 100644 Binary files a/bin/abacus/RegisterEditor$RegisterPanel$RegTimer.class and b/bin/abacus/RegisterEditor$RegisterPanel$RegTimer.class differ diff --git a/bin/abacus/RegisterEditor$RegisterPanel.class b/bin/abacus/RegisterEditor$RegisterPanel.class index 706d384..8e8bd89 100644 Binary files a/bin/abacus/RegisterEditor$RegisterPanel.class and b/bin/abacus/RegisterEditor$RegisterPanel.class differ diff --git a/bin/abacus/RegisterEditor.class b/bin/abacus/RegisterEditor.class index 99a9b9d..15c8c84 100644 Binary files a/bin/abacus/RegisterEditor.class and b/bin/abacus/RegisterEditor.class differ diff --git a/bin/abacus/Simulator$Player.class b/bin/abacus/Simulator$Player.class index 2ae3323..78cf0a2 100644 Binary files a/bin/abacus/Simulator$Player.class and b/bin/abacus/Simulator$Player.class differ diff --git a/bin/abacus/Simulator.class b/bin/abacus/Simulator.class index 513cadc..49ffb3b 100644 Binary files a/bin/abacus/Simulator.class and b/bin/abacus/Simulator.class differ diff --git a/bin/abacus/TestFileData.class b/bin/abacus/TestFileData.class new file mode 100644 index 0000000..b5caa7a Binary files /dev/null and b/bin/abacus/TestFileData.class differ diff --git a/bin/abacus/ZoomablePanel$MoveThread.class b/bin/abacus/ZoomablePanel$MoveThread.class index c7f51ec..205059f 100644 Binary files a/bin/abacus/ZoomablePanel$MoveThread.class and b/bin/abacus/ZoomablePanel$MoveThread.class differ diff --git a/bin/abacus/ZoomablePanel$PaintThread.class b/bin/abacus/ZoomablePanel$PaintThread.class index 8f1b5c4..6d0d2da 100644 Binary files a/bin/abacus/ZoomablePanel$PaintThread.class and b/bin/abacus/ZoomablePanel$PaintThread.class differ diff --git a/bin/abacus/ZoomablePanel.class b/bin/abacus/ZoomablePanel.class index 115e5f0..5483993 100644 Binary files a/bin/abacus/ZoomablePanel.class and b/bin/abacus/ZoomablePanel.class differ diff --git a/importinputsreadme.pdf b/importinputsreadme.pdf new file mode 100644 index 0000000..7793f22 Binary files /dev/null and b/importinputsreadme.pdf differ diff --git a/source/abacus/EditNodeDialog.java b/source/abacus/EditNodeDialog.java index 5093318..00a8751 100644 --- a/source/abacus/EditNodeDialog.java +++ b/source/abacus/EditNodeDialog.java @@ -30,6 +30,11 @@ public class EditNodeDialog extends JDialog implements ActionListener, ItemListe private boolean sInitial; // initial state private boolean sAddition; // Addition state? private int register; + + public void itemStateChanged(ItemEvent e) + { + return; + } public EditNodeDialog(Frame parent) { diff --git a/source/abacus/InputsFileData.java b/source/abacus/InputsFileData.java new file mode 100644 index 0000000..d706f3d --- /dev/null +++ b/source/abacus/InputsFileData.java @@ -0,0 +1,173 @@ +package abacus; + +import java.awt.FileDialog; +import java.awt.Frame; +import java.beans.XMLDecoder; +import java.beans.XMLEncoder; +/*import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.BufferedReader; +import java.io.FileReader;*/ +import java.math.BigInteger; +import java.io.*; +import java.util.ArrayList; +import java.util.TreeMap; + +import javax.swing.JOptionPane; + +// a bean used for saving and loading the data +public class InputsFileData +{ + public ArrayList comments = new ArrayList(); + public ArrayList nodes = new ArrayList(); + public TreeMap regs = new TreeMap(); + public int regInputNum = 0; + public ArrayList otherRegs = new ArrayList(); + final static FileDialog fileChooser = new FileDialog(new Frame()); + private RegisterEditor target; + private Simulator runner; + + public InputsFileData(RegisterEditor given, Simulator sim) {target = given; runner = sim;} + + public ArrayList getNodes() + { + return nodes; + } + + public void setNodes(ArrayList nodes) + { + this.nodes = nodes; + } + + public ArrayList getComments() + { + return comments; + } + + public void setComments(ArrayList comments) + { + this.comments = comments; + } + + public TreeMap getRegs() + { + return regs; + } + + public void setRegs(TreeMap regs) + { + this.regs = regs; + } + + public ArrayList getOtherRegs() + { + return otherRegs; + } + + public void setOtherRegs(ArrayList otherRegs) + { + this.otherRegs = otherRegs; + } + + public int getRegInput() + { + return this.regInputNum; + } + + public void setRegInput(int n) + { + this.regInputNum = n; + } + + public void save() + { + fileChooser.setMode(FileDialog.SAVE); + fileChooser.setTitle("Save As..."); + fileChooser.setVisible(true); + String filename = fileChooser.getFile(); + + if (filename != null) // user didn't pressed cancel + { + filename = fileChooser.getDirectory() + filename; + + if (!filename.toLowerCase().endsWith(".yam")) + filename = filename + ".yam"; + + try + { + XMLEncoder e = new XMLEncoder( + new BufferedOutputStream( + new FileOutputStream(filename))); + e.writeObject(this); + //e.writeObject(nodes); + e.close(); + } + catch (Exception e) + { + JOptionPane.showMessageDialog(null,"Error saving: " + e); + } + } + } + + public boolean load() + { + fileChooser.setMode(FileDialog.LOAD); + fileChooser.setTitle("Select Puzzle"); + fileChooser.setVisible(true); + String filename = fileChooser.getFile(); + if (filename != null) + { + filename = fileChooser.getDirectory() + filename; + } + try + { + BufferedReader br = new BufferedReader(new FileReader(filename)); + String input; + try + { + input = br.readLine(); + for (int i = 0; i<10; i++) + { + target.setRegisterInput(i); + for(int j=1;j<10000;j++) + { + target.setRegisterContents(j, BigInteger.ZERO); + } + } + while (input != null) + { + String[] split = input.split(" "); + int num = Integer.parseInt(split[0]); + int inputnum = num - 1; + int register = Integer.parseInt(split[1]); + BigInteger value = BigInteger.valueOf(Integer.parseInt(split[2])); + target.setRegisterInput(inputnum); + target.setRegisterContents(register, value); + + try + { + input = br.readLine(); + } + catch (IOException e) + { + + } + } + target.setRegisterInput(0); + runner.setStepNumber(0); + } + catch (IOException e) + { + + } + + } + catch (FileNotFoundException e) + { + + } + return false; + } +} \ No newline at end of file diff --git a/source/abacus/NodeEditor.java b/source/abacus/NodeEditor.java index 9d53ccd..0b7b2ce 100644 --- a/source/abacus/NodeEditor.java +++ b/source/abacus/NodeEditor.java @@ -43,6 +43,7 @@ public class NodeEditor extends JFrame implements ActionListener JMenuItem loadMachine = new JMenuItem("Load Machine"); JMenuItem importMachine = new JMenuItem("Import Machine"); JMenuItem importRegisters = new JMenuItem("Import Registers"); + JMenuItem importInputs = new JMenuItem("Import Inputs"); JMenuItem export_xml = new JMenuItem("Export OwenTMS XML"); JMenuItem export_tm = new JMenuItem("Export OwenTMS TM"); JMenuItem close = new JMenuItem("Close All"); @@ -52,7 +53,7 @@ public class NodeEditor extends JFrame implements ActionListener JMenuItem help = new JMenuItem("Help"); - JMenuItem[] items = { newMachine, saveMachine, loadMachine, importMachine, importRegisters, export_xml, export_tm, close, help}; + JMenuItem[] items = { newMachine, saveMachine, loadMachine, importMachine, importRegisters, importInputs, export_xml, export_tm, close, help}; // buttons static Image imageAdd = makeRedTransparent(new ImageIcon("images/imageAdd.GIF").getImage()); @@ -109,6 +110,7 @@ public NodeEditor() file.add(loadMachine); file.add(importMachine); file.add(importRegisters); + file.add(importInputs); file.addSeparator(); file.add(export_xml); file.add(export_tm); @@ -455,7 +457,7 @@ else if (e.getSource() == loadMachine) ne.re.regInputNum = fd.getRegInput(); ne.re.otherRegs = fd.getOtherRegs(); ne.macPanel.comments = fd.getComments(); - ne.simulator.setInputNumberText(); + //ne.simulator.setInputNumberText(); ne.repaint(); ne.re.repaint(); } @@ -674,11 +676,16 @@ else if (e.getSource() == importRegisters) re.regInputNum = fd.getRegInput(); re.otherRegs = fd.getOtherRegs(); re.setRegisterInput(oldInput); - simulator.setInputNumberText(); + //simulator.setInputNumberText(); repaint(); re.repaint(); } } + else if (e.getSource() == importInputs) + { + TestFileData fd = new TestFileData(re, simulator); + fd.load(); + } else if (e.getSource() == help) { JOptionPane.showMessageDialog(null, @@ -780,7 +787,7 @@ else if (regSet.contains(e.getSource())) { int regNum = regSet.indexOf(e.getSource()); boolean RIrv = re.setRegisterInput(regNum); - simulator.setInputNumberText(); + //simulator.setInputNumberText(); } } } diff --git a/source/abacus/Simulator.java b/source/abacus/Simulator.java index a386eba..b9d3232 100644 --- a/source/abacus/Simulator.java +++ b/source/abacus/Simulator.java @@ -118,6 +118,11 @@ public Simulator(NodeEditor ne, RegisterEditor re) // if (re != null) // inputNumber.setText("Input: "+(re.regInputNum+1)); // } + + public void setStepNumber(int steps) + { + numSteps.setText("Number of Steps: " + steps); + } public boolean runningMultiple() { @@ -194,6 +199,9 @@ else if (e.getSource() == playMultipleButton) getInputs.add(inputNum); inputNums.add(inputNum); } + JCheckBox allinputs = new JCheckBox("All Inputs"); + getInputs.add(allinputs); + inputNums.add(allinputs); int result = JOptionPane.showConfirmDialog(null, getInputs, "Which inputs?", JOptionPane.OK_CANCEL_OPTION); boolean runOnInputs = false; @@ -201,6 +209,15 @@ else if (e.getSource() == playMultipleButton) startIntInputNums = new ArrayList(); while (result == JOptionPane.OK_OPTION && !runOnInputs) { + if (inputNums.get(10).isSelected()) + { + for (int i = 0; i