I'm trying to create an output table which has several lines per row for one cell. However, when I create a StringCell with these lines separated by a linefeed (or other control characters) they appear to be stripped out. This contrasts with PDB and SDF cell types when linefeeds are retained. (The same string can be used to set a warning message with the linefeeds retained). Any suggestions?
Hi THINK,
our StringCell implementation comes along with only an ordinary (JLabel) string representation, which strips special characters. PDB and SDF cells have a special renderer associated with them (org.knime.core.data.renderer.MultiLineStringValueRenderer), which retains the line breaks (and uses a fixed font).
We thought of adding this multi-line renderer also to StringCells but finally decided against it as in almost all cases the content is really only a small label. (And if not, they typically mean something special, such as SDF or PDB "strings".)
The same string can be used to set a warning message with the linefeeds retained
I didn't get that one. Does it mean that you add warning and error messages to individual rows? If so (and you really don't care about the string content itself except for displaying in a table), you could put the string into an html body, for instance "This warning message is automatically wrapped.", in which case it will contain line breaks (and also display them). Please note, that this string is not suitable for further processing (I'm not sure what happens if you write it to a csv file...???).
Hope it helps,
Bernd
Thanks for the prompt response.
I had jumped to the conclusion that I was doing something wrong rather than the render removing linefeeds! Hence my use of setWarningMessage to confirm that the linefeeds were in the string!
I hadn't realised that the String renderer was a HTML renderer which solves my immediate problem and which gives alot more scope ... is there a documented list of which HTML tags are permitted?
Thanks
Keith
I'm not sure whether we should advertise this html-feature much but since you've asked... it does use swing components after all, which means that the html functionality is limited to what swing allows you (see for instance here: http://java.sun.com/docs/books/tutorial/uiswing/components/html.html)
Please be aware that KNIME treats the entire html source as a single string. You may get undesired behavior if you feed the strings to a row filter (and then filter on them), use a csv file writer, do cell splitting, use it in a java snippet node, etc.
Regards
Bernd
I think this topic is ralated to what I need, but I don't really know how to implement it...
For practical reasons, I would indeed like to put several lines of text in a single row, in order to create some short summaries.
Here is my current situation.
I am currently creating reports about the biological activity of chemical compounds. As it is now, my reports have the following form.
RowID Structure Target & Activity
1 Compound1 Target1 xxxnM
2 Compound1 Target2 xxxnM
3 Compound1 Target3 xxxnM
4 Compound1 Target4 xxxnM
5 Compound2 Target1 xxxnM
.....
This means that a depiction of a structure is reapeated multiple times (one for each activity). This is not practical when making reports: I need to depict relatively complex structures (typically no more than 5 -6 pictures per page)... Once you start testing a compound on multiple targets , the same structure can be repeated over and over again, across multiple pages, with almost nothing written in the neighboring cells. The would be ample space for a short summary in the activity cells.
RowID | Structure | Target & Activity
1 | Compound1 | Target1 xxxnM
| | Target2 xxxnM
| | Target3 xxxnM
| | Target4 xxxnM
2 | Compound2 | Target1 xxxnM
| | Target2 xxxnM
I could of course use a concatenate option while using a "group by" node, but again, it's far from clear... Having the possibility of a multi-line cell when using "group by" would be way better.
Any option for this? Either in the node or by editing the contents of the cell after group_by would be fine. There is a discussion in this topic about using html codes, but I don't really know how to implement this. Can anyone provide me with a worked-out example?
Thanks in advance!
Hi Sandro,
I think using the Group-By node is the best way to go by creating a list of cells. As a next step, I would apply the Java Snippet node generating some kind of single html-formatted StringCell:
Double[] values = $column$; StringBuilder ret = new StringBuilder(); for (int i = 0; i < values.length; i++) { ret.append("<p>" + values[i] + "</p>"); } return "<html><body>" + ret.toString() + "</html></body>";Regards, Thomas