From 1c5e38fe69ac8a6decbdd8abe93112f4e3369315 Mon Sep 17 00:00:00 2001 From: Joshua Rahm Date: Fri, 30 Jan 2015 17:11:48 -0700 Subject: added source --- src/AbstractGraph.java | 114 +++ src/ActionList.java | 66 ++ src/AlertBox.java | 41 + src/AnswerPanel.java | 61 ++ src/AppendingThread.java | 38 + src/BaseComboBox.java | 15 + src/BooleanLogic.java | 79 ++ src/CalcConst.java | 9 + src/Calculator.java | 314 ++++++ src/CalculatorGUI.java | 1024 ++++++++++++++++++++ src/ComplicationAlert.java | 57 ++ src/ControlPanel.java | 349 +++++++ src/CoordinateSystem.java | 35 + src/Dynamic3DGraph.java | 181 ++++ src/DynamicGraphBuilder.java | 14 + src/Elucidean2DPointMaker.java | 18 + src/ElucideanDynamicGraphBuilder.java | 35 + src/ElucideanGraphIterator.java | 30 + src/EquasiveGraph3D.java | 225 +++++ src/EquationChangeListener.java | 9 + src/EquationDialog.java | 142 +++ src/Euclidean2DPointMaker.java | 18 + src/EuclideanDynamicGraphBuilder.java | 35 + src/EuclideanGraphIterator.java | 30 + src/ExtendablePointInvoker.java | 38 + src/ExtendedPointInvoker.java | 161 +++ src/FileChanger.java | 261 +++++ src/Flagger.java | 31 + src/FormatFrame.java | 92 ++ src/GUIComponents/GridPanel.java | 36 + src/GUIComponents/JOptionPanel.java | 60 ++ src/GUIComponents/MouseClickListener.java | 44 + src/GUIComponents/MouseOneClickListener.java | 34 + src/GUIComponents/OptionPanel.java | 58 ++ src/GUIComponents/ProgressFrame.java | 44 + src/GUIComponents/PushablePanel.java | 62 ++ src/GUIComponents/ThreadRunner.java | 29 + src/GUIComponents/ToggleButtonGroup.java | 51 + src/GUIComponents/WrapperPanel.java | 22 + src/Graph2D.java | 356 +++++++ src/Graph2DOptionFrame.java | 68 ++ src/Graph3D.java | 165 ++++ src/GraphBoxListener.java | 9 + src/GraphEventHandler.java | 66 ++ src/GraphFrame.java | 1020 +++++++++++++++++++ src/GraphIterator.java | 27 + src/GraphLineDrawEvent.java | 28 + src/GraphThread.java | 24 + src/GraphTranslator.java | 11 + src/GraphTypeHolder.java | 109 +++ src/GraphTypeStateChangedListener.java | 9 + src/HeightMapGraph.java | 66 ++ src/HeightMapReader.java | 51 + src/ImageFrame.java | 89 ++ src/JTurtle.jar | Bin 0 -> 99468 bytes src/Keyboard.java | 187 ++++ src/M3DGraphWindow.java | 264 +++++ src/MButtonGroup.java | 15 + src/META-INF/MANIFEST.MF | 6 + src/Main.java | 28 + src/Menu.java | 32 + src/MethodClass.java | 27 + src/ModulusThreads.java | 33 + src/MoveListener.java | 11 + src/NonZeroSpinnerModel.java | 43 + src/Object3D.java | 83 ++ src/Point2D.java | 63 ++ src/Point2DMaker.java | 34 + src/Point3D.java | 116 +++ src/PointGroup.java | 152 +++ src/PointHashMap.java | 89 ++ src/PointInvoker.java | 11 + src/PointMaker.java | 28 + src/PointModel.java | 91 ++ src/Polar2DPointMaker.java | 18 + src/Polar3DGraph.java | 111 +++ src/PolarGraphIterator.java | 26 + src/PressAnyKey.java | 19 + src/Prompt.java | 72 ++ src/RangeOptionFrame.java | 272 ++++++ src/RectangleDrawer.java | 71 ++ src/RegressionDialog.java | 96 ++ src/ReverseElucidean2DPointMaker.java | 18 + src/ReverseEuclidean2DPointMaker.java | 18 + src/RotatingThread.java | 46 + src/RunnablePrompt.java | 34 + src/ScriptReader.java | 308 ++++++ src/SilentThread.java | 21 + src/StandardIO/Approvable.java | 15 + src/StandardIO/FileIO/FileDecomposer.java | 60 ++ src/StandardIO/FileOutputArray.java | 49 + src/StandardIO/MFileFilter.java | 40 + src/StandardIO/MFileWriter.java | 26 + src/StandardIO/ModulusFileChooser.java | 49 + src/StandardIO/ModulusOutputStream.java | 168 ++++ src/StandardIO/PropertiesReader.java | 60 ++ src/StandardIO/SaveFileWriter.java | 20 + src/StatPlot.java | 76 ++ src/StatPlotCreationDialog.java | 257 +++++ src/StatPlotDialog.java | 163 ++++ src/SwingPrompter.java | 27 + src/Table.java | 189 ++++ src/TableFrame.java | 115 +++ src/TableSetter.java | 74 ++ src/TernarySolver.java | 47 + src/TrackingPanel.java | 59 ++ src/WindowRange.java | 86 ++ src/WindowRangeDialog.java | 159 +++ src/WirePlotter.java | 11 + src/XAxis.java | 86 ++ src/XAxisChar.java | 111 +++ src/XEqualsDynamicGraphBuilder.java | 37 + src/XEqualsGraphIterator.java | 30 + src/YAxis.java | 86 ++ src/YAxisChar.java | 79 ++ src/ZAxis.java | 83 ++ src/ZAxisChar.java | 97 ++ src/ZGraphEquationChooser.java | 106 ++ src/equations.jar | Bin 0 -> 11542 bytes src/ops.jar | Bin 0 -> 1738 bytes .../jdt/internal/jarinjarloader/JarRsrcLoader.java | 104 ++ .../internal/jarinjarloader/RsrcURLConnection.java | 36 + .../jarinjarloader/RsrcURLStreamHandler.java | 50 + .../RsrcURLStreamHandlerFactory.java | 34 + src/utilities/BaseConverter.java | 72 ++ src/utilities/DecimalFormatter.java | 109 +++ src/utilities/EFormatter.java | 26 + src/utilities/NoFormatter.java | 17 + src/utilities/PublicFileClassLoader.java | 44 + src/utilities/ScientificFormatter.java | 26 + 130 files changed, 11486 insertions(+) create mode 100644 src/AbstractGraph.java create mode 100644 src/ActionList.java create mode 100644 src/AlertBox.java create mode 100644 src/AnswerPanel.java create mode 100644 src/AppendingThread.java create mode 100644 src/BaseComboBox.java create mode 100644 src/BooleanLogic.java create mode 100644 src/CalcConst.java create mode 100644 src/Calculator.java create mode 100644 src/CalculatorGUI.java create mode 100644 src/ComplicationAlert.java create mode 100644 src/ControlPanel.java create mode 100644 src/CoordinateSystem.java create mode 100644 src/Dynamic3DGraph.java create mode 100644 src/DynamicGraphBuilder.java create mode 100644 src/Elucidean2DPointMaker.java create mode 100644 src/ElucideanDynamicGraphBuilder.java create mode 100644 src/ElucideanGraphIterator.java create mode 100644 src/EquasiveGraph3D.java create mode 100644 src/EquationChangeListener.java create mode 100644 src/EquationDialog.java create mode 100644 src/Euclidean2DPointMaker.java create mode 100644 src/EuclideanDynamicGraphBuilder.java create mode 100644 src/EuclideanGraphIterator.java create mode 100644 src/ExtendablePointInvoker.java create mode 100644 src/ExtendedPointInvoker.java create mode 100644 src/FileChanger.java create mode 100644 src/Flagger.java create mode 100644 src/FormatFrame.java create mode 100644 src/GUIComponents/GridPanel.java create mode 100644 src/GUIComponents/JOptionPanel.java create mode 100644 src/GUIComponents/MouseClickListener.java create mode 100644 src/GUIComponents/MouseOneClickListener.java create mode 100644 src/GUIComponents/OptionPanel.java create mode 100644 src/GUIComponents/ProgressFrame.java create mode 100644 src/GUIComponents/PushablePanel.java create mode 100644 src/GUIComponents/ThreadRunner.java create mode 100644 src/GUIComponents/ToggleButtonGroup.java create mode 100644 src/GUIComponents/WrapperPanel.java create mode 100644 src/Graph2D.java create mode 100644 src/Graph2DOptionFrame.java create mode 100644 src/Graph3D.java create mode 100644 src/GraphBoxListener.java create mode 100644 src/GraphEventHandler.java create mode 100644 src/GraphFrame.java create mode 100644 src/GraphIterator.java create mode 100644 src/GraphLineDrawEvent.java create mode 100644 src/GraphThread.java create mode 100644 src/GraphTranslator.java create mode 100644 src/GraphTypeHolder.java create mode 100644 src/GraphTypeStateChangedListener.java create mode 100644 src/HeightMapGraph.java create mode 100644 src/HeightMapReader.java create mode 100644 src/ImageFrame.java create mode 100644 src/JTurtle.jar create mode 100644 src/Keyboard.java create mode 100644 src/M3DGraphWindow.java create mode 100644 src/MButtonGroup.java create mode 100644 src/META-INF/MANIFEST.MF create mode 100644 src/Main.java create mode 100644 src/Menu.java create mode 100644 src/MethodClass.java create mode 100644 src/ModulusThreads.java create mode 100644 src/MoveListener.java create mode 100644 src/NonZeroSpinnerModel.java create mode 100644 src/Object3D.java create mode 100644 src/Point2D.java create mode 100644 src/Point2DMaker.java create mode 100644 src/Point3D.java create mode 100644 src/PointGroup.java create mode 100644 src/PointHashMap.java create mode 100644 src/PointInvoker.java create mode 100644 src/PointMaker.java create mode 100644 src/PointModel.java create mode 100644 src/Polar2DPointMaker.java create mode 100644 src/Polar3DGraph.java create mode 100644 src/PolarGraphIterator.java create mode 100644 src/PressAnyKey.java create mode 100644 src/Prompt.java create mode 100644 src/RangeOptionFrame.java create mode 100644 src/RectangleDrawer.java create mode 100644 src/RegressionDialog.java create mode 100644 src/ReverseElucidean2DPointMaker.java create mode 100644 src/ReverseEuclidean2DPointMaker.java create mode 100644 src/RotatingThread.java create mode 100644 src/RunnablePrompt.java create mode 100644 src/ScriptReader.java create mode 100644 src/SilentThread.java create mode 100644 src/StandardIO/Approvable.java create mode 100644 src/StandardIO/FileIO/FileDecomposer.java create mode 100644 src/StandardIO/FileOutputArray.java create mode 100644 src/StandardIO/MFileFilter.java create mode 100644 src/StandardIO/MFileWriter.java create mode 100644 src/StandardIO/ModulusFileChooser.java create mode 100644 src/StandardIO/ModulusOutputStream.java create mode 100644 src/StandardIO/PropertiesReader.java create mode 100644 src/StandardIO/SaveFileWriter.java create mode 100644 src/StatPlot.java create mode 100644 src/StatPlotCreationDialog.java create mode 100644 src/StatPlotDialog.java create mode 100644 src/SwingPrompter.java create mode 100644 src/Table.java create mode 100644 src/TableFrame.java create mode 100644 src/TableSetter.java create mode 100644 src/TernarySolver.java create mode 100644 src/TrackingPanel.java create mode 100644 src/WindowRange.java create mode 100644 src/WindowRangeDialog.java create mode 100644 src/WirePlotter.java create mode 100644 src/XAxis.java create mode 100644 src/XAxisChar.java create mode 100644 src/XEqualsDynamicGraphBuilder.java create mode 100644 src/XEqualsGraphIterator.java create mode 100644 src/YAxis.java create mode 100644 src/YAxisChar.java create mode 100644 src/ZAxis.java create mode 100644 src/ZAxisChar.java create mode 100644 src/ZGraphEquationChooser.java create mode 100644 src/equations.jar create mode 100644 src/ops.jar create mode 100644 src/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java create mode 100644 src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLConnection.java create mode 100644 src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandler.java create mode 100644 src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandlerFactory.java create mode 100644 src/utilities/BaseConverter.java create mode 100644 src/utilities/DecimalFormatter.java create mode 100644 src/utilities/EFormatter.java create mode 100644 src/utilities/NoFormatter.java create mode 100644 src/utilities/PublicFileClassLoader.java create mode 100644 src/utilities/ScientificFormatter.java diff --git a/src/AbstractGraph.java b/src/AbstractGraph.java new file mode 100644 index 0000000..cb36558 --- /dev/null +++ b/src/AbstractGraph.java @@ -0,0 +1,114 @@ +/* */ import java.awt.Color; +/* */ import java.util.ArrayList; +/* */ import java.util.List; +/* */ +/* */ public abstract class AbstractGraph extends GraphWorld +/* */ { +/* */ private static final long serialVersionUID = -4806217320367527179L; +/* 15 */ public static final Color[] colors = { +/* 16 */ Color.red, +/* 17 */ Color.blue, +/* 18 */ Color.green, +/* 19 */ Color.yellow.darker(), +/* 20 */ Color.magenta, +/* 21 */ Color.pink, +/* 22 */ Color.orange, +/* 23 */ Color.black, +/* 24 */ new Color(100, 100, 0), +/* 25 */ Color.gray }; +/* */ private ArrayList[] points; +/* */ private static ExtendablePointInvoker invoker; +/* */ private double lastY; +/* */ private double lastX; +/* */ private WindowRange winRange; +/* */ private int xskip; +/* */ +/* */ public AbstractGraph(int w, int h) +/* */ { +/* 38 */ super(w, h); +/* 39 */ this.points = new ArrayList[10]; +/* 40 */ for (int i = 0; i < this.points.length; i++) this.points[i] = new ArrayList(); +/* 41 */ this.winRange = new WindowRange(); +/* */ } +/* */ public void setWindowRange(WindowRange winRange) { +/* 44 */ this.winRange = winRange; +/* 45 */ repaint(); +/* */ } +/* */ public WindowRange getWindowRange() { +/* 48 */ return this.winRange; +/* */ } +/* */ public void addPoint(Point2D point, int index) { +/* 51 */ this.points[index].add(point); +/* */ } +/* */ public void pushPoint(Point2D point, int index) { +/* 54 */ this.points[index].add(0, point); +/* */ } +/* */ public void removePoint(Point2D point, int index) { +/* 57 */ this.points[index].remove(point); +/* */ } +/* */ +/* */ public ArrayList[] getPoints() { +/* 61 */ return this.points; +/* */ } +/* */ public String[] getEquations() { +/* 64 */ return GraphTypeHolder.getInstance().getEquations(); +/* */ } +/* */ public void setEquations(String[] equations) { +/* 67 */ GraphTypeHolder.getInstance().setEquations(equations); +/* 68 */ clearEvents(); +/* 69 */ repaint(); +/* */ } +/* */ +/* */ protected void setLastY(double last) { +/* 73 */ this.lastY = last; +/* */ } +/* */ protected void setLastX(double last) { +/* 76 */ this.lastX = last; +/* */ } +/* */ public double getLastY() { +/* 79 */ return this.lastY; +/* */ } +/* */ public double getLastX() { +/* 82 */ return this.lastX; +/* */ } +/* */ public ExtendablePointInvoker getInvoker() { +/* 85 */ return invoker; +/* */ } +/* */ public void setInvoker(ExtendablePointInvoker invoker) { +/* 88 */ invoker = invoker; +/* 89 */ repaint(); +/* */ } +/* */ public int getXSkip() { +/* 92 */ return this.xskip; +/* */ } +/* */ public void setXSkip(int xSkip) { +/* 95 */ this.xskip = xSkip; +/* 96 */ repaint(); +/* */ } +/* */ protected void wipe() { +/* 99 */ this.points = new ArrayList[10]; +/* 100 */ for (int i = 0; i < this.points.length; i++) { +/* 101 */ this.points[i] = new ArrayList(); +/* */ } +/* 103 */ repaint(); +/* */ } +/* */ public void appendEquation(String equation) { +/* 106 */ String[] temp = GraphTypeHolder.getInstance().getEquations(); +/* 107 */ String[] nother = new String[temp.length + 1]; +/* 108 */ for (int i = 0; i < temp.length; i++) nother[i] = temp[i]; +/* 109 */ nother[(nother.length - 1)] = equation; +/* 110 */ GraphTypeHolder.getInstance().setEquations(nother); } +/* */ public abstract void makePoints(); +/* */ +/* */ public abstract void remakePoints(); +/* */ +/* 115 */ protected void clearEvents() { int max = super.getEvents().size(); +/* 116 */ for (int i = 0; i < max; i++) +/* 117 */ super.removeEvent(0); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: AbstractGraph + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/ActionList.java b/src/ActionList.java new file mode 100644 index 0000000..193b8a0 --- /dev/null +++ b/src/ActionList.java @@ -0,0 +1,66 @@ +/* */ import java.awt.Color; +/* */ import java.awt.Font; +/* */ import java.awt.GridLayout; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import java.util.ArrayList; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JScrollPane; +/* */ import javax.swing.JToggleButton; +/* */ +/* */ public class ActionList extends JPanel +/* */ implements ActionListener +/* */ { +/* */ private JToggleButton[] buttons; +/* */ private JScrollPane pane; +/* */ private ArrayList listeners; +/* */ private JPanel mainPanel; +/* */ +/* */ public ActionList(Object[] args) +/* */ { +/* 22 */ this.listeners = new ArrayList(); +/* 23 */ this.mainPanel = new JPanel(new GridLayout(args.length, 1, 0, 0)); +/* 24 */ this.buttons = new JToggleButton[args.length]; +/* 25 */ for (int i = 0; i < args.length; i++) +/* */ { +/* 27 */ this.buttons[i] = new JToggleButton(args[i].toString()); +/* 28 */ this.buttons[i].setBackground(Color.white); +/* 29 */ this.buttons[i].setFont(new Font("Courier New", 0, 10)); +/* 30 */ this.buttons[i].setSize(70, 20); +/* 31 */ this.mainPanel.add(this.buttons[i]); +/* 32 */ this.buttons[i].addActionListener(this); +/* */ } +/* 34 */ add(this.mainPanel); +/* 35 */ this.pane = new JScrollPane(this); +/* */ } +/* */ public ActionList(Object[] args, ActionListener listen) { +/* 38 */ this(args); +/* 39 */ addActionListener(listen); +/* */ } +/* */ public JToggleButton getSelected() { +/* 42 */ for (int i = 0; i < this.buttons.length; i++) { +/* 43 */ if (this.buttons[i].isSelected()) return this.buttons[i]; +/* */ } +/* 45 */ return null; +/* */ } +/* */ public int getSelectedIndex() { +/* 48 */ for (int i = 0; i < this.buttons.length; i++) { +/* 49 */ if (this.buttons[i].isSelected()) return i; +/* */ } +/* 51 */ return -1; +/* */ } +/* 53 */ public void addActionListener(ActionListener x) { this.listeners.add(x); } +/* 54 */ public JToggleButton get(int index) { return this.buttons[index]; } +/* */ public void actionPerformed(ActionEvent e) { +/* 56 */ for (int i = 0; i < this.buttons.length; i++) { +/* 57 */ if ((this.buttons[i].isSelected()) && (e.getSource() != this.buttons[i])) this.buttons[i].setSelected(false); +/* */ } +/* 59 */ e.setSource(this); +/* 60 */ for (int i = 0; i < this.listeners.size(); i++) ((ActionListener)this.listeners.get(i)).actionPerformed(e); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: ActionList + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/AlertBox.java b/src/AlertBox.java new file mode 100644 index 0000000..14f20fc --- /dev/null +++ b/src/AlertBox.java @@ -0,0 +1,41 @@ +/* */ import java.awt.BorderLayout; +/* */ import java.awt.Toolkit; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import javax.swing.JButton; +/* */ import javax.swing.JFrame; +/* */ import javax.swing.JLabel; +/* */ import javax.swing.JPanel; +/* */ +/* */ public class AlertBox extends JFrame +/* */ implements ActionListener +/* */ { +/* */ private JPanel bottom; +/* */ private JPanel top; +/* */ private JButton ok; +/* */ +/* */ public AlertBox(String message, String title) +/* */ { +/* 19 */ setTitle(title); +/* 20 */ setLayout(new BorderLayout()); +/* 21 */ this.bottom = new JPanel(); +/* 22 */ this.top = new JPanel(); +/* 23 */ add(this.top, "North"); +/* 24 */ add(this.bottom, "South"); +/* 25 */ this.top.add(new JLabel(message)); +/* 26 */ this.ok = new JButton("OK"); +/* 27 */ this.bottom.add(this.ok); +/* 28 */ this.ok.addActionListener(this); +/* 29 */ setVisible(true); +/* 30 */ setIconImage(Toolkit.getDefaultToolkit().getImage("modulus_symbol.png")); +/* 31 */ pack(); +/* */ } +/* 33 */ public void actionPerformed(ActionEvent e) { setVisible(false); } +/* 34 */ public static void throwError(String alert) { new AlertBox(alert, "Error"); } +/* */ +/* */ } + +/* Location: Modulus.jar + * Qualified Name: AlertBox + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/AnswerPanel.java b/src/AnswerPanel.java new file mode 100644 index 0000000..be4eb8c --- /dev/null +++ b/src/AnswerPanel.java @@ -0,0 +1,61 @@ +/* */ import java.awt.FlowLayout; +/* */ import java.awt.GridLayout; +/* */ import java.text.DecimalFormat; +/* */ import javax.swing.JLabel; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JTextField; +/* */ +/* */ public class AnswerPanel extends JPanel +/* */ implements GraphTypeStateChangedListener, EquationChangeListener +/* */ { +/* */ private JTextField[] fields; +/* */ private JPanel[] panels; +/* */ private JLabel[] labels; +/* */ private String[] equations; +/* */ private DecimalFormat format; +/* */ private Graph2D graph; +/* */ +/* */ public AnswerPanel(String[] equations, Graph2D graph) +/* */ { +/* 19 */ this.equations = equations; +/* */ +/* 21 */ this.fields = new JTextField[equations.length]; +/* 22 */ this.panels = new JPanel[equations.length]; +/* 23 */ this.labels = new JLabel[equations.length]; +/* 24 */ setLayout(new GridLayout(5, 1)); +/* 25 */ for (int i = 0; i < this.fields.length; i++) { +/* 26 */ this.fields[i] = new JTextField("", 5); +/* 27 */ this.fields[i].setEditable(false); +/* 28 */ this.labels[i] = new JLabel("y" + i + "(" + GraphTypeHolder.getInstance().getGraphPointMaker().getIndependentVariable() + ") ="); +/* 29 */ this.panels[i] = new JPanel(new FlowLayout()); +/* 30 */ this.panels[i].add(this.labels[i]); +/* 31 */ this.panels[i].add(this.fields[i]); +/* 32 */ add(this.panels[i]); +/* */ } +/* */ +/* 36 */ GraphTypeHolder.getInstance().addGraphTypeStateChangedListener(this); +/* 37 */ GraphTypeHolder.getInstance().fireGraphTypeStateChanged(); +/* 38 */ this.format = new DecimalFormat(".00"); +/* 39 */ this.graph = graph; +/* */ } +/* */ public void graphTypeChanged(Point2DMaker maker) { +/* 42 */ for (int i = 0; i < this.labels.length; i++) +/* 43 */ this.labels[i].setText("" + maker.getDependentVariable() + "" + i + "(" + GraphTypeHolder.getInstance().getGraphPointMaker().getIndependentVariable() + ") ="); +/* */ } +/* */ +/* */ public void setEquations(String[] equations) { +/* 47 */ this.equations = equations; +/* */ } +/* */ public void load(double x, double y, double t) { +/* 50 */ Point2DMaker type = GraphTypeHolder.getInstance().getGraphPointMaker(); +/* 51 */ double ivar = type.getIndependentVariable() == 'y' ? y : type.getIndependentVariable() == 't' ? t : type.getIndependentVariable() == 'x' ? x : 0.0D; +/* 52 */ for (int i = 0; (i < this.equations.length) && (i < this.fields.length); i++) +/* 53 */ if ((this.equations[i] != null) && (this.equations[i].length() > 0)) +/* 54 */ this.fields[i].setText(this.format.format(this.graph.equation(ivar, this.equations[i]))); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: AnswerPanel + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/AppendingThread.java b/src/AppendingThread.java new file mode 100644 index 0000000..90fd434 --- /dev/null +++ b/src/AppendingThread.java @@ -0,0 +1,38 @@ +/* */ import java.io.PrintStream; +/* */ import java.util.ArrayList; +/* */ import utilities.DecimalFormatter; +/* */ +/* */ public class AppendingThread extends Thread +/* */ { +/* 12 */ private static int count = 1; +/* */ private int index; +/* */ private String str; +/* */ private ArrayList ans; +/* */ private DecimalFormatter f; +/* */ +/* */ public AppendingThread(String toSolve, int index, ArrayList ans, DecimalFormatter f) +/* */ { +/* 18 */ super(Thread.currentThread().getThreadGroup(), "AppendingThread - " + count); +/* 19 */ count += 1; +/* 20 */ this.str = toSolve; +/* 21 */ this.ans = ans; +/* 22 */ this.index = index; +/* 23 */ this.f = f; +/* */ } +/* */ public void run() { +/* 26 */ String temp = ""; +/* */ try { +/* 28 */ temp = ControlPanel.figure(this.str); +/* */ } catch (Exception e) { +/* 30 */ System.out.println(e.getMessage()); +/* 31 */ }CalculatorGUI.silentPrint(this.str + "->"); +/* 32 */ System.out.println(this.f.format(temp)); +/* 33 */ CalculatorGUI.silentPrint("\n"); +/* 34 */ this.ans.add(this.index + 1, this.f.format(temp)); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: AppendingThread + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/BaseComboBox.java b/src/BaseComboBox.java new file mode 100644 index 0000000..cc8797c --- /dev/null +++ b/src/BaseComboBox.java @@ -0,0 +1,15 @@ +/* */ import javax.swing.JComboBox; +/* */ +/* */ public class BaseComboBox extends JComboBox +/* */ { +/* */ public BaseComboBox(int index) +/* */ { +/* 14 */ super(new String[] { "Unary (1)", "Binary (2)", "Ternary (3)", "Quaternal (4)", "Quintal (5)", "Sextal (6)", "Septernal (7)", "Ocatal (8)", "Nonary (9)", "Decimal (default)", "Unidecimal (11)", "Dozenal (12)", "Tredecimal (13)", "Tetradecimal (14)", "Quindecimal (15)", "Hexadecimal (16)", "Septendecimal (17)", "Octodecimal (18)", "Nonadecimal (19)", "Vigesimal (20)", "Base 21", "Base 22", "Base 23", "Base 24", "Base 25", "Base 26", "Base 27", "Base 28", "Base 29", "Base 30", "Base 31", "Base 32", "Base 33", "Base 34", "Base 35", "Base 36" }); +/* 15 */ setSelectedIndex(index); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: BaseComboBox + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/BooleanLogic.java b/src/BooleanLogic.java new file mode 100644 index 0000000..20d5e33 --- /dev/null +++ b/src/BooleanLogic.java @@ -0,0 +1,79 @@ +/* */ import java.math.BigDecimal; +/* */ import java.util.ArrayList; +/* */ +/* */ public class BooleanLogic +/* */ { +/* */ public static String solve(String eq) +/* */ throws Exception +/* */ { +/* 13 */ eq = eq.replaceAll("\\s", ""); +/* 14 */ while (eq.contains("(")) { +/* 15 */ String part = eq.substring(eq.lastIndexOf("(", eq.indexOf(")")) + 1, eq.indexOf(")")); +/* 16 */ if (TernarySolver.containsTernary(part)) +/* 17 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + TernarySolver.solve(part) + eq.substring(eq.indexOf(")") + 1); +/* 18 */ else if (containsBoolean(part)) +/* 19 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + solve(part) + eq.substring(eq.indexOf(")") + 1); +/* */ else +/* 21 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + Calculator.solve(part) + eq.substring(eq.indexOf(")") + 1); +/* */ } +/* 23 */ String[] parts = eq.split("\\s*and\\s*|\\s*xor\\s*|\\s*or\\s*"); +/* 24 */ String[] logic = splitLogic(eq); +/* 25 */ boolean[] answers = new boolean[parts.length]; +/* 26 */ for (int i = 0; i < parts.length; i++) { +/* 27 */ answers[i] = parseSingleBoolean(parts[i]); +/* */ } +/* 29 */ boolean ans = answers[0]; +/* 30 */ for (int i = 0; i < logic.length; i++) { +/* 31 */ if (logic[i].equals("and")) ans &= answers[(i + 1)]; +/* 32 */ else if (logic[i].equals("xor")) ans ^= answers[(i + 1)]; +/* 33 */ else if (logic[i].equals("or")) ans |= answers[(i + 1)]; +/* */ } +/* 35 */ return ans ? 1 : 0; +/* */ } +/* */ public static boolean parseSingleBoolean(String eq) throws Exception { +/* 38 */ eq = eq.trim(); +/* 39 */ String store = ""; +/* 40 */ boolean flag = false; +/* 41 */ while (eq.startsWith("not")) { +/* 42 */ if (eq.equals("not0")) return true; +/* 43 */ if (eq.equals("not1")) return false; +/* 44 */ flag = !flag; +/* 45 */ eq = eq.substring(3); +/* */ } +/* 47 */ if ((eq.equals("1")) || (eq.equals("0")) || (eq.equals("true")) || (eq.equals("false"))) return eq.replaceAll("true", "1").contains("1") ^ flag; +/* 48 */ if ((eq.contains(">=")) || (eq.contains("=>"))) store = ">="; +/* 49 */ else if ((eq.contains("<=")) || (eq.contains("=<"))) store = "<="; +/* 50 */ else if (eq.contains(">")) store = ">"; +/* 51 */ else if (eq.contains("<")) store = "<"; else +/* 52 */ store = "="; +/* 53 */ String[] args = eq.split(">=|=>|<=|=<|<|>|="); +/* 54 */ String hold1 = Calculator.solve(args[0]); +/* 55 */ String hold2 = Calculator.solve(args[1]); +/* 56 */ switch (new BigDecimal(hold1).compareTo(new BigDecimal(hold2))) { case 0: +/* 57 */ return store.contains("=") ^ flag; +/* */ case 1: +/* 58 */ return store.contains(">") ^ flag; } +/* 59 */ return store.contains("<") ^ flag; +/* */ } +/* */ +/* */ public static String[] splitLogic(String eq) +/* */ { +/* 64 */ ArrayList ret = new ArrayList(); +/* 65 */ for (int i = 0; i < eq.length(); i++) { +/* 66 */ if ((eq.startsWith("or", i)) && (eq.charAt(i - 1) != 'x')) ret.add("or"); +/* 67 */ if (eq.startsWith("and", i)) ret.add("and"); +/* 68 */ if (eq.startsWith("xor", i)) ret.add("xor"); +/* */ } +/* 70 */ return Calculator.toStringArray(ret); +/* */ } +/* */ +/* */ public static boolean containsBoolean(String eq) { +/* 74 */ return (eq.contains("and")) || (eq.contains("or")) || (eq.contains("not")) || +/* 74 */ (eq.contains(">")) || (eq.contains("<")) || (eq.contains("=")); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: BooleanLogic + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/CalcConst.java b/src/CalcConst.java new file mode 100644 index 0000000..c04edf6 --- /dev/null +++ b/src/CalcConst.java @@ -0,0 +1,9 @@ +public class CalcConst +{ + public static final String ICON = "modulus_symbol.png"; +} + +/* Location: Modulus.jar + * Qualified Name: CalcConst + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/Calculator.java b/src/Calculator.java new file mode 100644 index 0000000..9086dba --- /dev/null +++ b/src/Calculator.java @@ -0,0 +1,314 @@ +/* */ import java.math.BigDecimal; +/* */ import java.math.BigInteger; +/* */ import java.math.MathContext; +/* */ import java.util.ArrayList; +/* */ import utilities.BaseConverter; +/* */ +/* */ public class Calculator +/* */ { +/* 19 */ private static int base = 10; +/* 20 */ private static boolean radians = false; +/* */ public static final String OPS = "%/*+^e:&\\?£"; +/* 22 */ public static final String[] OPS_ARR = { "%", "/", "*", "+", "^", "e", ":", "&", "\\", "?", "£" }; +/* */ +/* */ public static String solve(String eq) throws Exception { +/* 25 */ eq = expandMult(eq); +/* 26 */ while (eq.contains("(")) { +/* 27 */ String part = eq.substring(eq.lastIndexOf("(", eq.indexOf(")")) + 1, eq.indexOf(")")); +/* 28 */ if (TernarySolver.containsTernary(part)) +/* 29 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + TernarySolver.solve(part) + eq.substring(eq.indexOf(")") + 1); +/* 30 */ else if (BooleanLogic.containsBoolean(part)) +/* 31 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + BooleanLogic.solve(part) + eq.substring(eq.indexOf(")") + 1); +/* */ else +/* 33 */ eq = eq.substring(0, eq.lastIndexOf("(", eq.indexOf(")"))) + solve(part) + eq.substring(eq.indexOf(")") + 1); +/* */ } +/* 35 */ while (eq.contains("|")) { +/* 36 */ String x = solve(eq.substring(eq.lastIndexOf("|", eq.lastIndexOf("|") - 1) + 1, eq.lastIndexOf("|"))); +/* 37 */ if (x.startsWith("-")) x = x.substring(1); +/* 38 */ eq = eq.substring(0, eq.lastIndexOf("|", eq.lastIndexOf("|") - 1)) + x + eq.substring(eq.lastIndexOf("|") + 1); +/* */ } +/* */ +/* 45 */ String hold = "+"; +/* */ +/* 47 */ int errIndex = 0; +/* */ +/* 49 */ eq = eq.replaceAll("\\s", ""); +/* */ +/* 51 */ eq = sudoSubtraction(eq); +/* 52 */ while (errIndex < 65535) +/* */ { +/* 54 */ String[] numbers = splitNums(eq)[0]; +/* 55 */ if (base != 10) replaceBase(numbers); +/* */ +/* 57 */ String[] operators = splitNums(eq)[1]; +/* 58 */ if ((eq.startsWith("-")) || (eq.startsWith("+"))) hold = eq.charAt(0); +/* 59 */ if ((numbers.length == 1) && (operators.length == 0)) { +/* 60 */ singleArgCheck(numbers); +/* 61 */ if (base == 10) return numbers[0]; +/* 62 */ return BaseConverter.convertFromDecimal(Double.parseDouble(numbers[0]), base); +/* */ } +/* */ +/* 77 */ singleArgCheck(numbers); +/* */ +/* 79 */ int indexOfNext = indexOf(operators, new String[] { "^", "e", "£" }); +/* 80 */ if (indexOfNext == -1) indexOfNext = indexOf(operators, new String[] { "*", "/", "%", ":" }); +/* 81 */ if (indexOfNext == -1) indexOfNext = indexOf(operators, new String[] { "+" }); +/* 82 */ if (indexOfNext == -1) indexOfNext = indexOf(operators, new String[] { "&", "\\", "?" }); +/* 83 */ if (indexOfNext == -1) { +/* 84 */ if (base == 10) return eq; +/* 85 */ return BaseConverter.convertFromDecimal(Double.parseDouble(eq), base); +/* */ } +/* */ +/* */ try +/* */ { +/* 90 */ numbers = append(new String[][] { subarray(numbers, 0, indexOfNext), { solvePart(numbers[indexOfNext], operators[indexOfNext], numbers[(indexOfNext + 1)]) }, subarray(numbers, indexOfNext + 2, numbers.length) }); +/* 91 */ operators = append(new String[][] { subarray(operators, 0, indexOfNext), subarray(operators, indexOfNext + 1, operators.length) }); +/* */ } +/* */ catch (RuntimeException e) { +/* 94 */ if (base == 10) return solvePart(numbers[indexOfNext], operators[indexOfNext], numbers[(indexOfNext + 1)]); +/* 95 */ return BaseConverter.convertFromDecimal(Double.parseDouble(solvePart(numbers[indexOfNext], operators[indexOfNext], numbers[(indexOfNext + 1)])), base); +/* */ } +/* */ +/* 98 */ eq = ""; +/* 99 */ for (int i = 0; i < numbers.length; i++) { +/* 100 */ eq = eq + numbers[i]; +/* 101 */ if (i < operators.length) eq = eq + operators[i]; +/* */ } +/* 103 */ errIndex++; +/* */ } +/* 105 */ throw new Exception(eq + " could not be parsed"); +/* */ } +/* */ +/* */ private static boolean checkOps(String[] ops, String[] nums) { +/* 109 */ boolean flag = false; +/* 110 */ if (ops.length >= nums.length) { +/* 111 */ flag = true; +/* 112 */ nums[0] = (ops[0] + nums[0]); +/* */ } +/* 114 */ for (int i = 0; i < ops.length; i++) { +/* 115 */ if ((ops[i].length() > 1) && ((ops[i].charAt(ops[i].length() - 1) == '-') || (ops[i].charAt(ops[i].length() - 1) == '+'))) { +/* 116 */ nums[(flag ? i : i + 1)] = (ops[i].charAt(1) + nums[(i + 1)]); +/* 117 */ ops[i] = ops[i].charAt(0); +/* */ } +/* */ } +/* 120 */ return flag; +/* */ } +/* */ public static int indexOf(Object[] args, Object arg) { +/* 123 */ for (int i = 0; i < args.length; i++) if (arg.equals(args[i])) return i; +/* 124 */ return -1; +/* */ } +/* */ private static String solvePart(String num1, String op, String num2) { +/* 127 */ String ret = ""; +/* */ +/* 132 */ if (num2.endsWith(".0")) num2 = num2.substring(0, num2.indexOf(".")); +/* 133 */ if (num1.endsWith(".0")) num1 = num1.substring(0, num1.indexOf(".")); +/* 134 */ if (op.equals("^")) ret = Math.pow(Double.parseDouble(num1), Double.parseDouble(num2)); +/* 135 */ if (op.equals("£")) ret = Math.pow(Double.parseDouble(num1), 1.0D / Double.parseDouble(num2)); +/* 136 */ if (op.equals("e")) +/* */ { +/* 138 */ return Double.parseDouble(num1) * Math.pow(10.0D, Integer.parseInt(num2)); +/* */ } +/* 140 */ if (op.equals("*")) ret = new BigDecimal(num1).multiply(new BigDecimal(num2)).toPlainString(); +/* 141 */ else if (op.equals(":")) ret = new BigDecimal(num1).divide(new BigDecimal(num1).add(new BigDecimal(num2)), MathContext.DECIMAL64).toPlainString(); +/* 142 */ else if (op.equals("/")) { +/* 143 */ ret = new BigDecimal(num1).divide(new BigDecimal(num2), MathContext.DECIMAL64).toPlainString(); +/* */ } +/* 145 */ else if (op.equals("%")) ret = new BigDecimal(num1).remainder(new BigDecimal(num2)).toPlainString(); +/* 146 */ else if (op.equals("+")) ret = new BigDecimal(num1).add(new BigDecimal(num2)).toPlainString(); +/* 147 */ else if (op.equals("-")) ret = new BigDecimal(num1).subtract(new BigDecimal(num2)).toPlainString(); +/* 148 */ else if (op.equals("&")) ret = new BigInteger(num1).and(new BigInteger(num2)); +/* 149 */ else if (op.equals("\\")) ret = new BigInteger(num1).or(new BigInteger(num2)); +/* 150 */ else if (op.equals("?")) ret = new BigInteger(num1).xor(new BigInteger(num2)); +/* 151 */ return base == 10 ? ret : BaseConverter.convertFromDecimal(Double.parseDouble(ret), base); +/* */ } +/* */ private static void singleArgCheck(String[] nums) { +/* 154 */ boolean neg = false; +/* 155 */ for (int i = 0; i < nums.length; i++) { +/* 156 */ if (nums[i].startsWith("sqrt")) nums[i] = Math.sqrt(Double.parseDouble(nums[i].substring(4))); +/* 157 */ if (nums[i].startsWith("~")) nums[i] = new BigInteger(nums[i].substring(1)).not(); +/* 158 */ if (nums[i].startsWith("log")) nums[i] = (Math.log(Double.parseDouble(nums[i].substring(3))) / Math.log(10.0D)); +/* 159 */ if (nums[i].startsWith("ln")) nums[i] = Math.log(Double.parseDouble(nums[i].substring(2))); +/* 160 */ if (radians) { +/* 161 */ if (nums[i].startsWith("cos")) nums[i] = Math.cos(Double.parseDouble(nums[i].substring(3))); +/* 162 */ if (nums[i].startsWith("tan")) nums[i] = Math.tan(Double.parseDouble(nums[i].substring(3))); +/* 163 */ if (nums[i].startsWith("sin")) nums[i] = Math.sin(Double.parseDouble(nums[i].substring(3))); +/* 164 */ if (nums[i].startsWith("acos")) nums[i] = Math.acos(Double.parseDouble(nums[i].substring(4))); +/* 165 */ if (nums[i].startsWith("asin")) nums[i] = Math.asin(Double.parseDouble(nums[i].substring(4))); +/* 166 */ if (nums[i].startsWith("atan")) nums[i] = Math.atan(Double.parseDouble(nums[i].substring(4))); +/* */ } +/* */ else +/* */ { +/* 170 */ if (nums[i].startsWith("cos")) nums[i] = Math.cos(Math.toRadians(Double.parseDouble(nums[i].substring(3)))); +/* 171 */ if (nums[i].startsWith("tan")) nums[i] = Math.tan(Math.toRadians(Double.parseDouble(nums[i].substring(3)))); +/* 172 */ if (nums[i].startsWith("sin")) nums[i] = Math.sin(Math.toRadians(Double.parseDouble(nums[i].substring(3)))); +/* 173 */ if (nums[i].startsWith("acos")) nums[i] = Math.toDegrees(Math.acos(Double.parseDouble(nums[i].substring(4)))); +/* 174 */ if (nums[i].startsWith("asin")) nums[i] = Math.toDegrees(Math.asin(Double.parseDouble(nums[i].substring(4)))); +/* 175 */ if (nums[i].startsWith("atan")) nums[i] = Math.toDegrees(Math.atan(Double.parseDouble(nums[i].substring(4)))); +/* */ } +/* */ +/* 178 */ if (nums[i].endsWith("!")) { +/* 179 */ if (nums[i].contains(".")) nums[i] = (nums[i].substring(0, nums[i].indexOf(".")) + "!"); +/* 180 */ nums[i] = factorial(new BigInteger(nums[i].substring(0, nums[i].length() - 1))); +/* */ } +/* 182 */ if (nums[i].endsWith("_")) +/* */ { +/* */ String tmp866_860 = (new BigDecimal(nums[i].substring(0, nums[i].length() - 1)).toString() + ".0"); String x = tmp866_860; nums[i] = tmp866_860.substring(0, x.indexOf(".")); +/* */ } +/* 186 */ if (neg) nums[i] = ("-" + nums[i]); +/* */ } +/* */ } +/* */ +/* 190 */ private static int indexOf(Object[] args, Object[] find) { int min = -1; +/* */ +/* 192 */ for (Object o : find) +/* */ { +/* */ int idx; +/* 193 */ min = ((idx = indexOf(args, o)) != -1) && ((idx < min) || (min == -1)) ? idx : min; +/* */ } +/* 195 */ return min; } +/* */ +/* */ public static String[] subarray(String[] args, int start, int end) { +/* 198 */ String[] ret = new String[end - start]; +/* 199 */ for (int i = start; i < end; i++) ret[(i - start)] = args[i]; +/* 200 */ return ret; +/* */ } +/* */ private static String[] append(String[][] args) { +/* 203 */ int max = 0; +/* 204 */ String[][] arrayOfString = args; int j = args.length; for (int i = 0; i < j; i++) { String[] x = arrayOfString[i]; max += x.length; } +/* 205 */ String[] ret = new String[max]; +/* 206 */ int i = 0; for (int k = 0; i < args.length; i++) +/* 207 */ for (int j = 0; j < args[i].length; k++) { +/* 208 */ ret[k] = args[i][j]; +/* */ +/* 207 */ j++; +/* */ } +/* 209 */ return ret; +/* */ } +/* */ private static void swapAll(Object[] args, Object swap, Object with) { +/* 212 */ for (int i = 0; i < args.length; i++) if (swap.equals(args[i])) args[i] = with; +/* */ } +/* */ +/* */ private static BigInteger factorial(BigInteger x) +/* */ { +/* 215 */ if (x.longValue() <= 1L) return x; +/* 216 */ if (x.longValue() == 20L) return new BigInteger("2432902008176640000"); +/* 217 */ if (x.longValue() == 50L) return new BigInteger("30414093201713378043612608166064768844377641568960512000000000000"); +/* 218 */ if (x.longValue() == 70L) return new BigInteger("11978571669969891796070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); +/* 219 */ return x.multiply(factorial(x.subtract(new BigInteger("1")))); +/* */ } +/* */ +/* */ private static String[][] splitNums(String x) { +/* 223 */ ArrayList ret1 = new ArrayList(); +/* 224 */ ArrayList ret2 = new ArrayList(); +/* 225 */ boolean flag = true; +/* 226 */ String temp = ""; +/* 227 */ for (int i = 0; i < x.length(); i++) { +/* 228 */ if ("%/*+^e:&\\?£".contains(x.charAt(i))) { +/* 229 */ if (flag) { +/* 230 */ flag = !flag; +/* 231 */ ret1.add(temp); +/* 232 */ temp = ""; +/* */ } +/* */ +/* */ } +/* 236 */ else if (!flag) { +/* 237 */ flag = !flag; +/* 238 */ ret2.add(temp); +/* 239 */ temp = ""; +/* */ } +/* */ +/* 242 */ temp = temp + x.charAt(i); +/* */ } +/* 244 */ if (!flag) { +/* 245 */ flag = !flag; +/* 246 */ ret2.add(temp); +/* 247 */ temp = ""; +/* */ } +/* */ else { +/* 250 */ flag = !flag; +/* 251 */ ret1.add(temp); +/* 252 */ temp = ""; +/* */ } +/* */ +/* 255 */ return new String[][] { toStringArray(ret1), toStringArray(ret2) }; +/* */ } +/* */ public static String[] toStringArray(ArrayList x) { +/* 258 */ String[] ret = new String[x.size()]; +/* 259 */ for (int i = 0; i < x.size(); i++) ret[i] = ((String)x.get(i)).toString(); +/* 260 */ return ret; +/* */ } +/* */ public static boolean toggleRadians() { +/* 263 */ return Calculator.radians = radians ? 0 : 1; +/* */ } +/* */ private static String sudoSubtraction(String eq) { +/* 266 */ while ((eq.contains("++")) || (eq.contains("--"))) { +/* 267 */ eq = eq.replaceAll("--", "+"); +/* 268 */ eq = eq.replaceAll("\\+\\+", "+"); +/* */ } +/* 270 */ String ret = ""; +/* 271 */ if (eq.charAt(0) != '+') ret = ret + eq.charAt(0); +/* */ +/* 273 */ for (int i = 1; i < eq.length() - 1; i++) { +/* 274 */ if ((eq.charAt(i) == '-') && (Character.isDigit(eq.charAt(i - 1)))) { +/* 275 */ if (eq.charAt(i + 1) == '+') { +/* 276 */ i++; +/* */ } +/* 278 */ ret = ret + "+-"; +/* */ } +/* */ else { +/* 281 */ ret = ret + eq.charAt(i); +/* */ } +/* */ } +/* 284 */ return ret + (eq.length() > 1 ? Character.valueOf(eq.charAt(eq.length() - 1)) : ""); +/* */ } +/* */ private static String expandAfterNodes(String eq) { +/* 287 */ String ret = ""; +/* 288 */ for (int i = 0; i < eq.length(); i++) { +/* 289 */ ret = ret + eq.charAt(i); +/* 290 */ if ((eq.charAt(i) == ')') && (i < eq.length() - 1) && (Character.isDigit(eq.charAt(i + 1)))) ret = ret + "*"; +/* */ } +/* 292 */ return ret; +/* */ } +/* */ private static String expandMult(String eq) { +/* 295 */ String temp = ""; +/* 296 */ eq = eq.replaceAll("\\)\\(", ")*("); +/* */ +/* 299 */ int i = eq.indexOf("("); for (int last = 0; i >= 0; i = eq.indexOf("(", i + 1)) { +/* 300 */ if (i != 0) { +/* 301 */ temp = temp + eq.substring(last, i); +/* 302 */ if (Character.isDigit(eq.charAt(i - 1))) temp = temp + "*"; +/* */ } +/* 299 */ last = i; +/* */ } +/* */ +/* 304 */ eq = temp + eq.substring(last); +/* */ +/* 306 */ return expandAfterNodes(eq); +/* */ } +/* */ private static void replaceBase(String[] nums) { +/* 309 */ for (int i = 0; i < nums.length; i++) { +/* 310 */ String y = BaseConverter.convertToDecimal(nums[i].substring(indexOfDigit(nums[i]), lastIndexOfDigit(nums[i]) + 1), base); +/* 311 */ if (y.endsWith(".0")) y = y.substring(0, y.length() - 2); +/* 312 */ nums[i] = (nums[i].substring(0, indexOfDigit(nums[i])) + y + nums[i].substring(lastIndexOfDigit(nums[i]) + 1)); +/* */ } +/* */ } +/* 315 */ public static int getBase() { return base; } +/* 316 */ public static void setBase(int newBase) { base = newBase; } +/* */ private static int indexOfDigit(String eq) { +/* 318 */ for (int i = 0; i < eq.length(); i++) if ((Character.isDigit(eq.charAt(i))) || (Character.isUpperCase(eq.charAt(i)))) return i; +/* 319 */ return 0; +/* */ } +/* */ private static int lastIndexOfDigit(String eq) { +/* 322 */ for (int i = eq.length() - 1; i >= 0; i--) if ((Character.isDigit(eq.charAt(i))) || (Character.isUpperCase(eq.charAt(i)))) return i; +/* 323 */ return eq.length(); +/* */ } +/* */ public static void test() { +/* */ } +/* 327 */ public static void setRadians(boolean istrue) { radians = istrue; } +/* */ +/* */ } + +/* Location: Modulus.jar + * Qualified Name: Calculator + * JD-Core Version: 0.6.2 + */ \ No newline at end of file diff --git a/src/CalculatorGUI.java b/src/CalculatorGUI.java new file mode 100644 index 0000000..c96bfe8 --- /dev/null +++ b/src/CalculatorGUI.java @@ -0,0 +1,1024 @@ +/* */ import StandardIO.Approvable; +/* */ import StandardIO.MFileFilter; +/* */ import StandardIO.ModulusFileChooser; +/* */ import StandardIO.ModulusOutputStream; +/* */ import StandardIO.PropertiesReader; +/* */ import java.awt.BorderLayout; +/* */ import java.awt.Color; +/* */ import java.awt.Component; +/* */ import java.awt.Container; +/* */ import java.awt.Dimension; +/* */ import java.awt.FlowLayout; +/* */ import java.awt.Graphics; +/* */ import java.awt.Toolkit; +/* */ import java.awt.datatransfer.DataFlavor; +/* */ import java.awt.datatransfer.Transferable; +/* */ import java.awt.dnd.DropTarget; +/* */ import java.awt.dnd.DropTargetDragEvent; +/* */ import java.awt.dnd.DropTargetDropEvent; +/* */ import java.awt.dnd.DropTargetEvent; +/* */ import java.awt.dnd.DropTargetListener; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import java.awt.event.KeyEvent; +/* */ import java.awt.event.KeyListener; +/* */ import java.awt.event.MouseEvent; +/* */ import java.awt.event.MouseListener; +/* */ import java.awt.image.BufferedImage; +/* */ import java.io.File; +/* */ import java.io.IOException; +/* */ import java.io.PrintStream; +/* */ import java.util.ArrayList; +/* */ import java.util.List; +/* */ import javax.imageio.ImageIO; +/* */ import javax.swing.AbstractButton; +/* */ import javax.swing.ButtonGroup; +/* */ import javax.swing.JButton; +/* */ import javax.swing.JCheckBox; +/* */ import javax.swing.JCheckBoxMenuItem; +/* */ import javax.swing.JColorChooser; +/* */ import javax.swing.JComboBox; +/* */ import javax.swing.JComponent; +/* */ import javax.swing.JFileChooser; +/* */ import javax.swing.JFrame; +/* */ import javax.swing.JLabel; +/* */ import javax.swing.JList; +/* */ import javax.swing.JMenu; +/* */ import javax.swing.JMenuBar; +/* */ import javax.swing.JMenuItem; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JRadioButton; +/* */ import javax.swing.JRadioButtonMenuItem; +/* */ import javax.swing.JScrollPane; +/* */ import javax.swing.JSeparator; +/* */ import javax.swing.JTextArea; +/* */ import javax.swing.JTextField; +/* */ import javax.swing.JToggleButton; +/* */ import javax.swing.JWindow; +/* */ import javax.swing.SwingUtilities; +/* */ import javax.swing.UIManager; +/* */ import utilities.BaseConverter; +/* */ import utilities.DecimalFormatter; +/* */ import utilities.NoFormatter; +/* */ +/* */ public class CalculatorGUI extends JFrame +/* */ implements ActionListener, DropTargetListener, KeyListener, MouseListener +/* */ { +/* */ private static final long serialVersionUID = -7536111096507880724L; +/* */ private static CalculatorGUI currentInstance; +/* 89 */ private String[] props = { "1234567890\\QWERTYUIOP\\ASDFGHJKL\\ZXCVBNM", "none", "none", "none", "full", "false" }; +/* 90 */ private static CalculatorGUI.SplashScreen splash = new CalculatorGUI.SplashScreen(); +/* 91 */ public static String CREDITS = "Modulus v2.0\nBy: Joshua Rahm\nSkyline High School\nLongmont, CO\nEmail: rahm_joshua@digitalagenation.com\nWebpage: http://www.digitalagenation/modulus.html"; +/* 92 */ private Keyboard[] keys = { +/* 93 */ new Keyboard("1234567890\\QWERTYUIOP\\ASDFGHJKL\\ZXCVBNM"), +/* 94 */ new Keyboard(new String[][] { { "7", "8", "9" }, { "4", "5", "6" }, { "1", "2", "3" }, { ".", "0", "Entr" } }, 25, 35, null), +/* 95 */ new Keyboard(new String[][] { { "acos(", "cos(" }, { "asin(", "sin(" }, { "atan(", "tan(" }, { "ln(", "log(" } }, 25, 45, null), +/* 96 */ new Keyboard(":£^%e"), +/* 97 */ new Keyboard("/\\*\\-\\+"), +/* 98 */ new Keyboard("~?|&"), +/* 99 */ new Keyboard("[(|!\\]),_"), +/* 100 */ new Keyboard(new String[][] { { ">=", "<=", ">", "<", "=", " else " }, { " and ", " or ", " xor ", "not(", " if ", " then " } }, 25, 45, null), +/* 101 */ new Keyboard(new String[][] { { "x2", "√x", "x3", "x-1" } }, 25, 35, null), +/* 102 */ new Keyboard(new String[][] { { "Bkspc", "Clear" } }, 25, 45, null), +/* 103 */ new Keyboard(new String[][] { { "ClrHome" } }, 25, 55, null), +/* 104 */ new Keyboard(new String[][] { { "STO ", "STP ", "PUSH ", "POP " }, { "DISP ", "STACK ", "DEL ", "DEC " } }, 25, 55, null) }; +/* */ private DecimalFormatter formatter; +/* 108 */ private boolean controlHeld = false; +/* 109 */ private boolean shiftHeld = false; +/* 110 */ private ArrayList last = new ArrayList(); +/* 111 */ private ArrayList ans = new ArrayList(); +/* 112 */ private int lastIndex = 0; +/* 113 */ private String[] topOpsArr = { "^2", "sqrt(", "^3", "^-1" }; +/* */ +/* 115 */ private JPanel[] panels = { new JPanel(new FlowLayout()), new JPanel(new FlowLayout()), new JPanel(new BorderLayout()) }; +/* 116 */ private JPanel numberPanel = new JPanel(new BorderLayout()); +/* */ +/* 118 */ private JTextArea answerArea = new JTextArea(18, 17); +/* */ +/* 120 */ private JTextField answerField = new JTextField(35); +/* */ private JScrollPane scroll; +/* 123 */ private JMenuBar mainbar = new JMenuBar(); +/* */ +/* 126 */ private Object temp = null; +/* 127 */ private long sysTime = 0L; +/* */ +/* 129 */ private JButton terminate = new JButton("Terminate"); +/* 130 */ private ArrayList exec = new ArrayList(); +/* 131 */ private File functions = new File("./functions"); +/* 132 */ private ButtonGroup layout = new ButtonGroup(); +/* */ +/* 134 */ private String[][] map = { +/* 135 */ { "Add", "Subtract", "Multiply", "Divide", "Power", "Shift", "Root", "Sine", "Cosine", "Tangent", "Arcsine", "Arccosine", "Arctangent", "Logarithm", "Greater Than", "Less Than", +/* 136 */ "Greater Than Equal To", "Less Than Equal To", "Equal To", "And", "Or", "Exclusive or", "Not", "if", "then", "else", "Bitwise And", "Bitwise or", "Bitwise Exclusive or", "Bitwise not", +/* 137 */ "x Squared", "x Cubed", "Square Root x", "Inverse of x" }, +/* 138 */ { "+", "-", "*", "/", "^", "e", "?", "sin(", "cos(", "tan(", "asin(", "acos(", "atan(", "log(", ">", "<", ">=", "<=", "=", " and ", " or ", " xor ", "not(", "if( ", " then( ", " else( ", "&", "\\", "?", "~(", +/* 139 */ "^2", "^3", "sqrt(", "^-1" } }; +/* */ +/* 145 */ private Menu[] menus = { +/* 146 */ new Menu("File", new AbstractButton[] { +/* 147 */ new JMenuItem("Close"), +/* 148 */ new JMenuItem("Save") }), +/* 150 */ new Menu("Edit", new AbstractButton[] { +/* 151 */ new JMenuItem("Change Base"), +/* 152 */ new JMenuItem("Convert Base"), +/* 153 */ new JMenuItem("Clear"), +/* 154 */ new JMenuItem("Manage Programs") }), +/* 157 */ new Menu("Calculate", new AbstractButton[] { +/* 158 */ new Menu("Basic Operators", new AbstractButton[] { +/* 159 */ new JMenuItem("Add"), +/* 160 */ new JMenuItem("Subtract"), +/* 161 */ new JMenuItem("Multiply"), +/* 162 */ new JMenuItem("Divide"), +/* 163 */ new JMenuItem("Power"), +/* 164 */ new JMenuItem("Shift"), +/* 165 */ new JMenuItem("Root") }), +/* 167 */ new Menu("Trigometic Operators", new AbstractButton[] { +/* 168 */ new JMenuItem("Sine"), +/* 169 */ new JMenuItem("Cosine"), +/* 170 */ new JMenuItem("Tangent"), +/* 171 */ new JMenuItem("Arccosine"), +/* 172 */ new JMenuItem("Arcsin"), +/* 173 */ new JMenuItem("Arctangent"), +/* 174 */ new JMenuItem("Loagrithm") }), +/* 176 */ new Menu("Boolean Operators", new AbstractButton[] { +/* 177 */ new Menu("Relational Operators", new JComponent[] { +/* 178 */ new JMenuItem("Greater Than"), +/* 179 */ new JMenuItem("Less Than"), +/* 180 */ new JMenuItem("Greater Than Equal To"), +/* 181 */ new JMenuItem("Less Than Equal To"), +/* 182 */ new JMenuItem("Equal To") }), +/* 184 */ new Menu("Logical Operators", new AbstractButton[] { +/* 185 */ new JMenuItem("And"), +/* 186 */ new JMenuItem("Or"), +/* 187 */ new JMenuItem("Exclusive or"), +/* 188 */ new JMenuItem("Not") }), +/* 190 */ new Menu("Flow Operators", new AbstractButton[] { +/* 191 */ new JMenuItem("if"), +/* 192 */ new JMenuItem("then"), +/* 193 */ new JMenuItem("else") }) }), +/* 196 */ new Menu("Bitwise Operators", new AbstractButton[] { +/* 197 */ new JMenuItem("Bitwise And"), +/* 198 */ new JMenuItem("Bitwise or"), +/* 199 */ new JMenuItem("Bitwise Exclusive or"), +/* 200 */ new JMenuItem("Bitwise not") }), +/* 202 */ new Menu("Other Operators", new AbstractButton[] { +/* 203 */ new JMenuItem("x Squared"), +/* 204 */ new JMenuItem("x Cubed"), +/* 205 */ new JMenuItem("Square Root x"), +/* 206 */ new JMenuItem("Inverse of x") }), +/* 208 */ new JCheckBoxMenuItem("Radians") }), +/* 210 */ new Menu("Programming", new JComponent[] { +/* 211 */ new JCheckBoxMenuItem("Toggle Shell Mode"), +/* 212 */ new JMenuItem("Run a Script..."), +/* 213 */ new JMenuItem("Function..."), +/* 214 */ new JMenuItem("Load Library"), +/* 215 */ new JMenuItem("Manage Startup Libraries"), +/* 216 */ new JSeparator(), +/* 217 */ new JSeparator(), +/* 218 */ new JMenuItem("View Stacks"), +/* 219 */ new JMenuItem("View Hold Variable"), +/* 220 */ new JSeparator(), +/* 221 */ new JSeparator(), +/* 222 */ new JMenuItem("Run in Terminal...") }), +/* 224 */ new Menu("Properties", new JComponent[] { +/* 225 */ new JMenuItem("Change Color"), +/* 226 */ new JMenuItem("Change Keyboard Style"), +/* 227 */ new JCheckBoxMenuItem("Always Show Commands", true), +/* 228 */ new JCheckBoxMenuItem("Auto Complete", true), +/* 229 */ new JSeparator(), +/* 230 */ new JSeparator(), +/* 231 */ new JMenuItem("Set Formatting") }), +/* 233 */ new Menu("View", new JComponent[] { +/* 234 */ new JCheckBox("Always On Top"), +/* 235 */ new JSeparator(), +/* 236 */ new JSeparator(), +/* 237 */ new JRadioButtonMenuItem("Standard"), +/* 238 */ new JRadioButtonMenuItem("Scientific"), +/* 239 */ new JRadioButtonMenuItem("Boolean"), +/* 240 */ new JRadioButtonMenuItem("Bitwise"), +/* 241 */ new JRadioButtonMenuItem("Full Calc", true), +/* 242 */ new JSeparator(), +/* 243 */ new JSeparator(), +/* 244 */ new JMenuItem("View Graph"), +/* 245 */ new JMenuItem("View 3D Graph") }) }; +/* */ +/* 248 */ private JPanel[] subPanels = { +/* 249 */ new JPanel(new FlowLayout()), new JPanel(new FlowLayout()), new JPanel(new FlowLayout()), new JPanel(new BorderLayout()) }; +/* */ +/* 251 */ private Approvable[] approvables = { +/* 252 */ new Approvable() { +/* */ public void onApprove(File file) { +/* 254 */ CalculatorGUI.silentPrint("------------------------------\n"); +/* 255 */ CalculatorGUI.silentPrint("Started Running File: " + file + " On new Thread\n"); +/* 256 */ CalculatorGUI.silentPrint("------------------------------\n"); +/* */ Thread run; +/* 258 */ CalculatorGUI.this.exec.add(run = new SilentThread(new CalculatorGUI.Run(CalculatorGUI.this, file), file.toString())); +/* 259 */ run.start(); +/* 260 */ CalculatorGUI.this.props[2] = file.getParent().toString(); +/* 261 */ CalculatorGUI.this.writeProperties(); +/* */ } +/* */ +/* */ public void onCancel() +/* */ { +/* */ } +/* */ } +/* */ , new Approvable() { +/* */ public void onApprove(File file) { +/* 267 */ CalculatorGUI.silentPrint("------------------------------\n"); +/* 268 */ CalculatorGUI.silentPrint("Loaded " + file); +/* 269 */ CalculatorGUI.silentPrint("------------------------------\n"); +/* */ try { +/* 271 */ ControlPanel.load(file.toString()); +/* */ } +/* */ catch (Exception e) { +/* 274 */ e.printStackTrace(); +/* */ } +/* 276 */ CalculatorGUI.this.props[3] = file.getParent().toString(); +/* 277 */ CalculatorGUI.this.writeProperties(); +/* */ } +/* */ +/* */ public void onCancel() +/* */ { +/* */ } +/* */ } +/* */ , new Approvable() { +/* */ public void onApprove(File file) { +/* 283 */ if ((System.out instanceof ModulusOutputStream)) +/* 284 */ ((ModulusOutputStream)System.out).flushTo(file); } +/* */ public void onCancel() { } } }; +/* */ +/* 449 */ private JButton[] hold = { new JButton("OK"), new JButton("OK"), new JButton("OK"), new JButton("OK") }; +/* 450 */ private Prompt[] prompt = { new Prompt(this, "Change Base", new JComboBox[] { new BaseComboBox(9) }, this, this.hold[0]), +/* 451 */ new Prompt(this, "Layouts", new JComponent[] { new JRadioButton("Qwerty"), +/* 452 */ new JRadioButton("Dvorak"), +/* 453 */ new JRadioButton("Alphabetical"), +/* 454 */ new JRadioButton("Other"), +/* 455 */ new JTextField("Enter other (\\ = new line)") }, this, this.hold[1]), +/* 456 */ new Prompt(this, "Functions", new JComponent[] { new ActionList(ControlPanel.getFunctions(), this), +/* 457 */ new JTextField("", 10) }, this, this.hold[2]), +/* 458 */ new Prompt(this, "Convert Bases", new JComponent[] { new BaseComboBox(9), new JTextField("", 7), new JLabel("To"), new BaseComboBox(9) }, this, this.hold[3]), +/* 459 */ new Prompt(this, "Hold Stack:", new JComponent[] { new JList() }, this, new JButton()) }; +/* */ private ButtonGroup keyboards; +/* */ +/* 294 */ public CalculatorGUI() { c