4242import de .bwravencl .controllerbuddy .input .action .ButtonToModeAction ;
4343import de .bwravencl .controllerbuddy .input .action .IAction ;
4444import de .bwravencl .controllerbuddy .input .action .IActivatableAction ;
45- import de .bwravencl .controllerbuddy .input .action .IActivatableAction .Activation ;
4645import de .bwravencl .controllerbuddy .input .action .ILongPressAction ;
4746import de .bwravencl .controllerbuddy .input .action .ToAxisAction ;
47+ import de .bwravencl .controllerbuddy .input .action .ToCursorAction ;
48+ import de .bwravencl .controllerbuddy .input .action .ToScrollAction ;
4849import de .bwravencl .controllerbuddy .json .ActionTypeAdapter ;
4950import de .bwravencl .controllerbuddy .json .ColorTypeAdapter ;
5051import de .bwravencl .controllerbuddy .json .LockKeyAdapter ;
128129import java .time .format .DateTimeFormatter ;
129130import java .time .format .FormatStyle ;
130131import java .util .ArrayList ;
132+ import java .util .Arrays ;
133+ import java .util .Collection ;
134+ import java .util .Collections ;
131135import java .util .Comparator ;
132136import java .util .EnumMap ;
133137import java .util .EnumSet ;
@@ -1887,20 +1891,17 @@ private int addTSpanElement(final List<? extends IAction<?>> actions, final Node
18871891 var description = action .getDescription (input );
18881892
18891893 if (action instanceof final ButtonToModeAction buttonToModeAction ) {
1890- description = (buttonToModeAction .isToggle () ? "⇪" : "⇧" ) + " " + description ;
1894+ description = description + " " + (buttonToModeAction .isToggle () ? "⇪" : "⇧" );
18911895 }
18921896
18931897 return description ;
1894- }).distinct ().collect (Collectors .joining (", " )), false , parentNode );
1898+ }).distinct ().collect (Collectors .joining (", " )), parentNode );
18951899 }
18961900
1897- private int addTSpanElement (final String textContent , final boolean bold , final Node parentNode ) {
1901+ private int addTSpanElement (final String textContent , final Node parentNode ) {
18981902 final var prefixTSpanElement = parentNode .getOwnerDocument ().createElementNS ("http://www.w3.org/2000/svg" ,
18991903 "tspan" );
19001904
1901- if (bold ) {
1902- prefixTSpanElement .setAttribute ("style" , "font-weight: bold" );
1903- }
19041905 prefixTSpanElement .setTextContent (textContent );
19051906 parentNode .appendChild (prefixTSpanElement );
19061907
@@ -1948,7 +1949,7 @@ private int addTSpanElement(final String textContent, final boolean bold, final
19481949 }
19491950 }
19501951
1951- final var font = new Font (fontFamily , bold ? Font . BOLD : Font .PLAIN , fontSizePt );
1952+ final var font = new Font (fontFamily , Font .PLAIN , fontSizePt );
19521953 final var fontMetrics = frame .getFontMetrics (font );
19531954
19541955 final var extensionWidth = fontMetrics .stringWidth (textContent );
@@ -4293,43 +4294,61 @@ private int updateSvgElements(final Document svgDocument, final String idPrefix,
42934294 }
42944295
42954296 final var delayedActions = new ArrayList <ILongPressAction <?>>();
4297+ final var whilePressedActions = new ArrayList <IActivatableAction <?>>();
4298+ final var onPressActions = new ArrayList <IActivatableAction <?>>();
42964299 final var onReleaseActions = new ArrayList <IActivatableAction <?>>();
42974300 final var otherActions = new ArrayList <IAction <?>>();
42984301
42994302 for (final var action : actions ) {
4300- var addToOtherActions = true ;
4301-
43024303 if (action instanceof final ILongPressAction <?> longPressAction && longPressAction .isLongPress ()) {
43034304 delayedActions .add (longPressAction );
4304- addToOtherActions = false ;
4305- }
4306- if (action instanceof final IActivatableAction <?> activatableAction
4307- && activatableAction .getActivation () == Activation .ON_RELEASE ) {
4308- onReleaseActions .add (activatableAction );
4309- addToOtherActions = false ;
4310- }
4311-
4312- if (addToOtherActions ) {
4305+ } else if (action instanceof final IActivatableAction <?> activatableAction ) {
4306+ switch (activatableAction .getActivation ()) {
4307+ case WHILE_PRESSED -> whilePressedActions .add (activatableAction );
4308+ case ON_PRESS -> onPressActions .add (activatableAction );
4309+ case ON_RELEASE -> onReleaseActions .add (activatableAction );
4310+ }
4311+ } else {
43134312 otherActions .add (action );
43144313 }
43154314 }
43164315
43174316 final List <? extends IAction <?>> actionGroupA ;
4318- final List <? extends IAction <?>> actionGroupB ;
4317+ List <? extends IAction <?>> actionGroupB ;
4318+ List <? extends IAction <?>> actionGroupC ;
43194319 final String groupAPrefix ;
4320- final String groupBPrefix ;
4320+ String groupBPrefix ;
4321+ String groupCPrefix ;
43214322
43224323 // noinspection SuspiciousMethodCalls
43234324 if (delayedActions .isEmpty () || delayedActions .containsAll (actions )) {
4324- actionGroupA = Stream .concat (otherActions .stream (), delayedActions .stream ()).toList ();
4325- actionGroupB = onReleaseActions ;
4326- groupAPrefix = "VISUALIZATION_ON_PRESS_PREFIX" ;
4327- groupBPrefix = "VISUALIZATION_ON_RELEASE_PREFIX" ;
4325+ final var partitionedNonActivateableActionsMap = Stream .of ( otherActions , delayedActions ).flatMap (Collection ::stream ).collect (Collectors .partitioningBy (action -> switch (action ) {
4326+ case final ButtonToModeAction buttonToModeAction -> !buttonToModeAction .isToggle ();
4327+ case final ToAxisAction <?> _, final ToCursorAction <?> _ , final ToScrollAction <?> _ -> true ;
4328+ default -> false ;
4329+ }));
4330+
4331+ actionGroupA = Stream .of (onPressActions , partitionedNonActivateableActionsMap .get (false )).flatMap (Collection ::stream ).toList ();
4332+ actionGroupB = Stream .of (whilePressedActions , partitionedNonActivateableActionsMap .get (true )).flatMap (Collection ::stream ).toList ();
4333+ actionGroupC = onReleaseActions ;
4334+ groupAPrefix = "⤓" ;
4335+ groupBPrefix = "↦" ;
4336+ groupCPrefix = "⤒" ;
43284337 } else {
4329- actionGroupA = Stream .concat (otherActions .stream (), onReleaseActions .stream ()).toList ();
4338+ actionGroupA = Stream .of (onPressActions , whilePressedActions , onReleaseActions ).flatMap (Collection ::stream )
4339+ .toList ();
43304340 actionGroupB = delayedActions ;
4331- groupAPrefix = "VISUALIZATION_SHORT_PREFIX" ;
4332- groupBPrefix = "VISUALIZATION_LONG_PREFIX" ;
4341+ actionGroupC = Collections .emptyList ();
4342+ groupAPrefix = "➧" ;
4343+ groupBPrefix = "➡" ;
4344+ groupCPrefix = null ;
4345+ }
4346+
4347+ if (actionGroupB .isEmpty () && !actionGroupC .isEmpty ()) {
4348+ actionGroupB = actionGroupC ;
4349+ actionGroupC = Collections .emptyList ();
4350+ groupBPrefix = groupCPrefix ;
4351+ groupCPrefix = null ;
43334352 }
43344353
43354354 final var groupBPresent = !actionGroupB .isEmpty ();
@@ -4345,19 +4364,24 @@ private int updateSvgElements(final Document svgDocument, final String idPrefix,
43454364 var extensionWidth = 0 ;
43464365
43474366 if (bothGroupsPresent ) {
4348- extensionWidth += addTSpanElement ("• " + STRINGS . getString ( groupAPrefix ) + ": " , true , tSpanNode );
4367+ extensionWidth += addTSpanElement (groupAPrefix + " " , tSpanNode );
43494368 }
43504369
43514370 extensionWidth += addTSpanElement (actionGroupA , tSpanNode );
43524371
43534372 if (bothGroupsPresent ) {
4354- extensionWidth += addTSpanElement (" • " + STRINGS . getString ( groupBPrefix ) + ": " , true , tSpanNode );
4373+ extensionWidth += addTSpanElement (" " + groupBPrefix + " " , tSpanNode );
43554374 }
43564375
43574376 extensionWidth += addTSpanElement (actionGroupB , tSpanNode );
43584377
4378+ if (!actionGroupC .isEmpty ()) {
4379+ extensionWidth += addTSpanElement (" " + groupCPrefix + " " , tSpanNode );
4380+ extensionWidth += addTSpanElement (actionGroupC , tSpanNode );
4381+ }
4382+
43594383 if (swapped ) {
4360- extensionWidth += addTSpanElement (" " + SWAPPED_SYMBOL , true , tSpanNode );
4384+ extensionWidth += addTSpanElement (" " + SWAPPED_SYMBOL , tSpanNode );
43614385 }
43624386
43634387 if (darkTheme ) {
0 commit comments