Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating AMS to 3.7 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed ams.jar
Binary file not shown.
Binary file modified bin/TuringMachine/OTMSExporter$INode.class
Binary file not shown.
Binary file modified bin/TuringMachine/OTMSExporter.class
Binary file not shown.
Binary file modified bin/TuringMachine/State.class
Binary file not shown.
Binary file modified bin/TuringMachine/Transition.class
Binary file not shown.
Binary file modified bin/abacus/BigIntegerBean.class
Binary file not shown.
Binary file modified bin/abacus/Comment.class
Binary file not shown.
Binary file modified bin/abacus/EditNodeDialog.class
Binary file not shown.
Binary file modified bin/abacus/FileData.class
Binary file not shown.
Binary file added bin/abacus/InputsFileData.class
Binary file not shown.
Binary file modified bin/abacus/MachinePanel$MouseAction.class
Binary file not shown.
Binary file modified bin/abacus/MachinePanel.class
Binary file not shown.
Binary file modified bin/abacus/Main.class
Binary file not shown.
Binary file modified bin/abacus/Node.class
Binary file not shown.
Binary file modified bin/abacus/NodeEditor$1.class
Binary file not shown.
Binary file modified bin/abacus/NodeEditor.class
Binary file not shown.
Binary file modified bin/abacus/RegisterEditor$RegisterPanel$RegTimer.class
Binary file not shown.
Binary file modified bin/abacus/RegisterEditor$RegisterPanel.class
Binary file not shown.
Binary file modified bin/abacus/RegisterEditor.class
Binary file not shown.
Binary file modified bin/abacus/Simulator$Player.class
Binary file not shown.
Binary file modified bin/abacus/Simulator.class
Binary file not shown.
Binary file added bin/abacus/TestFileData.class
Binary file not shown.
Binary file modified bin/abacus/ZoomablePanel$MoveThread.class
Binary file not shown.
Binary file modified bin/abacus/ZoomablePanel$PaintThread.class
Binary file not shown.
Binary file modified bin/abacus/ZoomablePanel.class
Binary file not shown.
Binary file added importinputsreadme.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions source/abacus/EditNodeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
173 changes: 173 additions & 0 deletions source/abacus/InputsFileData.java
Original file line number Diff line number Diff line change
@@ -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<TreeMap> otherRegs = new ArrayList<TreeMap>();
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<TreeMap> getOtherRegs()
{
return otherRegs;
}

public void setOtherRegs(ArrayList<TreeMap> 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;
}
}
15 changes: 11 additions & 4 deletions source/abacus/NodeEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand 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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions source/abacus/Simulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -194,13 +199,25 @@ 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;
intInputNums = new ArrayList<Integer>();
startIntInputNums = new ArrayList<Integer>();
while (result == JOptionPane.OK_OPTION && !runOnInputs)
{
if (inputNums.get(10).isSelected())
{
for (int i = 0; i<ne.getNumRegSets(); i++)
{
intInputNums.add(i);
runOnInputs = true;
}
break;
}
for (int i = 0; i < ne.getNumRegSets(); i++)
{
if (inputNums.get(i).isSelected())
Expand Down