SilverStream
Application Server 3.5

com.sssw.rt.tview
Class AgoColumnText

java.lang.Object
 |
 +--com.sssw.rt.tview.AgoColumnBase
       |
       +--com.sssw.rt.tview.AgoColumnText
Direct Known Subclasses:
AgoColumnComboBox, AgoColumnHierarchy, AgoColumnTextEditor

public class AgoColumnText
extends AgoColumnBase

AgoColumnText is a bound column that you can use to display data to users. These columns are for read-only textual data.


Field Summary
static int MULTILINE
          Column alignments.
 
Constructor Summary
AgoColumnText(int width, boolean visible, boolean transparent, Color backgroundColor, int borderType)
          AgoColumnText constructor.
 
Method Summary
 String applyFormat(Object obj)
          Return a String which is the result of applying the format pattern to a specified object (String, Long, Date etc.)
 boolean getAdjustWidthForContent()
          Returns a boolean which specifies whether the column automatically adjusts its width to accomodate its content.
 Color getColor()
          Returns a Color object that represents the color of the column's text.
 String getColumnName()
          Returns the text of the column if it is able to get the name (for example, if this column has been initialized either with setColumnName() or with initColumnTextHeader()).
 int getDatatype()
          Returns the datatype of the column.
 AgoFontIdentifier getFontIdentifier()
          Returns the SilverStream font object (AgoFontIdentifier) which describes the font used for text in this column.
 String getFormatPattern()
          Returns the format pattern or null if no format pattern has been set for the column.
 int getFormatStyle()
          Get the format style.
 int getMaxPointSize()
          Returns the maximum point size allowed for the text in this column.
 int getMinPointSize()
          Returns the minimum point size allowed for the text in this column.
 String getPropertyName()
          Returns the name of the property associated with this column.
 void initColumnTextHeader(String headerText, AgoFontIdentifier fontid, Color textColor, int alignment)
          Utility method for setting up a number of parameters for the column text simultaneously.
 void initColumnTextProperty(String propertyName, AgoFontIdentifier fontid, Color textColor, int alignment)
          Utility method that allows you to bind the column to data and set its font, text color, and alignment for the column.
 void setAdjustWidthForContent(boolean adjustwidthforcontent)
          Sets the AdjustWidthForContent property.
 void setColor(Color color)
          Sets the column text color.
 boolean setColumnName(String columnName)
          Sets the text to be displayed in the specified column.
 void setFontIdentifier(AgoFontIdentifier fontid)
          Specifies the SilverStream font object (AgoFontIdentifier) which describes the size, style and font to be used for the text in this column.
 void setFormatPattern(String pattern, char datatype)
          Set the format pattern for the column.
 void setFormatStyle(int style, char datatype)
          Set the format style and column datatype.
 void setMaxPointSize(int maxpointsize)
          Sets maximum point size allowed for the text in this column.
 void setMinPointSize(int minpointsize)
          Set the minimum point size allowed for the text in this column.
 void setPropertyName(String propertyName)
          Set the name of the property associated with this column.
 
Methods inherited from class com.sssw.rt.tview.AgoColumnBase
getAlignment, getBackgroundColor, getBorderType, getDisplayWidth, getHidden, getResizable, getSelectable, getTransparent, getVisible, getWidth, isWidthFixed, setAlignment, setBackgroundColor, setBorderType, setFixedWidth, setHidden, setProportionalWidth, setProportionalWidth, setResizable, setSelectable, setTransparent, setVisible, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MULTILINE

public static final int MULTILINE
Column alignments. If you change one of these or add a new one, modify the getPvFontInstanceAlignment method below.
Constructor Detail

AgoColumnText

public AgoColumnText(int width,
                     boolean visible,
                     boolean transparent,
                     Color backgroundColor,
                     int borderType)
AgoColumnText constructor. Use to set several properties for the AgoColumnText object.
Parameters:
width - column text width, in pixels
visible - true means text column is visible
transparent - true means text column is transparent
Color - text column background color. Background color is only visible when the column is not transparent.
borderType - column border type
Usage:

For the borderType parameter, see the setBorderType method.

Example:
	AgoColumnText colText = new AgoColumnText(25, // width in pixels
		true,		                   // visible
		false,		                  // not transparent
		Color.red,	                 // background color
		AgoColumnBase.BORDER_3D);	// border type
See Also:
AgoColumnBase, AgoColumnText.initColumnTextProperty(String propertyName, AgoFontIdentifier fontid, Color textColor, int alignment), AgoColumnText.initColumnTextHeader(String headerText, AgoFontIdentifier fontid, Color textColor, int alignment)
Method Detail

initColumnTextProperty

public void initColumnTextProperty(String propertyName,
                                   AgoFontIdentifier fontid,
                                   Color textColor,
                                   int alignment)
Utility method that allows you to bind the column to data and set its font, text color, and alignment for the column. Use this method only for a column in a data (not header) band.
Parameters:
propertyName - the AgcData column name from which to initialize this column
fontid - AgoFontIdentifier
textColor - text color (java.awt.Color object)
alignment - text alignment
Usage:

For a list of values to use with the alignment parameter, see the Column Alignment Values in the AgoColumnBase.

Example:
	AgoFontIdentifier fontid = new
		AgoFontIdentifier("Helvetica", 0, 12);
	colText.initColumnTextProperty(
		"CustomerId",	// use CustomerId property for the value of this column
 		 fontid, 	// the font identifier for text in this column
		 Color.black,	// the color for text in this column
		AgoColumnBase.ALIGN_TOP_LEFT);// the alignment of text in this column
See Also:
AgoFontIdentifier

initColumnTextHeader

public void initColumnTextHeader(String headerText,
                                 AgoFontIdentifier fontid,
                                 Color textColor,
                                 int alignment)
Utility method for setting up a number of parameters for the column text simultaneously. Use this method only for a column in a header band.
Parameters:
headerText - the actual text to display in this column
fontid - AgoFontIdentifier
textColor - text color (java.awt.Color object)
alignment - text alignment
Usage:

The list of values for the alignment parameter are described in the Column Alignment Values section of AgoColumnBase class..

Example:
	AgoFontIdentifier fontid = new
		AgoFontIdentifier("Helvetica", 0, 12);
	colText.initColumnTextHeader(
		"CustomerId",	// this column will always display the text "CustomerId"
		fontid, 	// the font identifier for text in this column
		Color.black,	// the color for text in this column
		AgoColumnBase.ALIGN_TOP_LEFT);// the alignment of text in this column
See Also:
AgoFontIdentifier

getFontIdentifier

public final AgoFontIdentifier getFontIdentifier()
Returns the SilverStream font object (AgoFontIdentifier) which describes the font used for text in this column.
Usage:

The AgoFontIdentifier object consists of three parts: a Font Name, a Font Style and a Font Size. The Font Style can be one of these values:

     AgoFontIdentifier.PLAIN
     AgoFontIdentifier.BOLD
     AgoFontIdentifier.ITALIC
     AgoFontIdentifier.BOLD + AgoFontIdentifier.ITALIC
The Font Name can be one of these values:Dialog, SansSerif, Serif, Monospaced, Helvetica, TimesRoman, Courier, DialogInput, Zapfdingbats. At runtime, Java translates this value to the appropriate font installed on the system. The Font Size can be any integer.
Example:

The following code fragment illustrates how to construct a new AgoFontIdentifier object (called newFont) and how to call the getFontIdentifier() method:

     AgoFontIdentifier font;
     font = colText.getFontIdentifier();
See Also:
AgoColumnText.setFontIdentifier(AgoFontIdentifier fontid)

setFontIdentifier

public final void setFontIdentifier(AgoFontIdentifier fontid)
Specifies the SilverStream font object (AgoFontIdentifier) which describes the size, style and font to be used for the text in this column.

If you change this value at runtime, you must call the AgcView.setAgoViewFormat() method to repaint the view and make the change visible to the user.

Parameters:
fontid - the AgoFontIdentifier
Usage:

The AgoFontIdentifier object consists of three parts: a Font Name, a Font Style and a Font Size.

The Font Name can be one of these values:Dialog, SansSerif, Serif, Monospaced, Helvetica, TimesRoman, Courier, DialogInput, Zapfdingbats.

At runtime, Java translates this value to the appropriate font installed on the system.

The Font Size can be any integer.

The Font Style can be one of these values:

     AgoFontIdentifier.PLAIN
     AgoFontIdentifier.BOLD
     AgoFontIdentifier.ITALIC
     AgoFontIdentifier.BOLD + AgoFontIdentifier.ITALIC
Example:

This code fragment illustrates how to construct a new AgoFontIdentifier object (called newFont) and how to call the setFontIdentifier() method:

     AgoFontIdentifier     newFont;

     newFont=new AgoFontIdentifier("TimesRoman",
		AgoFontIdentifier.ITALIC, 20);
     columnFmt.setFontIdentifier(newFont);
See Also:
AgoFontIdentifier

getMinPointSize

public final int getMinPointSize()
Returns the minimum point size allowed for the text in this column.
Usage:

When the font size is scaled up or down according to the indent level, it will never be made smaller than this value. When you define a font value using AgoFontIdentifier, the font size is ignored if it is set smaller than the minimum point size.

When changing this value at runtime, you must call the AgcView.setAgoViewFormat() method. It repaints the view and makes the font change visible to the user.

Example:
	int pointSize = colText.getMinPointSize();
See Also:
AgoColumnText.setMinPointSize(int minpointsize), AgoColumnText.getMaxPointSize()

setMinPointSize

public final void setMinPointSize(int minpointsize)
Set the minimum point size allowed for the text in this column.
Parameters:
minpointsize - value for the minimum font size Font size will not scale smaller than this size.
Usage:

When the font size is scaled up or down according to the indent level, it will never be made smaller than this value. When you define a font value using AgoFontIdentifier, the font size is ignored if it is set smaller than the minimum point size.

When changing this value at runtime, you must call the AgcView.setAgoViewFormat() method. It repaints the view and makes the font change visible to the user.

Example:
	colText.setMaxPointSize(8);
See Also:
AgoColumnText.getMinPointSize(), AgoColumnText.setMaxPointSize(int maxpointsize)

getMaxPointSize

public final int getMaxPointSize()
Returns the maximum point size allowed for the text in this column.
Usage:

When the font size is scaled up or down according to the indent level, it will never be made larger than this value. When you define a font value using AgoFontIdentifier, the font size is ignored if it is set larger than the maximum point size.

When changing this value at runtime, you must call the AgcView.setAgoViewFormat() method. It repaints the view and makes the font change visible to the user.

Example:
	int pointSize = colText.getMaxPointSize();
See Also:
AgoColumnText.getMinPointSize()

setMaxPointSize

public final void setMaxPointSize(int maxpointsize)
Sets maximum point size allowed for the text in this column.
Parameters:
maxpointsize - maximum font point size. The font will not scale larger than this size.
Usage:

When the font size is scaled up or down according to the indent level, it will never be made larger than this value. When you define a font value using AgoFontIdentifier, the font size is ignored if it is set larger than the maximum point size.

When changing this value at runtime, you must call the AgcView.setAgoViewFormat() method. It repaints the view and makes the font change visible to the user.

Example:
	colText.setMaxPointSize(20);
See Also:
AgoColumnText.getMaxPointSize(), AgoColumnText.setMinPointSize(int minpointsize)

getColor

public final Color getColor()
Returns a Color object that represents the color of the column's text.
Example:
    Color textColor = colText.getColor();
See Also:
AgoColumnText.setColor(Color color)

setColor

public final void setColor(Color color)
Sets the column text color.

If you change this value at runtime, you must call the AgcView.setAgoViewFormat() method to repaint the view and make the change immediately visible to the user.

Parameters:
color - the text color as defined in java.awt.Color
Example:
	colText.setColor(Color.green);
See Also:
AgoColumnText.getColor()

getAdjustWidthForContent

public final boolean getAdjustWidthForContent()
Returns a boolean which specifies whether the column automatically adjusts its width to accomodate its content. When true the column automatically adjusts its width to accomodate its content.
Example:
	boolean willAdjust = colText.getAdjustWidthforContent();
See Also:
AgoColumnText.setAdjustWidthForContent(boolean adjustwidthforcontent)

setAdjustWidthForContent

public final void setAdjustWidthForContent(boolean adjustwidthforcontent)
Sets the AdjustWidthForContent property. When true, the column automatically adjusts its width according to its content. By default, the value is false and any content that does not fit within the columns pixel width is cropped.
Parameters:
adjustwidthforcontent - when true, the column is automatically adjusted for the width of the text.
Usage:

Consider setting any header columns to the same value to maintain a consistent look and feel for the control.

If you change this value at runtime, you must call the AgcView.setAgoViewFormat() method to repaint the view and make the change immediately visible to the user.

Example:
	coltext.setAdjustWidthForContent(true);
See Also:
AgoColumnText.getAdjustWidthForContent()

setPropertyName

public final void setPropertyName(String propertyName)
Set the name of the property associated with this column.
Parameters:
propertyName - the property name
Example:
	colText.setPropertyName("CustomerNumber");
See Also:
AgoColumnText.getPropertyName()

getPropertyName

public final String getPropertyName()
Returns the name of the property associated with this column.
Usage:

If the column was initialized with initColumnTextProperty(), the value returned will be the value specified in the initColumnTextProperty() call, or by any subsequent call to setPropertyName(). If the column was initialized with initColumnTextHeader(), the value returned will be the value specified in the initColumnTextHeader() call, or by any subsequent call to setColumnName().

Example:

This example shows what happens when the column is initialized with initColumnTextProperty(), then setPropertyName() is called to change the property name, and then getPropertyName() is called:

	AgoFontIdentifier fontid = new
		AgoFontIdentifier("Helvetica", 0, 12);
	colText.initColumnTextProperty(
		"CustomerId",	// use CustomerId property
				//	for the value of this column
		fontid, 	// the font identifier for
				//	text in this column
		Color.black,	// the color for text in this column
		AgoColumnBase.ALIGN_TOP_LEFT);// the alignment of text in this column

	colText.setPropertyName("CustomerNumber");
	// this will return "CustomerNumber"
	String propName = colText.getPropertyName();
This example shows what happens when the column is initialized with initColumnTextHeader(), then setColumnName() is used to change the column text, and then getPropertyName() is called:
	AgoFontIdentifier fontid = new
		AgoFontIdentifier("Helvetica", 0, 12);
	colText.initColumnTextHeader(
		"CustomerId",	// this column will always
				//	 display the text "CustomerId"
		fontid, 	// the font identifier for
				//	text in this column
		Color.black,	// the color for text in this column
		AgoColumnBase.ALIGN_TOP_LEFT);// the alignment of text in this column

	// this column will always display the text "CustomerNumber"
	colText.setColumnName("CustomerNumber");
	// this will return "CustomerNumber"
	String propName = colText.getPropertyName();
See Also:
AgoColumnText.setPropertyName(String propertyName)

setFormatPattern

public final void setFormatPattern(String pattern,
                                   char datatype)
Set the format pattern for the column. You must also supply the column's data type.
Parameters:
pattern - the pattern to be used for formatting the text in this column (for example, "yyyy/MM/dd")
datatype - the value which specifies the datatype of this column
Usage:

The following is a list of settable datatype values. The only valid datatype values for AgoColumnText are DatatypeCodes with an * in this list.
DatatypeCodes.TYPE_BOOLEAN DatatypeCodes.TYPE_CHAR DatatypeCodes.TYPE_BYTE
DatatypeCodes.TYPE_SHORT DatatypeCodes.TYPE_INT * DatatypeCodes.TYPE_LONG
DatatypeCodes.TYPE_FLOAT * DatatypeCodes.TYPE_DOUBLE DatatypeCodes.TYPE_BYTEARRAY
DatatypeCodes.TYPE_STRING DatatypeCodes.TYPE_NUMERIC * DatatypeCodes.TYPE_DATE
* DatatypeCodes.TYPE_TIME * DatatypeCodes.TYPE_TIMESTAMP DatatypeCodes.TYPE_UUID

Example:
	colText1.setFormatPattern("yyyy/MM/dd", DatatypeCodes.TYPE_DATE);
	colText2.setFormatPattern("##.##", DatatypeCodes.TYPE_DOUBLE);
See Also:
AgoColumnText.getFormatPattern(), AgoColumnText.setFormatStyle(int style, char datatype), AgoColumnText.getDatatype()

getFormatPattern

public final String getFormatPattern()
Returns the format pattern or null if no format pattern has been set for the column. No format patter is set by default.
Usage:

The format pattern is used for formatting the column's text.

Example:
	String fmt = colText.getFormatPattern();
See Also:
AgoColumnText.setFormatPattern(String pattern, char datatype), AgoColumnText.getFormatStyle(), AgoColumnText.getDatatype()

setFormatStyle

public final void setFormatStyle(int style,
                                 char datatype)
Set the format style and column datatype.
Parameters:
style - the value which specifies the format style to use
datatype - the value which specifies the datatype of this column
Usage:

For the datatype parameter, see the List of datatypes.
For Longs and Doubles, use AgFormat.NUMBERSTYLE, AgFormat.CURRENCYSTYLE, or AgFormat.PERCENTSTYLE. For Dates, Times, and Timestamps use DatatypeCodes.TYPE_DEFAULT, DatatypeCodes.TYPE_SHORT, DatatypeCodes.TYPE_LONG, or DatatypeCodes.TYPE_FULL.

Example:
	colText1.setFormatStyle(DEFAULT, DatatypeCodes.TYPE_TIME);
	colText2.setFormatStyle(CURRENCYSTYLE, DatatypeCodes.TYPE_DOUBLE);
See Also:
AgoColumnText.getFormatStyle(), AgoColumnText.setFormatPattern(String pattern, char datatype), AgoColumnText.getDatatype()

getFormatStyle

public final int getFormatStyle()
Get the format style.
Usage:

Returns the format style text column.

Example:
	int style = colText.getFormatStyle();
See Also:
AgoColumnText.setFormatStyle(int style, char datatype), AgoColumnText.setFormatPattern(String pattern, char datatype), AgoColumnText.getDatatype()

getDatatype

public final int getDatatype()
Returns the datatype of the column.
Usage:

For a list of return values see List of datatypes.

Example:
	int datatype = colText.getDatatype();
See Also:
AgoColumnText.getFormatPattern(), AgoColumnText.getFormatStyle()

setColumnName

public final boolean setColumnName(String columnName)
Sets the text to be displayed in the specified column. It returns true if it is able to set the property (i.e. if this column has not yet been initialized, or has been initialized with initColumnTextHeader()), and it returns false if it is not able to set the property (i.e. if this column has been initialized with initColumnTextProperty()).
Parameters:
columnName - the text you want to display in the column
Usage:

Use this method only if this column is to contain a constant value (normally a column of a header band). The columnName parameter is equivalent to the string passed in to initColumnTextHeader() method.

Example:
     colText.setColumnName("Product ID");
See Also:
AgoColumnText.initColumnTextProperty(String propertyName, AgoFontIdentifier fontid, Color textColor, int alignment), AgoColumnText.initColumnTextHeader(String headerText, AgoFontIdentifier fontid, Color textColor, int alignment)

getColumnName

public final String getColumnName()
Returns the text of the column if it is able to get the name (for example, if this column has been initialized either with setColumnName() or with initColumnTextHeader()).

Returns null if it is not able to get the name, for example, if this column has been initialized with initColumnTextProperty() and not the initColumnTextHeader(), or the column is bound to a column in the database.

Usage:

The return value is equivalent to the string passed in to initColumnTextHeader(). It is available only if this column contains a constant value, which generally means it has to be a column of a header band.

The same value will be returned by a call to getPropertyName().

Example:

This example shows what happens when the column is initialized with initColumnTextHeader, then setColumnName is used to change the column text, and then getColumnName is called:

	AgoFontIdentifier fontid = new
		AgoFontIdentifier("Helvetica", 0, 12);
	colText.initColumnTextHeader(
		"CustomerId",	// this column will always
				// display the text "CustomerId"
		fontid, 	// the font identifier for text
				// in this column
	   	Color.black,	// the color for text in this column
		AgoColumnBase.ALIGN_TOP_LEFT);// the alignment of text in this column

	// this column will always display the text "CustomerNumber"
	colText.setColumnName("CustomerNumber");
	// this will return "CustomerNumber"
	String propName = colText.getColumnName();
See Also:
AgoColumnText.initColumnTextProperty(String propertyName, AgoFontIdentifier fontid, Color textColor, int alignment), AgoColumnText.initColumnTextHeader(String headerText, AgoFontIdentifier fontid, Color textColor, int alignment)

applyFormat

public final String applyFormat(Object obj)
Return a String which is the result of applying the format pattern to a specified object (String, Long, Date etc.)
Usage:

This is a utility function which can be used to format an object in the same way it would be formatted if it were the value of the column. The object specified must be of the same datatype as the column.

Example:
	colText.setFormatPattern("##.00", DatatypeCodes.TYPE_DOUBLE);
	Double aNumber = new Double(98.4);
	// this will return "98.40"
	String theNumber = colText.applyFormat(aNumber);
	colText.setFormatPattern("##.##", DatatypeCodes.TYPE_DOUBLE);
	// this will return "98.4"
	String theNumber = colText.applyFormat(aNumber);

SilverStream
Application Server 3.5