pysnt.converters.enhancement module#
Java object enhancement functionality.
This module provides enhanced methods for Java objects, including: - Enhancement predicate functions for object type detection - Enhancement classes that add methods to Java objects - Enhancement functions for automatic object enhancement - Object type predicates for different SNT object types
Dependencies: core.py
- class EnhancedJavaObject(java_obj)[source]#
Bases:
objectWrapper class that adds enhanced show() and setVisible() methods to Java objects.
This wrapper delegates all attribute access to the wrapped Java object, but provides enhanced methods with fallback logic for GUI operations.
- enhance_java_object(obj: Any) Any[source]#
Enhance a Java object with fallback show() and setVisible() methods if applicable.
This function checks if the object is an SNT chart or GUI object and if so, wraps it with an enhanced version that falls back to display() on GUI method failures.
- Parameters:
obj (Any) – Java object to potentially enhance
- Returns:
Enhanced wrapper object if applicable, otherwise the original object
- Return type:
Any
Examples
>>> # For charts >>> chart = stats.getHistogram('Branch length') >>> enhanced_chart = enhance_java_object(chart) >>> enhanced_chart.show() # Will fallback to display() if GUI fails
>>> # For GUI objects >>> ui = pysnt.PathManagerUI() >>> enhanced_ui = enhance_java_object(ui) >>> enhanced_ui.setVisible(True) # Will fallback to display() if GUI fails
- auto_enhance_java_objects(enabled: bool = True)[source]#
Enable or disable automatic enhancement of Java objects.
When enabled, this function monkey-patches scyjava’s jimport to automatically enhance returned Java objects with fallback show() methods.
- Parameters:
enabled (bool, default True) – Whether to enable automatic enhancement
Note
This is experimental and may have side effects. Use with caution.