Purpose

This Java Bean is the first step to build a utilities' bean that will group several functionalities.
In this introduction, the Java Bean starts with a "Font" chapter that allows to get the bounding box for any string of any font, and also to get the list of available fonts.


utilities (1)


The Java code

      fjfont.java


The Implementation Class property

      forms.fd.utilities.FJFont


The properties you can set

The target font

Set_Custom_Property( 'BL.BEAN', 1, 'SET_FONT', 'font_name,font_type,font_size' ) ;

font_type could be:
   . N (normal)
   . B (bold)
   .
I (Italic)
   . BI (bold+italic)


Set_Custom_Property( 'BL.BEAN', 1, 'SET_FONT', 'Tahoma,N,8' ) ;

The string that we want calculate the bounding box

Set_Custom_Property( 'BL.BEAN', 1, 'SET_STRING', 'string' ) ;

Set_Custom_Property( 'BL.BEAN', 1, 'SET_STRING', 'Hello World' ) ;

Draw the selected font

Set_Custom_Property( 'BL.BEAN', 1, 'DRAW_FONT', NUM_FONT ) ;


The properties you can get

Get the width of the string

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_WIDTH' ) ;

Get the height of the string

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_HEIGHT' ) ;

Get both width and height

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_SIZE' ) ;
(return format will be : width,height)

Get the font list

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_FONTLIST' );

Get the first font in the list

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_FIRSTFONT' );

Get the next font in the list

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_NEXTFONT' );


The sample dialog

     . Download the utilities.zip file
     . Unzip the file
     . copy the fjutilities.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the UTILITIES.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

In this dialog, the "input" item is resized on the When-Validate-Item trigger:

-- compute the new size
Declare
 LN$Width   pls_integer := 0 ;
 LN$Height  pls_integer := 0 ;
Begin 
  If :BL.INPUT is not null Then
    Set_Custom_Property( 'BL.BEANSTRING', 1, 'SET_STRING', :BL.INPUT ) ;
    :BL.WIDTH  := 6 + Get_Custom_Property( 'BL.BEANSTRING', 1, 'GET_WIDTH' ) ;
    :BL.HEIGHT := Get_Custom_Property( 'BL.BEANSTRING', 1, 'GET_HEIGHT' ) ; 
    Set_Item_Property( 'BL.INPUT', WIDTH, :BL.WIDTH ) ;
  End if ;
End;