Skip to content

Commit

Permalink
Mais uma enxugada na interface. Erros amigaveis, console não trava ma…
Browse files Browse the repository at this point in the history
…is, clique duplo fantasma arrumado (testar), modo 'lento' funciona melhor, icone feio (fazer outro), x++ funciona (como statement apenas, ++x ainda não), e mais.
  • Loading branch information
anderson- committed Apr 3, 2014
1 parent 14a8905 commit 7ccd99b
Show file tree
Hide file tree
Showing 35 changed files with 1,085 additions and 667 deletions.
Binary file added examples/AlienMoveResposta.proj
Binary file not shown.
Binary file added examples/Percurso.proj
Binary file not shown.
Binary file added examples/alienRotResposta.proj
Binary file not shown.
Binary file added examples/xismaismais.proj
Binary file not shown.
2 changes: 1 addition & 1 deletion nbproject/private/private.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=/home/andy/.netbeans/7.4/build.properties
user.properties.file=/home/anderson/.netbeans/7.4/build.properties
36 changes: 24 additions & 12 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/robot/RobotControlPanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/interpreter/Interpreter.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/util/trafficsimulator/Clock.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/Block.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/robot/RobotManager.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/console/LimitLinesDocumentListener.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/If.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/begginer/Move.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/Command.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/robot/Robot.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/swing/DrawableProcedureBlock.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/GUI.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/parser/parameterparser/Argument.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/swing/MutableWidgetContainer.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/begginer/Rotate.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/sidepanel/SidePanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/swing/component/WidgetLine.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/swing/WidgetContainer.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/SimulationPanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/Procedure.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/console/MessageConsole.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/util/PrintString.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/begginer/ReadDevice.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/FlowchartBlock.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/util/StepMode.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/Comment.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/begginer/Wait.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/DrawingPanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/BreakLoop.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/FlowchartPanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/gui/panels/robot/RobotControlPanel.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/DummyBlock.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/If.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/interpreter/ResourceNotFoundException.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/drawable/swing/MutableWidgetContainer.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/interpreter/ExecutionException.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/plugin.txt</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/interpreter/Expression.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/algorithm/procedure/Function.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/plugin/cmdpack/util/PrintString.java</file>
<file>file:/home/andy/Projects/RobotInterface/src/robotinterface/robot/simulation/Environment.java</file>
</group>
</open-files>
</project-private>
Binary file added src/resources/jifi_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/wut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/robotinterface/algorithm/parser/decoder/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions src/robotinterface/algorithm/parser/decoder/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JIFIJavaCC</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
35 changes: 23 additions & 12 deletions src/robotinterface/algorithm/parser/decoder/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,21 @@ final public void ifStatement(Block b) throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ELSE:
jj_consume_token(ELSE);
block(bFalse, false);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LBRACE:
block(bFalse, false);
break;
case IF:
ifStatement(bFalse);
break;
default:
jj_la1[39] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[39] = jj_gen;
jj_la1[40] = jj_gen;
;
}
i.addLineArg(0, Argument.EXPRESSION, ex);
Expand Down Expand Up @@ -1548,18 +1559,18 @@ private boolean jj_3R_61() {
private Token jj_scanpos, jj_lastpos;
private int jj_la;
private int jj_gen;
final private int[] jj_la1 = new int[40];
final private int[] jj_la1 = new int[41];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
jj_la1_init_0();
jj_la1_init_1();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x80,0x0,0x0,0x2000000,0x688000,0x0,0x688000,0x688000,0x0,0x0,0x0,0x0,0x0,0x90000000,0x90000000,0x6c000000,0x6c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x688000,0x0,0x688000,0x0,0x0,0x0,0x288000,0x400000,0x288000,0x0,0x688000,0x689ae0,0x689ae0,0x0,0x688000,0x400,};
jj_la1_0 = new int[] {0x80,0x0,0x0,0x2000000,0x688000,0x0,0x688000,0x688000,0x0,0x0,0x0,0x0,0x0,0x90000000,0x90000000,0x6c000000,0x6c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x688000,0x0,0x688000,0x0,0x0,0x0,0x288000,0x400000,0x288000,0x0,0x688000,0x689ae0,0x689ae0,0x0,0x688000,0x200,0x400,};
}
private static void jj_la1_init_1() {
jj_la1_1 = new int[] {0x0,0x80000,0x10000,0x0,0x301103c,0x80000,0x301103c,0x300103c,0x1,0x2,0x200,0x400,0x100,0x0,0x0,0x0,0x0,0xe00000,0xe00000,0x30,0x30,0x8c0,0x8c0,0x30,0x300103c,0x3000000,0x3001000,0xc,0xc,0x110000,0x0,0x1000,0x0,0x110000,0x0,0x304503c,0x304503c,0x80000,0x300103c,0x0,};
jj_la1_1 = new int[] {0x0,0x80000,0x10000,0x0,0x301103c,0x80000,0x301103c,0x300103c,0x1,0x2,0x200,0x400,0x100,0x0,0x0,0x0,0x0,0xe00000,0xe00000,0x30,0x30,0x8c0,0x8c0,0x30,0x300103c,0x3000000,0x3001000,0xc,0xc,0x110000,0x0,0x1000,0x0,0x110000,0x0,0x304503c,0x304503c,0x80000,0x300103c,0x4000,0x0,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[4];
private boolean jj_rescan = false;
Expand All @@ -1576,7 +1587,7 @@ public Decoder(java.io.InputStream stream, String encoding) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand All @@ -1591,7 +1602,7 @@ public void ReInit(java.io.InputStream stream, String encoding) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand All @@ -1602,7 +1613,7 @@ public Decoder(java.io.Reader stream) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand All @@ -1613,7 +1624,7 @@ public void ReInit(java.io.Reader stream) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand All @@ -1623,7 +1634,7 @@ public Decoder(DecoderTokenManager tm) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand All @@ -1633,7 +1644,7 @@ public void ReInit(DecoderTokenManager tm) {
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 40; i++) jj_la1[i] = -1;
for (int i = 0; i < 41; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}

Expand Down Expand Up @@ -1750,7 +1761,7 @@ public ParseException generateParseException() {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 40; i++) {
for (int i = 0; i < 41; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/robotinterface/algorithm/parser/decoder/Function.jj
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
block.add(new Comment(getString(m)));
}| { m = mark(); } expression() ";" { if (block != null && !functionCall) { if (last == null || last.getClass() != Procedure.class) { last = new Procedure(getString(m)); block.add(last); } else { last.append(getString(m)); } } functionCall = false; }| ifStatement(block)| whileStatement(block)| < BREAK > ";" { block.add(new BreakLoop()); }| { m = mark(); } variableDeclaration() //alterar para statementExpression() para permitir a++
{ if (block != null) { if (last == null || last.getClass() != Procedure.class) { last = new Procedure(getString(m)); block.add(last); } else { last.append(getString(m)); } } }}void functionCall(Block block) :{ int m = 0; Stack < Integer > argType = new Stack < Integer > (); Stack < String > argEx = new Stack < String > (); Token tmpToken; Token functionID;}{ functionID = < IDENTIFIER > "(" [ { m = mark(); tmpToken = token; } expression() { argType.push(((tmpToken.next.image == token.image) ? token.kind : - 1)); argEx.push(getString(m)); } ( "," { m = mark(); tmpToken = token; } expression() { argType.push(((tmpToken.next.image == token.image) ? token.kind : - 1)); argEx.push(getString(m)); } )* ] { boolean error = true; for (FunctionToken ftoken : EditorPanel.getFunctionTokens()) { if (ftoken.getToken().equals(functionID.toString())) { Argument [ ] args = ParameterParser.parse(functionID.toString(), argType, argEx, - 1 /*ftoken.getParameters()*/, token); block.add(ftoken.createInstance(args)); //parameters = parameters.trim(); //block.add(ftoken.createInstance(parameters)); error = false; functionCall = true; last = null; break; } } jep.initFunTab(); // clear the contents of the function table
jep.addStandardFunctions(); for (Object o : jep.getFunctionTable().keySet()) { if (o.toString().equals(functionID.toString())) { error = false; break; } } if (error) { throw new ParseException(token, new int [ ] [ ] {} , new String [ ] { "Função \"" + functionID.toString() + "\" inválida" } ); } } ")"}void ifStatement(Block b) :{ String ex; If i = new If(); last = i; Block bTrue = i.getBlockTrue(), bFalse = i.getBlockFalse();}{ < IF > "(" { int m = mark(); } expression() { ex = getString(m); } ")" block(bTrue, false) [ < ELSE > block(bFalse, false) ] { i.addLineArg(0, Argument.EXPRESSION, ex); b.add(i); localBlock = b; }}void whileStatement(Block b) :{ While w = new While(); last = w; String ex;}{ < WHILE > "(" { int m = mark(); } expression() { ex = getString(m); } ")" block(w, false) {
jep.addStandardFunctions(); for (Object o : jep.getFunctionTable().keySet()) { if (o.toString().equals(functionID.toString())) { error = false; break; } } if (error) { throw new ParseException(token, new int [ ] [ ] {} , new String [ ] { "Função \"" + functionID.toString() + "\" inválida" } ); } } ")"}void ifStatement(Block b) :{ String ex; If i = new If(); last = i; Block bTrue = i.getBlockTrue(), bFalse = i.getBlockFalse();}{ < IF > "(" { int m = mark(); } expression() { ex = getString(m); } ")" block(bTrue, false) [ < ELSE > (block(bFalse, false) | ifStatement(bFalse)) ] { i.addLineArg(0, Argument.EXPRESSION, ex); b.add(i); localBlock = b; }}void whileStatement(Block b) :{ While w = new While(); last = w; String ex;}{ < WHILE > "(" { int m = mark(); } expression() { ex = getString(m); } ")" block(w, false) {
w.addLineArg(0, Argument.EXPRESSION, ex); b.add(w); localBlock = b; }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public final Widget setValueOf(Widget... ws) {

throw new Error("JComponent not found : " + type + ", widgets found: " + ws.length + " : " + ((ws.length > 0) ? (ws[0].getJComponent().getClass().getSimpleName()) : "null"));
}

@Deprecated
public String getStatement(){
return statement;
}

@Override
public final String toString() {
Expand Down
2 changes: 1 addition & 1 deletion src/robotinterface/algorithm/procedure/DummyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void splitBoxLabel(String original, Collection<String> splitted) {
@Override
public GraphicObject getDrawableResource() {
if (resource == null) {
resource = createSimpleBlock(" vazio ", Color.LIGHT_GRAY, Color.LIGHT_GRAY);
resource = createSimpleBlock(" - ", Color.LIGHT_GRAY, Color.LIGHT_GRAY);
}
return resource;
}
Expand Down
7 changes: 4 additions & 3 deletions src/robotinterface/algorithm/procedure/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected FunctionEnd() {
@Override
public GraphicObject getDrawableResource() {
if (resource == null) {
resource = createSimpleBlock(" fim ", Color.black, Color.black);
resource = createSimpleBlock(" END ", Color.black, Color.decode("#631864"));
}
return resource;
}
Expand All @@ -89,7 +89,7 @@ public void toString(String ident, StringBuilder sb) {
}
}

private String name = "meuPrograma";
private String name = "prog";
private ArrayList<String> args;

public Function() {
Expand Down Expand Up @@ -465,7 +465,8 @@ public String getBoxLabel() {
@Override
public GraphicObject getDrawableResource() {
if (resource == null) {
resource = createDrawableFunction(this);
//resource = createDrawableFunction(this);
resource = createSimpleBlock(" BEGIN ", Color.black, Color.decode("#631864"));
}
return resource;
}
Expand Down
2 changes: 1 addition & 1 deletion src/robotinterface/algorithm/procedure/If.java
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ public void drawLines(Graphics2D g) {
GraphicFlowchart.GF_K);

//true
g.drawString("V", (int) bTrueStart.getCenterX() - 3, (int) bThis.getCenterY() - 4);
g.drawString("T", (int) bTrueStart.getCenterX() - 3, (int) bThis.getCenterY() - 4);

path.moveTo(bThis.getCenterX(), bThis.getCenterY());
path.lineTo(bTrueStart.getCenterX(), bThis.getCenterY());
Expand Down
21 changes: 19 additions & 2 deletions src/robotinterface/algorithm/procedure/Procedure.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JTextField;
Expand Down Expand Up @@ -70,6 +72,7 @@ public class Procedure extends Command implements Classifiable {
private ArrayList<Argument> myArgs;
private String procedure;
private boolean varArgs;
private Pattern p = Pattern.compile("(\\S+)(\\+\\+)");

public Procedure() { //tornar private
varArgs = true;
Expand Down Expand Up @@ -176,9 +179,23 @@ protected final Object execute(String procedure, ResourceManager rm) throws Exec
}

for (String str : procedure.split(";")) {
if (!str.startsWith("var")) {
str = str.trim();
if (!(str.startsWith("var") || str.isEmpty())) {

Matcher m = p.matcher(str);
if (m.find()) {
String valid = m.group(1) + " = " + m.group(1) + " + 1";
if (this.procedure.equals(procedure)) {
this.procedure = procedure.replace(str, valid);
}
str = valid;
}

parser.parseExpression(str);
o = parser.getValueAsObject();
if (parser.hasError()) {
throw new ExecutionException(parser.getErrorInfo() + " in \"" + str + "\"");
}
}
}

Expand Down Expand Up @@ -269,7 +286,7 @@ public Argument addLineArg(int index, int type, Object data) {
}
}
Argument arg = myArgs.get(index);
if (data != nill){
if (data != nill) {
arg.set(data, type);
}
return arg;
Expand Down
2 changes: 0 additions & 2 deletions src/robotinterface/algorithm/procedure/While.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public Command step(ResourceManager rm) throws ExecutionException {

if (evaluate(rm)) {
return start;
} else {
System.out.println("fail: " + super.getProcedure());
}
return super.step(rm);
}
Expand Down
9 changes: 9 additions & 0 deletions src/robotinterface/drawable/DrawingPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public DrawingPanel(Clock c, boolean autoFullSize) {
public DrawingPanel() {
this(new Clock());
}

public Clock getClock(){
return clock;
}

private void addListeners() {
this.addMouseListener(this);
Expand Down Expand Up @@ -936,6 +940,11 @@ public Point getMouseDrag() {
public int getMouseWheelRotation() {
return mouseWheelRotation;
}

public void getMouseClickConsume() {
mouseClickCount = 0;
mouseClick = false;
}
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public void draw(Graphics2D g, DrawingPanel.GraphicAttributes ga, DrawingPanel.I
if (widgetsEnabled & in.mouseClicked() && in.getMouseClickCount() == 2) {
setWidgetVisible(!isWidgetVisible());
shapeBounds.setRect(0, 0, 0, 0);
in.getMouseClickConsume();
}

//sombra
Expand Down
Loading

0 comments on commit 7ccd99b

Please sign in to comment.