Skip to content

Commit

Permalink
tmf.ui: add support for unicode character marker symbols
Browse files Browse the repository at this point in the history
This is very useful to be able to identify markers by letters
or more importantly by numbers to show sequences.

Change-Id: I99044e1166e9c6835c35a4903b618e03781ca712
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
  • Loading branch information
MatthewKhouzam authored and PatrickTasse committed Apr 22, 2024
1 parent 7243b9f commit a167d28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ public interface FontWeight {
/**
* Symbol type as a string. Possible values: {@link SymbolType}.
* <p>
* Default: @link {@link SymbolType#NONE}
* Default: {@link SymbolType#NONE}
* <p>
* If the value is not amongst {@link SymbolType}, the string value itself
* is drawn.
*/
public static final String SYMBOL_TYPE = "symbol-type"; //$NON-NLS-1$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,8 @@ protected void drawMarker(IMarkerEvent marker, Rectangle bounds, ITimeDataProvid
} else if (VerticalAlign.TOP.equals(verticalAlign)) {
y -= Math.max(0, rect.height / 2 - symbolSize);
}
switch (String.valueOf(symbolType)) {
String symbol = String.valueOf(symbolType);
switch (symbol) {
case SymbolType.CROSS:
SymbolHelper.drawCross(gc, color, symbolSize, rect.x, y);
break;
Expand All @@ -2333,8 +2334,22 @@ protected void drawMarker(IMarkerEvent marker, Rectangle bounds, ITimeDataProvid
case SymbolType.CIRCLE:
SymbolHelper.drawCircle(gc, color, symbolSize, rect.x, y);
break;
default:
case SymbolType.DIAMOND:
SymbolHelper.drawDiamond(gc, color, symbolSize, rect.x, y);
break;
default:
Color oldColor = gc.getForeground();
gc.setForeground(color);
int height = (int) (rect.height * heightFactor);
TimeGraphRender.setFontForHeight(height, gc);
int textSize = (gc.textExtent(symbol).y + 1) / 2;
if (VerticalAlign.BOTTOM.equals(verticalAlign)) {
y = rect.y + rect.height / 2 + Math.max(0, rect.height / 2 - textSize);
} else if (VerticalAlign.TOP.equals(verticalAlign)) {
y = rect.y + rect.height / 2 - Math.max(0, rect.height / 2 - textSize);
}
gc.drawText(symbol, rect.x - symbolSize, y - textSize, true);
gc.setForeground(oldColor);
}
gc.setAlpha(OPAQUE);
if (marker.getDuration() == 0) {
Expand Down

0 comments on commit a167d28

Please sign in to comment.