how to find out if the string given will fit on a particular gwt label or not. - gwt

I am new to gwt and I am trying to check if the dynamic string document id that i am retrieving will will fit on the gwt label or not. Now I am checking for the number of characters and if the number exceeds 15 I am appending ... after 12 characters and displaying the actual id in the tooltip. I need to know how do i achieve this without calculating the number of characters. Please help

The width of a label does not only depend on the string size, but on the font used.
You could write you string in a temporary label attached to the dom and query the size using the method 'getClientWidth' of the element or gwtquery, and remove recursively the last character until you get the appropriate size.
In my opinion the easier way would be to use css and define a fixed width of your label and set the property overflow to hidden, so you see just the chars which fit in the label and you dont have to deal with a different string.

Related

Unity ScrollView with multiline string Content height adaption

So, I have a growing string with many "\n". Every app start I will load the total string and every app use some new lines will be added.
The string is inside the Content of a ScrollView. But the Content size is not scaling with the string length. I want the Content to be exactly as high as the text lines go and be scrollable.
I can think of calculating the line count and set the content height manually. But maybe there is a more simple way? Please tell me your solutions.
I found a convenient non-code answer myself. You put the Text-Component directly on your Content GameObject. Then you use a ContentSizeFitter and set Vertical: Preferred. Also the Content anchors have to be set for variable height.
This enables me to dynamically set and scroll through a different text length with a ScrollView. (The font size is kept, to still fit the rest of the GUI)
I am still open for other answers.

Set backend title for Mask-Elements in Typo3

I have a Typo3 server. On that I created some different content elements with mask.
In this elements there are often repeating content, like texts or other stuff.
So the editors make a new element in the backend, there they can add a headline and as much text parts as they want.
Often it looks like this:
Thats good, the editor can see a "preview" of the textparts. In this example "Karriere,Partner...". This naming happens automatically.
My Problem is, some times there arent any titles. Its always "No title". As an editor its quite hard to find the right dropdown to edit some stuff, you mostly have to open all dropdowns and search for the right one.
Its look then like this:
In both elements there are some string inputs that are very good for the title.
So my question is, how is mask gonna choose the title? Its not the first string input.
And secondly, can I tell Mask that they have to choose input field XYZ as title?
Heyo
Yes, you can tell Mask which field to use as a title for inline elements (like repeating contents). When you're setting up a new Mask element, right below the "Label" field of the repeated inline element, there is a field "Field that should be used as label for inline element (starting with tx_mask_)". This will be used as the title that is displayed in the backend. In the placeholder of that field, it explicitly says that "If empty, first field is used".
So, if your inline element has a field "my_awesome_header" which you would like to use as the title in the backend, set the above to "tx_mask_my_awesome_header".
I am not certain as to why it does not display anything in your second example. It might be that either the first input field is not a string, or the first input field is a string but it is empty.
I hope this helps. Let me know if you need further clarification.
Edit: Since that question came up, it should be possible to set a static default title to the containing Mask element using mod.wizards.newContentElement.wizardItems.mask.elements.[name of the mask element].tt_content_defValues.header = My awesome static title. As I said in the comments, though: I always give my Mask elements a header field and let editors fill that in.

stretch a textField to a max height in jasper reports

I think this is more of a general issue. I would like to use a textfield that gets dynamic data and doesn't stretch more than a given max height. For instance, I have a textfield that, if it gets text that fits in one line, the textfield will be one line height, and i have other elements under it, that will move up with float positioning. Or, if I want a 3 line max height and if the text exceeds that space, then the rest will be trimmed.
I don't want to use java expressions to trim that text, as it is not always accurate. I am new to jasper and I am trying to know if there is any way to do this. I did a lot of searches, but maybe there is something that i missed, and i hope someone can help me. Thank you
I managed to solve this by extending net.sf.jasperreports.engine.fill.TextMeasurer and overriding initialize() method; also I had to extend net.sf.jasperreports.engine.util.AbstractTextMeasurerFactory and override the createMeasurer() method.
Now, whenever I want to have max # of lines, with no overflow, I add a property to that text field (e.g. maxLines) which is being passed to my custom TextMeasurerFactory. I hope this helped you.
We had a similar problem at work with JASPER Reports 4.5, where we had an invoice with a header and a table. We wanted the header to have dynamic height based on the lengths of certain fields (like address, partner name, etc,), but not more than a critical limit, otherwise the header will push the table and thus making a mess by splitting it across multiple pages. Also, the invoice shouldn't exceed 1 page.
We eventually had to move the header in the background section, where we also put a background for the table consisting of vertical lines (so it will extend to the end of an A4 page) and a white opaque square.
This way, if the header exceeds the max height it will go underneath the table's background, cropping the text. This was the desired effect we were looking for.
Sounds crazy, but it worked ...

Text not fitting into form fields (iTextSharp)

I created a .PDF file using Adobe Acrobat Pro. The file has several text fields. Using iTextSharp, I'm able to populate all the fields and mail out the .PDF.
One thing is bugging me - some of the next will not "fit" in the textbox. In Adobe, if I type more that the allocated height, the scroll bar kicks in - this happens when font size is NOT set to auto and multi-line is allowed.
However, when I attempt to set the following properties:
//qSize is float and set to 15;
//auto size of font is not being set here.
pdfFormFields.SetFieldProperty("notification_desc", "textsize", qSize, null);
// set multiline
pdfFormFields.SetFieldProperty("notification_desc", "setfflags", PdfFormField.FF_MULTILINE, null);
//fill the field
pdfFormFields.SetField("notification_desc", complaintinfo.OWNER_DESC);
However upon compilation and after stamping, the scroll bar does not appear in the final .PDF.
I'm not sure if this is the right thing to do. I'm thinking that perhaps I should create a table and flood it with the the text but the documentation makes little or no reference to scroll bars....
When you flatten a document, you remove all interactivity. Expecting working scroll bars on a flattened form, is similar to expecting working scroll bars on printed paper. That's why you don't get a lot of response to your question: it's kind of absurd.
When you fill out a rectangle with text, all text that doesn't fit will be omitted. That's why some people set the font size to 0. In this case, the font size will be adapted to make the text fit. I don't know if that's an option for you as you clearly state that the font size must be 15 pt.
If you can't change the font size, you shouldn't expect the AcroForm form field to adapt itself to the content. ISO-32000-1 is clear about that: the coordinates of a text field are fixed.
Your only alternative is to take control over how iText should fill the field. I made an example showing how to do this in the context of my book: MovieAds.java/MovieAds.cs. In this example, I ask the field for its coordinates:
AcroFields.FieldPosition f = form.GetFieldPositions(TEXT)[0];
This object gives you the page number f.page and a Rectangle f.position. You can use these variables in combination with ColumnText to add the content exactly the way you want to (and to check if all content has been added).
I hope you understand that:
it's only normal that there are no scroll bars on a flattened form,
the standard way of filling out fields clips content that doesn't fit,
you need to do more programming if you want a custom result.
For more info: please consult "iText in Action - Second Edition".

How to stretch a text field relative to data width in Jasper Reports

I have a text field followed by a static text field and I am trying to do 2 things with it:
Get the text field to stretch horizontally (not wrap) when text is longer then the field width and
Push the static text field right when the text field to the left of it stretches
Both of the fields are contained within a frame.
I have both fields set to positionType=float and the text field set to stretchWithOverflow=true, which enable text to wrap vertically but not stretch horizontally.
Is it possible to achieve 1 and 2 above? If so How?
Instead of having 2 text fields (dynamic and static), you can have 1 text field with value as $F{Field} + "statix text". This will probably fix your issue. Also, you can set the "width" and "stretch with overflow" properties, as per your requirements.
Well it's bad news!! According to Jaspersoft's documentation on stretching fields it is not possible to stretch the width of a field:
"Usually, the stretching process refers to the height adjustment only.
When stretching report elements, adjusting the width could affect also
the page width and raise unexpected errors at runtime (for instance,
truncated information could be printed out on pages). This is why
stretching an element let its width unchanged, while its height gets
definitely enlarged in order to make room for all information that
have to be displayed." (Jaspersoft documentation [v4.5.0], 2011)
However a solution to the original issue can be found here thanks to #mdahlman
Just select text field and from its textfield properties choose "stretch with overflow" and it will change its height dynamically according to text .enter image description here