Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
alg
Knowledge Space WP Plugin
Commits
9976fe6a
Commit
9976fe6a
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Added node labels to default render
parent
04dafd01
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
editor/js/editor.js
+1
-1
1 addition, 1 deletion
editor/js/editor.js
editor/js/state.js
+17
-1
17 additions, 1 deletion
editor/js/state.js
editor/js/tools/tool.js
+1
-1
1 addition, 1 deletion
editor/js/tools/tool.js
with
19 additions
and
3 deletions
editor/js/editor.js
+
1
−
1
View file @
9976fe6a
...
...
@@ -63,7 +63,7 @@ function load() {
state
.
onBackgroundClick
(
event
,
extractPositions
(
event
))
)
.
nodeCanvasObjectMode
((
node
)
=>
state
.
nodeCanvasObjectMode
(
node
))
.
nodeCanvasObject
((
node
,
ctx
)
=>
state
.
nodeCanvasObject
(
node
,
ctx
))
.
nodeCanvasObject
((
node
,
ctx
,
globalScale
)
=>
state
.
nodeCanvasObject
(
node
,
ctx
,
globalScale
))
.
onLinkClick
((
link
)
=>
state
.
onLinkClick
(
link
));
graph
.
onChangeCallbacks
.
push
((
data
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
editor/js/state.js
+
17
−
1
View file @
9976fe6a
...
...
@@ -124,7 +124,7 @@ export class State extends Tool {
return
key
.
keyCode
;
}
nodeCanvasObject
(
node
,
ctx
)
{
nodeCanvasObject
(
node
,
ctx
,
globalScale
)
{
var
toolValue
=
this
.
tool
.
nodeCanvasObject
(
node
,
ctx
);
if
(
toolValue
!==
undefined
)
{
...
...
@@ -156,6 +156,22 @@ export class State extends Tool {
);
}
// Draw label
const
label
=
node
[
Graph
.
NODE_LABEL
];
const
fontSize
=
11
/
globalScale
;
ctx
.
font
=
`
${
fontSize
}
px Sans-Serif`
;
const
textWidth
=
ctx
.
measureText
(
label
).
width
;
const
bckgDimensions
=
[
textWidth
,
fontSize
].
map
(
n
=>
n
+
fontSize
*
0.2
);
// some padding
const
nodeHeightOffset
=
Graph
.
IMAGE_SIZE
/
3
+
bckgDimensions
[
1
];
ctx
.
fillStyle
=
'
rgba(0, 0, 0, 0.5)
'
;
ctx
.
fillRect
(
node
.
x
-
bckgDimensions
[
0
]
/
2
,
node
.
y
-
bckgDimensions
[
1
]
/
2
+
nodeHeightOffset
,
...
bckgDimensions
);
ctx
.
textAlign
=
'
center
'
;
ctx
.
textBaseline
=
'
middle
'
;
ctx
.
fillStyle
=
'
white
'
;
ctx
.
fillText
(
label
,
node
.
x
,
node
.
y
+
nodeHeightOffset
);
// TODO: Render label as always visible
}
...
...
This diff is collapsed.
Click to expand it.
editor/js/tools/tool.js
+
1
−
1
View file @
9976fe6a
...
...
@@ -54,7 +54,7 @@ export default class Tool {
}
}
nodeCanvasObject
(
node
,
ctx
)
{
nodeCanvasObject
(
node
,
ctx
,
globalScale
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "nodeCanvasObject" not implemented.
'
);
}
...
...
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