Commit c5abccad8d5216e616814a6b0d971337ea72cedb

Authored by pfrison
1 parent c52f6592

PercTeacher interface PC done

PercTeacher/Sources/Action.java 0 → 100644
... ... @@ -0,0 +1,88 @@
  1 +
  2 +
  3 +public class Action {
  4 + public static final long DELAI_DEFAULT = 1000;
  5 +
  6 + private boolean endAction = true;
  7 +
  8 + private long deltaL = 0;
  9 + private long deltaR = 0;
  10 +
  11 + private long delaiL = DELAI_DEFAULT; // in us
  12 + private long delaiR = DELAI_DEFAULT; // in us
  13 +
  14 + public Action() {}
  15 + public Action(long deltaL, long deltaR) {
  16 + this.deltaL = deltaL;
  17 + this.deltaR = deltaR;
  18 + this.endAction = false;
  19 + }
  20 + public Action(long deltaL, long deltaR, long delaiL, long delaiR) {
  21 + this.deltaL = deltaL;
  22 + this.deltaR = deltaR;
  23 + this.delaiL = delaiL;
  24 + this.delaiR = delaiR;
  25 + this.endAction = false;
  26 + }
  27 +
  28 + public void addDeltaL(long amount){this.deltaL += amount; endAction = false;}
  29 + public void addDeltaR(long amount){this.deltaR += amount; endAction = false;}
  30 + public void setDeltaL(long amount){this.deltaL = amount; endAction = false;}
  31 + public void setDeltaR(long amount){this.deltaR = amount; endAction = false;}
  32 + public long getDeltaL(){return this.deltaL;}
  33 + public long getDeltaR(){return this.deltaR;}
  34 +
  35 + public void setDelaiL(long delai){this.delaiL = delai; endAction = false;}
  36 + public void setDelaiR(long delai){this.delaiR = delai; endAction = false;}
  37 + public long getDelaiL(){return this.delaiL;}
  38 + public long getDelaiR(){return this.delaiR;}
  39 +
  40 + public boolean isEmpty() {return endAction;}
  41 +
  42 + public void calculateDelais(long microseconds) {
  43 + // left
  44 + double ticksL = (double) microseconds / (double) deltaL;
  45 + delaiL = (long) (ticksL / 2d); // 1 step = 1 "on state" + 1 "off state"
  46 +
  47 + // right
  48 + double ticksR = (double) microseconds / (double) deltaR;
  49 + delaiR = (long) (ticksR / 2d);
  50 +
  51 + // tests
  52 + if(delaiL < 50 || delaiR < 50)
  53 + System.out.println("Warning : delais are very small ! (< 50 us)");
  54 + }
  55 +
  56 + @Override
  57 + public String toString() {
  58 + if(endAction)
  59 + return "End sequence";
  60 + if(deltaL == 0 && deltaR == 0)
  61 + return "Pause for " + String.valueOf((double) delaiL / 1000d) + " miliseconds";
  62 + if(deltaL == 0) {
  63 + if(deltaR > 0)
  64 + return "Turning right forward for " + String.valueOf(deltaR) + " steps during " + String.valueOf((double) (deltaR * delaiR) / 1000d) + " miliseconds";
  65 + else
  66 + return "Turning right backward for " + String.valueOf(-deltaR) + " steps during " + String.valueOf((double) (-deltaR * delaiR) / 1000d) + " miliseconds";
  67 + } if(deltaR == 0) {
  68 + if(deltaL > 0)
  69 + return "Turning left forward for " + String.valueOf(deltaL) + " steps during " + String.valueOf((double) (deltaL * delaiL) / 1000d) + " miliseconds";
  70 + else
  71 + return "Turning left backward for " + String.valueOf(-deltaL) + " steps during " + String.valueOf((double) (-deltaL * delaiL) / 1000d) + " miliseconds";
  72 + } if(deltaR == deltaL) {
  73 + if(deltaL > 0)
  74 + return "Going forward for " + String.valueOf(deltaL) + " steps during " + String.valueOf((double) (deltaL * delaiL) / 1000d) + " miliseconds";
  75 + else
  76 + return "Going backward for " + String.valueOf(-deltaL) + " steps during " + String.valueOf((double) (deltaL * delaiL) / 1000d) + " miliseconds";
  77 + } if(deltaR == -deltaL) {
  78 + if(deltaL > 0)
  79 + return "Turning on the spot clockwise for " + String.valueOf(deltaL) + " steps during "
  80 + + String.valueOf((double) (deltaL * delaiL) / 1000d) + " miliseconds";
  81 + else
  82 + return "Turning on the spot anti-clockwise for " + String.valueOf(deltaR) + " steps during "
  83 + + String.valueOf((double) (deltaR * delaiR) / 1000d) + " miliseconds";
  84 + }
  85 + return "Custom curve dL:" + String.valueOf(deltaL) + "steps tL:" + String.valueOf((double) (deltaL * delaiL) / 1000d) + "ms | dR"
  86 + + String.valueOf(deltaR) + "steps tR:" + String.valueOf((double) (deltaR * delaiR) / 1000d) + "ms";
  87 + }
  88 +}
... ...
PercTeacher/Sources/ActionList.java 0 → 100644
... ... @@ -0,0 +1,128 @@
  1 +import java.util.ArrayList;
  2 +
  3 +public class ActionList {
  4 + private ArrayList<Action> actions;
  5 +
  6 + public ActionList() {
  7 + actions = new ArrayList<>();
  8 + actions.add(new Action());
  9 + }
  10 + public ActionList(long[] leftDeltaArray, long[] rightDeltaArray, long[] leftDelaiArray, long[] rightDelaiArray) {
  11 + if(leftDelaiArray.length != rightDelaiArray.length
  12 + || leftDelaiArray.length != leftDelaiArray.length
  13 + || leftDelaiArray.length != rightDelaiArray.length)
  14 + throw new InvalidActionListArrays();
  15 + actions = new ArrayList<>();
  16 + for(int i=0; i<leftDeltaArray.length; i++)
  17 + actions.add(new Action(leftDeltaArray[i], rightDeltaArray[i], leftDelaiArray[i], rightDelaiArray[i]));
  18 + actions.add(new Action());
  19 + }
  20 +
  21 + public void addToActionList(int i, int j, long step) {
  22 + switch (j * 10 + i) {
  23 + case 00: //ACTION_LEFT_PLUS;
  24 + addToLastAction(step, 0);
  25 + break;
  26 + case 02: //ACTION_LEFT_MINUS;
  27 + addToLastAction(-step, 0);
  28 + break;
  29 + case 20: //ACTION_RIGHT_PLUS;
  30 + addToLastAction(0, step);
  31 + break;
  32 + case 22: //ACTION_RIGHT_MINUS;
  33 + addToLastAction(0, -step);
  34 + break;
  35 + case 10: //ACTION_FORWARD;
  36 + addToLastAction(step, step);
  37 + break;
  38 + case 12: //ACTION_BACKWARD;
  39 + addToLastAction(-step, -step);
  40 + break;
  41 + case 01: //ACTION_CLOCKWISE;
  42 + addToLastAction(step, -step);
  43 + break;
  44 + case 21: //ACTION_ANTI_CLOCKWISE;
  45 + addToLastAction(-step, step);
  46 + break;
  47 + default:
  48 + throw new InvalidInputException();
  49 + }
  50 + }
  51 +
  52 + public void completeAction() {
  53 + if(!actions.get(actions.size() - 1).isEmpty())
  54 + actions.add(new Action());
  55 + }
  56 +
  57 + public void completeActionAndAddPause(long delai) {
  58 + if(actions.get(actions.size() - 1).isEmpty())
  59 + actions.set(actions.size() - 1, new Action(0, 0, delai, delai));
  60 + else
  61 + actions.add(new Action(0, 0, delai, delai));
  62 + completeAction();
  63 + }
  64 +
  65 + private void addToLastAction(long deltaL, long deltaR) {
  66 + actions.get(actions.size() - 1).addDeltaL(deltaL);
  67 + actions.get(actions.size() - 1).addDeltaR(deltaR);
  68 + }
  69 +
  70 + public void revertLastAction() {
  71 + if(actions.size() <= 0)
  72 + return;
  73 + if(actions.get(actions.size() - 1).isEmpty()) {
  74 + actions.remove(actions.size() - 1);
  75 + if(actions.size() != 0)
  76 + actions.set(actions.size() - 1, new Action());
  77 + else
  78 + actions.add(new Action());
  79 + } else {
  80 + actions.set(actions.size() - 1, new Action());
  81 + }
  82 + }
  83 +
  84 + public String getLeftDeltaArray() {
  85 + String str = "{";
  86 + for(Action action : actions) {
  87 + if(!action.isEmpty())
  88 + str += String.valueOf(action.getDeltaL()) + "L, ";
  89 + }
  90 + str = str.substring(0, str.length() - 2) + "}";
  91 + return str;
  92 + }
  93 + public String getRightDeltaArray() {
  94 + String str = "{";
  95 + for(Action action : actions) {
  96 + if(!action.isEmpty())
  97 + str += String.valueOf(action.getDeltaR()) + "L, ";
  98 + }
  99 + str = str.substring(0, str.length() - 2) + "}";
  100 + return str;
  101 + }
  102 + public String getLeftDelaiArray() {
  103 + String str = "{";
  104 + for(Action action : actions) {
  105 + if(!action.isEmpty())
  106 + str += String.valueOf(action.getDeltaR()) + "L, ";
  107 + }
  108 + str = str.substring(0, str.length() - 2) + "}";
  109 + return str;
  110 + }
  111 + public String getRightDelaiArray() {
  112 + String str = "{";
  113 + for(Action action : actions) {
  114 + if(!action.isEmpty())
  115 + str += String.valueOf(action.getDeltaR()) + "L, ";
  116 + }
  117 + str = str.substring(0, str.length() - 2) + "}";
  118 + return str;
  119 + }
  120 +
  121 + @Override
  122 + public String toString() {
  123 + String str = "";
  124 + for(Action action : actions)
  125 + str += action.toString() + "\n";
  126 + return str;
  127 + }
  128 +}
... ...
PercTeacher/Sources/ImportExport.java 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +import java.io.BufferedWriter;
  2 +import java.io.File;
  3 +import java.io.FileWriter;
  4 +import java.io.IOException;
  5 +import java.nio.charset.Charset;
  6 +import java.nio.file.Files;
  7 +import java.nio.file.Paths;
  8 +
  9 +import javax.swing.JFileChooser;
  10 +import javax.swing.JOptionPane;
  11 +import javax.swing.filechooser.FileNameExtensionFilter;
  12 +
  13 +public class ImportExport {
  14 + public static void exportWithDialog(ActionList list) {
  15 + JFileChooser chooser = new JFileChooser();
  16 + FileNameExtensionFilter filter = new FileNameExtensionFilter("Array data", "adata");
  17 + chooser.setFileFilter(filter);
  18 + chooser.setApproveButtonText("Exporter");
  19 + int returnVal = chooser.showOpenDialog(null);
  20 + if(returnVal == JFileChooser.APPROVE_OPTION)
  21 + export(list, chooser.getSelectedFile().getPath());
  22 + }
  23 + private static void export(ActionList list, String path) {
  24 + String str = list.getLeftDeltaArray() + "\n" + list.getRightDeltaArray() + "\n" + list.getLeftDelaiArray() + "\n" + list.getRightDelaiArray();
  25 +
  26 + if(!path.endsWith(".adata"))
  27 + path += ".adata";
  28 + BufferedWriter bufferedWriter = null;
  29 + try {
  30 + File file = new File(path);
  31 + if (!file.exists())
  32 + file.createNewFile();
  33 + bufferedWriter = new BufferedWriter(new FileWriter(file));
  34 + bufferedWriter.write(str);
  35 + bufferedWriter.close();
  36 + } catch (IOException e) {
  37 + e.printStackTrace();
  38 + }
  39 + }
  40 +
  41 + public static ActionList importsWithDialog() {
  42 + JFileChooser chooser = new JFileChooser();
  43 + FileNameExtensionFilter filter = new FileNameExtensionFilter("Array data", "adata");
  44 + chooser.setFileFilter(filter);
  45 + chooser.setMultiSelectionEnabled(false);
  46 + chooser.setApproveButtonText("Importer");
  47 + int returnVal = chooser.showOpenDialog(null);
  48 + if(returnVal == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().exists() && chooser.getSelectedFile().isFile())
  49 + return imports(chooser.getSelectedFile().getPath());
  50 + if(returnVal == JFileChooser.APPROVE_OPTION)
  51 + JOptionPane.showMessageDialog(null, "You have to choose an exisiting file", "Import error", JOptionPane.ERROR_MESSAGE);
  52 + return null;
  53 + }
  54 + private static ActionList imports(String path) {
  55 + try {
  56 + byte[] encoded = Files.readAllBytes(Paths.get(path));
  57 + String str = new String(encoded, Charset.defaultCharset());
  58 + long[][] longList = Util.getArraysFromImport(str);
  59 + if(longList != null)
  60 + return new ActionList(longList[0], longList[1], longList[2], longList[3]);
  61 + JOptionPane.showMessageDialog(null, "The choosen file is invalid or currupted", "Import error", JOptionPane.ERROR_MESSAGE);
  62 + } catch (IOException ignored) {}
  63 + return null;
  64 + }
  65 +}
... ...
PercTeacher/Sources/Interface.java 0 → 100644
... ... @@ -0,0 +1,230 @@
  1 +import java.awt.BorderLayout;
  2 +import java.awt.Color;
  3 +import java.awt.Component;
  4 +import java.awt.FlowLayout;
  5 +import java.awt.Font;
  6 +import java.awt.GridLayout;
  7 +import java.awt.event.ActionEvent;
  8 +import java.awt.event.ActionListener;
  9 +import java.awt.event.FocusEvent;
  10 +import java.awt.event.FocusListener;
  11 +
  12 +import javax.swing.BorderFactory;
  13 +import javax.swing.BoxLayout;
  14 +import javax.swing.ImageIcon;
  15 +import javax.swing.JButton;
  16 +import javax.swing.JFrame;
  17 +import javax.swing.JLabel;
  18 +import javax.swing.JOptionPane;
  19 +import javax.swing.JPanel;
  20 +import javax.swing.JScrollPane;
  21 +import javax.swing.JSeparator;
  22 +import javax.swing.JTextArea;
  23 +import javax.swing.JTextField;
  24 +import javax.swing.border.Border;
  25 +
  26 +public class Interface extends JFrame implements ActionListener, FocusListener {
  27 + private static final long serialVersionUID = 1L;
  28 + private static final Font titleFont = new Font(new JLabel().getFont().getName(), Font.BOLD, 14);
  29 + private static final Font defaultFont = new Font(new JLabel().getFont().getName(), Font.PLAIN, new JLabel().getFont().getSize());
  30 + private static final Border defaultJTextFieldBorder = new JTextField().getBorder();
  31 +
  32 + private JTextArea logs;
  33 + private JButton[][] moveButtons = new JButton[3][3];
  34 + private JTextField stepsField;
  35 + private JButton waitButton;
  36 + private JButton nextButton;
  37 + private JButton revertButton;
  38 + private JButton exportButton;
  39 + private JButton importButton;
  40 +
  41 + private ActionList actionList;
  42 +
  43 + public Interface(ActionList actionList) {
  44 + super("PercTeacher");
  45 + this.actionList = actionList;
  46 + setResizable(false);
  47 + populateWindow();
  48 + pack();
  49 + setLocationRelativeTo(null); // center window
  50 + }
  51 +
  52 + private void populateWindow() {
  53 + JPanel mainPanel = new JPanel(new BorderLayout());
  54 + addLogPanel(mainPanel);
  55 +
  56 + JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
  57 + addMoveCommandsPanel(centerPanel);
  58 + JPanel optionCommandsPanel = new JPanel();
  59 + addOptionCommandsPanel(centerPanel, optionCommandsPanel);
  60 + addExportImportPanel(optionCommandsPanel);
  61 +
  62 + mainPanel.add(centerPanel, BorderLayout.CENTER);
  63 + add(mainPanel);
  64 +
  65 + updateLogs();
  66 + }
  67 +
  68 + private void addLogPanel(JPanel parent) {
  69 + JPanel logPanel = new JPanel(new BorderLayout());
  70 + logPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.LIGHT_GRAY));
  71 +
  72 + JLabel loglabel = new JLabel("Actions");
  73 + loglabel.setFont(titleFont);
  74 + logPanel.add(loglabel, BorderLayout.NORTH);
  75 +
  76 + logs = new JTextArea(6, 0);
  77 + logs.setEditable(false);
  78 + JScrollPane logScroll = new JScrollPane(logs, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  79 + logPanel.add(logScroll, BorderLayout.CENTER);
  80 +
  81 + parent.add(logPanel, BorderLayout.SOUTH);
  82 + }
  83 +
  84 + private void addMoveCommandsPanel(JPanel parent) {
  85 + JPanel moveCommandsPanel = new JPanel(new GridLayout(3, 3));
  86 + moveCommandsPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2, Color.LIGHT_GRAY));
  87 +
  88 + for(int i=0; i<3; i++) {
  89 + for(int j=0; j<3; j++) {
  90 + if(i == 1 && j == 1) { // central component is an image of the robot
  91 + JLabel label = new JLabel(new ImageIcon(getClass().getResource("/icons/robot.png")));
  92 + moveButtons[i][j] = null;
  93 + moveCommandsPanel.add(label);
  94 + } else {
  95 + JButton button = new JButton(new ImageIcon(getClass().getResource("/icons/move" + String.valueOf(j) + String.valueOf(i) + ".png")));
  96 + moveButtons[i][j] = button;
  97 + button.addActionListener(this);
  98 + moveCommandsPanel.add(button);
  99 + }
  100 + }
  101 + }
  102 +
  103 + parent.add(moveCommandsPanel, BorderLayout.CENTER);
  104 + }
  105 +
  106 + private void addOptionCommandsPanel(JPanel parent, JPanel optionCommandsPanel) {
  107 + optionCommandsPanel.setLayout(new BoxLayout(optionCommandsPanel, BoxLayout.PAGE_AXIS));
  108 +
  109 + // title
  110 + JLabel title = new JLabel("Options");
  111 + title.setFont(titleFont);
  112 + title.setAlignmentX(Component.LEFT_ALIGNMENT);
  113 + optionCommandsPanel.add(title);
  114 +
  115 + // steps
  116 + JPanel stepPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
  117 + stepPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  118 +
  119 + JLabel stepLabel = new JLabel("Steps : ");
  120 + stepLabel.setFont(defaultFont);
  121 + stepPanel.add(stepLabel);
  122 +
  123 + stepsField = new JTextField(10);
  124 + stepsField.setText("10");
  125 + stepsField.addFocusListener(this);
  126 + stepPanel.add(stepsField);
  127 +
  128 + optionCommandsPanel.add(stepPanel);
  129 +
  130 + //buttons
  131 + JPanel buttonsPanel = new JPanel(new GridLayout(0, 1));
  132 + buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  133 +
  134 + // wait button
  135 + waitButton = new JButton("Add a pause");
  136 + waitButton.addActionListener(this);
  137 + buttonsPanel.add(waitButton);
  138 +
  139 + // next action button
  140 + nextButton = new JButton("Next action");
  141 + nextButton.addActionListener(this);
  142 + buttonsPanel.add(nextButton);
  143 +
  144 + // revert action button
  145 + revertButton = new JButton("Revert last action");
  146 + revertButton.addActionListener(this);
  147 + buttonsPanel.add(revertButton);
  148 +
  149 + optionCommandsPanel.add(buttonsPanel);
  150 +
  151 + // separator
  152 + JSeparator sep = new JSeparator();
  153 + sep.setForeground(Color.LIGHT_GRAY);
  154 + sep.setBackground(Color.LIGHT_GRAY);
  155 + optionCommandsPanel.add(sep);
  156 +
  157 + parent.add(optionCommandsPanel, BorderLayout.EAST);
  158 + }
  159 +
  160 + private void addExportImportPanel(JPanel parent) {
  161 + JPanel exportImportPanel = new JPanel(new GridLayout(0, 1));
  162 + exportImportPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  163 +
  164 + // export
  165 + exportButton = new JButton("Export actions");
  166 + exportButton.addActionListener(this);
  167 + exportImportPanel.add(exportButton);
  168 +
  169 + // import
  170 + importButton = new JButton("Import actions");
  171 + importButton.addActionListener(this);
  172 + exportImportPanel.add(importButton);
  173 +
  174 + parent.add(exportImportPanel);
  175 + }
  176 +
  177 + @Override
  178 + public void actionPerformed(ActionEvent e) {
  179 + for(int i=0; i<3; i++) {
  180 + for(int j=0; j<3; j++) {
  181 + if(e.getSource() == moveButtons[i][j]) {
  182 + String str = stepsField.getText();
  183 + try {
  184 + if(str != null && !str.equals("")) {
  185 + long step = Long.parseLong(str);
  186 + actionList.addToActionList(i, j, step);
  187 + }
  188 + } catch (NumberFormatException ignored) {
  189 + stepsField.setBorder(BorderFactory.createLineBorder(Color.RED));
  190 + }
  191 + }
  192 + }
  193 + }
  194 + if(e.getSource() == waitButton) {
  195 + String str = JOptionPane.showInputDialog(null, "Pause duration (in miliseconds) :");
  196 + try {
  197 + if(str != null && !str.equals("")) {
  198 + long delai = Long.parseLong(str) * 1000;
  199 + actionList.completeActionAndAddPause(delai);
  200 + }
  201 + } catch (NumberFormatException ignored) {}
  202 + } else if(e.getSource() == nextButton) {
  203 + actionList.completeAction();
  204 + } else if(e.getSource() == revertButton) {
  205 + actionList.revertLastAction();
  206 + } else if(e.getSource() == exportButton) {
  207 + ImportExport.exportWithDialog(actionList);
  208 + } else if(e.getSource() == importButton) {
  209 + ActionList newActionList = ImportExport.importsWithDialog();
  210 + if(newActionList != null)
  211 + actionList = newActionList;
  212 + }
  213 + updateLogs();
  214 + }
  215 +
  216 + private void updateLogs() {
  217 + if(actionList != null)
  218 + logs.setText(actionList.toString());
  219 + }
  220 +
  221 + @Override
  222 + public void focusGained(FocusEvent e) {
  223 + if(e.getSource() == stepsField) {
  224 + stepsField.setBorder(defaultJTextFieldBorder);
  225 + stepsField.setCaretPosition(stepsField.getDocument().getLength());
  226 + }
  227 + }
  228 + @Override
  229 + public void focusLost(FocusEvent e) {}
  230 +}
... ...
PercTeacher/Sources/InvalidActionListArrays.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class InvalidActionListArrays extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public InvalidActionListArrays() {
  6 + super("Arrays to initialise an ActionList must have an equal length");
  7 + }
  8 +}
... ...
PercTeacher/Sources/InvalidInputException.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class InvalidInputException extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public InvalidInputException() {
  6 + super("Invalid Action");
  7 + }
  8 +}
... ...
PercTeacher/Sources/Main.java 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +import javax.swing.JFrame;
  2 +
  3 +/* TODO list :
  4 + * - data to send to the arduino : do action, revert action
  5 + */
  6 +
  7 +public class Main {
  8 + public static void main(String[] args) {
  9 + ActionList actionList = new ActionList();
  10 +
  11 + Interface i = new Interface(actionList);
  12 + i.setVisible(true);
  13 + i.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  14 + }
  15 +}
... ...
PercTeacher/Sources/Util.java 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +
  2 +public class Util {
  3 + public static long[][] getArraysFromImport(String str){
  4 + long[][] arrays = new long[4][];
  5 + String[] split = str.split("\n");
  6 + if(split.length < 4)
  7 + return null;
  8 +
  9 + for(int i=0; i<arrays.length; i++) {
  10 + arrays[i] = getArrayFromLine(split[i]);
  11 + if(arrays[i] == null)
  12 + return null;
  13 + }
  14 + return arrays;
  15 + }
  16 + private static long[] getArrayFromLine(String str) {
  17 + str = str.substring(1, str.length() - 2); // remove { and }
  18 + String[] longsStr = str.split("L, ");
  19 + try {
  20 + long[] longs = new long[longsStr.length];
  21 + for(int i=0; i<longs.length; i++)
  22 + longs[i] = Long.parseLong(longsStr[i]);
  23 + return longs;
  24 + } catch (NumberFormatException ignored) {}
  25 + return null;
  26 + }
  27 +}
... ...
PercTeacher/Sources/icons/Thumbs.db 0 → 100644
No preview for this file type
PercTeacher/Sources/icons/move00.png 0 → 100644

1.03 KB

PercTeacher/Sources/icons/move01.png 0 → 100644

1.07 KB

PercTeacher/Sources/icons/move02.png 0 → 100644

1.03 KB

PercTeacher/Sources/icons/move10.png 0 → 100644

605 Bytes

PercTeacher/Sources/icons/move12.png 0 → 100644

604 Bytes

PercTeacher/Sources/icons/move20.png 0 → 100644

1.03 KB

PercTeacher/Sources/icons/move21.png 0 → 100644

1016 Bytes

PercTeacher/Sources/icons/move22.png 0 → 100644

1.04 KB

PercTeacher/Sources/icons/robot.png 0 → 100644

4.42 KB