Skip to content

Commit

Permalink
disable showing the image names as a default in grid views
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Oct 30, 2024
1 parent c202c89 commit fd7fcff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>org.embl.mobie</groupId>
<artifactId>mobie-viewer-fiji</artifactId>
<version>5.5.3</version>
<version>5.5.4</version>
<!-- mvn clean install -Dmaven.test.skip=true -Dscijava.app.directory=/Users/tischer/Desktop/Fiji/Fiji-MoBIE.app -->

<!-- ../scijava-scripts/release-version.sh - -skip-version-check - -skip-license-update -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void updateOverlayItems( Graphics2D g )
g,
bounds,
annotatedRegion.getValue( annotationColumn ).toString(),
font
g.getFont()
);

overlayItems.add( newItem );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void createAndAddNewOverlayItem( Graphics2D g, AffineTransform3D viewerT
g,
viewerTransform.estimateBounds( imageMask ),
image.getName(),
font );
g.getFont() );

boolean addItem = true;
for ( OverlayItem item : overlayItems )
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,29 @@ public static OverlayItem itemFromBounds(
final double center = ( bounds.realMax( 0 ) + bounds.realMin( 0 ) ) / 2.0;

g.setFont( font );
final float computedFontSize = ( float ) ( 1.0F * ImageNameOverlay.MAX_FONT_SIZE * width / ( 1.0F * g.getFontMetrics().stringWidth( text ) ) );
final float finalFontSize = Math.min( ImageNameOverlay.MAX_FONT_SIZE, computedFontSize );
Font finalFont = font.deriveFont( finalFontSize );
g.setFont( finalFont );

if ( g.getFontMetrics().stringWidth( text ) > width )
{
float adaptedFontSize = (float) ( font.getSize() * ( 1.0 * width / g.getFontMetrics().stringWidth( text ) ) );
Font adaptedFont = font.deriveFont( adaptedFontSize );
g.setFont( adaptedFont );
}

final OverlayItem item = new OverlayItem();
item.text = text;
item.font = finalFont;
item.font = g.getFont();
item.width = g.getFontMetrics().stringWidth( text );
item.height = g.getFontMetrics().getHeight();
item.x = (int) ( center - item.width / 2.0 );
item.y = (int) ( bounds.realMax( 1 ) + 1.1F * finalFont.getSize() );
item.y = (int) ( bounds.realMax( 1 ) + 1.1F * item.font.getSize() );
item.interval = FinalInterval.createMinSize(
item.x,
item.y - item.height + g.getFontMetrics().getDescent(),
item.width,
item.height );

g.setFont( font ); // reset the original font

return item;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ else if ( existingDisplay instanceof ImageDisplay )
dataset.views() );

gridView.setExclusive( true );
gridView.overlayNames( true );
gridView.overlayNames( false ); // <- TODO: exchange this with the showing the regionId column as an annotation overlay!

// Create grid regions table
Selection rowSelection = Selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ else if ( sources.getGridType().equals( GridType.Transformed ) )
viewerTransform,
false,
null );
view.overlayNames( true );

// TODO: Replace this with showing the regionID annotation text column; this would need to be communicated
// somehow to the table view
view.overlayNames( false );

dataset.views().put( view.getName(), view );
}
}
1 change: 0 additions & 1 deletion src/main/java/org/embl/mobie/ui/UserInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public UserInterface( MoBIE moBIE )
}



private void configureWindowClosing( MoBIE moBIE )
{
frame.addWindowListener(
Expand Down

0 comments on commit fd7fcff

Please sign in to comment.