de.jreality.geometry
Class CoordinateSystemFactory

java.lang.Object
  extended by de.jreality.geometry.CoordinateSystemFactory

public class CoordinateSystemFactory
extends java.lang.Object

Factory for creating a representation of a coordinate system in Euclidean space.

This is created for an existing SceneGraphComponent (or for a given extent).
For a given SceneGraphComponent the factory creates a bounding box and axes through the origin including ticks with their labels.
A new SceneGraphNode containing the coordinate system is added to the children of the given SceneGraphComponent.

Use the factory as following:

 SceneGraphCompontent component;
 double axisScale = 10.0;
 [...]
 CoordinateSystemFactory factory = new CoordinateSystemFactory(component, axisScale);
Above line creates the coordinate system using default properties and adds it to the scene.
axisScale (i.e. the distance between two ticks on the coordinate axes) depends on size of component.
You can change properties afterwards:
 factory.showAxes(false);
 factory.showBox(true);
 factory.beautify(true);
 [setting more properties]
 

The coordinate system may be removed from the SceneGraph by

component.removeChild(factory.getCoordinateSystem());

Author:
msommer

Field Summary
static int X
          Index of coordinate x (use in arrays).
static int Y
          Index of coordinate y (use in arrays).
static int Z
          Index of coordinate z (use in arrays).
 
Constructor Summary
CoordinateSystemFactory(double extent)
          see CoordinateSystemFactory(double extent, double axisScale)
here axisScale is set to 1.0
CoordinateSystemFactory(double[] extent)
          see CoordinateSystemFactory(double[] extent, double axisScale)
here axisScale is set to 1.0
CoordinateSystemFactory(double[] extent, double axisScale)
          Creates a coordinate system where min and max values of each of the three coordinate axes is specified by extent, i.e.
CoordinateSystemFactory(double extent, double axisScale)
          Creates a coordinate system where min and max values of each coordinate axis are specified by extent, i.e.
CoordinateSystemFactory(SceneGraphComponent component)
          see CoordinateSystemFactory(SceneGraphComponent component, double axisScale)
here axisScale is set to 1.0
CoordinateSystemFactory(SceneGraphComponent component, double axisScale)
          Creates a coordinate system where min and max values of each coordinate axis are specified by a given SceneGraphComponent.
A new SceneGraphNode containing the coordinate system is added to the children of component.
 
Method Summary
 void beautify(boolean b)
          Beautify the coordinate system automatically iff set to true, i.e.
 void dispose()
           
 double getAxisScale()
          Get the current axis scale, i.e.
 java.awt.Color getBoxColor()
          Get the current color of the bounding box.
 java.awt.Color getColor()
          Get the current color of the coordinate system (axes and bounding box).
 SceneGraphComponent getCoordinateSystem()
          Get the coordinate system specified in this factory.
(The coordinate system may be removed from the SceneGraph using this method.)
 java.awt.Color getGridColor()
          Get the current color of the grid on the bounding box faces.
 java.awt.Color getLabelColor()
          Get the current color of all labels of the coordinate system.
 java.awt.Font getLabelFont()
          Get the current font of all labels of the coordinate system.
 double getLabelScale()
          Get the current label scale, i.e.
 void setAxisScale(double axisScale)
          Set the axis scale, i.e.
 void setBoxColor(java.awt.Color c)
          Set the color of the bounding box.
 void setColor(java.awt.Color c)
          Set the color of the coordinate system (axes and bounding box).
 void setGridColor(java.awt.Color c)
          Set the color of the grid on the bounding box faces.
 void setLabelBoxEdges(int[][] edges)
          Set the box edges on which labels are to be shown.
 void setLabelColor(java.awt.Color c)
          Set the color of all labels of the coordinate system.
 void setLabelFont(java.awt.Font f)
          Set the font of all labels of the coordinate system.
 void setLabelScale(double labelScale)
          Set the label scale, i.e.
 void showAxes(boolean b)
          Show or hide the axes of the coordinate system going through the origin.
 void showAxesArrows(boolean b)
          Show or hide the arrows of the axes of the coordinate system going through the origin.
 void showBox(boolean b)
          Show or hide the bounding box of the coordinate system.
 void showBoxArrows(boolean b)
          Show or hide the arrows of the bounding box of the coordinate system.
 void showGrid(boolean b)
          Show or hide the grid on the bounding box faces.
 void showLabels(boolean b)
          Show or hide the tick & axis labels of axes and bounding box of the coordinate system.
 void updateBox(double[] cameraToObject)
          Beautifies the box regarding the current transformation from camera coordinates to local coordinates of the coordiante system, i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

public static final int X
Index of coordinate x (use in arrays).

See Also:
Constant Field Values

Y

public static final int Y
Index of coordinate y (use in arrays).

See Also:
Constant Field Values

Z

public static final int Z
Index of coordinate z (use in arrays).

See Also:
Constant Field Values
Constructor Detail

CoordinateSystemFactory

public CoordinateSystemFactory(double extent,
                               double axisScale)
Creates a coordinate system where min and max values of each coordinate axis are specified by extent, i.e. x,y,z are within [-extent, extent].

Parameters:
extent - extent of each coordinate axis
axisScale - the axis scale, i.e. the distance between two ticks on the coordinate axes

CoordinateSystemFactory

public CoordinateSystemFactory(double extent)
see CoordinateSystemFactory(double extent, double axisScale)
here axisScale is set to 1.0


CoordinateSystemFactory

public CoordinateSystemFactory(double[] extent,
                               double axisScale)
Creates a coordinate system where min and max values of each of the three coordinate axes is specified by extent, i.e. x is within [-extent[0], extent[0]] etc.

Parameters:
extent - the extent of each of the three coordinate axes
axisScale - the axis scale, i.e. the distance between two ticks on the coordinate axes

CoordinateSystemFactory

public CoordinateSystemFactory(double[] extent)
see CoordinateSystemFactory(double[] extent, double axisScale)
here axisScale is set to 1.0


CoordinateSystemFactory

public CoordinateSystemFactory(SceneGraphComponent component,
                               double axisScale)
Creates a coordinate system where min and max values of each coordinate axis are specified by a given SceneGraphComponent.
A new SceneGraphNode containing the coordinate system is added to the children of component.

Parameters:
component - the SceneGraphComponent specifying the extent of the coordinate system
axisScale - the axis scale, i.e. the distance between two ticks on the coordinate axes

CoordinateSystemFactory

public CoordinateSystemFactory(SceneGraphComponent component)
see CoordinateSystemFactory(SceneGraphComponent component, double axisScale)
here axisScale is set to 1.0

Method Detail

dispose

public void dispose()

updateBox

public void updateBox(double[] cameraToObject)
Beautifies the box regarding the current transformation from camera coordinates to local coordinates of the coordiante system, i.e. hides certain box vertices including box edges and grid faces.

Parameters:
cameraToObject - the transformation matrix from camera coordinates to local coordinates of the coordinate system within the SceneGraph

getCoordinateSystem

public SceneGraphComponent getCoordinateSystem()
Get the coordinate system specified in this factory.
(The coordinate system may be removed from the SceneGraph using this method.)

Returns:
the coordinate system

setAxisScale

public void setAxisScale(double axisScale)
Set the axis scale, i.e. the distance between two ticks on the coordinate axes.

Parameters:
axisScale - the axis scale

getAxisScale

public double getAxisScale()
Get the current axis scale, i.e. the distance between two ticks on the coordinate axes.

Returns:
the current axis scale

setLabelScale

public void setLabelScale(double labelScale)
Set the label scale, i.e. the size of labels of axes and ticks
(including the size of arrows and ticks).

Parameters:
labelScale - the label scale

getLabelScale

public double getLabelScale()
Get the current label scale, i.e. the size of labels of axes and ticks.

Returns:
the current label scale

showAxes

public void showAxes(boolean b)
Show or hide the axes of the coordinate system going through the origin.

Parameters:
b - true iff axes are to be shown

showBox

public void showBox(boolean b)
Show or hide the bounding box of the coordinate system.

Parameters:
b - true iff the box is to be shown

showGrid

public void showGrid(boolean b)
Show or hide the grid on the bounding box faces.

Parameters:
b - true iff the grid is to be shown

showAxesArrows

public void showAxesArrows(boolean b)
Show or hide the arrows of the axes of the coordinate system going through the origin.

Parameters:
b - true iff the arrows are to be shown

showBoxArrows

public void showBoxArrows(boolean b)
Show or hide the arrows of the bounding box of the coordinate system.

Parameters:
b - true iff the arrows are to be shown

showLabels

public void showLabels(boolean b)
Show or hide the tick & axis labels of axes and bounding box of the coordinate system.

Parameters:
b - true iff the labels are to be shown

setColor

public void setColor(java.awt.Color c)
Set the color of the coordinate system (axes and bounding box).

Parameters:
c - the color

getColor

public java.awt.Color getColor()
Get the current color of the coordinate system (axes and bounding box).

Returns:
the current color

setGridColor

public void setGridColor(java.awt.Color c)
Set the color of the grid on the bounding box faces.

Parameters:
c - the color

getGridColor

public java.awt.Color getGridColor()
Get the current color of the grid on the bounding box faces.

Returns:
the current color

setBoxColor

public void setBoxColor(java.awt.Color c)
Set the color of the bounding box.

Parameters:
c - the color

getBoxColor

public java.awt.Color getBoxColor()
Get the current color of the bounding box.

Returns:
the current color

setLabelColor

public void setLabelColor(java.awt.Color c)
Set the color of all labels of the coordinate system.

Parameters:
c - the color

getLabelColor

public java.awt.Color getLabelColor()
Get the current color of all labels of the coordinate system.

Returns:
the current color

setLabelFont

public void setLabelFont(java.awt.Font f)
Set the font of all labels of the coordinate system.

Parameters:
f - the font

getLabelFont

public java.awt.Font getLabelFont()
Get the current font of all labels of the coordinate system.

Returns:
the current font

beautify

public void beautify(boolean b)
Beautify the coordinate system automatically iff set to true, i.e. hide certain box vertices including box edges and grid faces.
(Adds or removes the tool CoordinateSystemBeautifier to the coordinate system.)

Parameters:
b - true iff coordinate system is to be beautified automatically

setLabelBoxEdges

public void setLabelBoxEdges(int[][] edges)
Set the box edges on which labels are to be shown.
Edges={{dir_y, dir_z}, {dir_x, dir_z}, {dir_x, dir_y}} specifies on which three edges of the bounding box labels are shown. The dir_i must be either -1 or +1 and specifies whether labels are shown on the edge of the box with a larger or smaller value of coordinate i, respectively.
(This method is analogous to the Mathematica Graphics3D directive 'AxesEdges'.)

Parameters:
edges - specifies on which edges of the bounding box labels are to be shown