Spaces:
Running
Running
smaller fonts
Browse files
src/pages/data_collection.py
CHANGED
|
@@ -2122,7 +2122,7 @@ div.leaflet-container {background: #f2f2f3 !important;}
|
|
| 2122 |
draw = ImageDraw.Draw(base_img)
|
| 2123 |
# Smaller font for more compact display
|
| 2124 |
BOX_FONT_SIZE = 20 # Smaller but still sharp text
|
| 2125 |
-
LABEL_FONT_SIZE =
|
| 2126 |
|
| 2127 |
# Try common font paths for different platforms
|
| 2128 |
font_paths = [
|
|
@@ -3038,7 +3038,7 @@ div.leaflet-container {background: #f2f2f3 !important;}
|
|
| 3038 |
# Color rule: if Tin > Tout -> red (cooling stream), else blue (heating stream). Unknown -> gray.
|
| 3039 |
# Labels now ONLY appear at top (Tin, ṁ, cp) and bottom (Tout, ṁ, cp) – nothing in the middle so arrows can be closer.
|
| 3040 |
arrow_len_v = 45 # vertical arrow length above / below box
|
| 3041 |
-
base_stream_spacing =
|
| 3042 |
|
| 3043 |
def _draw_v_arrow(draw_ctx, x_pos, y_from, y_to, head_at_end=True, color=(0,0,0,245), width=3):
|
| 3044 |
"""Draw vertical arrow from y_from to y_to at x_pos. If head_at_end True head at y_to else at y_from."""
|
|
@@ -3069,11 +3069,12 @@ div.leaflet-container {background: #f2f2f3 !important;}
|
|
| 3069 |
if use_font and use_font != ImageFont.load_default():
|
| 3070 |
# Only use font metrics if we have a real font (not the default)
|
| 3071 |
tb = draw.textbbox((0,0), text_str, font=use_font)
|
| 3072 |
-
t_width = tb[2]-tb[0]
|
|
|
|
| 3073 |
else:
|
| 3074 |
-
#
|
| 3075 |
-
t_width = len(text_str) *
|
| 3076 |
-
t_height =
|
| 3077 |
text_xc = int(x_center - t_width/2)
|
| 3078 |
text_yc = int(y_baseline - (t_height if above else 0))
|
| 3079 |
draw.rectangle([text_xc-1, text_yc-1, text_xc+t_width+1, text_yc+t_height+1], fill=(255,255,255,240))
|
|
|
|
| 2122 |
draw = ImageDraw.Draw(base_img)
|
| 2123 |
# Smaller font for more compact display
|
| 2124 |
BOX_FONT_SIZE = 20 # Smaller but still sharp text
|
| 2125 |
+
LABEL_FONT_SIZE = 6 # Very small font for stream labels
|
| 2126 |
|
| 2127 |
# Try common font paths for different platforms
|
| 2128 |
font_paths = [
|
|
|
|
| 3038 |
# Color rule: if Tin > Tout -> red (cooling stream), else blue (heating stream). Unknown -> gray.
|
| 3039 |
# Labels now ONLY appear at top (Tin, ṁ, cp) and bottom (Tout, ṁ, cp) – nothing in the middle so arrows can be closer.
|
| 3040 |
arrow_len_v = 45 # vertical arrow length above / below box
|
| 3041 |
+
base_stream_spacing = 35 # Even more reduced spacing
|
| 3042 |
|
| 3043 |
def _draw_v_arrow(draw_ctx, x_pos, y_from, y_to, head_at_end=True, color=(0,0,0,245), width=3):
|
| 3044 |
"""Draw vertical arrow from y_from to y_to at x_pos. If head_at_end True head at y_to else at y_from."""
|
|
|
|
| 3069 |
if use_font and use_font != ImageFont.load_default():
|
| 3070 |
# Only use font metrics if we have a real font (not the default)
|
| 3071 |
tb = draw.textbbox((0,0), text_str, font=use_font)
|
| 3072 |
+
t_width = min(tb[2]-tb[0], len(text_str) * 6) # Cap width to prevent huge labels
|
| 3073 |
+
t_height = min(tb[3]-tb[1], 8) # Cap height to prevent huge labels
|
| 3074 |
else:
|
| 3075 |
+
# Very conservative fallback sizing for when fonts fail
|
| 3076 |
+
t_width = len(text_str) * 3 # Much smaller fallback
|
| 3077 |
+
t_height = 5 # Much smaller height fallback
|
| 3078 |
text_xc = int(x_center - t_width/2)
|
| 3079 |
text_yc = int(y_baseline - (t_height if above else 0))
|
| 3080 |
draw.rectangle([text_xc-1, text_yc-1, text_xc+t_width+1, text_yc+t_height+1], fill=(255,255,255,240))
|
src/pages/potential_analysis.py
CHANGED
|
@@ -285,7 +285,7 @@ def generate_subprocess_level_map(group_idx=None):
|
|
| 285 |
|
| 286 |
# Load font - Cross-platform font loading
|
| 287 |
BOX_FONT_SIZE = 20
|
| 288 |
-
LABEL_FONT_SIZE =
|
| 289 |
|
| 290 |
# Try common font paths for different platforms
|
| 291 |
font_paths = [
|
|
@@ -669,7 +669,7 @@ def generate_subprocess_level_map(group_idx=None):
|
|
| 669 |
|
| 670 |
# Draw vertical stream arrows (Tin/Tout)
|
| 671 |
arrow_len_v = 45
|
| 672 |
-
base_stream_spacing =
|
| 673 |
|
| 674 |
def _draw_v_arrow(draw_ctx, x_pos, y_from, y_to, head_at_end=True, color=(0, 0, 0, 245), width=3):
|
| 675 |
draw_ctx.line([(x_pos, y_from), (x_pos, y_to)], fill=color, width=width)
|
|
@@ -697,8 +697,8 @@ def generate_subprocess_level_map(group_idx=None):
|
|
| 697 |
if use_font and use_font != ImageFont.load_default():
|
| 698 |
# Only use font metrics if we have a real font (not the default)
|
| 699 |
tb = draw.textbbox((0, 0), text_str, font=use_font)
|
| 700 |
-
t_width = tb[2] - tb[0]
|
| 701 |
-
t_height = tb[3] - tb[1]
|
| 702 |
else:
|
| 703 |
# Very conservative fallback sizing for when fonts fail
|
| 704 |
t_width = len(text_str) * 3 # Much smaller fallback
|
|
|
|
| 285 |
|
| 286 |
# Load font - Cross-platform font loading
|
| 287 |
BOX_FONT_SIZE = 20
|
| 288 |
+
LABEL_FONT_SIZE = 6 # Very small font for stream labels
|
| 289 |
|
| 290 |
# Try common font paths for different platforms
|
| 291 |
font_paths = [
|
|
|
|
| 669 |
|
| 670 |
# Draw vertical stream arrows (Tin/Tout)
|
| 671 |
arrow_len_v = 45
|
| 672 |
+
base_stream_spacing = 35 # Even more reduced spacing
|
| 673 |
|
| 674 |
def _draw_v_arrow(draw_ctx, x_pos, y_from, y_to, head_at_end=True, color=(0, 0, 0, 245), width=3):
|
| 675 |
draw_ctx.line([(x_pos, y_from), (x_pos, y_to)], fill=color, width=width)
|
|
|
|
| 697 |
if use_font and use_font != ImageFont.load_default():
|
| 698 |
# Only use font metrics if we have a real font (not the default)
|
| 699 |
tb = draw.textbbox((0, 0), text_str, font=use_font)
|
| 700 |
+
t_width = min(tb[2] - tb[0], len(text_str) * 6) # Cap width to prevent huge labels
|
| 701 |
+
t_height = min(tb[3] - tb[1], 8) # Cap height to prevent huge labels
|
| 702 |
else:
|
| 703 |
# Very conservative fallback sizing for when fonts fail
|
| 704 |
t_width = len(text_str) * 3 # Much smaller fallback
|