mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 19:09:03 +00:00
wip
This commit is contained in:
parent
fce894d4e1
commit
ac0ccd1af2
@ -139,6 +139,10 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
|
||||
this.stacks2.add(Ident.empty());
|
||||
}
|
||||
|
||||
final public String getPortFor(String ent1String, Ident ident1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Ident getLastID() {
|
||||
if (stacks2.size() == 0) {
|
||||
// Thread.dumpStack();
|
||||
|
@ -179,8 +179,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
return executePackageLink(diagram, arg);
|
||||
}
|
||||
|
||||
String port1 = null;
|
||||
String port2 = null;
|
||||
String port1 = diagram.getPortFor(ent1String, ident1);
|
||||
String port2 = diagram.getPortFor(ent2String, ident2);
|
||||
|
||||
if (diagram.V1972()) {
|
||||
if ("::".equals(diagram.getNamespaceSeparator())) {
|
||||
@ -207,12 +207,12 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (removeMemberPartLegacy1972(diagram, ident1) != null) {
|
||||
if (port1 == null && removeMemberPartLegacy1972(diagram, ident1) != null) {
|
||||
port1 = ident1.getPortMember();
|
||||
code1 = removeMemberPartLegacy1972(diagram, ident1);
|
||||
ident1 = ident1.removeMemberPart();
|
||||
}
|
||||
if (removeMemberPartLegacy1972(diagram, ident2) != null) {
|
||||
if (port2 == null && removeMemberPartLegacy1972(diagram, ident2) != null) {
|
||||
port2 = ident2.getPortMember();
|
||||
code2 = removeMemberPartLegacy1972(diagram, ident2);
|
||||
ident2 = ident2.removeMemberPart();
|
||||
|
@ -65,18 +65,17 @@ public class DedicationCrypted implements Dedication {
|
||||
public synchronized BufferedImage getImage(final TinyHashableString sentence) {
|
||||
final String line = sentence.getSentence();
|
||||
|
||||
if (line.length() < 40) {
|
||||
if (line.length() < 40)
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (solution == null || line.equals(this.solution) == false) {
|
||||
if (System.currentTimeMillis() < next) {
|
||||
if (System.currentTimeMillis() < next)
|
||||
return null;
|
||||
}
|
||||
if (this.tinyHash != sentence.tinyHash()) {
|
||||
|
||||
if (this.tinyHash != sentence.tinyHash())
|
||||
return null;
|
||||
}
|
||||
|
||||
this.next = System.currentTimeMillis() + 5000L;
|
||||
}
|
||||
|
||||
@ -105,9 +104,9 @@ public class DedicationCrypted implements Dedication {
|
||||
|
||||
final String argon = Noise.computeArgon2String(current, (pq.toString(34) + line).getBytes(UTF_8));
|
||||
|
||||
if (this.argon2.equals(argon) == false) {
|
||||
if (this.argon2.equals(argon) == false)
|
||||
return null;
|
||||
}
|
||||
|
||||
Noise.shuffle(current, rndMT);
|
||||
current = Noise.reverse(current, rndMT.nextInt());
|
||||
|
||||
|
@ -52,9 +52,8 @@ public class DedicationSimple implements Dedication {
|
||||
}
|
||||
|
||||
public synchronized BufferedImage getImage(TinyHashableString sentence) {
|
||||
if (same(this.sentence, sentence.getSentence()) == false) {
|
||||
if (same(this.sentence, sentence.getSentence()) == false)
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
byte[] current = crypted.clone();
|
||||
|
@ -58,6 +58,7 @@ public class Dedications {
|
||||
all.add(new DedicationSimple(load("boundaries"), "Boundaries allow discipline to create true strength"));
|
||||
all.add(new DedicationSimple(load("dr_chet"), "Thank you, Dr. Chet. I wouldn't be where I am without you"));
|
||||
all.add(new DedicationSimple(load("ben"), "Ben and Jen 2020"));
|
||||
all.add(new DedicationSimple(load("baraye"), "baraye"));
|
||||
all.add(secret(5, "835ff5d643b58cd35a20db6480071d05751aa6a0e01da78662ceafd0161f3f5e", new BigInteger(
|
||||
"1182423723677118831606503500858825217076578422970565964857326298418401529955036896808663335300684244453386039908536275400945824932191521017102701344437753036730900076162922741167523337650578479960119614237031234925702200473053235777")));
|
||||
all.add(secret(3, "514816d583044efbd336882227deb822194ff63e3bdc3cf707a01f17770d5a6a", new BigInteger(
|
||||
@ -87,9 +88,8 @@ public class Dedications {
|
||||
final TinyHashableString sentence = new TinyHashableString(line);
|
||||
for (Dedication dedication : all) {
|
||||
final BufferedImage image = dedication.getImage(sentence);
|
||||
if (image != null) {
|
||||
if (image != null)
|
||||
return image;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class Noise {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void shuffle(byte[] buffer, MTRandom rnd) {
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
final int r1 = rnd.nextInt();
|
||||
@ -83,11 +83,11 @@ public class Noise {
|
||||
buffer[b] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void xor(byte[] buffer, byte[] xor) {
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
for (int i = 0; i < buffer.length; i++)
|
||||
buffer[i] ^= xor[i % xor.length];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void xor(byte[] buffer, BlumBlumShub rnd) {
|
||||
@ -96,7 +96,7 @@ public class Noise {
|
||||
buffer[i] = (byte) (buffer[i] ^ mask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static byte[] reverse(byte[] buffer, int delta) {
|
||||
delta = Math.abs(delta) % buffer.length;
|
||||
final byte result[] = new byte[buffer.length];
|
||||
@ -105,10 +105,4 @@ public class Noise {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ public class PSystemDedicationFactory extends PSystemSingleLineFactory {
|
||||
@Override
|
||||
protected AbstractPSystem executeLine(UmlSource source, String line) {
|
||||
final BufferedImage dedication = Dedications.get(line);
|
||||
if (dedication != null) {
|
||||
if (dedication != null)
|
||||
return new PSystemDedication(source, dedication);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ public class QBlock {
|
||||
for (int i = 0; i < size; i++) {
|
||||
final int read = source.read();
|
||||
if (read == -1) {
|
||||
if (i == 0) {
|
||||
if (i == 0)
|
||||
return null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
block[i + 1] = (byte) read;
|
||||
@ -77,15 +77,15 @@ public class QBlock {
|
||||
|
||||
public byte[] getData512() {
|
||||
final byte[] nb = big.toByteArray();
|
||||
if (nb.length == 512) {
|
||||
if (nb.length == 512)
|
||||
return nb;
|
||||
}
|
||||
|
||||
final byte[] result = new byte[512];
|
||||
if (nb.length < 512) {
|
||||
if (nb.length < 512)
|
||||
System.arraycopy(nb, 0, result, 512 - nb.length, nb.length);
|
||||
} else {
|
||||
else
|
||||
System.arraycopy(nb, nb.length - 512, result, 0, 512);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -101,11 +101,10 @@ public class QBlock {
|
||||
public void write(OutputStream os, int size) throws IOException {
|
||||
final byte[] data = big.toByteArray();
|
||||
final int start = data.length - size;
|
||||
if (start < 0) {
|
||||
for (int i = 0; i < -start; i++) {
|
||||
if (start < 0)
|
||||
for (int i = 0; i < -start; i++)
|
||||
os.write(0);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = Math.max(start, 0); i < data.length; i++) {
|
||||
int b = data[i];
|
||||
os.write(b);
|
||||
|
@ -54,18 +54,18 @@ public class QBlocks {
|
||||
final QBlocks result = new QBlocks();
|
||||
while (true) {
|
||||
final QBlock block = QBlock.read(source, size);
|
||||
if (block == null) {
|
||||
if (block == null)
|
||||
return result;
|
||||
}
|
||||
|
||||
result.all.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
public QBlocks change(BigInteger E, BigInteger N) {
|
||||
final QBlocks result = new QBlocks();
|
||||
for (QBlock rsa : all) {
|
||||
for (QBlock rsa : all)
|
||||
result.all.add(rsa.change(E, N));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,9 @@ public class RBlock {
|
||||
}
|
||||
|
||||
public byte[] getData(int size) {
|
||||
if (buffer.length == size) {
|
||||
if (buffer.length == size)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
final byte[] result = new byte[size];
|
||||
System.arraycopy(buffer, buffer.length - size, result, 0, size);
|
||||
return result;
|
||||
|
@ -75,9 +75,9 @@ public class RBlocks {
|
||||
|
||||
public RBlocks change(BigInteger E, BigInteger N) {
|
||||
final RBlocks result = new RBlocks();
|
||||
for (RBlock rsa : all) {
|
||||
for (RBlock rsa : all)
|
||||
result.all.add(rsa.change(E, N));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -51,9 +51,9 @@ public final class TinyHashableString {
|
||||
}
|
||||
|
||||
public synchronized int tinyHash() {
|
||||
if (cachedTinyHash == -1) {
|
||||
if (cachedTinyHash == -1)
|
||||
cachedTinyHash = Noise.shortHash(sentence.getBytes(UTF_8), Dedication.N.toByteArray());
|
||||
}
|
||||
|
||||
return cachedTinyHash;
|
||||
|
||||
}
|
||||
|
@ -45,14 +45,14 @@ public class TurningBytes {
|
||||
}
|
||||
|
||||
public byte nextByte() {
|
||||
if (key.length == 0) {
|
||||
if (key.length == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
final byte result = key[idx];
|
||||
idx++;
|
||||
if (idx >= key.length) {
|
||||
if (idx >= key.length)
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
BIN
src/net/sourceforge/plantuml/dedication/baraye.png
Normal file
BIN
src/net/sourceforge/plantuml/dedication/baraye.png
Normal file
Binary file not shown.
@ -92,15 +92,15 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
||||
lines = lines.trim().removeEmptyLines();
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
|
||||
final IEntity entity = executeArg0(diagram, line0);
|
||||
if (entity == null) {
|
||||
if (entity == null)
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
}
|
||||
|
||||
lines = lines.subExtract(1, 1);
|
||||
for (StringLocated s : lines) {
|
||||
assert s.getString().length() > 0;
|
||||
if (VisibilityModifier.isVisibilityCharacter(s.getString())) {
|
||||
if (VisibilityModifier.isVisibilityCharacter(s.getString()))
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
|
||||
entity.getBodier().addFieldOrMethod(s.getString());
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
@ -113,9 +113,9 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
||||
final String display = line0.get("NAME", 0);
|
||||
final String stereotype = line0.get("STEREO", 0);
|
||||
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
|
||||
if (leafExist) {
|
||||
if (leafExist)
|
||||
return diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), code, LeafType.OBJECT, null);
|
||||
}
|
||||
|
||||
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
@ -123,8 +123,8 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
final String s = line0.get("COLOR", 0);
|
||||
entity.setSpecificColorTOBEREMOVED(ColorType.BACK, s == null ? null
|
||||
: diagram.getSkinParam().getIHtmlColorSet().getColor(s));
|
||||
entity.setSpecificColorTOBEREMOVED(ColorType.BACK,
|
||||
s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s));
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public abstract class Eater {
|
||||
|
||||
final public TValue eatExpression(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated {
|
||||
if (peekChar() == '{') {
|
||||
String data = eatAllToEnd();
|
||||
final String data = eatAllToEnd();
|
||||
// System.err.println("data=" + data);
|
||||
final JsonValue json = Json.parse(data);
|
||||
// System.err.println("json=" + json);
|
||||
@ -92,9 +92,9 @@ public abstract class Eater {
|
||||
final protected TokenStack eatTokenStack() throws EaterException {
|
||||
final TokenStack tokenStack = new TokenStack();
|
||||
addIntoTokenStack(tokenStack, false);
|
||||
if (tokenStack.size() == 0) {
|
||||
if (tokenStack.size() == 0)
|
||||
throw EaterException.located("Missing expression");
|
||||
}
|
||||
|
||||
return tokenStack;
|
||||
}
|
||||
|
||||
@ -106,21 +106,23 @@ public abstract class Eater {
|
||||
}
|
||||
|
||||
final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterException {
|
||||
Token lastToken = null;
|
||||
while (true) {
|
||||
final Token token = TokenType.eatOneToken(this, stopAtColon);
|
||||
// System.err.println("token=" + token);
|
||||
if (token == null) {
|
||||
final Token token = TokenType.eatOneToken(lastToken, this, stopAtColon);
|
||||
if (token == null)
|
||||
return;
|
||||
}
|
||||
|
||||
tokenStack.add(token);
|
||||
if (token.getTokenType() != TokenType.SPACES)
|
||||
lastToken = token;
|
||||
}
|
||||
}
|
||||
|
||||
final public String eatAndGetQuotedString() throws EaterException {
|
||||
final char separator = peekChar();
|
||||
if (TLineType.isQuote(separator) == false) {
|
||||
if (TLineType.isQuote(separator) == false)
|
||||
throw EaterException.located("quote10");
|
||||
}
|
||||
|
||||
checkAndEatChar(separator);
|
||||
final StringBuilder value = new StringBuilder();
|
||||
addUpTo(separator, value);
|
||||
@ -130,27 +132,27 @@ public abstract class Eater {
|
||||
|
||||
final protected String eatAndGetOptionalQuotedString() throws EaterException {
|
||||
final char quote = peekChar();
|
||||
if (TLineType.isQuote(quote)) {
|
||||
if (TLineType.isQuote(quote))
|
||||
return eatAndGetQuotedString();
|
||||
}
|
||||
|
||||
final StringBuilder value = new StringBuilder();
|
||||
// DEPLICATE eatUntilCloseParenthesisOrComma
|
||||
|
||||
int level = 0;
|
||||
while (true) {
|
||||
char ch = peekChar();
|
||||
if (ch == 0) {
|
||||
if (ch == 0)
|
||||
throw EaterException.located("until001");
|
||||
}
|
||||
if (level == 0 && (ch == ',' || ch == ')')) {
|
||||
|
||||
if (level == 0 && (ch == ',' || ch == ')'))
|
||||
return value.toString().trim();
|
||||
}
|
||||
|
||||
ch = eatOneChar();
|
||||
if (ch == '(') {
|
||||
if (ch == '(')
|
||||
level++;
|
||||
} else if (ch == ')') {
|
||||
else if (ch == ')')
|
||||
level--;
|
||||
}
|
||||
|
||||
value.append(ch);
|
||||
}
|
||||
|
||||
@ -162,9 +164,14 @@ public abstract class Eater {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
while (true) {
|
||||
final char ch = peekChar();
|
||||
if (ch == 0 || TLineType.isLatinDigit(ch) == false) {
|
||||
return result.toString();
|
||||
if (result.length() == 0 && ch == '-') {
|
||||
result.append(eatOneChar());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == 0 || TLineType.isLatinDigit(ch) == false)
|
||||
return result.toString();
|
||||
|
||||
result.append(eatOneChar());
|
||||
}
|
||||
}
|
||||
@ -173,47 +180,47 @@ public abstract class Eater {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
while (true) {
|
||||
final char ch = peekChar();
|
||||
if (ch == 0 || TLineType.isSpaceChar(ch) == false) {
|
||||
if (ch == 0 || TLineType.isSpaceChar(ch) == false)
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
result.append(eatOneChar());
|
||||
}
|
||||
}
|
||||
|
||||
final protected String eatAndGetVarname() throws EaterException {
|
||||
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) {
|
||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
||||
throw EaterException.located("a002");
|
||||
}
|
||||
|
||||
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
||||
return varname.toString();
|
||||
}
|
||||
|
||||
final protected String eatAndGetFunctionName() throws EaterException {
|
||||
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) {
|
||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
||||
throw EaterException.located("a003");
|
||||
}
|
||||
|
||||
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
||||
return varname.toString();
|
||||
}
|
||||
|
||||
final public void skipSpaces() {
|
||||
while (i < s.length() && Character.isWhitespace(s.charAt(i))) {
|
||||
while (i < s.length() && Character.isWhitespace(s.charAt(i)))
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final protected void skipUntilChar(char ch) {
|
||||
while (i < s.length() && s.charAt(i) != ch) {
|
||||
while (i < s.length() && s.charAt(i) != ch)
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final public char peekChar() {
|
||||
if (i >= s.length()) {
|
||||
if (i >= s.length())
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s.charAt(i);
|
||||
}
|
||||
|
||||
@ -224,9 +231,9 @@ public abstract class Eater {
|
||||
}
|
||||
|
||||
final public char peekCharN2() {
|
||||
if (i + 1 >= s.length()) {
|
||||
if (i + 1 >= s.length())
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s.charAt(i + 1);
|
||||
}
|
||||
|
||||
@ -241,40 +248,40 @@ public abstract class Eater {
|
||||
}
|
||||
|
||||
final protected void checkAndEatChar(char ch) throws EaterException {
|
||||
if (i >= s.length() || s.charAt(i) != ch) {
|
||||
if (i >= s.length() || s.charAt(i) != ch)
|
||||
throw EaterException.located("a001");
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
final protected boolean safeCheckAndEatChar(char ch) throws EaterException {
|
||||
if (i >= s.length() || s.charAt(i) != ch) {
|
||||
if (i >= s.length() || s.charAt(i) != ch)
|
||||
return false;
|
||||
}
|
||||
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
|
||||
final protected void optionallyEatChar(char ch) throws EaterException {
|
||||
if (i >= s.length() || s.charAt(i) != ch) {
|
||||
if (i >= s.length() || s.charAt(i) != ch)
|
||||
return;
|
||||
}
|
||||
|
||||
assert s.charAt(i) == ch;
|
||||
i++;
|
||||
}
|
||||
|
||||
final protected void checkAndEatChar(String s) throws EaterException {
|
||||
for (int j = 0; j < s.length(); j++) {
|
||||
for (int j = 0; j < s.length(); j++)
|
||||
checkAndEatChar(s.charAt(j));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final protected void addUpToLastLetterOrUnderscoreOrDigit(StringBuilder sb) {
|
||||
while (i < s.length()) {
|
||||
final char ch = s.charAt(i);
|
||||
if (TLineType.isLetterOrUnderscoreOrDigit(ch) == false) {
|
||||
if (TLineType.isLetterOrUnderscoreOrDigit(ch) == false)
|
||||
return;
|
||||
}
|
||||
|
||||
i++;
|
||||
sb.append(ch);
|
||||
}
|
||||
@ -283,26 +290,14 @@ public abstract class Eater {
|
||||
final protected void addUpTo(char separator, StringBuilder sb) {
|
||||
while (i < s.length()) {
|
||||
final char ch = peekChar();
|
||||
if (ch == separator) {
|
||||
if (ch == separator)
|
||||
return;
|
||||
}
|
||||
|
||||
i++;
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
|
||||
// final protected void addUpToUnused(char separator1, char separator2,
|
||||
// StringBuilder sb) {
|
||||
// while (i < s.length()) {
|
||||
// final char ch = peekChar();
|
||||
// if (ch == separator1 || ch == separator2) {
|
||||
// return;
|
||||
// }
|
||||
// i++;
|
||||
// sb.append(ch);
|
||||
// }
|
||||
// }
|
||||
|
||||
final protected TFunctionImpl eatDeclareFunction(TContext context, TMemory memory, boolean unquoted,
|
||||
LineLocation location, boolean allowNoParenthesis, TFunctionType type)
|
||||
throws EaterException, EaterExceptionLocated {
|
||||
@ -310,9 +305,9 @@ public abstract class Eater {
|
||||
final String functionName = eatAndGetFunctionName();
|
||||
skipSpaces();
|
||||
if (safeCheckAndEatChar('(') == false) {
|
||||
if (allowNoParenthesis) {
|
||||
if (allowNoParenthesis)
|
||||
return new TFunctionImpl(functionName, args, unquoted, type);
|
||||
}
|
||||
|
||||
throw EaterException.located("Missing opening parenthesis");
|
||||
}
|
||||
while (true) {
|
||||
|
@ -58,9 +58,9 @@ public class Token {
|
||||
}
|
||||
|
||||
public TokenOperator getTokenOperator() {
|
||||
if (this.tokenType != TokenType.OPERATOR) {
|
||||
if (this.tokenType != TokenType.OPERATOR)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final char ch2 = surface.length() > 1 ? surface.charAt(1) : 0;
|
||||
return TokenOperator.getTokenOperator(surface.charAt(0), ch2);
|
||||
}
|
||||
@ -74,16 +74,16 @@ public class Token {
|
||||
}
|
||||
|
||||
public Token muteToFunction() {
|
||||
if (this.tokenType != TokenType.PLAIN_TEXT) {
|
||||
if (this.tokenType != TokenType.PLAIN_TEXT)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return new Token(surface, TokenType.FUNCTION_NAME, null);
|
||||
}
|
||||
|
||||
public JsonValue getJson() {
|
||||
if (this.tokenType != TokenType.JSON_DATA) {
|
||||
if (this.tokenType != TokenType.JSON_DATA)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.tim.expression;
|
||||
|
||||
|
||||
//https://en.cppreference.com/w/c/language/operator_precedence
|
||||
|
||||
public enum TokenOperator {
|
||||
@ -53,7 +52,7 @@ public enum TokenOperator {
|
||||
return v1.add(v2);
|
||||
}
|
||||
},
|
||||
SUBSTRACTION(100 - 4, "-") {
|
||||
SUBSTRACTION(100 - 4, "" + TokenType.COMMERCIAL_MINUS_SIGN) {
|
||||
public TValue operate(TValue v1, TValue v2) {
|
||||
return v1.minus(v2);
|
||||
}
|
||||
@ -97,8 +96,7 @@ public enum TokenOperator {
|
||||
public TValue operate(TValue v1, TValue v2) {
|
||||
return v1.logicalOr(v2);
|
||||
}
|
||||
},
|
||||
;
|
||||
};
|
||||
|
||||
private final int precedence;
|
||||
private final String display;
|
||||
@ -113,16 +111,14 @@ public enum TokenOperator {
|
||||
}
|
||||
|
||||
public static TokenOperator getTokenOperator(char ch, char ch2) {
|
||||
for (TokenOperator op : TokenOperator.values()) {
|
||||
if (op.display.length() == 2 && op.display.charAt(0) == ch && op.display.charAt(1) == ch2) {
|
||||
for (TokenOperator op : TokenOperator.values())
|
||||
if (op.display.length() == 2 && op.display.charAt(0) == ch && op.display.charAt(1) == ch2)
|
||||
return op;
|
||||
}
|
||||
}
|
||||
for (TokenOperator op : TokenOperator.values()) {
|
||||
if (op.display.length() == 1 && op.display.charAt(0) == ch) {
|
||||
|
||||
for (TokenOperator op : TokenOperator.values())
|
||||
if (op.display.length() == 1 && op.display.charAt(0) == ch)
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -53,33 +53,6 @@ public class TokenStack {
|
||||
|
||||
final private List<Token> tokens;
|
||||
|
||||
// public boolean isSpecialAffectationWhenFunctionCall() {
|
||||
// if (tokens.size() != 1) {
|
||||
// return false;
|
||||
// }
|
||||
// final Token single = tokens.get(0);
|
||||
// if (single.getTokenType() != TokenType.PLAIN_TEXT) {
|
||||
// return false;
|
||||
// }
|
||||
// return isSpecialAffectationWhenFunctionCall(single.getSurface());
|
||||
// }
|
||||
//
|
||||
// public static boolean isSpecialAffectationWhenFunctionCall(String surface) {
|
||||
// final int idx = surface.indexOf('=');
|
||||
// if (idx <= 0) {
|
||||
// return false;
|
||||
// }
|
||||
// if (TLineType.isLetterOrUnderscoreOrDollar(surface.charAt(0)) == false) {
|
||||
// return false;
|
||||
// }
|
||||
// for (int i = 1; i < idx; i++) {
|
||||
// if (TLineType.isLetterOrUnderscoreOrDigit(surface.charAt(i)) == false) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
public TokenStack() {
|
||||
this(new ArrayList<Token>());
|
||||
}
|
||||
@ -117,6 +90,7 @@ public class TokenStack {
|
||||
static public TokenStack eatUntilCloseParenthesisOrComma(Eater eater) throws EaterException {
|
||||
final TokenStack result = new TokenStack();
|
||||
int level = 0;
|
||||
Token lastToken = null;
|
||||
while (true) {
|
||||
eater.skipSpaces();
|
||||
final char ch = eater.peekChar();
|
||||
@ -126,13 +100,15 @@ public class TokenStack {
|
||||
if (level == 0 && (ch == ',' || ch == ')'))
|
||||
return result;
|
||||
|
||||
final Token token = TokenType.eatOneToken(eater, false);
|
||||
final Token token = TokenType.eatOneToken(lastToken, eater, false);
|
||||
final TokenType type = token.getTokenType();
|
||||
if (type == TokenType.OPEN_PAREN_MATH)
|
||||
level++;
|
||||
else if (type == TokenType.CLOSE_PAREN_MATH)
|
||||
level--;
|
||||
|
||||
if (token.getTokenType() != TokenType.SPACES)
|
||||
lastToken = token;
|
||||
result.add(token);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,10 @@ import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.TLineType;
|
||||
|
||||
public enum TokenType {
|
||||
QUOTED_STRING, JSON_DATA, OPERATOR, OPEN_PAREN_MATH, COMMA, CLOSE_PAREN_MATH, NUMBER, PLAIN_TEXT, SPACES, FUNCTION_NAME, OPEN_PAREN_FUNC, CLOSE_PAREN_FUNC;
|
||||
QUOTED_STRING, JSON_DATA, OPERATOR, OPEN_PAREN_MATH, COMMA, CLOSE_PAREN_MATH, NUMBER, PLAIN_TEXT, SPACES,
|
||||
FUNCTION_NAME, OPEN_PAREN_FUNC, CLOSE_PAREN_FUNC;
|
||||
|
||||
public static final char COMMERCIAL_MINUS_SIGN = '\u2052';
|
||||
|
||||
private boolean isSingleChar1() {
|
||||
return this == OPEN_PAREN_MATH || this == COMMA || this == CLOSE_PAREN_MATH;
|
||||
@ -47,47 +50,52 @@ public enum TokenType {
|
||||
|
||||
private static boolean isPlainTextBreak(char ch, char ch2) {
|
||||
final TokenType tmp = fromChar(ch, ch2);
|
||||
if (tmp.isSingleChar1() || tmp == TokenType.OPERATOR || tmp == SPACES) {
|
||||
if (tmp.isSingleChar1() || tmp == TokenType.OPERATOR || tmp == SPACES)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static TokenType fromChar(char ch, char ch2) {
|
||||
TokenType result = PLAIN_TEXT;
|
||||
if (TLineType.isQuote(ch)) {
|
||||
if (TLineType.isQuote(ch))
|
||||
result = QUOTED_STRING;
|
||||
} else if (TokenOperator.getTokenOperator(ch, ch2) != null) {
|
||||
else if (TokenOperator.getTokenOperator(ch, ch2) != null)
|
||||
result = OPERATOR;
|
||||
} else if (ch == '(') {
|
||||
else if (ch == '(')
|
||||
result = OPEN_PAREN_MATH;
|
||||
} else if (ch == ')') {
|
||||
else if (ch == ')')
|
||||
result = CLOSE_PAREN_MATH;
|
||||
} else if (ch == ',') {
|
||||
else if (ch == ',')
|
||||
result = COMMA;
|
||||
} else if (TLineType.isLatinDigit(ch)) {
|
||||
else if (TLineType.isLatinDigit(ch))
|
||||
result = NUMBER;
|
||||
} else if (TLineType.isSpaceChar(ch)) {
|
||||
else if (TLineType.isSpaceChar(ch))
|
||||
result = SPACES;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
final static public Token eatOneToken(Eater eater, boolean manageColon) throws EaterException {
|
||||
final char ch = eater.peekChar();
|
||||
if (ch == 0) {
|
||||
final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon) throws EaterException {
|
||||
char ch = eater.peekChar();
|
||||
if (ch == 0)
|
||||
return null;
|
||||
}
|
||||
if (manageColon && ch == ':') {
|
||||
|
||||
if (manageColon && ch == ':')
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ch == '-' && isTheMinusAnOperation(lastToken))
|
||||
ch = COMMERCIAL_MINUS_SIGN;
|
||||
|
||||
final TokenOperator tokenOperator = TokenOperator.getTokenOperator(ch, eater.peekCharN2());
|
||||
if (TLineType.isQuote(ch)) {
|
||||
return new Token(eater.eatAndGetQuotedString(), TokenType.QUOTED_STRING, null);
|
||||
} else if (tokenOperator != null) {
|
||||
if (tokenOperator.getDisplay().length() == 1) {
|
||||
return new Token(eater.eatOneChar(), TokenType.OPERATOR, null);
|
||||
eater.eatOneChar();
|
||||
return new Token(ch, TokenType.OPERATOR, null);
|
||||
}
|
||||
|
||||
return new Token("" + eater.eatOneChar() + eater.eatOneChar(), TokenType.OPERATOR, null);
|
||||
} else if (ch == '(') {
|
||||
return new Token(eater.eatOneChar(), TokenType.OPEN_PAREN_MATH, null);
|
||||
@ -95,7 +103,7 @@ public enum TokenType {
|
||||
return new Token(eater.eatOneChar(), TokenType.CLOSE_PAREN_MATH, null);
|
||||
} else if (ch == ',') {
|
||||
return new Token(eater.eatOneChar(), TokenType.COMMA, null);
|
||||
} else if (TLineType.isLatinDigit(ch)) {
|
||||
} else if (TLineType.isLatinDigit(ch) || ch == '-') {
|
||||
return new Token(eater.eatAndGetNumber(), TokenType.NUMBER, null);
|
||||
} else if (TLineType.isSpaceChar(ch)) {
|
||||
return new Token(eater.eatAndGetSpaces(), TokenType.SPACES, null);
|
||||
@ -103,13 +111,22 @@ public enum TokenType {
|
||||
return new Token(eatAndGetTokenPlainText(eater), TokenType.PLAIN_TEXT, null);
|
||||
}
|
||||
|
||||
private static boolean isTheMinusAnOperation(Token lastToken) {
|
||||
if (lastToken == null)
|
||||
return false;
|
||||
final TokenType type = lastToken.getTokenType();
|
||||
if (type == TokenType.OPERATOR)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static private String eatAndGetTokenPlainText(Eater eater) throws EaterException {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
while (true) {
|
||||
final char ch = eater.peekChar();
|
||||
if (ch == 0 || TokenType.isPlainTextBreak(ch, eater.peekCharN2())) {
|
||||
if (ch == 0 || TokenType.isPlainTextBreak(ch, eater.peekCharN2()))
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
result.append(eater.eatOneChar());
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ import net.sourceforge.plantuml.timingdiagram.TimingNote;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingRuler;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
|
||||
@ -184,20 +185,13 @@ public class Ribbon implements PDrawing {
|
||||
}
|
||||
|
||||
private void drawPentaA(UGraphic ug, double len, ChangeState change) {
|
||||
SymbolContext context;
|
||||
if (change == null) {
|
||||
final HColor back = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
|
||||
final HColor line = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
|
||||
context = new SymbolContext(back, line).withStroke(style.getStroke());
|
||||
} else {
|
||||
context = change.getContext(skinParam, style);
|
||||
final HColor back = initialColors.getColor(ColorType.BACK);
|
||||
final HColor line = initialColors.getColor(ColorType.LINE);
|
||||
if (back != null)
|
||||
context = context.withBackColor(back);
|
||||
if (line != null)
|
||||
context = context.withForeColor(line);
|
||||
}
|
||||
SymbolContext context = change.getContext(skinParam, style);
|
||||
final HColor back = initialColors.getColor(ColorType.BACK);
|
||||
final HColor line = initialColors.getColor(ColorType.LINE);
|
||||
if (back != null)
|
||||
context = context.withBackColor(back);
|
||||
if (line != null)
|
||||
context = context.withForeColor(line);
|
||||
|
||||
final PentaAShape shape = PentaAShape.create(len, getRibbonHeight(), context);
|
||||
shape.drawU(ug);
|
||||
@ -262,9 +256,8 @@ public class Ribbon implements PDrawing {
|
||||
return;
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
if (changes.size() == 0) {
|
||||
final double a = 0;
|
||||
drawPentaA(ug.apply(UTranslate.dx(-getInitialWidth(stringBounder))), getInitialWidth(stringBounder) + a,
|
||||
null);
|
||||
drawSingle(ug.apply(UTranslate.dx(-getInitialWidth(stringBounder))),
|
||||
getInitialWidth(stringBounder) + ruler.getWidth());
|
||||
} else {
|
||||
final double a = getPosInPixel(changes.get(0));
|
||||
drawPentaA(ug.apply(UTranslate.dx(-getInitialWidth(stringBounder))), getInitialWidth(stringBounder) + a,
|
||||
@ -281,6 +274,23 @@ public class Ribbon implements PDrawing {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawSingle(UGraphic ug, double len) {
|
||||
final HColor back = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
|
||||
final HColor line = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
|
||||
SymbolContext context = new SymbolContext(back, back).withStroke(style.getStroke());
|
||||
ug = context.apply(ug);
|
||||
|
||||
final double height = getRibbonHeight();
|
||||
final URectangle rect = new URectangle(len, height);
|
||||
ug.draw(rect);
|
||||
|
||||
final ULine border = ULine.hline(len);
|
||||
ug = ug.apply(line);
|
||||
ug.draw(border);
|
||||
ug.apply(UTranslate.dy(height)).draw(border);
|
||||
|
||||
}
|
||||
|
||||
private void drawStates(UGraphic ug) {
|
||||
for (int i = 0; i < changes.size() - 1; i++) {
|
||||
final double a = getPosInPixel(changes.get(i));
|
||||
|
@ -81,7 +81,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static int beta() {
|
||||
final int beta = 5;
|
||||
final int beta = 7;
|
||||
return beta;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user