Commit fd1b0be8 authored by Tobias Liese's avatar Tobias Liese

Begin working on interactive transitions

parent d025cfd4
Pipeline #96354 failed with stages
in 18 minutes and 19 seconds
Mrz 10, 2020 7:03:30 VORM. com.redhat.quarkus.ls.QuarkusLanguageServer initialize
INFORMATION: Initializing Quarkus server 0.0.4-20191120-1547 with C:\Users\tobia\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.6073.9\jbr
Mrz 10, 2020 8:54:53 VORM. com.redhat.quarkus.ls.QuarkusLanguageServer initialize
INFORMATION: Initializing Quarkus server 0.0.4-20191120-1547 with C:\Users\tobia\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.6073.9\jbr
Mrz 10, 2020 5:53:52 NACHM. com.redhat.quarkus.ls.QuarkusLanguageServer initialize
INFORMATION: Initializing Quarkus server 0.0.4-20191120-1547 with C:\Users\tobia\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.6073.9\jbr
Mrz 10, 2020 5:54:33 NACHM. org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNUNG: Notification threw an exception: {
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"version": 26,
"uri": "file:///C:/Users/tobia/Projekte/aut0m4t0n/src/main/resources/application.properties"
},
"contentChanges": [
{
"range": {
"start": {
"line": 5,
"character": 47
},
"end": {
"line": 6,
"character": 0
}
},
"rangeLength": -47,
"text": ""
}
]
}
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
at com.redhat.quarkus.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:140)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
... 12 more
Caused by: java.lang.StringIndexOutOfBoundsException: start 276, end 229, length 290
at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1724)
at java.base/java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:946)
at java.base/java.lang.StringBuilder.replace(StringBuilder.java:302)
at com.redhat.quarkus.ls.commons.TextDocument.update(TextDocument.java:177)
at com.redhat.quarkus.ls.commons.TextDocuments.onDidChangeTextDocument(TextDocuments.java:83)
at com.redhat.quarkus.ls.QuarkusTextDocumentService.didChange(QuarkusTextDocumentService.java:113)
... 16 more
......@@ -22,7 +22,6 @@ public class AutomatonResource {
@Path("{name}")
@Produces(MediaType.TEXT_HTML)
public TemplateInstance get(@PathParam("name") String name) {
return automaton.data("automaton", new Automaton(name, new User("")));
}
}
......@@ -57,12 +57,31 @@ class Field {
}
states.textContent = states.innerText.replace(/{.*}/gm, "{" + this.states.toString() + "}");
}
getStateIndex(x, y) {
getObjectAt(x, y) {
let i = 0;
while (i < this.states.length) {
let state = this.getStateByIndex(i);
if (Math.sqrt(Math.pow(x - state.x, 2) + Math.pow(y - state.y, 2)) <= state.radius) {
return i;
return state;
}
for (let transition of state.transitions.values()) {
for (let destination of transition) {
let vector = [
state.x - destination.x,
state.y - destination.y
];
let delta = [
state.x - x,
state.y - y
];
let tmp = delta[0] / vector[0];
let tmp2 = delta[1] / vector[1];
if ((tmp / tmp2 < 1.1) && (tmp / tmp2 > 0.99) &&
x > Math.min(state.x, destination.x) && x < Math.max(state.x, destination.x) &&
y > Math.min(state.y, destination.y) && y < Math.max(state.y, destination.y)) {
return transition;
}
}
}
i++;
}
......@@ -107,7 +126,7 @@ class State {
this.field.context.fillText(this.name, this.x, this.y + this.height);
this.transitions.forEach((states, key) => {
states.forEach((state) => {
this.field.drawLineTo(this, state.x, state.y, null);
this.field.drawLineTo(this, state.x, state.y, 20);
});
});
}
......@@ -118,7 +137,7 @@ class State {
onmousemove = (event) => {
let x = event.clientX - field.xOrigin + window.pageXOffset.valueOf();
let y = event.clientY - field.yOrigin + window.pageYOffset.valueOf();
selected = field.getStateIndex(x, y);
selected = field.getObjectAt(x, y);
if (selected != null) {
if (!transitionMode) {
lastSelected = selected;
......
......@@ -57,7 +57,6 @@ class Field {
this.context.lineTo(x, y)
// @todo add option to curve the line
// this.context.bezierCurveTo(orig.x / curve, orig.y * curve, x / curve, y * curve, x, y)
// this.context.quadraticCurveTo(((orig.x - x) / 2 + x) * curve, ((orig.y - y) / 2 + y) * curve, x, y)
this.context.stroke()
this.context.restore()
}
......@@ -72,13 +71,35 @@ class Field {
}
getStateIndex(x: number, y: number): number {
getObjectAt(x: number, y: number): Object {
// let's try every State and check if x and y are inside the state
let i: number = 0;
while (i < this.states.length) {
let state = this.getStateByIndex(i)
if (Math.sqrt(Math.pow(x - state.x, 2) + Math.pow(y - state.y, 2)) <= state.radius) {
return i
return state
}
// or the cursor points to a transition
for (let transition of state.transitions.values()) {
for (let destination of transition) {
let vector = [
state.x - destination.x,
state.y - destination.y
]
let delta = [
state.x - x,
state.y - y
]
let tmp = delta[0] / vector[0]
let tmp2 = delta[1] / vector[1]
if (
(tmp / tmp2 < 1.1) && (tmp / tmp2 > 0.99) &&
x > Math.min(state.x, destination.x) && x < Math.max(state.x, destination.x) &&
y > Math.min(state.y, destination.y) && y < Math.max(state.y, destination.y)
) {
return transition
}
}
}
i++
}
......@@ -141,7 +162,7 @@ class State {
)
this.transitions.forEach((states: State[], key: String) => {
states.forEach((state: State) => {
this.field.drawLineTo(this, state.x, state.y, null)
this.field.drawLineTo(this, state.x, state.y, 20)
})
}
)
......@@ -156,7 +177,7 @@ class State {
onmousemove = (event: MouseEvent) => {
let x = event.clientX - field.xOrigin + window.pageXOffset.valueOf()
let y = event.clientY - field.yOrigin + window.pageYOffset.valueOf()
selected = field.getStateIndex(x, y)
selected = field.getObjectAt(x, y)
if (selected != null) {
if (!transitionMode) {
lastSelected = selected
......@@ -233,7 +254,7 @@ let menuVisible: boolean = false
let editName: HTMLInputElement = <HTMLInputElement>document.getElementById("stateName")
let states = document.getElementById("states");
let contextMenu
let selected: number
let selected: Object
let lastSelected: number
const field: Field = new Field();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment