Skip to content

Commit

Permalink
Merge pull request bigdataviewer#10 from haesleinhuepf/positionAndVie…
Browse files Browse the repository at this point in the history
…wLogging

Implement ViewerTransformLogger and PositionLogger
  • Loading branch information
haesleinhuepf authored Dec 14, 2019
2 parents d9262dc + 45a5f6b commit b51cf18
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/sc/fiji/bdv/log/Logger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sc.fiji.bdv.log;

public interface Logger
{
void out( String msg );
void err( String msg );
}
6 changes: 6 additions & 0 deletions src/main/java/sc/fiji/bdv/log/Logs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package sc.fiji.bdv.log;

public class Logs
{
public static String BDV = "BigDataViewer";
}
16 changes: 16 additions & 0 deletions src/main/java/sc/fiji/bdv/log/SystemLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package sc.fiji.bdv.log;

import sc.fiji.bdv.log.Logger;

public class SystemLogger implements Logger
{
public void out( String msg )
{
System.out.println( msg );
}

public void err( String msg )
{
System.err.println( msg );
}
}
32 changes: 32 additions & 0 deletions src/main/java/sc/fiji/bdv/navigate/PositionLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sc.fiji.bdv.navigate;

import bdv.util.BdvHandle;
import net.imglib2.RealPoint;
import sc.fiji.bdv.log.Logger;
import sc.fiji.bdv.log.Logs;
import sc.fiji.bdv.log.SystemLogger;

public class PositionLogger implements Runnable
{
private final BdvHandle bdvHandle;
private final Logger logger;

public PositionLogger( BdvHandle bdvHandle )
{
this( bdvHandle, new SystemLogger() );
}

public PositionLogger( BdvHandle bdvHandle, Logger logger )
{
this.bdvHandle = bdvHandle;
this.logger = logger;
}

@Override
public void run()
{
final RealPoint realPoint = new RealPoint( 3 );
bdvHandle.getViewerPanel().getGlobalMouseCoordinates( realPoint );
logger.out( Logs.BDV + ": Position at Mouse: " + realPoint.toString() );
}
}
33 changes: 33 additions & 0 deletions src/main/java/sc/fiji/bdv/navigate/ViewerTransformLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package sc.fiji.bdv.navigate;

import bdv.util.BdvHandle;
import net.imglib2.RealPoint;
import net.imglib2.realtransform.AffineTransform3D;
import sc.fiji.bdv.log.Logger;
import sc.fiji.bdv.log.Logs;
import sc.fiji.bdv.log.SystemLogger;

public class ViewerTransformLogger implements Runnable
{
private final BdvHandle bdvHandle;
private final Logger logger;

public ViewerTransformLogger( BdvHandle bdvHandle )
{
this( bdvHandle, new SystemLogger() );
}

public ViewerTransformLogger( BdvHandle bdvHandle, Logger logger )
{
this.bdvHandle = bdvHandle;
this.logger = logger;
}

@Override
public void run()
{
final AffineTransform3D view = new AffineTransform3D();
bdvHandle.getViewerPanel().getState().getViewerTransform( view );
logger.out( Logs.BDV + ": Viewer Transform: " + view.toString() );
}
}

0 comments on commit b51cf18

Please sign in to comment.