Package docking.widgets.fieldpanel.field
Class StrutFieldElement
java.lang.Object
docking.widgets.fieldpanel.field.StrutFieldElement
- All Implemented Interfaces:
FieldElement
Used to force a clip to happen by using this field with space characters and size that far
exceeds the available painting width.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) Returns the character at the given index.Returns the base type replaced by this strut; may be nullintgetCharacterIndexForDataLocation(int dataRow, int dataColumn) Returns the character index appropriate for the given data locationgetColor(int charIndex) Returns the color for a given character within this element, since different colors may be applied to different characters.getDataLocationForCharacterIndex(int characterIndex) Translates the given character index to a data location related to the data model, as determined by the FieldFactory.getFieldElement(int characterOffset) Returns the inner-most FieldElement inside this field element at the given locationintReturns the amount of height above the baseline of this element.intReturns the amount of height below the baseline of this element.intgetMaxCharactersForWidth(int stringWidth) As the name implies, this method returns the maximum number of characters from this field element that will fit within the given width.intReturns the string width of this element.getText()Returns the text contained by this field element.intlength()Returns the length of the text within this element.voidpaint(JComponent c, Graphics g, int x, int y) Paints the text contained in this field element at the given x,y screen coordinate using the given Graphics object.replaceAll(char[] targets, char replacement) Returns a new FieldElement with all occurrences of the target characters replaced with the given replacement character.substring(int start) Returns a new FieldElement containing just the characters beginning at the given index.substring(int start, int end) Returns a new FieldElement containing just the characters beginning at the given start index (inclusive) and ending at the given end index (exclusive).toString()
-
Constructor Details
-
StrutFieldElement
Constructor. Clients may choose to pass- Parameters:
baseElement- the base type replaced by this strut; may be null if no type is being replacedwidth- the width of this strut class
-
-
Method Details
-
getBaseType
Returns the base type replaced by this strut; may be null- Returns:
- the base type replaced by this strut; may be null
-
charAt
public char charAt(int index) Description copied from interface:FieldElementReturns the character at the given index.- Specified by:
charAtin interfaceFieldElement- Parameters:
index- the index of the character in this field element.- Returns:
- the character at the given index.
-
getCharacterIndexForDataLocation
public int getCharacterIndexForDataLocation(int dataRow, int dataColumn) Description copied from interface:FieldElementReturns the character index appropriate for the given data location- Specified by:
getCharacterIndexForDataLocationin interfaceFieldElement- Parameters:
dataRow- the row in the data model as determined by the creating field factory.dataColumn- the column in the data model as determined by the creating field factory.- Returns:
- the character index appropriate for the given data location; -1 if this field does not contain the given location
-
getDataLocationForCharacterIndex
Description copied from interface:FieldElementTranslates the given character index to a data location related to the data model, as determined by the FieldFactory.- Specified by:
getDataLocationForCharacterIndexin interfaceFieldElement- Parameters:
characterIndex- The character index to translate.- Returns:
- The data location in the model coordinates.
-
getColor
Description copied from interface:FieldElementReturns the color for a given character within this element, since different colors may be applied to different characters.- Specified by:
getColorin interfaceFieldElement- Parameters:
charIndex- The character index- Returns:
- the color for a given character within this element.
-
getFieldElement
Description copied from interface:FieldElementReturns the inner-most FieldElement inside this field element at the given location- Specified by:
getFieldElementin interfaceFieldElement- Parameters:
characterOffset- the character offset.- Returns:
- the inner-most FieldElement inside this field element at the given location
-
getHeightAbove
public int getHeightAbove()Description copied from interface:FieldElementReturns the amount of height above the baseline of this element.- Specified by:
getHeightAbovein interfaceFieldElement- Returns:
- the amount of height above the baseline of this element.
-
getHeightBelow
public int getHeightBelow()Description copied from interface:FieldElementReturns the amount of height below the baseline of this element.- Specified by:
getHeightBelowin interfaceFieldElement- Returns:
- the amount of height below the baseline of this element.
-
getMaxCharactersForWidth
public int getMaxCharactersForWidth(int stringWidth) Description copied from interface:FieldElementAs the name implies, this method returns the maximum number of characters from this field element that will fit within the given width.- Specified by:
getMaxCharactersForWidthin interfaceFieldElement- Parameters:
stringWidth- The width constraint- Returns:
- the maximum number of characters from this field element that will fit within the given width.
-
getStringWidth
public int getStringWidth()Description copied from interface:FieldElementReturns the string width of this element. The width is based upon the associated FontMetrics object within this element.- Specified by:
getStringWidthin interfaceFieldElement- Returns:
- the string width of this element.
-
getText
Description copied from interface:FieldElementReturns the text contained by this field element.- Specified by:
getTextin interfaceFieldElement- Returns:
- the text contained by this field element.
-
length
public int length()Description copied from interface:FieldElementReturns the length of the text within this element. This is a convenience method for callinggetText().length().- Specified by:
lengthin interfaceFieldElement- Returns:
- the length of the text within this element.
-
paint
Description copied from interface:FieldElementPaints the text contained in this field element at the given x,y screen coordinate using the given Graphics object.- Specified by:
paintin interfaceFieldElement- Parameters:
c- the component being painted.g- the Graphics object used to paint the field text.x- the horizontal screen position to painty- the vertical screen position to paint.
-
replaceAll
Description copied from interface:FieldElementReturns a new FieldElement with all occurrences of the target characters replaced with the given replacement character.- Specified by:
replaceAllin interfaceFieldElement- Parameters:
targets- The array of characters to replace.replacement- The replacement character.- Returns:
- a new FieldElement with all occurrences of the target characters replaced with the given replacement character.
-
substring
Description copied from interface:FieldElementReturns a new FieldElement containing just the characters beginning at the given index.- Specified by:
substringin interfaceFieldElement- Parameters:
start- The starting index (inclusive) from which to substring this element.- Returns:
- a new FieldElement containing just the characters beginning at the given index.
-
substring
Description copied from interface:FieldElementReturns a new FieldElement containing just the characters beginning at the given start index (inclusive) and ending at the given end index (exclusive).- Specified by:
substringin interfaceFieldElement- Parameters:
start- The starting index (inclusive) from which to substring this element.end- The end index (exclusive) to which the substring will be performed.- Returns:
- a new FieldElement containing just the characters beginning at the given index.
-
toString
-