Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openmole
gate
Commits
e8ccc4e0
Commit
e8ccc4e0
authored
Mar 31, 2017
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some doc
parent
42bdff67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
FlowChart.scala
client/src/main/scala/fr/iscpif/client/FlowChart.scala
+9
-3
No files found.
client/src/main/scala/fr/iscpif/client/FlowChart.scala
View file @
e8ccc4e0
...
@@ -33,6 +33,7 @@ trait Selectable {
...
@@ -33,6 +33,7 @@ trait Selectable {
val
selected
:
Var
[
Boolean
]
=
Var
(
false
)
val
selected
:
Var
[
Boolean
]
=
Var
(
false
)
}
}
// DEFINE SOME CASE CLASS TO STORE TASK AND EDGE STRUCTURES
object
Graph
{
object
Graph
{
case
class
Task
(
title
:
Var
[
String
]
=
Var
(
""
),
case
class
Task
(
title
:
Var
[
String
]
=
Var
(
""
),
...
@@ -81,6 +82,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -81,6 +82,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
val
MARK_END_ARROW
:
String
=
"mark-end-arrow"
val
MARK_END_ARROW
:
String
=
"mark-end-arrow"
val
URL_MARK_END_ARROW
:
String
=
s
"url(#${MARK_END_ARROW})"
val
URL_MARK_END_ARROW
:
String
=
s
"url(#${MARK_END_ARROW})"
// DEFINE A SVG ELEMENT TO DISPLAY A PHANTOM LINK WHILE DRAGGING A LINK FROM ONE TASK TO ANOTHER
class
DragLine
{
class
DragLine
{
private
val
m
:
Var
[(
Int
,
Int
)]
=
Var
((
0
,
0
))
private
val
m
:
Var
[(
Int
,
Int
)]
=
Var
((
0
,
0
))
private
val
l
:
Var
[(
Int
,
Int
)]
=
Var
((
0
,
0
))
private
val
l
:
Var
[(
Int
,
Int
)]
=
Var
((
0
,
0
))
...
@@ -122,6 +124,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -122,6 +124,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
val
mouseDownTask
:
Var
[
Option
[
Task
]]
=
Var
(
None
)
val
mouseDownTask
:
Var
[
Option
[
Task
]]
=
Var
(
None
)
val
dragging
:
Var
[
Option
[
DragLine
]]
=
Var
(
None
)
val
dragging
:
Var
[
Option
[
DragLine
]]
=
Var
(
None
)
// EVENT DEFINITIONS FOR MOUSEUP AND MOUSEDOWN ON THE SCENE
svg
.
onmousemove
=
(
me
:
MouseEvent
)
=>
mousemove
(
me
)
svg
.
onmousemove
=
(
me
:
MouseEvent
)
=>
mousemove
(
me
)
svg
.
onmouseup
=
(
me
:
MouseEvent
)
=>
mouseup
(
me
)
svg
.
onmouseup
=
(
me
:
MouseEvent
)
=>
mouseup
(
me
)
...
@@ -177,7 +180,8 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -177,7 +180,8 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
addTask
addTask
}
}
def
circle
(
task
:
Task
)
=
{
// RETURN A SVG CIRCLE, WHICH CAN BE SELECTED (ON CLICK), MOVED OR DELETED (DEL KEY)
def
circle
(
task
:
Task
)
=
{
val
element
:
SVGElement
=
Rx
{
val
element
:
SVGElement
=
Rx
{
svgTags
.
g
(
svgTags
.
g
(
ms
(
CIRCLE
+
{
ms
(
CIRCLE
+
{
...
@@ -214,6 +218,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -214,6 +218,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
addEdge
(
edge
(
e
.
source
.
now
,
e
.
target
.
now
))
addEdge
(
edge
(
e
.
source
.
now
,
e
.
target
.
now
))
}
}
// DEFINE A LINK, WHICH CAN BE SELECTED AND REMOVED (DEL KEY)
def
link
(
edge
:
Edge
)
=
{
def
link
(
edge
:
Edge
)
=
{
val
sVGElement
:
SVGElement
=
Rx
{
val
sVGElement
:
SVGElement
=
Rx
{
val
p
=
path
(
ms
=
(
if
(
edge
.
selected
())
ms
(
SELECTED
)
else
emptyMod
)
+++
val
p
=
path
(
ms
=
(
if
(
edge
.
selected
())
ms
(
SELECTED
)
else
emptyMod
)
+++
...
@@ -236,6 +241,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -236,6 +241,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
svgTags
.
g
(
sVGElement
).
render
svgTags
.
g
(
sVGElement
).
render
}
}
// ADD ALL LINKS AND CIRCLES ON THE SCENE. THE RX SEQUENCE IS AUTOMATICALLY RUN IN CASE OF tasks or edges ALTERATION
def
addToScene
[
T
](
s
:
Var
[
Seq
[
Var
[
T
]]],
draw
:
T
=>
SVGElement
)
=
{
def
addToScene
[
T
](
s
:
Var
[
Seq
[
Var
[
T
]]],
draw
:
T
=>
SVGElement
)
=
{
val
element
:
SVGElement
=
Rx
{
val
element
:
SVGElement
=
Rx
{
svgTags
.
g
(
svgTags
.
g
(
...
@@ -252,7 +258,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -252,7 +258,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
addToScene
(
edges
,
link
)
addToScene
(
edges
,
link
)
addToScene
(
tasks
,
circle
)
addToScene
(
tasks
,
circle
)
//
GLOBAL EVENTS //
//
DEAL WITH DEL KEY ACTION
dom
.
document
.
onkeydown
=
(
e
:
KeyboardEvent
)
=>
{
dom
.
document
.
onkeydown
=
(
e
:
KeyboardEvent
)
=>
{
e
.
keyCode
match
{
e
.
keyCode
match
{
case
DELETE_KEY
⇒
case
DELETE_KEY
⇒
...
@@ -266,7 +272,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
...
@@ -266,7 +272,7 @@ class GraphCreator(svg: SVGElement, _tasks: Seq[Task], _edges: Seq[Edge]) {
}
}
}
}
// ADD, SELECT AND REMOVE ITEMS
//
// ADD, SELECT AND REMOVE ITEMS
def
unselectTasks
=
tasks
.
now
.
foreach
{
t
⇒
t
.
now
.
selected
()
=
false
}
def
unselectTasks
=
tasks
.
now
.
foreach
{
t
⇒
t
.
now
.
selected
()
=
false
}
def
unselectEdges
=
edges
.
now
.
foreach
{
e
⇒
e
.
now
.
selected
()
=
false
}
def
unselectEdges
=
edges
.
now
.
foreach
{
e
⇒
e
.
now
.
selected
()
=
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment