VerticalTextPainter alignment issue [message #1326245] |
Thu, 01 May 2014 16:49 |
Rajesh Arumugam Messages: 24 Registered: October 2013 |
Junior Member |
|
|
Hi Experts,
I have created a complex NatTable with 3 level column grouping, freezing, sorting, and with lot NatTable features. As part of it, I need to align the column header in Vertical manner. I created my configuration for column header layer and done with vertical alignment using VerticalTextPainter.
And here comes the issue : The Column header content for some columns are really big, say 80 characters, so we thought to go with text wrap and vertical alignment as Middle. But the content is not fitting into the column header properly though its wrapping the text. But its not alignment the text in Middle alignment(its happening with big content, incase of small content, the alignment is fine)
Say for example , if my total content is 80 characters, i am able to see only 60 characters (with text wrapping) and not able to see 1st 20 characters.
If you consider my content is :
"For Auto component the maximum output cuurent @ voltage 14.5 and 0 degree temperature"
I am able to see content that highlighted in Bold font.Not able to see 1st few characters, and the alignment goes like this for text wrapping(Texts are in vertical manner) :
Can anyone help me on this?
-Regards,
Rajesh
|
|
|
|
|
|
Re: VerticalTextPainter alignment issue [message #1327971 is a reply to message #1327769] |
Fri, 02 May 2014 12:41 |
Rajesh Arumugam Messages: 24 Registered: October 2013 |
Junior Member |
|
|
My header text doesnt contains any white spaces.. just single spaces between words. Right now, it seems like the custom labels i have given for the column header is not working with new jars.
and here is the code i am using for registering custom labels for ColumnHeaderLayer and ColumnGroupHeaderLayer
columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, underlyingBodyLayer,
underlyingBodyLayer.getSelectionLayer()) {
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
{
LabelStack result = super.getConfigLabelsByPosition(columnPosition, rowPosition);
int columnIndex = getColumnIndexByPosition(columnPosition);
int rowIndex = getRowIndexByPosition(rowPosition);
if (rowIndex == 0 && columnIndex == signalConstants.COMMENTS_COLUMN_IDX)
result.addLabel(HORIZONTAL_ALIGNMENT_LABEL);
else if (rowIndex == 0)
result.addLabel(VERTICAL_ALIGNMENT_LABEL);
return result;
}
};
ColumnGroupHeaderLayer columGrpHeaderLayer = new ColumnGroupHeaderLayer(columnHeaderLayer,
underlyingBodyLayer.getSelectionLayer(), _1stColumnGrpModel) {
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
{
LabelStack result = super.getConfigLabelsByPosition(columnPosition, rowPosition);
int columnIndex = getColumnIndexByPosition(columnPosition);
int rowIndex = getRowIndexByPosition(rowPosition);
System.out.println("Header Value is :"
+ getDataValueByPosition(columnPosition, rowPosition)
+ "And Row Index is :" + rowIndex);
if (rowIndex == 0 && columnIndex != signalConstants.COMMENTS_COLUMN_IDX)
result.addLabel(HORIZONTAL_ALIGNMENT_LABEL);
else if (rowIndex == 0 && this.isColumnInGroup(columnIndex))
result.addLabel(VERTICAL_ALIGNMENT_LABEL);
return result;
}
};
and this code is for adding custom style for the header text
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER,
new BeveledBorderDecorator(new VerticalTextImagePainter(true, true, 7, false)),
DisplayMode.NORMAL, VERTICAL_ALIGNMENT_LABEL);
Style style = new Style();
style.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT,
HorizontalAlignmentEnum.CENTER);
Style style1 = new Style();
style1.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT,
VerticalAlignmentEnum.MIDDLE);
Font tableHeaderFont = GUIHelper.getFont(new FontData("Arial", 9, SWT.NORMAL));
style1.setAttributeValue(CellStyleAttributes.FONT, tableHeaderFont);
style.setAttributeValue(CellStyleAttributes.FONT, tableHeaderFont);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style1,
DisplayMode.NORMAL, VERTICAL_ALIGNMENT_LABEL);
But this style is not working . The result comes like this:
Since configuration is not able to realize the custom label added for vertical painter, the text appear in horizontal alignment.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04307 seconds