forked from bigdataviewer/bigdataviewer-vistools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bigdataviewer#10 from haesleinhuepf/positionAndVie…
…wLogging Implement ViewerTransformLogger and PositionLogger
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
src/main/java/sc/fiji/bdv/navigate/ViewerTransformLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ); | ||
} | ||
} |