Skip to content

Commit 2d8be90

Browse files
committed
docs: Update connection_selection_feedback_figure documentation
Focus on figure-level policy handling instead of technical implementation details
1 parent b0e7495 commit 2d8be90

46 files changed

Lines changed: 1041 additions & 73570 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dist/draw2d.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/draw2d.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/draw2d.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/examples/connection_selection_feedback/ConnectionSelectionFeedbackPolicy.js renamed to docs/examples/connection_selection_feedback_canvas/ConnectionSelectionFeedbackPolicy.js

File renamed without changes.

docs/examples/connection_selection_feedback/css/example.css renamed to docs/examples/connection_selection_feedback_canvas/css/example.css

File renamed without changes.

docs/examples/connection_selection_feedback/icon.png renamed to docs/examples/connection_selection_feedback_canvas/icon.png

File renamed without changes.

docs/examples/connection_selection_feedback/index.html renamed to docs/examples/connection_selection_feedback_canvas/index.html

File renamed without changes.

docs/examples/connection_selection_feedback/lib/jquery-ui.js renamed to docs/examples/connection_selection_feedback_canvas/lib/jquery-ui.js

File renamed without changes.

docs/examples/connection_selection_feedback/lib/jquery.js renamed to docs/examples/connection_selection_feedback_canvas/lib/jquery.js

File renamed without changes.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* A custom SelectionFeedbackPolicy for connections.
3+
* Extends LineSelectionFeedbackPolicy to add visual feedback (color, stroke, outline)
4+
* while keeping the standard resize handles functionality.
5+
*
6+
* @extends draw2d.policy.line.LineSelectionFeedbackPolicy
7+
*/
8+
var ConnectionSelectionFeedbackPolicy = draw2d.policy.line.LineSelectionFeedbackPolicy.extend({
9+
10+
NAME: "ConnectionSelectionFeedbackPolicy",
11+
12+
/**
13+
* Constructor
14+
*/
15+
init: function(attr, setter, getter) {
16+
this._super(attr, setter, getter);
17+
},
18+
19+
/**
20+
* Called when the figure is selected.
21+
* Store original attributes and apply selection feedback.
22+
*
23+
* @param {draw2d.Canvas} canvas - The canvas
24+
* @param {draw2d.Figure} figure - The figure being selected (should be a Connection)
25+
* @param {Boolean} isPrimarySelection - Whether this is the primary selection
26+
*/
27+
onSelect: function(canvas, figure, isPrimarySelection) {
28+
this._super(canvas, figure, isPrimarySelection);
29+
30+
// Store original state if not already stored
31+
if (!figure._selectionFeedbackState) {
32+
figure._selectionFeedbackState = {
33+
stroke: figure.getStroke(),
34+
color: figure.getColor(),
35+
outlineStroke: figure.getOutlineStroke(),
36+
outlineColor: figure.getOutlineColor()
37+
};
38+
}
39+
40+
// Apply selection feedback
41+
var originalColor = figure._selectionFeedbackState.color;
42+
var originalStroke = figure._selectionFeedbackState.stroke;
43+
44+
// Make color lighter (60% lighter) - originalColor is already a Color object
45+
var lighterColor = originalColor.lighter(0.6);
46+
47+
// Apply the visual feedback using attr() for batch update
48+
figure.attr({
49+
stroke: originalStroke * 2, // Double the stroke width
50+
color: lighterColor, // Lighter color
51+
outlineStroke: 3, // Add outline
52+
outlineColor: "#000000" // Black outline
53+
});
54+
},
55+
56+
/**
57+
* Called when the figure is unselected.
58+
* Restore original attributes.
59+
*
60+
* @param {draw2d.Canvas} canvas - The canvas
61+
* @param {draw2d.Figure} figure - The figure being unselected
62+
*/
63+
onUnselect: function(canvas, figure) {
64+
this._super(canvas, figure);
65+
66+
// Restore original attributes if we have stored state
67+
if (figure._selectionFeedbackState) {
68+
// Restore original attributes using attr() for batch update
69+
figure.attr({
70+
stroke: figure._selectionFeedbackState.stroke,
71+
color: figure._selectionFeedbackState.color,
72+
outlineStroke: figure._selectionFeedbackState.outlineStroke,
73+
outlineColor: figure._selectionFeedbackState.outlineColor
74+
});
75+
76+
// Clean up stored state
77+
delete figure._selectionFeedbackState;
78+
}
79+
},
80+
81+
});

0 commit comments

Comments
 (0)