Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » VerticalTextPainter alignment issue
VerticalTextPainter alignment issue [message #1326245] Thu, 01 May 2014 16:49 Go to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
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) :

index.php/fa/18006/0/

Can anyone help me on this?

-Regards,
Rajesh
Re: VerticalTextPainter alignment issue [message #1326514 is a reply to message #1326245] Thu, 01 May 2014 19:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Which version are you using? If you are using a development snapshot it might be an issue with the reworked painter. In that case try to use the VerticalImageTextPainter (I think that is the new name for the old implementation).
Re: VerticalTextPainter alignment issue [message #1327574 is a reply to message #1326514] Fri, 02 May 2014 08:17 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

Thanks for reply. I was using old version. With new version, the vertical alignment is totally gone. I am registering my own labels and returning it for both ColumnHeaderLayer and ColumnGroupHeaderLayer. This was working fine with old jars. But this alignment is not working now with new jars. I tried with both VerticalImageTextPainter and VerticalTextPainter. But nothing works.any idea?

Re: VerticalTextPainter alignment issue [message #1327769 is a reply to message #1327574] Fri, 02 May 2014 10:27 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I don't really have an idea. Did you configure the VerticalTextPainter to wrap automatically or does your String values contain line breaks? The reason why I'm asking is that your column header values for the vertical text looks not aligned correctly, and I'm not sure if the String values themselves are responsible. Maybe they contain white spaces (e.g. tabs).

When I tested the vertical implementations (both old and new) I also tested line wrapping in the TextPainterExamples, and there everything looked fine (and it still looks fine now)
Re: VerticalTextPainter alignment issue [message #1327971 is a reply to message #1327769] Fri, 02 May 2014 12:41 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
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:

index.php/fa/18009/0/

Since configuration is not able to realize the custom label added for vertical painter, the text appear in horizontal alignment.
Re: VerticalTextPainter alignment issue [message #1327996 is a reply to message #1327971] Fri, 02 May 2014 12:57 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Well, that is because there are new labels that are added on top of the label stack. And you are overriding getConfigLabelsByPosition() and adding your labels at the bottom. Try to add your labels on top.
Previous Topic:EMF Examples
Next Topic:NatTable 1.1.0 released
Goto Forum:
  


Current Time: Thu Mar 28 23:17:23 GMT 2024

Powered by FUDForum. Page generated in 0.03394 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top