Skip to content

Commit

Permalink
Merge branch 'ControlSystemStudio:master' into css611_disconnect_display
Browse files Browse the repository at this point in the history
  • Loading branch information
rjwills28 authored Mar 20, 2024
2 parents fb44e9f + 6b1fce6 commit 21b3630
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 11.0.19
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,25 @@ public int getDesiredHeight(final GC gc, final int bounds_width,
final Font orig_font = gc.getFont();
gc.setFont(font);

int items = 0;
int max_width = 1, max_height = 1; // Start with 1 pixel to avoid later div-by-0
for (Trace<XTYPE> trace : traces)
{
if (!trace.isVisible())
continue;
final Point size = gc.textExtent(trace.getLabel());
if (size.x > max_width)
max_width = size.x;
if (size.y > max_height)
max_height = size.y;
items++;
}
// Arrange in grid with some extra space
grid_x = max_width + max_height / 2;
grid_y = max_height;

gc.setFont(orig_font);

final int items = traces.size();
final int items_per_row = Math.max(1, bounds_width / grid_x); // Round down, counting full items
final int rows = (items + items_per_row-1) / items_per_row; // Round up
return rows * grid_y;
Expand Down

0 comments on commit 21b3630

Please sign in to comment.