Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProB 2 Jupyter Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB 2 Jupyter Kernel
Commits
df4aa861
Commit
df4aa861
authored
4 years ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Use new high-level dot and table visualization APIs
parent
17c0c37a
Branches
Branches containing commit
No related tags found
Loading
Checking pipeline status
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/prob2/jupyter/commands/DotCommand.java
+6
-7
6 additions, 7 deletions
src/main/java/de/prob2/jupyter/commands/DotCommand.java
src/main/java/de/prob2/jupyter/commands/TableCommand.java
+5
-10
5 additions, 10 deletions
src/main/java/de/prob2/jupyter/commands/TableCommand.java
with
11 additions
and
17 deletions
src/main/java/de/prob2/jupyter/commands/DotCommand.java
+
6
−
7
View file @
df4aa861
...
@@ -15,7 +15,7 @@ import com.google.inject.Inject;
...
@@ -15,7 +15,7 @@ import com.google.inject.Inject;
import
com.google.inject.Provider
;
import
com.google.inject.Provider
;
import
de.prob.animator.command.GetAllDotCommands
;
import
de.prob.animator.command.GetAllDotCommands
;
import
de.prob.animator.
command.GetSvgFor
VisualizationCommand
;
import
de.prob.animator.
domainobjects.Dot
VisualizationCommand
;
import
de.prob.animator.domainobjects.DynamicCommandItem
;
import
de.prob.animator.domainobjects.DynamicCommandItem
;
import
de.prob.animator.domainobjects.FormulaExpand
;
import
de.prob.animator.domainobjects.FormulaExpand
;
import
de.prob.animator.domainobjects.IEvalElement
;
import
de.prob.animator.domainobjects.IEvalElement
;
...
@@ -105,9 +105,8 @@ public final class DotCommand implements Command {
...
@@ -105,9 +105,8 @@ public final class DotCommand implements Command {
}
}
final
Trace
trace
=
this
.
animationSelector
.
getCurrentTrace
();
final
Trace
trace
=
this
.
animationSelector
.
getCurrentTrace
();
final
GetAllDotCommands
cmd1
=
new
GetAllDotCommands
(
trace
.
getCurrentState
());
final
DotVisualizationCommand
dotCommand
=
DotVisualizationCommand
.
getAll
(
trace
.
getCurrentState
())
trace
.
getStateSpace
().
execute
(
cmd1
);
.
stream
()
final
DynamicCommandItem
item
=
cmd1
.
getCommands
().
stream
()
.
filter
(
i
->
command
.
equals
(
i
.
getCommand
()))
.
filter
(
i
->
command
.
equals
(
i
.
getCommand
()))
.
findAny
()
.
findAny
()
.
orElseThrow
(()
->
new
UserErrorException
(
"No such dot command: "
+
command
));
.
orElseThrow
(()
->
new
UserErrorException
(
"No such dot command: "
+
command
));
...
@@ -118,9 +117,8 @@ public final class DotCommand implements Command {
...
@@ -118,9 +117,8 @@ public final class DotCommand implements Command {
}
catch
(
final
IOException
e
)
{
}
catch
(
final
IOException
e
)
{
throw
new
UncheckedIOException
(
"Failed to create temp file"
,
e
);
throw
new
UncheckedIOException
(
"Failed to create temp file"
,
e
);
}
}
final
GetSvgForVisualizationCommand
cmd2
=
new
GetSvgForVisualizationCommand
(
trace
.
getCurrentState
(),
item
,
outPath
.
toFile
(),
dotCommandArgs
);
// Provide source code (if any) to error highlighter
// Provide source code (if any) to error highlighter
final
Runnable
execute
=
()
->
trace
.
getStateSpace
().
execute
(
cmd2
);
final
Runnable
execute
=
()
->
dotCommand
.
visualizeAsSvgToFile
(
outPath
,
dotCommandArgs
);
if
(
code
!=
null
)
{
if
(
code
!=
null
)
{
CommandUtils
.
withSourceCode
(
code
,
execute
);
CommandUtils
.
withSourceCode
(
code
,
execute
);
}
else
{
}
else
{
...
@@ -153,7 +151,8 @@ public final class DotCommand implements Command {
...
@@ -153,7 +151,8 @@ public final class DotCommand implements Command {
final
GetAllDotCommands
cmd
=
new
GetAllDotCommands
(
trace
.
getCurrentState
());
final
GetAllDotCommands
cmd
=
new
GetAllDotCommands
(
trace
.
getCurrentState
());
trace
.
getStateSpace
().
execute
(
cmd
);
trace
.
getStateSpace
().
execute
(
cmd
);
final
String
prefix
=
commandName
.
substring
(
0
,
at
);
final
String
prefix
=
commandName
.
substring
(
0
,
at
);
final
List
<
String
>
commands
=
cmd
.
getCommands
().
stream
()
final
List
<
String
>
commands
=
DotVisualizationCommand
.
getAll
(
trace
.
getCurrentState
())
.
stream
()
.
filter
(
DynamicCommandItem:
:
isAvailable
)
.
filter
(
DynamicCommandItem:
:
isAvailable
)
.
map
(
DynamicCommandItem:
:
getCommand
)
.
map
(
DynamicCommandItem:
:
getCommand
)
.
filter
(
s
->
s
.
startsWith
(
prefix
))
.
filter
(
s
->
s
.
startsWith
(
prefix
))
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/prob2/jupyter/commands/TableCommand.java
+
5
−
10
View file @
df4aa861
...
@@ -7,12 +7,10 @@ import java.util.stream.Collectors;
...
@@ -7,12 +7,10 @@ import java.util.stream.Collectors;
import
com.google.inject.Inject
;
import
com.google.inject.Inject
;
import
com.google.inject.Provider
;
import
com.google.inject.Provider
;
import
de.prob.animator.command.GetAllTableCommands
;
import
de.prob.animator.command.GetTableForVisualizationCommand
;
import
de.prob.animator.domainobjects.DynamicCommandItem
;
import
de.prob.animator.domainobjects.FormulaExpand
;
import
de.prob.animator.domainobjects.FormulaExpand
;
import
de.prob.animator.domainobjects.IEvalElement
;
import
de.prob.animator.domainobjects.IEvalElement
;
import
de.prob.animator.domainobjects.TableData
;
import
de.prob.animator.domainobjects.TableData
;
import
de.prob.animator.domainobjects.TableVisualizationCommand
;
import
de.prob.statespace.AnimationSelector
;
import
de.prob.statespace.AnimationSelector
;
import
de.prob.statespace.Trace
;
import
de.prob.statespace.Trace
;
import
de.prob.unicode.UnicodeTranslator
;
import
de.prob.unicode.UnicodeTranslator
;
...
@@ -75,15 +73,12 @@ public final class TableCommand implements Command {
...
@@ -75,15 +73,12 @@ public final class TableCommand implements Command {
final
String
code
=
kernel
.
insertLetVariables
(
args
.
get
(
EXPRESSION_PARAM
));
final
String
code
=
kernel
.
insertLetVariables
(
args
.
get
(
EXPRESSION_PARAM
));
final
IEvalElement
formula
=
CommandUtils
.
withSourceCode
(
code
,
()
->
kernel
.
parseFormula
(
code
,
FormulaExpand
.
EXPAND
));
final
IEvalElement
formula
=
CommandUtils
.
withSourceCode
(
code
,
()
->
kernel
.
parseFormula
(
code
,
FormulaExpand
.
EXPAND
));
final
GetAllTableCommands
cmd1
=
new
GetAllTableCommands
(
trace
.
getCurrentState
());
final
TableData
table
=
TableVisualizationCommand
.
getAll
(
trace
.
getCurrentState
())
trace
.
getStateSpace
().
execute
(
cmd1
);
.
stream
()
final
DynamicCommandItem
dc
=
cmd1
.
getCommands
().
stream
()
.
filter
(
c
->
"expr_as_table"
.
equals
(
c
.
getCommand
()))
.
filter
(
c
->
"expr_as_table"
.
equals
(
c
.
getCommand
()))
.
findAny
()
.
findAny
()
.
orElseThrow
(
AssertionError:
:
new
);
.
orElseThrow
(
AssertionError:
:
new
)
final
GetTableForVisualizationCommand
cmd2
=
new
GetTableForVisualizationCommand
(
trace
.
getCurrentState
(),
dc
,
Collections
.
singletonList
(
formula
));
.
visualize
(
Collections
.
singletonList
(
formula
));
trace
.
getStateSpace
().
execute
(
cmd2
);
final
TableData
table
=
cmd2
.
getTable
();
final
StringBuilder
sbPlain
=
new
StringBuilder
();
final
StringBuilder
sbPlain
=
new
StringBuilder
();
final
StringBuilder
sbMarkdown
=
new
StringBuilder
();
final
StringBuilder
sbMarkdown
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment