-
Notifications
You must be signed in to change notification settings - Fork 36
feat!: configure IconPainter via constructor options #3419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f19ce42
feat!: configure IconPainter via constructor options
tbouffard e7d26c7
remove extra exclamation mark
tbouffard 34b07a9
simplify graph instantiation
tbouffard 166eb47
demo: let set a custom IconPainter by using a query parameter
tbouffard 9dc1ba1
demo - custom iconPainter: dynamic fill color, based on stroke color
tbouffard 2920339
EXTRA add missing method returned type
tbouffard b76dcfd
README: document some query parameter to tune the demo
tbouffard 7553ccc
improve jsdoc of RenderOptions.iconPainter
tbouffard 0d50ec2
integrate review feedback
tbouffard 9fcee53
Merge branch 'master' into feat/pass_iconPainter_to_constructor
tbouffard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| Copyright 2025 Bonitasoft S.A. | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import type { PaintParameter } from '../../../src/component/mxgraph/shape/render'; | ||
|
|
||
| import { IconPainter } from '../../../src/component/mxgraph/shape/render'; | ||
|
|
||
| // Taken from https://github.com/process-analytics/bpmn-visualization-examples/blob/v0.47.0/examples/custom-bpmn-theme/custom-user-task-icon/index.js#L9 | ||
| // The only difference is the fill color of the icon, which is not set here, to let the theme define it. | ||
| export class CustomIconPainter extends IconPainter { | ||
| // adapted from https://github.com/primer/octicons/blob/638c6683c96ec4b357576c7897be8f19c933c052/icons/person.svg | ||
| // use mxgraph-svg2shape to generate the code from the svg | ||
| override paintPersonIcon(paintParameter: PaintParameter): void { | ||
| const canvas = this.newBpmnCanvas(paintParameter, { height: 13, width: 12 }); | ||
| // respect the color in the current theme | ||
tbouffard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| canvas.setFillColor(paintParameter.iconStyleConfig.strokeColor); | ||
|
|
||
| canvas.begin(); | ||
| canvas.moveTo(12, 13); | ||
| canvas.arcTo(1, 1, 0, 0, 1, 11, 14); | ||
| canvas.lineTo(1, 14); | ||
| canvas.arcTo(1, 1, 0, 0, 1, 0, 13); | ||
| canvas.lineTo(0, 12); | ||
| canvas.curveTo(0, 9.37, 4, 8, 4, 8); | ||
| canvas.curveTo(4, 8, 4.23, 8, 4, 8); | ||
| canvas.curveTo(3.16, 6.38, 3.06, 5.41, 3, 3); | ||
| canvas.curveTo(3.17, 0.59, 4.87, 0, 6, 0); | ||
| canvas.curveTo(7.13, 0, 8.83, 0.59, 9, 3); | ||
| canvas.curveTo(8.94, 5.41, 8.84, 6.38, 8, 8); | ||
| canvas.curveTo(8, 8, 12, 9.37, 12, 12); | ||
| canvas.lineTo(12, 13); | ||
| canvas.close(); | ||
| canvas.fill(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.