org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL Class Reference

Inheritance diagram for org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL:

Inheritance graph
[legend]
Collaboration diagram for org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL:

Collaboration graph
[legend]

Public Member Functions

 CenteredTextDrawerGL ()
void setFilledBoxSize (double boxWidth, double boxHeight)
Vector3D[] placeBoundingBox (Vector3D[] bbox, Vector3D textCenter, double rotationAngle)
TextGrid placeTextGrid (TextGrid stringPositions, Vector3D textCenterPix, double rotationAngle)

Private Attributes

double halfCenteredBoxWidth
double halfCenteredBoxHeight

Detailed Description

Class drawing text with tex_box_mode set to centered.
Author:
Jean-Baptiste Silvy

Definition at line 25 of file CenteredTextDrawerGL.java.


Constructor & Destructor Documentation

org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL::CenteredTextDrawerGL (  )  [inline]

Default constructor

Definition at line 33 of file CenteredTextDrawerGL.java.

References halfCenteredBoxHeight, and halfCenteredBoxWidth.

00033                                       {
00034                 super();
00035                 halfCenteredBoxWidth = 0.0;
00036                 halfCenteredBoxHeight = 0.0;
00037         }


Member Function Documentation

void org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL::setFilledBoxSize ( double  boxWidth,
double  boxHeight 
) [inline]

Set the size of the box which the text will fill.

Parameters:
boxWidth width of the box.
boxHeight height of the box.

Definition at line 44 of file CenteredTextDrawerGL.java.

References halfCenteredBoxHeight, and halfCenteredBoxWidth.

00044                                                                         {
00045                 halfCenteredBoxWidth = (boxWidth / 2.0);
00046                 halfCenteredBoxHeight = (boxHeight / 2.0);
00047         }

Vector3D [] org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL::placeBoundingBox ( Vector3D[]  bbox,
Vector3D  textCenter,
double  rotationAngle 
) [inline, virtual]

Move the bounding box to the right position.

Parameters:
bbox intial bounding box centered at the origin.
textCenter text center
rotationAngle rotation angle around the text center
Returns:
new bouding box turned

Implements org::scilab::modules::renderer::textDrawing::TextContentDrawerGL.

Definition at line 56 of file CenteredTextDrawerGL.java.

References org::scilab::modules::renderer::utils::geom3D::Vector3D::add(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), halfCenteredBoxHeight, halfCenteredBoxWidth, i, and org::scilab::modules::renderer::utils::geom3D::Vector3D::rotate().

00056                                                                                                        {
00057                 // text center refer here to the bottom left corner.
00058                 // So we need to add half of the box size.
00059                 double halfBoxWidth = (bbox[2].getX() - bbox[1].getX()) / 2.0;
00060                 double halfBoxHeight = (bbox[0].getY() - bbox[1].getY()) / 2.0;
00061                 
00062                 Vector3D rotationAxis = new Vector3D(0.0, 0.0, 1.0);
00063                 for (int i = 0; i < bbox.length; i++) {
00064                         
00065                         // translate to textCenter
00066                         bbox[i] = bbox[i].add(textCenter);
00067                         bbox[i] = bbox[i].add(new Vector3D(halfCenteredBoxWidth - halfBoxWidth, halfCenteredBoxHeight - halfBoxHeight, 0.0));
00068                         
00069 //                       rotate around textCenter
00070                         bbox[i] = bbox[i].rotate(textCenter, rotationAxis, rotationAngle);
00071                 }
00072                 return bbox;
00073         }

Here is the call graph for this function:

TextGrid org::scilab::modules::renderer::textDrawing::CenteredTextDrawerGL::placeTextGrid ( TextGrid  stringPositions,
Vector3D  textCenterPix,
double  rotationAngle 
) [inline, virtual]

Put the text grid at the right position

Parameters:
stringPositions Initial position of strings, centered on (0,0).
textCenterPix position of the center in pixel coordinates
rotationAngle angle in radian.
Returns:
the new text grid ut at the right position.

Implements org::scilab::modules::renderer::textDrawing::TextContentDrawerGL.

Definition at line 82 of file CenteredTextDrawerGL.java.

References org::scilab::modules::renderer::textDrawing::TextGrid::getExtremBounds(), org::scilab::modules::renderer::ObjectGL::getGL(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getZ(), halfCenteredBoxHeight, and halfCenteredBoxWidth.

00082                                                                                                               {
00083                 //               text center refer here to the bottom left corner.
00084                 // So we need to add half of the box size.
00085                 Vector3D[] bbox = stringPositions.getExtremBounds();
00086                 double halfBoxWidth = (bbox[2].getX() - bbox[1].getX()) / 2.0;
00087                 double halfBoxHeight = (bbox[0].getY() - bbox[1].getY()) / 2.0;
00088                 
00089                 GL gl = getGL();
00090                 gl.glTranslated(textCenterPix.getX(), textCenterPix.getY(), textCenterPix.getZ());
00091                 gl.glRotated(Math.toDegrees(rotationAngle), 0.0, 0.0, 1.0);
00092                 gl.glTranslated(halfCenteredBoxWidth - halfBoxWidth, halfCenteredBoxHeight - halfBoxHeight, 0.0);
00093                 return stringPositions;
00094         }

Here is the call graph for this function:


Field Documentation


The documentation for this class was generated from the following file:

Generated on Tue Sep 9 18:29:23 2008 for Scilab [trunk] by  doxygen 1.5.5