Class SpatialUtil
java.lang.Object
com.eco.bio7.spatial.SpatialUtil
A class which offers some custom methods for the Spatial view.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanStep()This method returns a boolean which is triggered by the UI slider to adjust a frame rate.static voidRemoves the bounds of the data of a model (the box and the grids have the size of the space again).static voidRemoves the legend and the color bar of the 3D view.static com.jogamp.opengl.util.awt.OverlayThis method creates an overlay object.static ClippingReturns the clipping (box, cutting plane and slice) of the volume and the iso surface of the 3d view.floatReturns the x-size of the cube in the Spatial view.floatReturns the y-size of the cube in the Spatial view.floatReturns the z-size of the cube in the Spatial view.static IsoSurfaceReturns the iso surface of the 3d view (e.g., to create an iso surface of the data of a model with IsoSurface.setData).static float[]Returns the light position of the first lamp.static float[]Returns the light position of the second lamp.static float[]Returns the light position of the third lamp.float[]Returns the light position of the fourth lamp.static Measurement3dReturns the measurements of the iso surface and the volume of the 3d view (objects, region statistics and picked points, displayed in the Bio7 table).static com.eco.bio7.loader3d.MeshModelgetModel()Returns the model of the Model tab (a mesh file: OBJ, STL, PLY or OFF).static OBJModelA method which returns a reference to the UI loaded *.obj model.static floatGet the x-rotation value.static floatGet the y-rotation value.static floatGet the z-rotation value.static intThis method returns the height of the visible screen.static intThis method returns the width of the visible screen.static VolumeRendererReturns the volume renderer of the 3d view (e.g., to load a stack with VolumeRenderer.load).static booleanReturns true if the custom camera is used.static booleanReturns true while the first view of a frame is drawn: the main view (false for the small view of the split view and for the second eye of the stereo view).static booleanReturns true while the small view of the split view is drawn (false without the split view).static booleanReturns if a split view is active.static booleanThis method returns the boolean value "true" if the OpenGL run method is triggered!.static booleanReturns if the movement has been stopped.static voidRemoves the title, the axis titles, the logarithmic axes, the number formats, the axis ranges, the legend and the color bar of the plot view.static voidResets the rotation of the rotation matrix.static voidsetAxisNumberFormats(String x, String y, String z) Sets the formats of the numbers of the axes of the plot view (see java.util.Formatter, e.g., "%.2e" for 1.34e+10, "%.1f" or "%,.0f").static voidsetAxisRanges(double x0, double x1, double y0, double y1, double z0, double z1) Sets the values of the axis numbers of the plot view at the data bounds (see setDataBounds).static voidsetAxisTitles(String x, String y, String z) Sets the titles of the axes of the plot view (e.g., the names and the units of the data).static voidsetBackgroundColor(int r, int g, int b) Sets the background color.static voidsetColorBar(String title, double min, double max, int[] colors) Displays a color bar at the right side of the 3D view: a color ramp with the numbers of the values (e.g., the heights of a surface).static voidsetColorBar(String title, double min, double max, int[] colors, boolean log, String format) Displays a color bar at the right side of the 3D view (see setColorBar(String, double, double, int[])) with logarithmic values or a format of the numbers.static voidsetCustomCamera(boolean enabled) Enables or disables the custom camera (the check box in the Camera tab is updated).static voidsetCustomCamera(double xpos, double ypos, double zpos, double xlook, double ylook, double zlook) Sets the custom camera (the position and the look at) and enables it (see the Camera tab, the check box is updated).static voidsetCustomCameraInMainView(boolean mainView) Displays the custom camera in the main view: with the split view the small view shows the normal camera (see SpatialCamera for the other camera settings, e.g., SpatialCamera.copyWalkthroughToCustomCamera).static voidsetDataBounds(double x0, double x1, double y0, double y1, double z0, double z1) Sets the bounds of the data of a model (e.g., spheres of a script) for the box, the grids, the plot view with the axis numbers and the camera (if no texture, volume or iso surface is displayed).static voidTriggers the fullscreen mode in the 3D view (on the primary monitor like F2).static voidsetFullscreen(int i) Triggers the fullscreen mode and opens the 3D view in monitor i (0: the primary, 1: the secondary monitor, etc., like F2, F3 and F4).static voidDisplays a legend of categories in the top left corner of the 3D view: a box with the color and the label of each category (e.g., the groups of a scatter plot).static voidsetLightPos1(float x, float y, float z) Sets the light position of the first lamp.static voidsetLightPos2(float x, float y, float z) Sets the light position of the second lamp.static voidsetLightPos3(float x, float y, float z) Sets the light position of the third lamp.static voidsetLightPos4(float x, float y, float z) Sets the light position of the fourth lamp.static voidsetLinesColor(int r, int g, int b) Sets the color of the cube, axes and grid.static voidsetLogAxes(boolean x, boolean y, boolean z) Selects logarithmic axes of the plot view.static voidsetMainCamera(boolean enabled) Uses the camera of the main view (see SpatialCamera.setMainCamera) instead of the camera rotated with the mouse.static voidsetPlotExportAction(boolean visible) Shows or hides the action "Export Plot (WebGL, Blender)" in the toolbar of the 3D view (hidden by default).static voidsetPlotFonts(String title, String numbers, String axisTitles, String legend) Sets the font families of the texts of the plot view (e.g., "Arial", "Georgia", null = Verdana): the title, the numbers of the axes, the titles of the axes and the legend with the color bar.static voidsetPlotFontSize(float scale) Sets all font sizes of the plot view (the title, the axis titles and numbers and the legends) as a factor of the default sizes (1 = default).static voidsetPlotFontSizes(float title, float axisTitles, float numbers, float legends) Sets the font sizes of the plot view as factors of the default sizes (1 = default, 2 = twice as large, 0.5 = half the size).static voidsetPlotGrids(boolean xy, boolean xz, boolean yz) Selects the grid planes of the plot view (behind the data): the floor (XY, off by default because a height map covers it) and the walls (XZ, YZ).static voidsetPlotTextColors(int title, int numbers, int axisTitles, int legend) Sets the colors of the texts of the plot view (0xRRGGBB, -1 = the color of the lines of the 3D view): the title, the numbers of the axes, the titles of the axes and the legend with the color bar.static voidsetPlotTitle(String title) Sets the title of the plot view (displayed at the top of the 3D view).static voidsetPlotView(boolean plotView) Enables or disables the plot view (the grids behind the data and the axes with the numbers at the edges of the box, like a 3D plot).static voidsetRotationX(float rotatx) Sets the rotation in x-direction.static voidsetRotationY(float rotaty) Sets the rotation in y-direction.static voidsetRotationZ(float rotatz) Sets the rotation in z-direction.static voidsetSplitScreenSizeLocation(int x, int y, int width, int height) A method to set the splitscreen coordinates and size.static voidsetSplitView(boolean splitView) This methods triggers the switch from split view to normal view.static voidsetStopMovement(boolean stop) A method which stops the movement in the Spatial panel for selection and custom purposes.static voidsetup()This method invokes the setup method of the compiled OpenGL code if available.static voidshowAxes(boolean value) This method enables or disables the visualization of the axes orientation.static voidshowGrid(boolean value) This method enables or disables the visualization of the grid orientation.static voidshowQuad(boolean value) This method enables or disables the visualization of the quad orientation.static voidThis method invokes the "run" method triggered by the timer.
-
Constructor Details
-
SpatialUtil
public SpatialUtil()
-
-
Method Details
-
getIsoSurface
Returns the iso surface of the 3d view (e.g., to create an iso surface of the data of a model with IsoSurface.setData).- Returns:
- the iso surface or null if the 3d view is not opened
-
getClipping
Returns the clipping (box, cutting plane and slice) of the volume and the iso surface of the 3d view.- Returns:
- the clipping or null if the 3d view is not opened
-
getMeasurement
Returns the measurements of the iso surface and the volume of the 3d view (objects, region statistics and picked points, displayed in the Bio7 table).- Returns:
- the measurements or null if the 3d view is not available
-
getVolumeRenderer
Returns the volume renderer of the 3d view (e.g., to load a stack with VolumeRenderer.load).- Returns:
- the volume renderer or null if the 3d view is not opened
-
getRotationX
public static float getRotationX()Get the x-rotation value.- Returns:
- a float value.
-
setRotationX
public static void setRotationX(float rotatx) Sets the rotation in x-direction.- Parameters:
rotatx- a float value.
-
getRotationY
public static float getRotationY()Get the y-rotation value.- Returns:
- a float value.
-
setRotationY
public static void setRotationY(float rotaty) Sets the rotation in y-direction.- Parameters:
rotaty- a float value.
-
getRotationZ
public static float getRotationZ()Get the z-rotation value.- Returns:
- a float value.
-
setRotationZ
public static void setRotationZ(float rotatz) Sets the rotation in z-direction.- Parameters:
rotatz- a float value.
-
setDataBounds
public static void setDataBounds(double x0, double x1, double y0, double y1, double z0, double z1) Sets the bounds of the data of a model (e.g., spheres of a script) for the box, the grids, the plot view with the axis numbers and the camera (if no texture, volume or iso surface is displayed). The data is moved into the center of the view.- Parameters:
x0- the minimum xx1- the maximum xy0- the minimum yy1- the maximum yz0- the minimum zz1- the maximum z
-
clearDataBounds
public static void clearDataBounds()Removes the bounds of the data of a model (the box and the grids have the size of the space again). -
setPlotGrids
public static void setPlotGrids(boolean xy, boolean xz, boolean yz) Selects the grid planes of the plot view (behind the data): the floor (XY, off by default because a height map covers it) and the walls (XZ, YZ).- Parameters:
xy- the XY grid (floor)xz- the XZ gridyz- the YZ grid
-
setPlotView
public static void setPlotView(boolean plotView) Enables or disables the plot view (the grids behind the data and the axes with the numbers at the edges of the box, like a 3D plot). The axis numbers are enabled with the plot view.- Parameters:
plotView- true for the plot view
-
setPlotTitle
Sets the title of the plot view (displayed at the top of the 3D view).The texts of the plot view (the title, the axis titles and the legends) can contain a simple math markup: x^2, x^-0.5 or x^{n+1} for superscripts, N_0 or N_{max} for subscripts (\\^ and \\_ for the characters). Greek letters and symbols can be written as Unicode characters (e.g., α for alpha, · for a dot).
- Parameters:
title- the title (lines separated with \n) or null (no title)
-
setAxisTitles
-
setLogAxes
public static void setLogAxes(boolean x, boolean y, boolean z) Selects logarithmic axes of the plot view. The data of a logarithmic axis are drawn as log10 values (e.g., Math.log10(value)) and the numbers of the axis are the values (10^v, e.g., 100, 1e5, 1.34e10) with minor ticks and grid lines at 2, 3, ..., 9 times the powers of ten.- Parameters:
x- true for a logarithmic x axisy- true for a logarithmic y axisz- true for a logarithmic z axis
-
setAxisNumberFormats
Sets the formats of the numbers of the axes of the plot view (see java.util.Formatter, e.g., "%.2e" for 1.34e+10, "%.1f" or "%,.0f"). By default (null) the numbers are formatted automatically: very large or small numbers in a scientific notation (e.g., 1.34e10, 2.5e-6). The format "10^" displays the numbers as powers of ten with superscripts (e.g., 10^3, 1.34x10^10), e.g., for logarithmic axes.- Parameters:
x- the format of the x axis (null = automatic)y- the format of the y axis (null = automatic)z- the format of the z axis (null = automatic)
-
setAxisRanges
public static void setAxisRanges(double x0, double x1, double y0, double y1, double z0, double z1) Sets the values of the axis numbers of the plot view at the data bounds (see setDataBounds). The three axes of the 3D view have the same scale. For data with different units and ranges (e.g., the time in hours and cell counts up to 1e10) the data is drawn in the coordinates of the box (e.g., 0 - 10 for all axes) and the axis numbers display the values of the data (a linear mapping of the bounds to the values). For a logarithmic axis the values are log10 values.- Parameters:
x0- the value at the minimum x of the boundsx1- the value at the maximum x of the boundsy0- the value at the minimum y of the boundsy1- the value at the maximum y of the boundsz0- the value at the minimum z of the boundsz1- the value at the maximum z of the bounds
-
setLegend
Displays a legend of categories in the top left corner of the 3D view: a box with the color and the label of each category (e.g., the groups of a scatter plot).- Parameters:
title- the title of the legend (null = no title)labels- the labels of the categoriescolors- the colors of the categories (0xRRGGBB, e.g., 0xFF8000 or java.awt.Color.getRGB())
-
setColorBar
Displays a color bar at the right side of the 3D view: a color ramp with the numbers of the values (e.g., the heights of a surface). The colors are evenly distributed from the minimum to the maximum (see PlotLegend.rampColor to draw the data with the same colors and the ramps PlotLegend.VIRIDIS, RAINBOW, DIVERGING, TERRAIN).- Parameters:
title- the title of the color bar (e.g., the name and the unit)min- the value of the first colormax- the value of the last colorcolors- the colors of the ramp (0xRRGGBB)
-
setColorBar
public static void setColorBar(String title, double min, double max, int[] colors, boolean log, String format) Displays a color bar at the right side of the 3D view (see setColorBar(String, double, double, int[])) with logarithmic values or a format of the numbers.- Parameters:
title- the title of the color barmin- the value of the first color (a log10 value if log)max- the value of the last color (a log10 value if log)colors- the colors of the ramp (0xRRGGBB)log- true if min and max are log10 values (the numbers are 10^v)format- the format of the numbers (java.util.Formatter, e.g., "%.1f", "10^" for powers of ten, null = automatic, e.g., 1.34e10)
-
setPlotFontSizes
public static void setPlotFontSizes(float title, float axisTitles, float numbers, float legends) Sets the font sizes of the plot view as factors of the default sizes (1 = default, 2 = twice as large, 0.5 = half the size).- Parameters:
title- the title (default 16 points)axisTitles- the titles of the axesnumbers- the numbers of the axeslegends- the legend and the color bar (default 12 points)
-
setPlotFontSize
public static void setPlotFontSize(float scale) Sets all font sizes of the plot view (the title, the axis titles and numbers and the legends) as a factor of the default sizes (1 = default).- Parameters:
scale- the factor of all font sizes
-
setPlotExportAction
public static void setPlotExportAction(boolean visible) Shows or hides the action "Export Plot (WebGL, Blender)" in the toolbar of the 3D view (hidden by default). The action exports the plot of the plot API (see Plot3D) to an HTML page with WebGL.- Parameters:
visible- true to show the action
-
setPlotTextColors
public static void setPlotTextColors(int title, int numbers, int axisTitles, int legend) Sets the colors of the texts of the plot view (0xRRGGBB, -1 = the color of the lines of the 3D view): the title, the numbers of the axes, the titles of the axes and the legend with the color bar.- Parameters:
title- the color of the titlenumbers- the color of the axis numbersaxisTitles- the color of the axis titleslegend- the color of the texts of the legend and the color bar
-
setPlotFonts
Sets the font families of the texts of the plot view (e.g., "Arial", "Georgia", null = Verdana): the title, the numbers of the axes, the titles of the axes and the legend with the color bar.- Parameters:
title- the font of the titlenumbers- the font of the axis numbersaxisTitles- the font of the axis titleslegend- the font of the legend and the color bar
-
clearLegend
public static void clearLegend()Removes the legend and the color bar of the 3D view. -
resetPlotLabels
public static void resetPlotLabels()Removes the title, the axis titles, the logarithmic axes, the number formats, the axis ranges, the legend and the color bar of the plot view. -
resetRotation
public static void resetRotation()Resets the rotation of the rotation matrix. -
isStopMovement
public static boolean isStopMovement()Returns if the movement has been stopped.- Returns:
- a boolean value.
-
setStopMovement
public static void setStopMovement(boolean stop) A method which stops the movement in the Spatial panel for selection and custom purposes.- Parameters:
stop- a boolean value.
-
getCubeSizeX
public float getCubeSizeX()Returns the x-size of the cube in the Spatial view.- Returns:
- the x-size as a float.
-
getCubeSizeY
public float getCubeSizeY()Returns the y-size of the cube in the Spatial view.- Returns:
- the y-size as a float.
-
getCubeSizeZ
public float getCubeSizeZ()Returns the z-size of the cube in the Spatial view.- Returns:
- the z-size as a float.
-
isSplitView
public static boolean isSplitView()Returns if a split view is active.- Returns:
- a boolean value.
-
isMainViewDrawing
public static boolean isMainViewDrawing()Returns true while the first view of a frame is drawn: the main view (false for the small view of the split view and for the second eye of the stereo view). Something which should be done once per frame (e.g., an overlay) can be guarded with it. A step of a model is guarded already with canStep (true only in the first view of a frame).- Returns:
- true while the first view of a frame is drawn
-
isSplitPanelDrawing
public static boolean isSplitPanelDrawing()Returns true while the small view of the split view is drawn (false without the split view). Something which should be drawn only in the main view (e.g., an overlay) can be skipped with it.- Returns:
- true while the small view is drawn
-
setCustomCamera
public static void setCustomCamera(double xpos, double ypos, double zpos, double xlook, double ylook, double zlook) Sets the custom camera (the position and the look at) and enables it (see the Camera tab, the check box is updated).- Parameters:
xpos- the x-position of the cameraypos- the y-position of the camerazpos- the z-position of the cameraxlook- the x look at coordinateylook- the y look at coordinatezlook- the z look at coordinate
-
setCustomCamera
public static void setCustomCamera(boolean enabled) Enables or disables the custom camera (the check box in the Camera tab is updated).- Parameters:
enabled- true to use the custom camera
-
setCustomCameraInMainView
public static void setCustomCameraInMainView(boolean mainView) Displays the custom camera in the main view: with the split view the small view shows the normal camera (see SpatialCamera for the other camera settings, e.g., SpatialCamera.copyWalkthroughToCustomCamera).- Parameters:
mainView- true for the main view, false for the small view of the split view (the default)
-
setMainCamera
public static void setMainCamera(boolean enabled) Uses the camera of the main view (see SpatialCamera.setMainCamera) instead of the camera rotated with the mouse.- Parameters:
enabled- true to use the main view camera
-
isCustomCamera
public static boolean isCustomCamera()Returns true if the custom camera is used.- Returns:
- true if the custom camera is enabled
-
setSplitView
public static void setSplitView(boolean splitView) This methods triggers the switch from split view to normal view.- Parameters:
splitView- a boolean value.
-
setLightPos1
public static void setLightPos1(float x, float y, float z) Sets the light position of the first lamp.- Parameters:
x- the x-position as a float.y- the y-position as a float.z- the z-position as a float.
-
setLightPos2
public static void setLightPos2(float x, float y, float z) Sets the light position of the second lamp.- Parameters:
x- the x-position as a float.y- the y-position as a float.z- the z-position as a float.
-
setLightPos3
public static void setLightPos3(float x, float y, float z) Sets the light position of the third lamp.- Parameters:
x- the x-position as a float.y- the y-position as a float.z- the z-position as a float.
-
setLightPos4
public static void setLightPos4(float x, float y, float z) Sets the light position of the fourth lamp.- Parameters:
x- the x-position as a float.y- the y-position as a float.z- the z-position as a float.
-
getLightPos1
public static float[] getLightPos1()Returns the light position of the first lamp.- Returns:
- a float array.
-
getLightPos2
public static float[] getLightPos2()Returns the light position of the second lamp.- Returns:
- a float array.
-
getLightPos3
public static float[] getLightPos3()Returns the light position of the third lamp.- Returns:
- a float array.
-
getLightPos4
public float[] getLightPos4()Returns the light position of the fourth lamp.- Returns:
- a float array.
-
setFullscreen
public static void setFullscreen()Triggers the fullscreen mode in the 3D view (on the primary monitor like F2). -
setFullscreen
public static void setFullscreen(int i) Triggers the fullscreen mode and opens the 3D view in monitor i (0: the primary, 1: the secondary monitor, etc., like F2, F3 and F4). -
setSplitScreenSizeLocation
public static void setSplitScreenSizeLocation(int x, int y, int width, int height) A method to set the splitscreen coordinates and size.- Parameters:
x- the x-origin.y- the y-origin.width- the width.height- the height.
-
getScreenWidth
public static int getScreenWidth()This method returns the width of the visible screen.- Returns:
- the width as an integer value.
-
getScreenHeight
public static int getScreenHeight()This method returns the height of the visible screen.- Returns:
- the height as an integer value.
-
createOverlay
public static com.jogamp.opengl.util.awt.Overlay createOverlay()This method creates an overlay object.- Returns:
- an Overlay instance.
-
showGrid
public static void showGrid(boolean value) This method enables or disables the visualization of the grid orientation.- Parameters:
value- a boolean value.
-
showQuad
public static void showQuad(boolean value) This method enables or disables the visualization of the quad orientation.- Parameters:
value- a boolean value.
-
showAxes
public static void showAxes(boolean value) This method enables or disables the visualization of the axes orientation.- Parameters:
value- a boolean value.
-
setBackgroundColor
public static void setBackgroundColor(int r, int g, int b) Sets the background color.- Parameters:
r- the red value as an integer (0-255).g- the green value as an integer (0-255).b- the blue value as an integer (0-255).
-
setLinesColor
public static void setLinesColor(int r, int g, int b) Sets the color of the cube, axes and grid.- Parameters:
r- the red value as an integer (0-255).g- the green value as an integer (0-255).b- the blue value as an integer (0-255).
-
getObjModel
A method which returns a reference to the UI loaded *.obj model.- Returns:
- an object of type OBJModel.
-
getModel
public static com.eco.bio7.loader3d.MeshModel getModel()Returns the model of the Model tab (a mesh file: OBJ, STL, PLY or OFF).- Returns:
- the model or null
-
canStep
public static boolean canStep()This method returns a boolean which is triggered by the UI slider to adjust a frame rate. It is true only in the first view of a frame (not again in the small view of the split view or for the second eye of the stereo view), so a step of a model guarded with it is computed once per frame.- Returns:
- a boolean value.
-
setup
public static void setup()This method invokes the setup method of the compiled OpenGL code if available. -
startStop
public static void startStop()This method invokes the "run" method triggered by the timer. -
isStarted
public static boolean isStarted()This method returns the boolean value "true" if the OpenGL run method is triggered!.- Returns:
- a boolean value.
-