diff --git a/.gitignore b/.gitignore index c2463b8..f93ade3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ snap/ target/ debian/ +*.java~ *.class # Mobile Tools for Java (J2ME) diff --git a/README.md b/README.md index 5f49b60..625de6d 100644 --- a/README.md +++ b/README.md @@ -69,5 +69,5 @@ mvn clean package ## Run ```sh -java -jar target/torgo-1.5.0.jar +java -jar target/torgo-1.6.0.jar ``` diff --git a/TorgoInstallBuilder.xml b/TorgoInstallBuilder.xml index 208e420..6333d6f 100644 --- a/TorgoInstallBuilder.xml +++ b/TorgoInstallBuilder.xml @@ -1,7 +1,7 @@ Torgo Torgo - 1.5.0 + 1.6.0 src/main/resources/torgo-48x48.png src/main/resources/org/tros/images/splash.png diff --git a/circle.yml b/circle.yml index 285fb01..bd9776b 100644 --- a/circle.yml +++ b/circle.yml @@ -6,6 +6,10 @@ test: - mvn -DskipTests=false clean cobertura:cobertura post: - bash <(curl -s https://codecov.io/bash) +general: + branches: + ignore: + - gh-pages #general: # branches: # only: diff --git a/codecov.yml b/codecov.yml index c2cc21d..d3ee397 100644 --- a/codecov.yml +++ b/codecov.yml @@ -14,7 +14,15 @@ coverage: patch: true project: true ignore: +#auto-generated files - .*/antlr/.* + - .*/rsyntax/.* +#contrib files + - .*/org/tros/torgo/swing/JConsole.* + - .*/org/tros/torgo/viz/SpringUtilities.* + - .*/org/tros/utils/swing/JLinkButton.* +#literally untestable in junit + - .*/org/tros/torgo/MainSplash.* parsers: gcov: branch_detection: diff --git a/licenseheader.txt b/licenseheader.txt index bc5421a..a3f4ef5 100644 --- a/licenseheader.txt +++ b/licenseheader.txt @@ -1,7 +1,7 @@ <#if licenseFirst??> ${licenseFirst} -${licensePrefix}Copyright 2015-2016 Matthew Aguirre +${licensePrefix}Copyright 2015-2017 Matthew Aguirre ${licensePrefix} ${licensePrefix}Licensed under the Apache License, Version 2.0 (the "License"); ${licensePrefix}you may not use this file except in compliance with the License. diff --git a/pom.xml b/pom.xml index f9521de..186ec0f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.tros torgo - 1.5.0 + 1.6.0 jar torgo http://tros.org/torgo/ @@ -166,6 +166,42 @@ + + forMac + + false + + build.app + true + + + + + + sh.tak.appbundler + appbundle-maven-plugin + 1.2.0 + + org.tros.torgo.Main + true + torgo.icns + 1.8+ + ${project.version} + Dsun.java2d.opengl=true + 2015-2017 Matthew Aguirre + + + + package + + bundle + + + + + + + forWindows @@ -219,6 +255,18 @@ + org.apache.maven.plugins maven-surefire-plugin @@ -240,6 +288,7 @@ org.apache.commons.beanutils.Converter org.tros.utils.converters.ConverterRegister org.tros.torgo.InterpreterVisualization + org.fife.ui.rsyntaxtextarea.TokenMakerRegistration @@ -312,7 +361,7 @@ html xml - + @@ -360,7 +409,7 @@ 4.6 - com.fifesoft + org.tros rsyntaxtextarea 2.6.0 diff --git a/snapcraft.yaml b/snapcraft.yaml index cdd8589..41d91e1 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,5 +1,5 @@ name: torgo -version: 1.5.0 +version: 1.6.0 summary: A Logo interpreter written in Java. description: A Logo interpreter written in Java. grade: stable @@ -16,7 +16,7 @@ parts: plugin: maven source: . maven-options: - - -DskipTests + - -DskipTests=true stage-packages: - fontconfig-config - default-jdk diff --git a/src/main/java/org/tros/logo/DynamicLogoController.java b/src/main/java/org/tros/logo/DynamicLogoController.java index 5e70205..a6c32d3 100644 --- a/src/main/java/org/tros/logo/DynamicLogoController.java +++ b/src/main/java/org/tros/logo/DynamicLogoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/ExpressionListener.java b/src/main/java/org/tros/logo/ExpressionListener.java index eee5e46..344dd1a 100644 --- a/src/main/java/org/tros/logo/ExpressionListener.java +++ b/src/main/java/org/tros/logo/ExpressionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LexicalListener.java b/src/main/java/org/tros/logo/LexicalListener.java index 40a53e4..7ba8a59 100644 --- a/src/main/java/org/tros/logo/LexicalListener.java +++ b/src/main/java/org/tros/logo/LexicalListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LexicalLogoController.java b/src/main/java/org/tros/logo/LexicalLogoController.java index b7f5306..e1ce852 100644 --- a/src/main/java/org/tros/logo/LexicalLogoController.java +++ b/src/main/java/org/tros/logo/LexicalLogoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoBlock.java b/src/main/java/org/tros/logo/LogoBlock.java index f9a7239..97ff2c1 100644 --- a/src/main/java/org/tros/logo/LogoBlock.java +++ b/src/main/java/org/tros/logo/LogoBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoCanvas.java b/src/main/java/org/tros/logo/LogoCanvas.java index 9b5e417..b7e1d3f 100644 --- a/src/main/java/org/tros/logo/LogoCanvas.java +++ b/src/main/java/org/tros/logo/LogoCanvas.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoController.java b/src/main/java/org/tros/logo/LogoController.java index 2c26263..3239801 100644 --- a/src/main/java/org/tros/logo/LogoController.java +++ b/src/main/java/org/tros/logo/LogoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoFor.java b/src/main/java/org/tros/logo/LogoFor.java index e06d0cf..afbd3e0 100644 --- a/src/main/java/org/tros/logo/LogoFor.java +++ b/src/main/java/org/tros/logo/LogoFor.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoFunction.java b/src/main/java/org/tros/logo/LogoFunction.java index 8cafe02..0c05a14 100644 --- a/src/main/java/org/tros/logo/LogoFunction.java +++ b/src/main/java/org/tros/logo/LogoFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoIf.java b/src/main/java/org/tros/logo/LogoIf.java index 951fd0e..dc8df58 100644 --- a/src/main/java/org/tros/logo/LogoIf.java +++ b/src/main/java/org/tros/logo/LogoIf.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoProg.java b/src/main/java/org/tros/logo/LogoProg.java index 6394032..0d5f7ec 100644 --- a/src/main/java/org/tros/logo/LogoProg.java +++ b/src/main/java/org/tros/logo/LogoProg.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoRepeat.java b/src/main/java/org/tros/logo/LogoRepeat.java index a860085..6ef9d10 100644 --- a/src/main/java/org/tros/logo/LogoRepeat.java +++ b/src/main/java/org/tros/logo/LogoRepeat.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/LogoStatement.java b/src/main/java/org/tros/logo/LogoStatement.java index 195d9e8..e9618fa 100644 --- a/src/main/java/org/tros/logo/LogoStatement.java +++ b/src/main/java/org/tros/logo/LogoStatement.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.flex b/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.flex new file mode 100644 index 0000000..f322d54 --- /dev/null +++ b/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.flex @@ -0,0 +1,322 @@ +/* + * 11/13/2004 + * + * LogoTokenMaker.java - Scanner for the Logo programming language. + * + * This library is distributed under a modified BSD license. See the included + * RSyntaxTextArea.License.txt file for details. + */ +package org.tros.logo.rsyntax; + +import java.io.*; +import javax.swing.text.Segment; + +import org.fife.ui.rsyntaxtextarea.*; + + +/** + * Scanner for the Logo programming language.

+ * + * This implementation was created using + * JFlex 1.4.1; however, the generated file + * was modified for performance. Memory allocation needs to be almost + * completely removed to be competitive with the handwritten lexers (subclasses + * of AbstractTokenMaker, so this class has been modified so that + * Strings are never allocated (via yytext()), and the scanner never has to + * worry about refilling its buffer (needlessly copying chars around). + * We can achieve this because RText always scans exactly 1 line of tokens at a + * time, and hands the scanner this line as an array of characters (a Segment + * really). Since tokens contain pointers to char arrays instead of Strings + * holding their contents, there is no need for allocating new memory for + * Strings.

+ * + * The actual algorithm generated for scanning has, of course, not been + * modified.

+ * + * If you wish to regenerate this file yourself, keep in mind the following: + *

    + *
  • The generated LogoTokenMaker.java file will contain two + * definitions of both zzRefill and yyreset. + * You should hand-delete the second of each definition (the ones + * generated by the lexer), as these generated methods modify the input + * buffer, which we'll never have to do.
  • + *
  • You should also change the declaration/definition of zzBuffer to NOT + * be initialized. This is a needless memory allocation for us since we + * will be pointing the array somewhere else anyway.
  • + *
  • You should NOT call yylex() on the generated scanner + * directly; rather, you should use getTokenList as you would + * with any other TokenMaker instance.
  • + *
+ * + * @author Robert Futrell + * @version 0.5 + * + */ +%% + +%public +%class LogoTokenMaker +%extends AbstractJFlexTokenMaker +%unicode +%type org.fife.ui.rsyntaxtextarea.Token + + +%{ + + + /** + * Constructor. This must be here because JFlex does not generate a + * no-parameter constructor. + */ + public LogoTokenMaker() { + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + * @see #addToken(int, int, int) + */ + private void addHyperlinkToken(int start, int end, int tokenType) { + int so = start + offsetShift; + addToken(zzBuffer, start,end, tokenType, so, true); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + */ + private void addToken(int tokenType) { + addToken(zzStartRead, zzMarkedPos-1, tokenType); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + * @see #addHyperlinkToken(int, int, int) + */ + private void addToken(int start, int end, int tokenType) { + int so = start + offsetShift; + addToken(zzBuffer, start,end, tokenType, so, false); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param array The character array. + * @param start The starting offset in the array. + * @param end The ending offset in the array. + * @param tokenType The token's type. + * @param startOffset The offset in the document at which this token + * occurs. + * @param hyperlink Whether this token is a hyperlink. + */ + @Override + public void addToken(char[] array, int start, int end, int tokenType, + int startOffset, boolean hyperlink) { + super.addToken(array, start,end, tokenType, startOffset, hyperlink); + zzStartRead = zzMarkedPos; + } + + + /** + * {@inheritDoc} + */ + @Override + public String[] getLineCommentStartAndEnd(int languageIndex) { + return new String[] { ";", null }; + } + + + /** + * Returns the first token in the linked list of tokens generated + * from text. This method must be implemented by + * subclasses so they can correctly implement syntax highlighting. + * + * @param text The text from which to get tokens. + * @param initialTokenType The token type we should start with. + * @param startOffset The offset into the document at which + * text starts. + * @return The first Token in a linked list representing + * the syntax highlighted text. + */ + public Token getTokenList(Segment text, int initialTokenType, int startOffset) { + + resetTokenList(); + this.offsetShift = -text.offset + startOffset; + + // Start off in the proper state. + int state = Token.NULL; + + s = text; + try { + yyreset(zzReader); + yybegin(state); + return yylex(); + } catch (IOException ioe) { + ioe.printStackTrace(); + return new TokenImpl(); + } + + } + + + /** + * Refills the input buffer. + * + * @return true if EOF was reached, otherwise + * false. + */ + private boolean zzRefill() { + return zzCurrentPos>=s.offset+s.count; + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to YY_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(Reader reader) { + // 's' has been updated. + zzBuffer = s.array; + /* + * We replaced the line below with the two below it because zzRefill + * no longer "refills" the buffer (since the way we do it, it's always + * "full" the first time through, since it points to the segment's + * array). So, we assign zzEndRead here. + */ + //zzStartRead = zzEndRead = s.offset; + zzStartRead = s.offset; + zzEndRead = zzStartRead + s.count - 1; + zzCurrentPos = zzMarkedPos = s.offset; + zzLexicalState = YYINITIAL; + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + } + + +%} + +Letter = [A-Za-z] +LetterOrUnderscore = ({Letter}|"_") +NonzeroDigit = [1-9] +Digit = ("0"|{NonzeroDigit}) +HexDigit = ({Digit}|[A-Fa-f]) +OctalDigit = ([0-7]) +EscapedSourceCharacter = ("u"{HexDigit}{HexDigit}{HexDigit}{HexDigit}) +NonSeparator = ([^\t\f\r\n\ \(\)\{\}\[\]\;\,\.\=\>\<\!\~\?\:\+\-\*\/\&\|\^\%\"\']|"#"|"\\") +IdentifierStart = ({LetterOrUnderscore}|"$") +IdentifierPart = ({IdentifierStart}|{Digit}|("\\"{EscapedSourceCharacter})) + +LineTerminator = (\n) +WhiteSpace = ([ \t\f]) + +LineCommentBegin = ";" + +IntegerHelper1 = (({NonzeroDigit}{Digit}*)|"0") +IntegerHelper2 = ("0"(([xX]{HexDigit}+)|({OctalDigit}*))) +IntegerLiteral = ({IntegerHelper1}[lL]?) +HexLiteral = ({IntegerHelper2}[lL]?) +FloatHelper1 = ([fFdD]?) +FloatHelper2 = ([eE][+-]?{Digit}+{FloatHelper1}) +FloatLiteral1 = ({Digit}+"."({FloatHelper1}|{FloatHelper2}|{Digit}+({FloatHelper1}|{FloatHelper2}))) +FloatLiteral2 = ("."{Digit}+({FloatHelper1}|{FloatHelper2})) +FloatLiteral3 = ({Digit}+{FloatHelper2}) +FloatLiteral = ({FloatLiteral1}|{FloatLiteral2}|{FloatLiteral3}|({Digit}+[fFdD])) +ErrorNumberFormat = (({IntegerLiteral}|{HexLiteral}|{FloatLiteral}){NonSeparator}+) + +Separator = ([\(\)]) + +NonAssignmentOperator = ("+"|"-"|"<="|"^"|"<"|"*"|">="|"%"|">"|"/"|"\\"|"!="|"=="|"|"|"&&") +Operator = ({NonAssignmentOperator}) + +Identifier = ({IdentifierStart}{IdentifierPart}*) +ErrorIdentifier = ({NonSeparator}+) + +URLGenDelim = ([:\/\?#\[\]@]) +URLSubDelim = ([\!\$&'\(\)\*\+,;=]) +URLUnreserved = ({LetterOrUnderscore}|{Digit}|[\-\.\~]) +URLCharacter = ({URLGenDelim}|{URLSubDelim}|{URLUnreserved}|[%]) +URLCharacters = ({URLCharacter}*) +URLEndCharacter = ([\/\$]|{Letter}|{Digit}) +URL = (((https?|f(tp|ile))"://"|"www.")({URLCharacters}{URLEndCharacter})?) + + +%state EOL_COMMENT + +%% + + { + + "ds" | "drawstring" | "label"| + "pu" | "penup" | + "pd" | "pendown" | + "to" | "end" | + "cs" | "clear" | "clearscreen" | "cls" | + "fd" | "forward" | + "bk" | "backward" | "back" | + "rt" | "right" | + "lt" | "left" | + "cc" | "canvascolor" | + "pc" | "pencolor" | + "st" | "showturtle" | + "ht" | "hideturtle" | + "random" | + "print" | + "if" | + "for" | + "repeat" | + "pause" | + "fontsize" | "fontname" | "fontstyle" | + "bold" | "plain" | "italic" | "bold_italic" | + "setxy" | "getx" | "gety" | "getangle" | + "stop" | + "home" | + "make" | "localmake" + { addToken(Token.RESERVED_WORD); } + + {LineTerminator} { addNullToken(); return firstToken; } + {Identifier} { addToken(Token.IDENTIFIER); } + {WhiteSpace}+ { addToken(Token.WHITESPACE); } + {LineCommentBegin} { start = zzMarkedPos-1; yybegin(EOL_COMMENT); } + {Separator} { addToken(Token.SEPARATOR); } + {Operator} { addToken(Token.OPERATOR); } + + /* Numbers */ + {IntegerLiteral} { addToken(Token.LITERAL_NUMBER_DECIMAL_INT); } + {HexLiteral} { addToken(Token.LITERAL_NUMBER_HEXADECIMAL); } + {FloatLiteral} { addToken(Token.LITERAL_NUMBER_FLOAT); } + {ErrorNumberFormat} { addToken(Token.ERROR_NUMBER_FORMAT); } + + {ErrorIdentifier} { addToken(Token.ERROR_IDENTIFIER); } + + /* Ended with a line not in a string or comment. */ + <> { addNullToken(); return firstToken; } + + /* Catch any other (unhandled) characters and flag them as bad. */ + . { addToken(Token.ERROR_IDENTIFIER); } + +} + + + { + [^hwf\n]+ {} + {URL} { int temp=zzStartRead; addToken(start,zzStartRead-1, Token.COMMENT_EOL); addHyperlinkToken(temp,zzMarkedPos-1, Token.COMMENT_EOL); start = zzMarkedPos; } + [hwf] {} + \n { addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; } + <> { addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; } + +} diff --git a/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.java b/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.java new file mode 100644 index 0000000..caa513e --- /dev/null +++ b/src/main/java/org/tros/logo/rsyntax/LogoTokenMaker.java @@ -0,0 +1,981 @@ +/* The following code was generated by JFlex 1.4.1 on 1/11/17 10:38 AM */ + +/* + * 11/13/2004 + * + * LogoTokenMaker.java - Scanner for the Logo programming language. + * + * This library is distributed under a modified BSD license. See the included + * RSyntaxTextArea.License.txt file for details. + */ +package org.tros.logo.rsyntax; + +import java.io.*; +import javax.swing.text.Segment; + +import org.fife.ui.rsyntaxtextarea.*; + + +/** + * Scanner for the Logo programming language.

+ * + * This implementation was created using + * JFlex 1.4.1; however, the generated file + * was modified for performance. Memory allocation needs to be almost + * completely removed to be competitive with the handwritten lexers (subclasses + * of AbstractTokenMaker, so this class has been modified so that + * Strings are never allocated (via yytext()), and the scanner never has to + * worry about refilling its buffer (needlessly copying chars around). + * We can achieve this because RText always scans exactly 1 line of tokens at a + * time, and hands the scanner this line as an array of characters (a Segment + * really). Since tokens contain pointers to char arrays instead of Strings + * holding their contents, there is no need for allocating new memory for + * Strings.

+ * + * The actual algorithm generated for scanning has, of course, not been + * modified.

+ * + * If you wish to regenerate this file yourself, keep in mind the following: + *

    + *
  • The generated LogoTokenMaker.java file will contain two + * definitions of both zzRefill and yyreset. + * You should hand-delete the second of each definition (the ones + * generated by the lexer), as these generated methods modify the input + * buffer, which we'll never have to do.
  • + *
  • You should also change the declaration/definition of zzBuffer to NOT + * be initialized. This is a needless memory allocation for us since we + * will be pointing the array somewhere else anyway.
  • + *
  • You should NOT call yylex() on the generated scanner + * directly; rather, you should use getTokenList as you would + * with any other TokenMaker instance.
  • + *
+ * + * @author Robert Futrell + * @version 0.5 + * + */ + +public class LogoTokenMaker extends AbstractJFlexTokenMaker { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int EOL_COMMENT = 1; + public static final int YYINITIAL = 0; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\14\1\13\1\0\1\14\1\10\22\0\1\14\1\32\1\10"+ + "\1\11\1\1\1\30\1\33\1\34\2\24\1\30\1\22\1\34\1\22"+ + "\1\23\1\31\1\4\7\6\2\3\1\45\1\15\1\25\1\26\1\25"+ + "\1\34\1\11\3\5\1\20\1\21\1\20\5\1\1\17\13\1\1\16"+ + "\2\1\1\34\1\12\1\34\1\27\1\2\1\0\1\51\1\54\1\56"+ + "\1\47\1\44\1\41\1\53\1\35\1\42\1\1\1\57\1\43\1\61"+ + "\1\52\1\55\1\37\1\1\1\50\1\40\1\36\1\7\1\60\1\46"+ + "\1\64\1\63\1\62\1\10\1\27\1\10\1\34\uff81\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\2\0\1\1\1\2\2\3\1\1\1\4\1\5\1\6"+ + "\1\7\1\4\1\1\1\10\1\4\2\1\16\2\1\11"+ + "\1\12\3\11\1\1\1\13\1\3\1\14\1\13\1\14"+ + "\1\13\1\15\1\13\1\16\7\2\1\16\21\2\4\0"+ + "\1\1\1\14\1\0\2\15\11\2\1\16\16\2\4\0"+ + "\1\1\16\2\1\16\2\2\2\0\1\17\1\1\14\2"+ + "\1\16\1\2\2\0\1\1\21\2"; + + private static int [] zzUnpackAction() { + int [] result = new int[164]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\65\0\152\0\237\0\324\0\u0109\0\u013e\0\152"+ + "\0\u013e\0\u0173\0\u013e\0\u013e\0\u01a8\0\u013e\0\u01dd\0\u01dd"+ + "\0\u0212\0\u0247\0\u027c\0\u02b1\0\u02e6\0\u031b\0\u0350\0\u0385"+ + "\0\u03ba\0\u03ef\0\u0424\0\u0459\0\u048e\0\u04c3\0\u04f8\0\u052d"+ + "\0\u013e\0\u0562\0\u0597\0\u05cc\0\u0601\0\u0636\0\u0636\0\u0636"+ + "\0\u066b\0\u06a0\0\u06d5\0\u070a\0\u073f\0\237\0\u0774\0\u07a9"+ + "\0\u07de\0\u0813\0\u0848\0\u087d\0\u08b2\0\u08e7\0\u091c\0\u0951"+ + "\0\u0986\0\u09bb\0\u09f0\0\u0a25\0\u0a5a\0\u0a8f\0\u0ac4\0\u0af9"+ + "\0\u0b2e\0\u0b63\0\u0b98\0\u0bcd\0\u0c02\0\u0c37\0\u0c6c\0\u0ca1"+ + "\0\u0cd6\0\u0d0b\0\u0d40\0\u0d75\0\u0daa\0\u0ddf\0\u0636\0\u0e14"+ + "\0\u0e49\0\u0e7e\0\u0eb3\0\u0ee8\0\u0f1d\0\u0f52\0\u0f87\0\u0fbc"+ + "\0\u0ff1\0\u1026\0\u105b\0\u1090\0\u10c5\0\u10fa\0\u112f\0\u1164"+ + "\0\u1199\0\u11ce\0\u1203\0\u1238\0\u126d\0\u12a2\0\u12d7\0\u130c"+ + "\0\u1341\0\u1376\0\u13ab\0\u13e0\0\u1415\0\u144a\0\u147f\0\u14b4"+ + "\0\u14e9\0\u151e\0\u1553\0\u1588\0\u15bd\0\u15f2\0\u1627\0\u165c"+ + "\0\u1691\0\u16c6\0\u16fb\0\u1730\0\u1765\0\u179a\0\u17cf\0\u1804"+ + "\0\u1839\0\u186e\0\u18a3\0\u18d8\0\u190d\0\u1942\0\u1977\0\u19ac"+ + "\0\u19e1\0\u1a16\0\u1a4b\0\u1a80\0\u1ab5\0\u1aea\0\u1b1f\0\u1b54"+ + "\0\u1b89\0\u1839\0\u1bbe\0\u1bf3\0\u1c28\0\u1c5d\0\u1c92\0\u1cc7"+ + "\0\u1cfc\0\u1d31\0\u1d66\0\u1d9b\0\u1dd0\0\u1e05\0\u1e3a\0\u1e6f"+ + "\0\u1ea4\0\u1ed9\0\u1f0e\0\u1f43"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[164]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\3\2\4\1\5\1\6\1\4\1\5\1\4\1\7"+ + "\1\3\1\10\1\11\1\12\1\13\4\4\1\14\1\15"+ + "\1\16\1\17\1\20\3\14\1\20\1\21\1\7\1\22"+ + "\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\7"+ + "\1\4\1\32\1\33\2\4\1\34\1\35\1\4\1\36"+ + "\2\4\1\37\3\4\13\40\1\41\21\40\1\42\3\40"+ + "\1\43\4\40\1\44\16\40\10\3\1\0\2\3\3\0"+ + "\4\3\13\0\10\3\1\0\20\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\17\4\3\46"+ + "\2\5\1\46\1\5\1\46\1\0\2\46\3\0\1\46"+ + "\1\47\1\50\1\51\1\0\1\52\11\0\4\46\1\50"+ + "\1\46\1\47\1\51\1\0\1\46\1\50\20\46\1\53"+ + "\1\54\1\46\1\54\1\46\1\0\2\46\3\0\1\55"+ + "\1\47\1\50\1\51\1\0\1\52\11\0\4\46\1\50"+ + "\1\46\1\47\1\51\1\0\1\46\1\50\14\46\1\55"+ + "\101\0\1\12\53\0\2\52\1\0\1\52\104\0\1\14"+ + "\71\0\1\14\31\0\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\1\4\1\56\3\4\1\57\2\4"+ + "\1\0\7\4\1\60\7\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\7\4\1\56"+ + "\7\4\1\3\6\4\1\56\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\6\4\1\61\1\62\1\0\1\4\1\56"+ + "\1\63\1\64\4\4\1\56\6\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\1\65\1\66\5\4"+ + "\1\67\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\1\4\1\56\5\4"+ + "\1\70\7\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\1\4\1\71\2\4\1\56\3\4\1\0"+ + "\17\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\1\4\1\56\5\4\1\72\1\0\3\4\1\73"+ + "\3\4\1\74\7\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\4\4\1\75\12\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\3\4\1\56\4\4\1\0\2\4\1\76\14\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\1\4"+ + "\1\56\3\4\1\77\1\4\1\100\1\0\3\4\1\101"+ + "\13\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\7\4\1\102\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\3\4"+ + "\1\103\3\4\1\104\1\4\1\56\5\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\3\4\1\56"+ + "\2\4\1\105\1\4\1\0\3\4\1\106\4\4\1\56"+ + "\6\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\3\4\1\107\13\4\13\40\1\0"+ + "\21\40\1\0\3\40\1\0\4\40\1\0\16\40\36\0"+ + "\1\110\64\0\1\111\3\0\1\112\70\0\1\113\16\0"+ + "\7\3\1\114\1\0\2\3\3\0\4\3\13\0\10\3"+ + "\1\0\17\3\10\46\1\0\2\46\3\0\4\46\13\0"+ + "\10\46\1\0\22\46\2\115\1\46\1\115\1\46\1\0"+ + "\2\46\3\0\4\46\1\116\12\0\10\46\1\0\22\46"+ + "\2\52\1\46\1\52\1\46\1\0\2\46\3\0\2\46"+ + "\1\50\1\51\13\0\4\46\1\50\2\46\1\51\1\0"+ + "\1\46\1\50\20\46\2\53\1\46\1\53\1\46\1\0"+ + "\2\46\3\0\2\46\1\50\1\51\1\0\1\52\11\0"+ + "\4\46\1\50\2\46\1\51\1\0\1\46\1\50\20\46"+ + "\1\53\1\54\1\46\1\54\1\46\1\0\2\46\3\0"+ + "\1\46\1\117\1\50\1\51\1\0\1\52\11\0\4\46"+ + "\1\50\1\46\1\117\1\51\1\0\1\46\1\50\20\46"+ + "\4\120\1\46\1\0\2\46\3\0\2\46\2\120\13\0"+ + "\4\46\1\120\2\46\1\120\1\0\1\46\1\120\1\46"+ + "\1\120\2\46\1\120\1\46\1\120\6\46\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\10\4\1\0"+ + "\1\4\1\121\15\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\13\4\1\122\3\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\3\4\1\123\13\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\4\4"+ + "\1\124\12\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\5\4\1\125\2\4\1\0\17\4\1\3"+ + "\6\4\1\126\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\7\4\1\127\7\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\7\4\1\130\7\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\1\4\1\131\6\4"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\2\4\1\132\1\4\1\133"+ + "\12\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\3\4\1\134\13\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\4\4\1\135"+ + "\3\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\6\4\1\136\10\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\10\4\1\137\6\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\1\4"+ + "\1\56\15\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\3\4\1\140\13\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\5\4\1\141\11\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\2\4\1\142\5\4\1\0"+ + "\17\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\4\4\1\143\12\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\1\4\1\144"+ + "\6\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\10\4\1\145\6\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\6\4\1\146\1\4\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\3\4\1\56\3\4"+ + "\1\147\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\4\4\1\150\12\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\11\4\1\122\5\4\36\0\1\151\65\0"+ + "\1\152\70\0\1\153\67\0\1\154\16\0\3\3\4\155"+ + "\1\3\1\0\2\3\3\0\2\3\2\155\13\0\4\3"+ + "\1\155\2\3\1\155\1\0\1\3\1\155\1\3\1\155"+ + "\2\3\1\155\1\3\1\155\6\3\3\46\2\115\1\46"+ + "\1\115\1\46\1\0\2\46\3\0\2\46\1\50\1\46"+ + "\13\0\4\46\1\50\3\46\1\0\1\46\1\50\15\46"+ + "\3\0\2\115\1\0\1\115\56\0\3\46\4\120\1\46"+ + "\1\0\2\46\3\0\1\46\1\117\2\120\13\0\4\46"+ + "\1\120\1\46\1\117\1\120\1\0\1\46\1\120\1\46"+ + "\1\120\2\46\1\120\1\46\1\120\6\46\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\7\4\1\156"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\7\4\1\56\1\0\17\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\5\4\1\157"+ + "\2\4\1\0\17\4\1\3\6\4\1\130\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\1\4\1\160"+ + "\6\4\1\161\6\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\4\4\1\135\12\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\3\4\1\122\4\4\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\1\156"+ + "\16\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\2\4\1\56\5\4\1\0\17\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\10\4\1\0"+ + "\16\4\1\162\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\1\163\16\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\1\4\1\164"+ + "\6\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\6\4\1\165\1\4\1\0\17\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\1\4\1\56\6\4\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\7\4\1\166\1\0"+ + "\17\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\3\4\1\167\13\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\10\4\1\0"+ + "\1\170\16\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\1\135\7\4\1\0\17\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\7\4\1\171"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\1\4\1\172\15\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\3\4\1\173\11\4\2\56\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\11\4"+ + "\1\132\5\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\1\4\1\174\15\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\3\4\1\175\13\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\12\4\1\176"+ + "\4\4\37\0\1\177\72\0\1\200\63\0\1\152\43\0"+ + "\1\201\41\0\3\3\4\202\1\3\1\0\2\3\3\0"+ + "\2\3\2\202\13\0\4\3\1\202\2\3\1\202\1\0"+ + "\1\3\1\202\1\3\1\202\2\3\1\202\1\3\1\202"+ + "\7\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\1\4\1\203\6\4\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\4\4"+ + "\1\56\12\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\7\4\1\204\7\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\7\4\1\205\7\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\15\4\1\56"+ + "\1\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\3\4\1\206\13\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\3\4\1\207"+ + "\4\4\1\0\4\4\1\210\12\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\5\4\1\211\2\4"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\6\4\1\56\1\4\1\0\17\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\6\4"+ + "\1\212\1\4\1\0\17\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\3\4\1\213\4\4\1\0"+ + "\17\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\3\4\1\135\13\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\10\4\1\0"+ + "\7\4\1\214\7\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\4\4\1\215\12\4"+ + "\1\3\1\4\1\216\5\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\17\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\2\4"+ + "\1\217\14\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\3\4\1\220\13\4\40\0"+ + "\1\152\4\0\1\200\50\0\1\221\34\0\1\201\1\222"+ + "\5\201\1\0\1\222\3\0\1\222\4\201\3\222\1\0"+ + "\1\222\1\0\1\222\1\201\3\222\10\201\1\222\17\201"+ + "\3\3\4\223\1\3\1\0\2\3\3\0\2\3\2\223"+ + "\13\0\4\3\1\223\2\3\1\223\1\0\1\3\1\223"+ + "\1\3\1\223\2\3\1\223\1\3\1\223\7\3\6\4"+ + "\1\224\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\1\157\16\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\6\4\1\225"+ + "\1\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\2\4\1\75\14\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\1\4\1\226\3\4\1\227\2\4\1\0\17\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\3\4\1\60\13\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\10\4\1\56"+ + "\6\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\13\4\1\37\3\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\1\4\1\230"+ + "\6\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\10\4\1\0\13\4\1\56\3\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\5\4\1\231\11\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\5\4\1\232\2\4"+ + "\1\0\17\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\3\4\1\233\4\4\1\0\17\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\3\4"+ + "\1\234\4\4\1\0\17\4\31\0\1\201\33\0\3\3"+ + "\4\4\1\3\1\0\2\3\3\0\2\3\2\4\13\0"+ + "\4\3\1\4\2\3\1\4\1\0\1\3\1\4\1\3"+ + "\1\4\2\3\1\4\1\3\1\4\7\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\2\4"+ + "\1\235\14\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\10\4\1\0\7\4\1\236\7\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\15\4\1\231\1\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\10\4\1\0\14\4\1\122"+ + "\2\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\2\4\1\237\14\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\6\4\1\122"+ + "\1\4\1\0\17\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\1\4\1\71\6\4\1\0\17\4"+ + "\1\3\7\4\1\0\1\3\1\45\3\0\4\4\13\0"+ + "\10\4\1\0\10\4\1\240\6\4\1\3\7\4\1\0"+ + "\1\3\1\45\3\0\4\4\13\0\10\4\1\0\10\4"+ + "\1\161\6\4\1\3\7\4\1\0\1\3\1\45\3\0"+ + "\4\4\13\0\1\4\1\231\6\4\1\0\17\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\2\4\1\56\14\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\5\4\1\241\2\4\1\0"+ + "\17\4\1\3\7\4\1\0\1\3\1\45\3\0\4\4"+ + "\13\0\10\4\1\0\2\4\1\242\14\4\1\3\7\4"+ + "\1\0\1\3\1\45\3\0\4\4\13\0\10\4\1\0"+ + "\4\4\1\243\12\4\1\3\7\4\1\0\1\3\1\45"+ + "\3\0\4\4\13\0\7\4\1\244\1\0\17\4\1\3"+ + "\7\4\1\0\1\3\1\45\3\0\4\4\13\0\10\4"+ + "\1\0\5\4\1\56\11\4\1\3\7\4\1\0\1\3"+ + "\1\45\3\0\4\4\13\0\7\4\1\157\1\0\17\4"; + + private static int [] zzUnpackTrans() { + int [] result = new int[8056]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\2\0\4\1\1\11\1\1\1\11\1\1\2\11\1\1"+ + "\1\11\22\1\1\11\46\1\4\0\2\1\1\0\32\1"+ + "\4\0\22\1\2\0\20\1\2\0\22\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[164]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + + + /** + * Constructor. This must be here because JFlex does not generate a + * no-parameter constructor. + */ + public LogoTokenMaker() { + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + * @see #addToken(int, int, int) + */ + private void addHyperlinkToken(int start, int end, int tokenType) { + int so = start + offsetShift; + addToken(zzBuffer, start,end, tokenType, so, true); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + */ + private void addToken(int tokenType) { + addToken(zzStartRead, zzMarkedPos-1, tokenType); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param tokenType The token's type. + * @see #addHyperlinkToken(int, int, int) + */ + private void addToken(int start, int end, int tokenType) { + int so = start + offsetShift; + addToken(zzBuffer, start,end, tokenType, so, false); + } + + + /** + * Adds the token specified to the current linked list of tokens. + * + * @param array The character array. + * @param start The starting offset in the array. + * @param end The ending offset in the array. + * @param tokenType The token's type. + * @param startOffset The offset in the document at which this token + * occurs. + * @param hyperlink Whether this token is a hyperlink. + */ + @Override + public void addToken(char[] array, int start, int end, int tokenType, + int startOffset, boolean hyperlink) { + super.addToken(array, start,end, tokenType, startOffset, hyperlink); + zzStartRead = zzMarkedPos; + } + + + /** + * {@inheritDoc} + */ + @Override + public String[] getLineCommentStartAndEnd(int languageIndex) { + return new String[] { ";", null }; + } + + + /** + * Returns the first token in the linked list of tokens generated + * from text. This method must be implemented by + * subclasses so they can correctly implement syntax highlighting. + * + * @param text The text from which to get tokens. + * @param initialTokenType The token type we should start with. + * @param startOffset The offset into the document at which + * text starts. + * @return The first Token in a linked list representing + * the syntax highlighted text. + */ + public Token getTokenList(Segment text, int initialTokenType, int startOffset) { + + resetTokenList(); + this.offsetShift = -text.offset + startOffset; + + // Start off in the proper state. + int state = Token.NULL; + + s = text; + try { + yyreset(zzReader); + yybegin(state); + return yylex(); + } catch (IOException ioe) { + ioe.printStackTrace(); + return new TokenImpl(); + } + + } + + + /** + * Refills the input buffer. + * + * @return true if EOF was reached, otherwise + * false. + */ + private boolean zzRefill() { + return zzCurrentPos>=s.offset+s.count; + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to YY_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(Reader reader) { + // 's' has been updated. + zzBuffer = s.array; + /* + * We replaced the line below with the two below it because zzRefill + * no longer "refills" the buffer (since the way we do it, it's always + * "full" the first time through, since it points to the segment's + * array). So, we assign zzEndRead here. + */ + //zzStartRead = zzEndRead = s.offset; + zzStartRead = s.offset; + zzEndRead = zzStartRead + s.count - 1; + zzCurrentPos = zzMarkedPos = s.offset; + zzLexicalState = YYINITIAL; + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + } + + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public LogoTokenMaker(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public LogoTokenMaker(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 156) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public org.fife.ui.rsyntaxtextarea.Token yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 14: + { addToken(Token.RESERVED_WORD); + } + case 16: break; + case 2: + { addToken(Token.IDENTIFIER); + } + case 17: break; + case 12: + { addToken(Token.LITERAL_NUMBER_FLOAT); + } + case 18: break; + case 6: + { addToken(Token.WHITESPACE); + } + case 19: break; + case 15: + { int temp=zzStartRead; addToken(start,zzStartRead-1, Token.COMMENT_EOL); addHyperlinkToken(temp,zzMarkedPos-1, Token.COMMENT_EOL); start = zzMarkedPos; + } + case 20: break; + case 11: + { addToken(Token.ERROR_NUMBER_FORMAT); + } + case 21: break; + case 1: + { addToken(Token.ERROR_IDENTIFIER); + } + case 22: break; + case 7: + { start = zzMarkedPos-1; yybegin(EOL_COMMENT); + } + case 23: break; + case 13: + { addToken(Token.LITERAL_NUMBER_HEXADECIMAL); + } + case 24: break; + case 4: + { addToken(Token.OPERATOR); + } + case 25: break; + case 3: + { addToken(Token.LITERAL_NUMBER_DECIMAL_INT); + } + case 26: break; + case 5: + { addNullToken(); return firstToken; + } + case 27: break; + case 10: + { addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; + } + case 28: break; + case 9: + { + } + case 29: break; + case 8: + { addToken(Token.SEPARATOR); + } + case 30: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + switch (zzLexicalState) { + case EOL_COMMENT: { + addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; + } + case 165: break; + case YYINITIAL: { + addNullToken(); return firstToken; + } + case 166: break; + default: + return null; + } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java/org/tros/logo/rsyntax/LogoTokenRegistration.java b/src/main/java/org/tros/logo/rsyntax/LogoTokenRegistration.java new file mode 100644 index 0000000..1387032 --- /dev/null +++ b/src/main/java/org/tros/logo/rsyntax/LogoTokenRegistration.java @@ -0,0 +1,33 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.tros.logo.rsyntax; + +import org.fife.ui.rsyntaxtextarea.TokenMakerRegistration; +import org.fife.ui.rsyntaxtextarea.folding.FoldParser; + +/** + * + * @author matta + */ +public class LogoTokenRegistration implements TokenMakerRegistration { + + public static final String SYNTAX_STYLE = "text/logo"; + + @Override + public String getLanguage() { + return SYNTAX_STYLE; + } + + @Override + public String getTokenMaker() { + return LogoTokenMaker.class.getName(); + } + + @Override + public FoldParser getFoldParser() { + return null; + } +} diff --git a/src/main/java/org/tros/logo/swing/DrawListener.java b/src/main/java/org/tros/logo/swing/DrawListener.java index 17f89d9..741d00d 100644 --- a/src/main/java/org/tros/logo/swing/DrawListener.java +++ b/src/main/java/org/tros/logo/swing/DrawListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/swing/Drawable.java b/src/main/java/org/tros/logo/swing/Drawable.java index bd0cdc3..92b3af0 100644 --- a/src/main/java/org/tros/logo/swing/Drawable.java +++ b/src/main/java/org/tros/logo/swing/Drawable.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/logo/swing/LogoMenuBar.java b/src/main/java/org/tros/logo/swing/LogoMenuBar.java index e57d087..246795f 100644 --- a/src/main/java/org/tros/logo/swing/LogoMenuBar.java +++ b/src/main/java/org/tros/logo/swing/LogoMenuBar.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,6 @@ import java.text.MessageFormat; import java.util.Collections; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.imageio.stream.FileImageOutputStream; import javax.imageio.stream.ImageOutputStream; @@ -204,7 +202,7 @@ private void generatePNG(BufferedImageProvider bip, String filename) { try { ImageIO.write(bi, "png", outputfile); } catch (IOException ex) { - Logger.getLogger(LogoMenuBar.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoMenuBar.class).warn(null, ex); } } @@ -233,7 +231,7 @@ private JMenu setupExportMenu() { if (result == JFileChooser.APPROVE_OPTION) { String filename = chooser.getSelectedFile().getPath(); String extension = ".svg"; - if(!filename.endsWith(extension)) { + if (!filename.endsWith(extension)) { filename = filename + extension; } prefs.put("export-directory", chooser.getSelectedFile().getParent()); @@ -261,7 +259,7 @@ private JMenu setupExportMenu() { if (result == JFileChooser.APPROVE_OPTION) { String filename2 = chooser.getSelectedFile().getPath(); String extension = ".gif"; - if(!filename2.endsWith(extension)) { + if (!filename2.endsWith(extension)) { filename2 = filename2 + extension; } final String filename = filename2; @@ -272,9 +270,9 @@ private JMenu setupExportMenu() { try { generateGIF(((Drawable) canvas).cloneDrawable(), (BufferedImageProvider) canvas, filename); } catch (SVGGraphics2DIOException ex) { - Logger.getLogger(LogoMenuBar.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoMenuBar.class).warn(null, ex); } catch (IOException ex) { - Logger.getLogger(LogoMenuBar.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoMenuBar.class).warn(null, ex); } } }); @@ -295,7 +293,7 @@ private JMenu setupExportMenu() { if (result == JFileChooser.APPROVE_OPTION) { String filename2 = chooser.getSelectedFile().getPath(); String extension = ".png"; - if(!filename2.endsWith(extension)) { + if (!filename2.endsWith(extension)) { filename2 = filename2 + extension; } final String filename = filename2; diff --git a/src/main/java/org/tros/logo/swing/LogoPanel.java b/src/main/java/org/tros/logo/swing/LogoPanel.java index b4990c0..ad331cd 100644 --- a/src/main/java/org/tros/logo/swing/LogoPanel.java +++ b/src/main/java/org/tros/logo/swing/LogoPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/Controller.java b/src/main/java/org/tros/torgo/Controller.java index e3bf8aa..ab2a3df 100644 --- a/src/main/java/org/tros/torgo/Controller.java +++ b/src/main/java/org/tros/torgo/Controller.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/ControllerBase.java b/src/main/java/org/tros/torgo/ControllerBase.java index 9e7367f..74cce8c 100644 --- a/src/main/java/org/tros/torgo/ControllerBase.java +++ b/src/main/java/org/tros/torgo/ControllerBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; @@ -265,9 +263,9 @@ private void initSwing() { dockControl.readXML(elem); loaded = true; } catch (FileNotFoundException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn(null, ex); } catch (IOException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn(null, ex); } } if (!loaded) { @@ -277,7 +275,7 @@ private void initSwing() { dockControl.readXML(elem); loaded = true; } catch (IOException | java.util.NoSuchElementException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.WARNING, "Layout Error: Auto-generating: {0}", ex.getMessage()); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn("Layout Error: Auto-generating: {0}", ex.getMessage()); } } if (!loaded) { @@ -297,7 +295,7 @@ private void initSwing() { ImageIcon ico = new ImageIcon(resources.nextElement()); aboutMenu.setIcon(ico); } catch (IOException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn(null, ex); } aboutMenu.addActionListener((ActionEvent ae) -> { @@ -319,7 +317,7 @@ private void initSwing() { Desktop.getDesktop().browse(uri); } } catch (IOException | URISyntaxException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn(null, ex); } catch (UnsupportedOperationException ex) { ProcessBuilder pb = new ProcessBuilder("xdg-open", UpdateChecker.UPDATE_ADDRESS); try { @@ -371,7 +369,7 @@ public void windowClosing(WindowEvent e) { String layoutFile = PathUtils.getApplicationConfigDirectory(TorgoInfo.INSTANCE) + java.io.File.separatorChar + getLang() + "-layout.xml"; dockControl.writeXML(new java.io.File(layoutFile)); } catch (IOException ex) { - Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).warn(null, ex); } } @@ -557,7 +555,7 @@ public void saveFileAs() { if (result == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); String extension = "." + getLang(); - if(!filename.endsWith(extension)) { + if (!filename.endsWith(extension)) { filename = filename + extension; } prefs.put(ControllerBase.class.getName() + "-working-directory", chooser.getSelectedFile().getParent()); diff --git a/src/main/java/org/tros/torgo/ControllerListener.java b/src/main/java/org/tros/torgo/ControllerListener.java index 9b84477..e791b85 100644 --- a/src/main/java/org/tros/torgo/ControllerListener.java +++ b/src/main/java/org/tros/torgo/ControllerListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/InterpreterVisualization.java b/src/main/java/org/tros/torgo/InterpreterVisualization.java index 8d72d97..c6ffd51 100644 --- a/src/main/java/org/tros/torgo/InterpreterVisualization.java +++ b/src/main/java/org/tros/torgo/InterpreterVisualization.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/Main.java b/src/main/java/org/tros/torgo/Main.java index d54aba4..1aeb141 100644 --- a/src/main/java/org/tros/torgo/Main.java +++ b/src/main/java/org/tros/torgo/Main.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,22 +15,12 @@ */ package org.tros.torgo; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.SplashScreen; import java.awt.Window; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.NoSuchElementException; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -39,6 +29,7 @@ import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.tros.utils.ImageUtils; /** * Main entry point for torgo @@ -47,104 +38,7 @@ */ public class Main { - private static SplashScreen mySplash; - private static Graphics2D splashGraphics; - private static Image splashImage; - private static Font font; - private static Dimension splashDimension; - private static double currPercent = 0; - - /** - * Initialize the splash graphic. - */ - private static void splashInit() { - mySplash = SplashScreen.getSplashScreen(); - if (mySplash != null) { - try { - // if there are any problems displaying the splash this will be null - splashDimension = mySplash.getSize(); - splashImage = ImageIO.read(mySplash.getImageURL()); - - // create the Graphics environment for drawing status info - splashGraphics = mySplash.createGraphics(); - font = new Font(Font.SANS_SERIF, Font.PLAIN, 16); - splashGraphics.setFont(font); - splashGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); - - // initialize the status info - splashText("Starting"); - } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Display text in status area of Splash. Note: no validation it will fit. - * - * @param str - text to be displayed - */ - public static void splashText(String str) { - if (mySplash != null && mySplash.isVisible()) { - splashGraphics.drawImage(splashImage, 0, 0, null); - - splashGraphics.setPaint(Color.BLACK); - splashGraphics.drawString(str, 27, (int) (splashDimension.getHeight() - 12)); - splashProgress(currPercent); - - mySplash.update(); - } - } - - public static double numSteps = 1; - public static double currStep = 0; - - /** - * Set the number of steps to be completed. - * - * This number can be updated. - * - * @param steps - */ - public static void setNumSteps(int steps) { - if (steps > 0) { - numSteps = steps; - } - } - - /** - * Perform a step. - */ - public static void splashStep() { - currStep += 1.0; - currStep = Math.min(currStep, numSteps); - splashProgress(currStep / numSteps); - } - - /** - * Add a specified number of steps to the completed. - * - * @param steps - */ - public static void addSteps(int steps) { - if (steps > 0) { - numSteps += steps; - } - } - - /** - * Update splash progress. - * - * @param percent - */ - private static void splashProgress(double percent) { - if (mySplash != null && mySplash.isVisible()) { - currPercent = percent; - splashGraphics.setColor(Color.RED); - splashGraphics.fillRect(0, splashDimension.height - 5, (int) (splashDimension.getWidth() * percent), 5); - mySplash.update(); - } - } + private static final String DEFAULT_LANGUAGE = "dynamic-logo"; /** * Entry Point @@ -153,12 +47,13 @@ private static void splashProgress(double percent) { */ public static void main(String[] args) { //initialize the logging - splashInit(); + MainSplash.splashInit(); org.tros.utils.logging.Logging.initLogging(TorgoInfo.INSTANCE); + org.tros.utils.logging.Logger logger = org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class); Options options = new Options(); options.addOption("l", "lang", true, "Open using the desired language. [default is 'logo']"); options.addOption("i", "list", false, "List available languages."); - String lang = "dynamic-logo"; + String lang = DEFAULT_LANGUAGE; final String fileArgument = args.length - 1 >= 0 ? args[args.length - 1] : null; String ext = null; boolean quit = false; @@ -186,7 +81,7 @@ public static void main(String[] args) { quit = true; } } catch (ParseException ex) { - org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class).fatal(null, ex); + logger.fatal(null, ex); } //currently commented out for working with snapd @@ -195,7 +90,7 @@ public static void main(String[] args) { //set look and feel (laf) to that of the system. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { - org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class).fatal(null, ex); + logger.fatal(null, ex); } } @@ -206,6 +101,11 @@ public static void main(String[] args) { if (ext != null && TorgoToolkit.getToolkits().contains(ext)) { lang = ext; } + if (!TorgoToolkit.getToolkits().contains(lang)) { + logger.warn("Could not load: {0}", lang); + logger.warn("Loading Default: {0}", DEFAULT_LANGUAGE); + lang = DEFAULT_LANGUAGE; + } final String controlLang = lang; if (!quit) { @@ -235,13 +135,6 @@ public static ImageIcon getIcon() { } public static ImageIcon getIcon(String path) { - try { - java.util.Enumeration resources = ClassLoader.getSystemClassLoader().getResources(path); - ImageIcon ico = new ImageIcon(resources.nextElement()); - return ico; - } catch (NoSuchElementException | IOException ex) { - org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class).warn(null, ex); - } - return null; + return ImageUtils.createImageIcon(path, path); } } diff --git a/src/main/java/org/tros/torgo/MainSplash.java b/src/main/java/org/tros/torgo/MainSplash.java new file mode 100644 index 0000000..75817d1 --- /dev/null +++ b/src/main/java/org/tros/torgo/MainSplash.java @@ -0,0 +1,132 @@ +/* + * Copyright 2015-2017 Matthew Aguirre + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tros.torgo; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.RenderingHints; +import java.awt.SplashScreen; +import java.io.IOException; +import javax.imageio.ImageIO; + +/** + * + * @author matta + */ +class MainSplash { + + private static SplashScreen mySplash; + private static Graphics2D splashGraphics; + private static Image splashImage; + private static Font font; + private static Dimension splashDimension; + private static double currPercent = 0; + + /** + * Initialize the splash graphic. + */ + protected static void splashInit() { + mySplash = SplashScreen.getSplashScreen(); + if (mySplash != null) { + try { + // if there are any problems displaying the splash this will be null + splashDimension = mySplash.getSize(); + splashImage = ImageIO.read(mySplash.getImageURL()); + + // create the Graphics environment for drawing status info + splashGraphics = mySplash.createGraphics(); + font = new Font(Font.SANS_SERIF, Font.PLAIN, 16); + splashGraphics.setFont(font); + splashGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); + + // initialize the status info + splashText("Starting"); + } catch (IOException ex) { + org.tros.utils.logging.Logging.getLogFactory().getLogger(MainSplash.class).warn(null, ex); + } + } + } + + /** + * Display text in status area of Splash. Note: no validation it will fit. + * + * @param str - text to be displayed + */ + public static void splashText(String str) { + if (mySplash != null && mySplash.isVisible()) { + splashGraphics.drawImage(splashImage, 0, 0, null); + + splashGraphics.setPaint(Color.BLACK); + splashGraphics.drawString(str, 27, (int) (splashDimension.getHeight() - 12)); + splashProgress(currPercent); + + mySplash.update(); + } + } + + public static double numSteps = 1; + public static double currStep = 0; + + /** + * Set the number of steps to be completed. + * + * This number can be updated. + * + * @param steps + */ + public static void setNumSteps(int steps) { + if (steps > 0) { + numSteps = steps; + } + } + + /** + * Perform a step. + */ + public static void splashStep() { + currStep += 1.0; + currStep = Math.min(currStep, numSteps); + splashProgress(currStep / numSteps); + } + + /** + * Add a specified number of steps to the completed. + * + * @param steps + */ + public static void addSteps(int steps) { + if (steps > 0) { + numSteps += steps; + } + } + + /** + * Update splash progress. + * + * @param percent + */ + private static void splashProgress(double percent) { + if (mySplash != null && mySplash.isVisible()) { + currPercent = percent; + splashGraphics.setColor(Color.RED); + splashGraphics.fillRect(0, splashDimension.height - 5, (int) (splashDimension.getWidth() * percent), 5); + mySplash.update(); + } + } +} diff --git a/src/main/java/org/tros/torgo/TorgoInfo.java b/src/main/java/org/tros/torgo/TorgoInfo.java index 58e5d6c..9c6dc64 100644 --- a/src/main/java/org/tros/torgo/TorgoInfo.java +++ b/src/main/java/org/tros/torgo/TorgoInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/TorgoScreen.java b/src/main/java/org/tros/torgo/TorgoScreen.java index 987e0bd..93c58f0 100644 --- a/src/main/java/org/tros/torgo/TorgoScreen.java +++ b/src/main/java/org/tros/torgo/TorgoScreen.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/TorgoTextConsole.java b/src/main/java/org/tros/torgo/TorgoTextConsole.java index 181e644..df9526d 100644 --- a/src/main/java/org/tros/torgo/TorgoTextConsole.java +++ b/src/main/java/org/tros/torgo/TorgoTextConsole.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/TorgoToolkit.java b/src/main/java/org/tros/torgo/TorgoToolkit.java index cb2543d..2e0d71d 100644 --- a/src/main/java/org/tros/torgo/TorgoToolkit.java +++ b/src/main/java/org/tros/torgo/TorgoToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/UpdateChecker.java b/src/main/java/org/tros/torgo/UpdateChecker.java index 4e55d2f..d14859c 100644 --- a/src/main/java/org/tros/torgo/UpdateChecker.java +++ b/src/main/java/org/tros/torgo/UpdateChecker.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; -import java.util.logging.Level; -import java.util.logging.Logger; import org.jsoup.select.Elements; import org.jsoup.nodes.Document; @@ -35,6 +33,12 @@ public class UpdateChecker { private String updateVersion; private boolean checkForUpdate; + + private static final org.tros.utils.logging.Logger LOGGER; + + static { + LOGGER = org.tros.utils.logging.Logging.getLogFactory().getLogger(UpdateChecker.class); + } public UpdateChecker() { java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(UpdateChecker.class); @@ -54,11 +58,11 @@ public boolean hasUpdate() { } } } catch (MalformedURLException ex) { - Logger.getLogger(UpdateChecker.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.error(ex.getMessage(), ex); } catch (FileNotFoundException ex) { - Logger.getLogger(UpdateChecker.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.error(ex.getMessage(), ex); } catch (IOException ex) { - Logger.getLogger(UpdateChecker.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.error(ex.getMessage(), ex); } return ret; } diff --git a/src/main/java/org/tros/torgo/interpreter/CodeBlock.java b/src/main/java/org/tros/torgo/interpreter/CodeBlock.java index 18f05a4..fa8836f 100644 --- a/src/main/java/org/tros/torgo/interpreter/CodeBlock.java +++ b/src/main/java/org/tros/torgo/interpreter/CodeBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/CodeFunction.java b/src/main/java/org/tros/torgo/interpreter/CodeFunction.java index 72fabb0..2df836e 100644 --- a/src/main/java/org/tros/torgo/interpreter/CodeFunction.java +++ b/src/main/java/org/tros/torgo/interpreter/CodeFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/DynamicScope.java b/src/main/java/org/tros/torgo/interpreter/DynamicScope.java index 26b1bf0..d0b7c06 100644 --- a/src/main/java/org/tros/torgo/interpreter/DynamicScope.java +++ b/src/main/java/org/tros/torgo/interpreter/DynamicScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/InterpreterListener.java b/src/main/java/org/tros/torgo/interpreter/InterpreterListener.java index c628d04..b9c4147 100644 --- a/src/main/java/org/tros/torgo/interpreter/InterpreterListener.java +++ b/src/main/java/org/tros/torgo/interpreter/InterpreterListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/InterpreterThread.java b/src/main/java/org/tros/torgo/interpreter/InterpreterThread.java index 48ccea0..1d853cc 100644 --- a/src/main/java/org/tros/torgo/interpreter/InterpreterThread.java +++ b/src/main/java/org/tros/torgo/interpreter/InterpreterThread.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/InterpreterType.java b/src/main/java/org/tros/torgo/interpreter/InterpreterType.java index 4032303..1626921 100644 --- a/src/main/java/org/tros/torgo/interpreter/InterpreterType.java +++ b/src/main/java/org/tros/torgo/interpreter/InterpreterType.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/InterpreterValue.java b/src/main/java/org/tros/torgo/interpreter/InterpreterValue.java index e3fae7b..058e2fb 100644 --- a/src/main/java/org/tros/torgo/interpreter/InterpreterValue.java +++ b/src/main/java/org/tros/torgo/interpreter/InterpreterValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/LexicalAnalyzer.java b/src/main/java/org/tros/torgo/interpreter/LexicalAnalyzer.java index 7452f08..d403010 100644 --- a/src/main/java/org/tros/torgo/interpreter/LexicalAnalyzer.java +++ b/src/main/java/org/tros/torgo/interpreter/LexicalAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/LexicalScope.java b/src/main/java/org/tros/torgo/interpreter/LexicalScope.java index 23ea37e..c1df002 100644 --- a/src/main/java/org/tros/torgo/interpreter/LexicalScope.java +++ b/src/main/java/org/tros/torgo/interpreter/LexicalScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/ReturnValue.java b/src/main/java/org/tros/torgo/interpreter/ReturnValue.java index 0ed11ed..afba04d 100644 --- a/src/main/java/org/tros/torgo/interpreter/ReturnValue.java +++ b/src/main/java/org/tros/torgo/interpreter/ReturnValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/Scope.java b/src/main/java/org/tros/torgo/interpreter/Scope.java index b816044..f243583 100644 --- a/src/main/java/org/tros/torgo/interpreter/Scope.java +++ b/src/main/java/org/tros/torgo/interpreter/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/ScopeImpl.java b/src/main/java/org/tros/torgo/interpreter/ScopeImpl.java index 100607d..c9ead43 100644 --- a/src/main/java/org/tros/torgo/interpreter/ScopeImpl.java +++ b/src/main/java/org/tros/torgo/interpreter/ScopeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/ScopeListener.java b/src/main/java/org/tros/torgo/interpreter/ScopeListener.java index ebf7b58..e37f8ef 100644 --- a/src/main/java/org/tros/torgo/interpreter/ScopeListener.java +++ b/src/main/java/org/tros/torgo/interpreter/ScopeListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/types/BooleanType.java b/src/main/java/org/tros/torgo/interpreter/types/BooleanType.java index 0863404..0880614 100644 --- a/src/main/java/org/tros/torgo/interpreter/types/BooleanType.java +++ b/src/main/java/org/tros/torgo/interpreter/types/BooleanType.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/types/InterpreterTypeImpl.java b/src/main/java/org/tros/torgo/interpreter/types/InterpreterTypeImpl.java index 731ab19..a510638 100644 --- a/src/main/java/org/tros/torgo/interpreter/types/InterpreterTypeImpl.java +++ b/src/main/java/org/tros/torgo/interpreter/types/InterpreterTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/types/NullType.java b/src/main/java/org/tros/torgo/interpreter/types/NullType.java index 9b1f82e..735a608 100644 --- a/src/main/java/org/tros/torgo/interpreter/types/NullType.java +++ b/src/main/java/org/tros/torgo/interpreter/types/NullType.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/types/NumberType.java b/src/main/java/org/tros/torgo/interpreter/types/NumberType.java index 6784a70..38313f9 100644 --- a/src/main/java/org/tros/torgo/interpreter/types/NumberType.java +++ b/src/main/java/org/tros/torgo/interpreter/types/NumberType.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/interpreter/types/StringType.java b/src/main/java/org/tros/torgo/interpreter/types/StringType.java index 060fb8e..b83b506 100644 --- a/src/main/java/org/tros/torgo/interpreter/types/StringType.java +++ b/src/main/java/org/tros/torgo/interpreter/types/StringType.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/swing/AboutWindow.java b/src/main/java/org/tros/torgo/swing/AboutWindow.java index 5ed2a94..2a85abb 100644 --- a/src/main/java/org/tros/torgo/swing/AboutWindow.java +++ b/src/main/java/org/tros/torgo/swing/AboutWindow.java @@ -1,12 +1,12 @@ /* - * Copyright 2015-2016 Matthew Aguirre - * + * Copyright 2015-2017 Matthew Aguirre + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -141,7 +141,7 @@ public AboutWindow() { l.setToolTipText(l.getText()); text_panel.add(l); - apacheButton.setText("© 2015-2016 Matthew Aguirre, Apache License 2.0."); + apacheButton.setText("© 2015-2017 Matthew Aguirre, Apache License 2.0."); apacheButton.setBorderPainted(false); apacheButton.setOpaque(false); apacheButton.setToolTipText(APACHE_LICENSE_ADDRESS); diff --git a/src/main/java/org/tros/torgo/swing/BufferedImageProvider.java b/src/main/java/org/tros/torgo/swing/BufferedImageProvider.java index a67d7fc..3ae171b 100644 --- a/src/main/java/org/tros/torgo/swing/BufferedImageProvider.java +++ b/src/main/java/org/tros/torgo/swing/BufferedImageProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/swing/Localization.java b/src/main/java/org/tros/torgo/swing/Localization.java index 50ec2bf..497613d 100644 --- a/src/main/java/org/tros/torgo/swing/Localization.java +++ b/src/main/java/org/tros/torgo/swing/Localization.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/swing/TorgoMenuBar.java b/src/main/java/org/tros/torgo/swing/TorgoMenuBar.java index bca6001..fc27481 100644 --- a/src/main/java/org/tros/torgo/swing/TorgoMenuBar.java +++ b/src/main/java/org/tros/torgo/swing/TorgoMenuBar.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,6 @@ import java.io.IOException; import java.net.URL; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -126,7 +124,7 @@ public TorgoMenuBar(Component parent, final Controller controller) { add(setupFileMenu()); add(setupInterpreterMenu()); } catch (IOException ex) { - Logger.getLogger(TorgoMenuBar.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(TorgoMenuBar.class).warn(null, ex); } } diff --git a/src/main/java/org/tros/torgo/swing/TorgoToolBar.java b/src/main/java/org/tros/torgo/swing/TorgoToolBar.java index aac81f6..d52b37f 100644 --- a/src/main/java/org/tros/torgo/swing/TorgoToolBar.java +++ b/src/main/java/org/tros/torgo/swing/TorgoToolBar.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/torgo/swing/TorgoUserInputPanel.java b/src/main/java/org/tros/torgo/swing/TorgoUserInputPanel.java index 67792e3..ba50daf 100644 --- a/src/main/java/org/tros/torgo/swing/TorgoUserInputPanel.java +++ b/src/main/java/org/tros/torgo/swing/TorgoUserInputPanel.java @@ -19,15 +19,24 @@ import java.awt.Color; import java.awt.Component; import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseWheelEvent; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.util.concurrent.atomic.AtomicBoolean; import javax.swing.ImageIcon; +import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.JTabbedPane; +import javax.swing.KeyStroke; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; @@ -57,6 +66,15 @@ public class TorgoUserInputPanel implements TorgoTextConsole { private final LayeredHighlighter.LayerPainter defaultHighlighter; private final LayeredHighlighter.LayerPainter breakpointHighlighter; + private final float DEFAULT_FONT_SIZE = 12; + private final int FONT_INCREMENT_SIZE = 1; + private final int FONT_MAX_SIZE = 50; + private final int FONT_MIN_SIZE = 5; + + private JMenuItem jmi1; + private JMenuItem jmi2; + private JMenuItem jmi3; + /** * Constructor. * @@ -87,21 +105,160 @@ public TorgoUserInputPanel(Controller controller, String name, boolean editable, ImageIcon imageIcon = new ImageIcon(resources.nextElement()); gutter.setBookmarkIcon(imageIcon); } catch (IOException ex) { - Logger.getLogger(TorgoUserInputPanel.class.getName()).log(Level.SEVERE, null, ex); + org.tros.utils.logging.Logging.getLogFactory().getLogger(TorgoUserInputPanel.class).warn(null, ex); } gutter.setBookmarkingEnabled(true); - inputTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); + final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(TorgoUserInputPanel.class); + + outputTextArea = new JConsole(); + outputTextArea.setEditable(editable); + //get default pref + //update prefs + + Font font = new Font(Font.MONOSPACED, Font.PLAIN, (int) prefs.getFloat("font-size", DEFAULT_FONT_SIZE)); + inputTextArea.setFont(font); + outputTextArea.setFont(font); + + Runnable increase = () -> { + Font font1 = inputTextArea.getFont(); + float size = (float) (font1.getSize2D() + FONT_INCREMENT_SIZE); + if (size <= FONT_MAX_SIZE) { + font1 = font1.deriveFont(size); + inputTextArea.setFont(font1); + outputTextArea.setFont(font1); + prefs.putFloat("font-size", size); + } + }; + + Runnable decrease = () -> { + Font font1 = inputTextArea.getFont(); + float size = (float) (font1.getSize2D() - FONT_INCREMENT_SIZE); + if (size >= FONT_MIN_SIZE) { + font1 = font1.deriveFont(size); + inputTextArea.setFont(font1); + outputTextArea.setFont(font1); + prefs.putFloat("font-size", size); + } + }; + + Runnable reset = () -> { + Font font1 = inputTextArea.getFont(); + font1 = font1.deriveFont(DEFAULT_FONT_SIZE); + inputTextArea.setFont(font1); + outputTextArea.setFont(font1); + prefs.putFloat("font-size", DEFAULT_FONT_SIZE); + }; + + final AtomicBoolean ctrlDown = new AtomicBoolean(false); + inputTextArea.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent ke) { + } + + @Override + public void keyPressed(KeyEvent ke) { + if((ke.getModifiers() & KeyEvent.CTRL_MASK) != 0) { + ctrlDown.set(true); + } + if ((ke.getKeyCode() == KeyEvent.VK_EQUALS) + && (ke.getModifiers() == (KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK)) + || (ke.getKeyCode() == KeyEvent.VK_ADD) + && (ke.getModifiers() == (KeyEvent.CTRL_MASK))) { + increase.run(); + } + if ((ke.getKeyCode() == KeyEvent.VK_MINUS || ke.getKeyCode() == KeyEvent.VK_SUBTRACT) + && ((ke.getModifiers() == KeyEvent.CTRL_MASK))) { + decrease.run(); + } + if ((ke.getKeyCode() == KeyEvent.VK_0 || ke.getKeyCode() == KeyEvent.VK_NUMPAD0) + && ((ke.getModifiers() == KeyEvent.CTRL_MASK))) { + reset.run(); + } + } + + @Override + public void keyReleased(KeyEvent ke) { + if(ke.getModifiers() == 0) { + ctrlDown.set(false); + } + } + }); + + jmi1 = new JMenuItem("Zoom In"); + jmi1.addActionListener((ActionEvent ae) -> { + increase.run(); + }); + jmi2 = new JMenuItem("Zoom Out"); + jmi2.addActionListener((ActionEvent ae) -> { + decrease.run(); + }); + jmi3 = new JMenuItem("Zoom Reset"); + jmi3.addActionListener((ActionEvent ae) -> { + reset.run(); + }); + jmi1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_MASK)); + jmi2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_MASK)); + jmi3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_MASK)); + final AtomicBoolean added = new AtomicBoolean(false); + final Runnable r = () -> { + + if (!added.get()) { + added.set(true); + JPopupMenu popupMenu = inputTextArea.getPopupMenu(); + popupMenu.add(jmi1); + popupMenu.add(jmi2); + popupMenu.add(jmi3); + } + + }; + scrollPane.addMouseWheelListener((MouseWheelEvent mwe) -> { + if (ctrlDown.get()) { + if (mwe.getPreciseWheelRotation() < 0) { + increase.run(); + } else { + decrease.run(); + } + } + }); + inputTextArea.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent me) { + r.run(); + inputTextArea.removeMouseListener(this); + } + + @Override + public void mousePressed(MouseEvent me) { + r.run(); + inputTextArea.removeMouseListener(this); + } + + @Override + public void mouseReleased(MouseEvent me) { + r.run(); + inputTextArea.removeMouseListener(this); + } + + @Override + public void mouseEntered(MouseEvent me) { + r.run(); + inputTextArea.removeMouseListener(this); + } + + @Override + public void mouseExited(MouseEvent me) { + r.run(); + inputTextArea.removeMouseListener(this); + } + }); + inputTab.add(scrollPane, BorderLayout.CENTER); //TABS tabs = new JTabbedPane(); tabs.add(name, inputTab); - - outputTextArea = new JConsole(); - outputTextArea.setEditable(editable); - controller.addInterpreterListener(new InterpreterListener() { /** diff --git a/src/main/java/org/tros/torgo/viz/SpringUtilities.java b/src/main/java/org/tros/torgo/viz/SpringUtilities.java index 2abab1f..52bfe45 100644 --- a/src/main/java/org/tros/torgo/viz/SpringUtilities.java +++ b/src/main/java/org/tros/torgo/viz/SpringUtilities.java @@ -30,10 +30,9 @@ */ package org.tros.torgo.viz; -import java.awt.Component; -import java.awt.Container; +import javax.swing.*; import javax.swing.SpringLayout; -import javax.swing.Spring; +import java.awt.*; /** * A 1.4 file that provides utility methods for creating form- or grid-style @@ -42,6 +41,110 @@ */ public class SpringUtilities { + /** + * A debugging utility that prints to stdout the component's minimum, + * preferred, and maximum sizes. + * + * @param c + */ + public static void printSizes(Component c) { + System.out.println("minimumSize = " + c.getMinimumSize()); + System.out.println("preferredSize = " + c.getPreferredSize()); + System.out.println("maximumSize = " + c.getMaximumSize()); + } + + /** + * Aligns the first rows * cols components of + * parent in a grid. Each component is as big as the maximum + * preferred width and height of the components. The parent is made just big + * enough to fit them all. + * + * @param parent + * @param rows number of rows + * @param cols number of columns + * @param initialX x location to start the grid at + * @param initialY y location to start the grid at + * @param xPad x padding between cells + * @param yPad y padding between cells + */ + public static void makeGrid(Container parent, + int rows, int cols, + int initialX, int initialY, + int xPad, int yPad) { + SpringLayout layout; + try { + layout = (SpringLayout) parent.getLayout(); + } catch (ClassCastException exc) { + System.err.println("The first argument to makeGrid must use SpringLayout."); + return; + } + + Spring xPadSpring = Spring.constant(xPad); + Spring yPadSpring = Spring.constant(yPad); + Spring initialXSpring = Spring.constant(initialX); + Spring initialYSpring = Spring.constant(initialY); + int max = rows * cols; + + //Calculate Springs that are the max of the width/height so that all + //cells have the same size. + Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)). + getWidth(); + Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)). + getHeight(); + for (int i = 1; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints( + parent.getComponent(i)); + + maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth()); + maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight()); + } + + //Apply the new width/height Spring. This forces all the + //components to have the same size. + for (int i = 0; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints( + parent.getComponent(i)); + + cons.setWidth(maxWidthSpring); + cons.setHeight(maxHeightSpring); + } + + //Then adjust the x/y constraints of all the cells so that they + //are aligned in a grid. + SpringLayout.Constraints lastCons = null; + SpringLayout.Constraints lastRowCons = null; + for (int i = 0; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints( + parent.getComponent(i)); + if (i % cols == 0) { //start of new row + lastRowCons = lastCons; + cons.setX(initialXSpring); + } else { //x position depends on previous component + cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), + xPadSpring)); + } + + if (i / cols == 0) { //first row + cons.setY(initialYSpring); + } else { //y position depends on previous row + cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), + yPadSpring)); + } + lastCons = cons; + } + + //Set the parent's size. + SpringLayout.Constraints pCons = layout.getConstraints(parent); + pCons.setConstraint(SpringLayout.SOUTH, + Spring.sum( + Spring.constant(yPad), + lastCons.getConstraint(SpringLayout.SOUTH))); + pCons.setConstraint(SpringLayout.EAST, + Spring.sum( + Spring.constant(xPad), + lastCons.getConstraint(SpringLayout.EAST))); + } + /* Used by makeCompactGrid. */ private static SpringLayout.Constraints getConstraintsForCell( int row, int col, @@ -71,7 +174,13 @@ public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { - SpringLayout layout = (SpringLayout) parent.getLayout(); + SpringLayout layout; + try { + layout = (SpringLayout) parent.getLayout(); + } catch (ClassCastException exc) { + System.err.println("The first argument to makeCompactGrid must use SpringLayout."); + return; + } //Align all cells in each column and make them the same width. Spring x = Spring.constant(initialX); diff --git a/src/main/java/org/tros/torgo/viz/TraceLogger.java b/src/main/java/org/tros/torgo/viz/TraceLogger.java index ba1c7c1..7b3b570 100644 --- a/src/main/java/org/tros/torgo/viz/TraceLogger.java +++ b/src/main/java/org/tros/torgo/viz/TraceLogger.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Matthew Aguirre + * Copyright 2015-2017 Matthew Aguirre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/tros/utils/Mailbox.java b/src/main/java/org/tros/utils/Mailbox.java index 365e6e2..09ef643 100644 --- a/src/main/java/org/tros/utils/Mailbox.java +++ b/src/main/java/org/tros/utils/Mailbox.java @@ -20,7 +20,6 @@ public class Mailbox { private final java.util.ArrayList m_msgs; private boolean m_halt; - private final static org.tros.utils.logging.Logger LOGGER = org.tros.utils.logging.Logging.getLogFactory().getLogger(Mailbox.class); /** * Constructor. @@ -75,8 +74,8 @@ public synchronized T getMessage() { try { wait(); } catch (InterruptedException e) { - LOGGER.warn(null, e); - continue; + m_halt = true; + return null; } if (m_halt) { return null; @@ -99,8 +98,8 @@ public synchronized ArrayList getMessages() { try { wait(); } catch (InterruptedException e) { - LOGGER.warn(null, e); - continue; + m_halt = true; + return null; } if (m_halt) { return null; diff --git a/src/main/resources/layouts/dynamic-logo-layout.xml b/src/main/resources/layouts/dynamic-logo-layout.xml index 80d52fb..2578595 100644 --- a/src/main/resources/layouts/dynamic-logo-layout.xml +++ b/src/main/resources/layouts/dynamic-logo-layout.xml @@ -1,6 +1,6 @@