Skip to content

Commit

Permalink
Polyline: Arrow heads update with color rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kasemir committed Aug 27, 2024
1 parent 53c0a1f commit 382b6e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/dbwr/widgets/PolylineWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,12 @@ protected void fillHTML(final PrintWriter html, final int indent)
{
HTMLUtil.indent(html, indent+2);

// ID for arrow head marker, based on widget ID
final String arr_id = getWID() + "-arrow";

if (arrows != Arrows.NONE)
{ // Define arrow head. Magically scales with line_width!
html.print("<defs> <marker id=\"arrow\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" " +
html.print("<defs> <marker id=\"" + arr_id + "\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" " +
"markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\"> " +
"<path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"" + line_color + "\" /> " +
"</marker> </defs>");
Expand All @@ -163,9 +166,9 @@ protected void fillHTML(final PrintWriter html, final int indent)

// Add arrow heads
if (arrows == Arrows.FROM || arrows == Arrows.BOTH)
html.print("marker-start=\"url(#arrow)\"");
html.print("marker-start=\"url(#" + arr_id + ")\"");
if (arrows == Arrows.TO || arrows == Arrows.BOTH)
html.print("marker-end=\"url(#arrow)\"");
html.print("marker-end=\"url(#" + arr_id + ")\"");

html.println("/>");
}
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ view.jsp?cache=false&amp;display=file:/Path/to/Display+Builder/01_main.bob
<hr>

<div id="versions">
2024-08-27 Polyline: Arrow heads update with color rules.<br>
2024-08-26 Polyline: Support arrow heads.<br>
2024-05-22 Treat hex-formatted numbers in text update as "unsigned".<br>
2024-05-10 Text update handles 'string' format since PVWS now sends long strings as byte array<br>
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/widgets/polyline.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

function set_poly_line_color(widget, color)
{
// Set color of line, then also optional arrow heads
widget.find("polyline").attr("stroke", color);
widget.find("marker path").attr("fill", color);
}

0 comments on commit 382b6e2

Please sign in to comment.