Java Code Examples for org.apache.commons.lang3.text.WordUtils#wrap()
The following examples show how to use
org.apache.commons.lang3.text.WordUtils#wrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WordWrapFilter.java From jinjava with Apache License 2.0 | 6 votes |
@Override public Object filter(Object var, JinjavaInterpreter interpreter, String... args) { String str = Objects.toString(var, ""); int wrapLength = 79; if (args.length > 0) { wrapLength = NumberUtils.toInt(args[0], 79); } boolean wrapLongWords = true; if (args.length > 1) { wrapLongWords = BooleanUtils.toBoolean(args[1]); } return WordUtils.wrap(str, wrapLength, "\n", wrapLongWords); }
Example 2
Source File: YouScreen.java From xibalba with MIT License | 6 votes |
private void updateDefectsGroup() { defectsGroup.clear(); defectsGroup.addActor(new Label("Defects", Main.skin)); defectsGroup.addActor(new Label("", Main.skin)); Label instructions = new Label( WordUtils.wrap( "[DARK_GRAY]Taking a major defect gives you 2 points, taking a minor gives you 1", 70 ), Main.skin ); defectsGroup.addActor(instructions); defectsGroup.addActor(new Label("", Main.skin)); for (int i = 0; i < this.defects.size(); i++) { DefectData defectData = this.defects.get(i); defectsGroup.addActor( new Label(createDefectText(i, defectData), Main.skin) ); } }
Example 3
Source File: CommentRenderer.java From textuml with Eclipse Public License 1.0 | 5 votes |
private String generateCommentText(Comment element) { String body = element.getBody().trim().replaceAll("[\\n\\p{Space}]+", " "); int periodIndex = body.indexOf("."); int end = periodIndex == -1 ? body.length() : periodIndex; String wrapped = WordUtils.wrap(StringUtils.abbreviate(body.substring(0, end), 200), 30); return StringUtils.trimToNull(wrapped.replaceAll("\n", "\\\\n")); }
Example 4
Source File: AdamicAdar.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Adamic-Adar measures the similarity between vertex neighborhoods and is " + "computed as the sum of the inverse logarithm of centerpoint degree over shared " + "neighbors.") .appendNewLine() .append("The algorithm result contains two vertex IDs and the similarity score.") .toString(), 80); }
Example 5
Source File: HITS.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Hyperlink-Induced Topic Search computes two interdependent scores for " + "each vertex in a directed graph. A good \"hub\" links to good \"authorities\" " + "and good \"authorities\" are linked to from good \"hubs\".") .appendNewLine() .append("The result contains the vertex ID, hub score, and authority score.") .toString(), 80); }
Example 6
Source File: TriangleListing.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("List all triangles graph.") .appendNewLine() .append("The algorithm result contains three vertex IDs. For the directed algorithm " + "the result contains an additional bitmask indicating the presence of the six " + "potential connecting edges.") .toString(), 80); }
Example 7
Source File: ShellFunctions.java From metron with Apache License 2.0 | 5 votes |
private static String toWrappedString(Object o, int wrap) { String s = "" + o; if(wrap <= 0) { return s; } return WordUtils.wrap(s, wrap); }
Example 8
Source File: GodScreen.java From xibalba with MIT License | 5 votes |
private String createAbilityText(Ability ability) { String desc = WordUtils.wrap(ability.description, 70); if (ability.type == Ability.Type.PASSIVE) { return ability.name + "[LIGHT_GRAY] Passive\n[DARK_GRAY]" + desc; } else { return ability.name + "[LIGHT_GRAY] Usable every " + ability.recharge + " turns\n" + "[DARK_GRAY]" + desc; } }
Example 9
Source File: YouScreen.java From xibalba with MIT License | 5 votes |
private String createTraitText(int index, TraitData traitData) { String selected = playerSetup.traits.contains(traitData.name, false) ? "[WHITE]x " : ""; String type = traitData.cost == 1 ? "Minor" : "Major"; String desc = WordUtils.wrap(traitData.description, 70); boolean hasConflictingDefect = false; for (int i = 0; i < playerSetup.defects.size; i++) { String defect = playerSetup.defects.get(i); if (traitData.cantHave != null && traitData.cantHave.contains(defect)) { hasConflictingDefect = true; } } if (hasConflictingDefect) { if (sectionSelected == Section.TRAITS && index == itemSelected) { return selected + "[DARK_GRAY]> " + type + " " + traitData.name + "\n" + desc; } else { return selected + "[DARK_GRAY]" + type + " " + traitData.name + "\n" + desc; } } else if (sectionSelected == Section.TRAITS && index == itemSelected) { return selected + "[DARK_GRAY]> [WHITE]" + type + " [WHITE]" + traitData.name + "\n[DARK_GRAY]" + desc; } else { return selected + "[WHITE]" + type + " [LIGHT_GRAY]" + traitData.name + "\n[DARK_GRAY]" + desc; } }
Example 10
Source File: YouScreen.java From xibalba with MIT License | 5 votes |
private String createDefectText(int index, DefectData defectData) { String selected = playerSetup.defects.contains(defectData.name, false) ? "[WHITE]x " : ""; String type = defectData.reward == 1 ? "Minor" : "Major"; String desc = WordUtils.wrap(defectData.description, 70); boolean hasConflictingTrait = false; for (int i = 0; i < playerSetup.traits.size; i++) { String trait = playerSetup.traits.get(i); if (defectData.cantHave != null && defectData.cantHave.contains(trait)) { hasConflictingTrait = true; } } if (hasConflictingTrait) { if (sectionSelected == Section.TRAITS && index == itemSelected) { return selected + "[DARK_GRAY]> " + type + " " + defectData.name + "\n" + desc; } else { return selected + "[DARK_GRAY]" + type + " " + defectData.name + "\n" + desc; } } else if (sectionSelected == Section.DEFECTS && index == itemSelected) { return selected + "[DARK_GRAY]> [WHITE]" + type + " [WHITE]" + defectData.name + "\n[DARK_GRAY]" + desc; } else { return selected + "[WHITE]" + type + " [LIGHT_GRAY]" + defectData.name + "\n[DARK_GRAY]" + desc; } }
Example 11
Source File: ClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("The local clustering coefficient measures the connectedness of each " + "vertex's neighborhood. The global clustering coefficient measures the " + "connected of the graph. The average clustering coefficient is the mean local " + "clustering coefficient. Each score ranges from 0.0 (no edges between vertex " + "neighbors) to 1.0 (neighborhood or graph is a clique).") .appendNewLine() .append("The algorithm result contains the vertex ID, degree, and number of edges " + "connecting neighbors.") .toString(), 80); }
Example 12
Source File: AdamicAdar.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Adamic-Adar measures the similarity between vertex neighborhoods and is " + "computed as the sum of the inverse logarithm of centerpoint degree over shared " + "neighbors.") .appendNewLine() .append("The algorithm result contains two vertex IDs and the similarity score.") .toString(), 80); }
Example 13
Source File: Attributes.java From toolbox with Apache License 2.0 | 5 votes |
@Override public String toString(){ final int FIXED_WIDTH = 80; String s = ""; Iterator<Attribute> it = this.iterator(); if (it.hasNext()) { s += it.next().getName(); } while (it.hasNext()) { s += ", " + it.next().getName(); } return(WordUtils.wrap(s+"\n",FIXED_WIDTH)); }
Example 14
Source File: TriangleListing.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("List all triangles graph.") .appendNewLine() .append("The algorithm result contains three vertex IDs. For the directed algorithm " + "the result contains an additional bitmask indicating the presence of the six " + "potential connecting edges.") .toString(), 80); }
Example 15
Source File: JaccardIndex.java From flink with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Jaccard Index measures the similarity between vertex neighborhoods and " + "is computed as the number of shared neighbors divided by the number of " + "distinct neighbors. Scores range from 0.0 (no shared neighbors) to 1.0 (all " + "neighbors are shared).") .appendNewLine() .append("The result contains two vertex IDs, the number of shared neighbors, and " + "the number of distinct neighbors.") .toString(), 80); }
Example 16
Source File: ClusteringCoefficient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("The local clustering coefficient measures the connectedness of each " + "vertex's neighborhood. The global clustering coefficient measures the " + "connected of the graph. The average clustering coefficient is the mean local " + "clustering coefficient. Each score ranges from 0.0 (no edges between vertex " + "neighbors) to 1.0 (neighborhood or graph is a clique).") .appendNewLine() .append("The algorithm result contains the vertex ID, degree, and number of edges " + "connecting neighbors.") .toString(), 80); }
Example 17
Source File: AdamicAdar.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Adamic-Adar measures the similarity between vertex neighborhoods and is " + "computed as the sum of the inverse logarithm of centerpoint degree over shared " + "neighbors.") .appendNewLine() .append("The algorithm result contains two vertex IDs and the similarity score.") .toString(), 80); }
Example 18
Source File: HITS.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Hyperlink-Induced Topic Search computes two interdependent scores for " + "each vertex in a directed graph. A good \"hub\" links to good \"authorities\" " + "and good \"authorities\" are linked to from good \"hubs\".") .appendNewLine() .append("The result contains the vertex ID, hub score, and authority score.") .toString(), 80); }
Example 19
Source File: TriangleListing.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("List all triangles graph.") .appendNewLine() .append("The algorithm result contains three vertex IDs. For the directed algorithm " + "the result contains an additional bitmask indicating the presence of the six " + "potential connecting edges.") .toString(), 80); }
Example 20
Source File: CliClient.java From chipster with MIT License | 4 votes |
private void wrapAndPrint(String text) { String wrapped = WordUtils.wrap(text, 60); wrapped = " " + wrapped.replace("\n", "\n "); System.out.println(wrapped); }