Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.image.tools
Class ImageGenerator

java.lang.Object
  |
  +--oracle.cabo.image.tools.AbstractImageGenerator
        |
        +--oracle.cabo.image.tools.ImageGenerator

public class ImageGenerator
extends AbstractImageGenerator

ImageGenerator is a utility class that generates images based on parameters specified in an XML file.

The ImageGenerator was created to help HTML clients produce images that contain translated text. It also lets HTML clients create Browser Look And Feel buttons and tabs out of images instead of complex HTML tables.

Currently the ImageGenerator can produce images of "action" buttons, "global" buttons and tab bars with the Browser Look And Feel. The ImageGenerator will try to render images as described by an input XML file. If any resulting image contains more than 256 colors, the image is dithered to the web-safe color palette.

The ImageGenerator tool supports the following command line arguments:

For example, the following command line can be used to run the ImageGenerator to generate translated Japanese images.
   java oracle.cabo.image.tools.ImageGenerator -output=D:\Temp\images -language=ja -region=JP -bundle=oracle.sample.resource.ButtonBundle button.xml
 

The ImageGenerator XML file format uses an ImageGenerator root element, which must be placed in the UIX Dynamic Images namespace by defining an "xmlns" attribute. The ImageGenerator root element contains a defaults section, followed by elements which specify the images to generate. These image elements must be of type button, globalButton, or tabBar. A valid ImageGenerator XML file looks like this:

   <?xml version="1.0"?>
   <ImageGenerator version="2.0" xmlns="http://xmlns.oracle.com/uix/image">
   
   <!-- Set up some defaults -->
   <defaults>
     <!-- Let's use a really big font by default -->
     <font>
       <name>Arial</name>
       <size>18</size>
       <style>bold</style>
     </font>
   </defaults>

   <!-- An action button -->
   <button name="button1">
     <text>Hello, world!</text>
   </button>

   <!-- A global button -->
   <globalButton name="global1" source="images/help.gif"/>

   <!-- A tab bar -->
   <tabBar name="tabbar1" selectedIndex="0">
     <tab>
       <text>Tab 1</text>
     </tab>
     <tab>
       <text>Tab 2</text>
     </tab>
     <tab>
       <text>Tab 3</text>
     </tab>
   </tabBar>

   </ImageGenerator>
 
 

Defaults

Clients can specify default values for various attributes in the defaults section. These defaults are applied to all images in the XML file. Most of the values specified in the defaults section can be overridden on a per-image basis. The defaults tag may contain the following elements and attributes:
font
The font element contains three types of tags which are used to specify the default font to use when rendering text: name, size, and style. The name tag corresponds to the name of the font, the size tag is an integer that corresponds to the size of the font. Both these tags are required. The style tag specifies a font style. Valid styles include plain, bold, and italic. There can be more than one style tag, eg. to indicate both bold and italic. If no style is specified, the style defaults to plain. All three of these values can also be specified as attributes on the font element. For example, the following two samples both define a 16 point, Arial font:
     <font>
     <name>Arial</name>
     <size>16</size>
     </font>

     <font name="Arial" size="16"/>
     
foreground
The foreground element specifies the default foreground color to use for all generated images. The foreground tag, like all other color-based tags, uses attributes for the red, green, and blue values. The XML should look like this:
<foreground red="255" green="0" blue="0"></foreground>
Alternatively, colors can be specified with a single rgb attribute, using the "#RRGGBB" hexadecimal format. For example, the foreground color defined above using red, green and blue attributes can also be defined as:
<foreground rgb="#ff0000"/>
background
The background element specifies the default background color for all generated images. Like foreground, the background tag can either be defined using a single rgb attribute, or using individual red, green, and blue attributes.
textAntialias attribute
Th textAntialias attribute indicates whether text should be antialiased by default. By default, text is not antialiased. The value must be either "true" or "false".

Common XML

The following XML elements/attributes can be specified for all image types ie. for button, globalButton and tabBar elements. Several of these elements or attributes have equivalents in the defaults section. Any value specified at the individual image level takes precedence over an equivalent value specified in the defaults section.
name attribute
The name attribute specifies a unique name for the generated image. The name is used as the basis for the name of the output file name. It does not need to include a file extension. The appropriate file extension (eg. ".gif") is appended by the ImageGenerator.
font
The font tag specifies the font to use when rendering text. See above for a description of the font syntax. This is an optional element. If the font tag is not specified, the font value specified in the defaults section is used. If no font is specified in either the image element or in the defaults section, a look and feel-specific font will be selected.
foreground
The foreground tag specifies the foreground color. See above for a description of the foreground syntax. As with the font element, this element is not required - an appropriate default will be selected, either from the defaults section (if specified), or from the current look and feel.
background
The background tag specified the background color for the generated image. See above for a description of the background syntax. As with the font element, this element is not required - an appropriate default will be selected, either from the defaults section (if specified), or from the current look and feel.
disabled attribute
The disabled attribute specifies a boolean value indicating the disabled state. If the disabled attribute is specified as "true", the element will be rendered in its disabled state. Otherwise, the generated image will appear enabled. The default value for the disabled attribute is "false".
textAntialias attribute
This boolean attribute specifies if the text should be antialiased. The default value for the textAntialias attribute is "false".

Action Buttons

The ImageGenerator can generate action buttons with the Browser Look and Feel using the button tag. In addition to the common elements and attributes described above, clients can specify the following button-specific elements/attributes.
text
The text element indicates the text to be displayed in the button. The text value can optionally be specified as a text attribute on the button element.
translatedText
The translatedText tag can be used in place of the text tag to specify a translated text label for the button. The translatedText element has two attributes: bundle and key. The bundle attribute specifies the name of the resource bundle to use to obtain the text value. The key attribute specifies the key to use to retrieve the text value. key must be specified. If bundle is not specified, the default bundle specified when the ImageGenerator is run is used.
startRounded attribute
startRounded is a boolean attribute which is used to indicate whether the start of the button (left side in left to right languages, right side in right to left languages) should be rounded. By default, the start side of the button is rounded.
endRounded attribute
endRounded is a boolean attribute which is used to indicate whether the end of the button (right side in left to right languages, left side in right to left languages) should be rounded. By default, the end side of the button is rounded.

Global Buttons

The ImageGenerator can render Browser LAF "global" buttons. Each global button is described by a globalButton element. In addition to the common elements and attributes described above, globalButton elements may also contain the following:
source attribute
The source attribute is used to specify the input image to to use. The ImageGenerator will render a global button border around this image. source must be either a full path or relative path (relative to the current working directory) of a valid image file on the file system.
selected attribute
This boolean attribute indicates whether the global button is rendered in its selected state. The default value is "false".

Tab Bar

The ImageGenerator can render a Browser LAF tab bar which contains multiple tabs. In addition to generating an image of the tab bar, the ImageGenerator can also output a client side image map that corresponds to the rendered tab bar. The image map is saved to a ".map" file using the same file name as the generated image.

The XML for the tab bar consists of a tabBar element which may contain the commmon elements and attribtues described above, in addition the following tab bar-specific elements and attributes.

tab
The tab element is used to describe a single tab in the tab bar. The tab tag can contain three attributes: Each tab element may also contains a text or translatedText child which specifies the text label for the tab.
selectedIndex attribute
The selectedIndex attribute is a zero-based Integer value indicating the index of the selected tab in the tab bar. If selectedIndex is not specified, no tab is selected.
selectedForeground
This element specifies the foreground color for selected tab Like foreground, this element contains "red", "green" and "blue" attributes. This element is optional. If it is not specified, the appropriate color for the Browser LAF will be used.
selectedBackground
This element specifies the background color for selected tab Like foreground, this element contains "red", "green" and "blue" attributes. This element is optional. If it is not specified, the appropriate color for the Browser LAF will be used.
selectedFont
This element specifies the font for selected tab Like font, this element contains name, size and style child elements. This element is optional. If it is not specified, the appropriate font for the Browser LAF will be used.


Constructor Summary
protected ImageGenerator()
          Creates an ImageGenerator instance
 
Method Summary
protected  ImageProvider getImageProvider()
          Implementation of AbstractImageGenerator.getImageProvider().
static void main(java.lang.String[] args)
          Run the ImageGenerator.
 
Methods inherited from class oracle.cabo.image.tools.AbstractImageGenerator
generate, getBundle, getLocale, getOutputDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageGenerator

protected ImageGenerator()
Creates an ImageGenerator instance
Method Detail

main

public static void main(java.lang.String[] args)
Run the ImageGenerator. The argument list should contain a valid xml file or multiple xml files.

getImageProvider

protected ImageProvider getImageProvider()
Implementation of AbstractImageGenerator.getImageProvider().
Overrides:
getImageProvider in class AbstractImageGenerator

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.