drzg commited on
Commit
13d7153
·
1 Parent(s): 461391a

Test: show only T instead of full labels to verify deployment

Browse files
src/pages/data_collection.py CHANGED
@@ -2159,6 +2159,17 @@ div.leaflet-container {background: #f2f2f3 !important;}
2159
  # FORCE label_font to None to always use fallback sizing
2160
  label_font = None
2161
 
 
 
 
 
 
 
 
 
 
 
 
2162
  # First pass: compute positions & bounding boxes
2163
  positioned = [] # list of dicts with: idx,label,center,box,(next_raw)
2164
  name_index = {} # map lowercase name -> list of indices (to handle duplicates)
@@ -3064,13 +3075,23 @@ div.leaflet-container {background: #f2f2f3 !important;}
3064
  def _label_centered(text_str, x_center, y_baseline, above=True):
3065
  if not text_str:
3066
  return
3067
- # Always use ultra-conservative fallback sizing for labels (label_font is forced to None)
3068
- t_width = len(text_str) * 2.5 # Very small multiplier
3069
- t_height = 4 # Very small height
3070
- text_xc = int(x_center - t_width/2)
3071
- text_yc = int(y_baseline - (t_height if above else 0))
3072
- draw.rectangle([text_xc-1, text_yc-1, text_xc+t_width+1, text_yc+t_height+1], fill=(255,255,255,240))
3073
- draw.text((text_xc, text_yc), text_str, fill=(0,0,0,255))
 
 
 
 
 
 
 
 
 
 
3074
 
3075
  for item in positioned:
3076
  # Only draw streams for subprocesses, not main processes
@@ -3143,8 +3164,11 @@ div.leaflet-container {background: #f2f2f3 !important;}
3143
  if cp_part: bot_components.append(cp_part)
3144
  top_text = " | ".join(top_components)
3145
  bot_text = " | ".join(bot_components)
3146
- _label_centered(top_text, sx, inbound_top - 6, above=True)
3147
- _label_centered(bot_text, sx, outbound_bottom + 6, above=False)
 
 
 
3148
 
3149
  # Seventh pass: draw sub-subprocess overlays for expanded subprocesses (LAST - on top of everything)
3150
  subprocess_map_expanded = st.session_state.get('subprocess_map_expanded', {})
 
2159
  # FORCE label_font to None to always use fallback sizing
2160
  label_font = None
2161
 
2162
+ # Create a tiny font for labels that will work everywhere
2163
+ try:
2164
+ # Try to create the smallest possible truetype font
2165
+ tiny_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 4)
2166
+ except:
2167
+ try:
2168
+ tiny_font = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 4)
2169
+ except:
2170
+ # Last resort: use default but we'll override the sizing
2171
+ tiny_font = None
2172
+
2173
  # First pass: compute positions & bounding boxes
2174
  positioned = [] # list of dicts with: idx,label,center,box,(next_raw)
2175
  name_index = {} # map lowercase name -> list of indices (to handle duplicates)
 
3075
  def _label_centered(text_str, x_center, y_baseline, above=True):
3076
  if not text_str:
3077
  return
3078
+ # Try to use tiny font, otherwise use manual sizing
3079
+ if tiny_font:
3080
+ tb = draw.textbbox((0,0), text_str, font=tiny_font)
3081
+ t_width = tb[2]-tb[0]
3082
+ t_height = tb[3]-tb[1]
3083
+ text_xc = int(x_center - t_width/2)
3084
+ text_yc = int(y_baseline - (t_height if above else 0))
3085
+ draw.rectangle([text_xc-1, text_yc-1, text_xc+t_width+1, text_yc+t_height+1], fill=(255,255,255,240))
3086
+ draw.text((text_xc, text_yc), text_str, fill=(0,0,0,255), font=tiny_font)
3087
+ else:
3088
+ # Manual ultra-small sizing as fallback
3089
+ t_width = len(text_str) * 2.5
3090
+ t_height = 4
3091
+ text_xc = int(x_center - t_width/2)
3092
+ text_yc = int(y_baseline - (t_height if above else 0))
3093
+ draw.rectangle([text_xc-1, text_yc-1, text_xc+t_width+1, text_yc+t_height+1], fill=(255,255,255,240))
3094
+ draw.text((text_xc, text_yc), text_str, fill=(0,0,0,255))
3095
 
3096
  for item in positioned:
3097
  # Only draw streams for subprocesses, not main processes
 
3164
  if cp_part: bot_components.append(cp_part)
3165
  top_text = " | ".join(top_components)
3166
  bot_text = " | ".join(bot_components)
3167
+ # TEMP: Make labels very short for testing
3168
+ # _label_centered(top_text, sx, inbound_top - 6, above=True)
3169
+ # _label_centered(bot_text, sx, outbound_bottom + 6, above=False)
3170
+ _label_centered("T", sx, inbound_top - 6, above=True) # Just show T for testing
3171
+ _label_centered("T", sx, outbound_bottom + 6, above=False) # Just show T for testing
3172
 
3173
  # Seventh pass: draw sub-subprocess overlays for expanded subprocesses (LAST - on top of everything)
3174
  subprocess_map_expanded = st.session_state.get('subprocess_map_expanded', {})
src/pages/potential_analysis.py CHANGED
@@ -321,6 +321,17 @@ def generate_subprocess_level_map(group_idx=None):
321
 
322
  # FORCE label_font to None to always use fallback sizing
323
  label_font = None
 
 
 
 
 
 
 
 
 
 
 
324
 
325
  processes = st.session_state.get('processes', [])
326
  map_center = st.session_state.get('map_center', [0, 0])
@@ -692,13 +703,23 @@ def generate_subprocess_level_map(group_idx=None):
692
  def _label_centered(text_str, x_center, y_baseline, above=True):
693
  if not text_str:
694
  return
695
- # Always use ultra-conservative fallback sizing for labels (label_font is forced to None)
696
- t_width = len(text_str) * 2.5 # Very small multiplier
697
- t_height = 4 # Very small height
698
- text_xc = int(x_center - t_width / 2)
699
- text_yc = int(y_baseline - (t_height if above else 0))
700
- draw.rectangle([text_xc - 1, text_yc - 1, text_xc + t_width + 1, text_yc + t_height + 1], fill=(255, 255, 255, 240))
701
- draw.text((text_xc, text_yc), text_str, fill=(0, 0, 0, 255))
 
 
 
 
 
 
 
 
 
 
702
 
703
  # Draw stream arrows for each subprocess
704
  for item in positioned:
@@ -771,10 +792,11 @@ def generate_subprocess_level_map(group_idx=None):
771
 
772
  top_text = " | ".join(top_components)
773
  bot_text = " | ".join(bot_components)
774
- _label_centered(top_text, sx, inbound_top - 6, above=True)
775
- _label_centered(bot_text, sx, outbound_bottom + 6, above=False)
776
-
777
- print(f"DEBUG: Subprocess map for group {group_idx} complete.")
 
778
  print(f" - Total processes in session: {len(processes)}")
779
  print(f" - Skipped: {skipped_count}, Included: {included_count}")
780
  print(f" - Positioned (drawable): {len(positioned)}")
 
321
 
322
  # FORCE label_font to None to always use fallback sizing
323
  label_font = None
324
+
325
+ # Create a tiny font for labels that will work everywhere
326
+ try:
327
+ # Try to create the smallest possible truetype font
328
+ tiny_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 4)
329
+ except:
330
+ try:
331
+ tiny_font = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 4)
332
+ except:
333
+ # Last resort: use default but we'll override the sizing
334
+ tiny_font = None
335
 
336
  processes = st.session_state.get('processes', [])
337
  map_center = st.session_state.get('map_center', [0, 0])
 
703
  def _label_centered(text_str, x_center, y_baseline, above=True):
704
  if not text_str:
705
  return
706
+ # Try to use tiny font, otherwise use manual sizing
707
+ if tiny_font:
708
+ tb = draw.textbbox((0, 0), text_str, font=tiny_font)
709
+ t_width = tb[2] - tb[0]
710
+ t_height = tb[3] - tb[1]
711
+ text_xc = int(x_center - t_width / 2)
712
+ text_yc = int(y_baseline - (t_height if above else 0))
713
+ draw.rectangle([text_xc - 1, text_yc - 1, text_xc + t_width + 1, text_yc + t_height + 1], fill=(255, 255, 255, 240))
714
+ draw.text((text_xc, text_yc), text_str, fill=(0, 0, 0, 255), font=tiny_font)
715
+ else:
716
+ # Manual ultra-small sizing as fallback
717
+ t_width = len(text_str) * 2.5
718
+ t_height = 4
719
+ text_xc = int(x_center - t_width / 2)
720
+ text_yc = int(y_baseline - (t_height if above else 0))
721
+ draw.rectangle([text_xc - 1, text_yc - 1, text_xc + t_width + 1, text_yc + t_height + 1], fill=(255, 255, 255, 240))
722
+ draw.text((text_xc, text_yc), text_str, fill=(0, 0, 0, 255))
723
 
724
  # Draw stream arrows for each subprocess
725
  for item in positioned:
 
792
 
793
  top_text = " | ".join(top_components)
794
  bot_text = " | ".join(bot_components)
795
+ # TEMP: Make labels very short for testing
796
+ # _label_centered(top_text, sx, inbound_top - 6, above=True)
797
+ # _label_centered(bot_text, sx, outbound_bottom + 6, above=False)
798
+ _label_centered("T", sx, inbound_top - 6, above=True) # Just show T for testing
799
+ _label_centered("T", sx, outbound_bottom + 6, above=False) # Just show T for testing
800
  print(f" - Total processes in session: {len(processes)}")
801
  print(f" - Skipped: {skipped_count}, Included: {included_count}")
802
  print(f" - Positioned (drawable): {len(positioned)}")