/** * Append a new segment with the given text and styleclasses * * @param text * the text * @param styleClass * the style classes * @see StyledStringSegment#StyledStringSegment(String, String...) */ public void appendSegment(String text, String... styleClass) { this.segmentList.add(new StyledStringSegment(text, styleClass)); }
private final StringBuffer buffer() { StringBuffer rv = this.buffer; if (rv == null) { rv = this.buffer = new StringBuffer(); for (StyledStringSegment s : this.segmentList) { rv.append(s.getText()); } } return rv; }
/** * Create a scenegraph node from the styled string * * @param s * the string * @return a scenegraph node */ public static Node toNode(StyledString s) { List<Text> segList = new ArrayList<>(); for (StyledStringSegment seg : s.getSegmentList()) { Text t = new Text(seg.getText()); t.getStyleClass().addAll(seg.getStyleClass()); segList.add(t); } return new TextFlow(segList.toArray(new Node[0])); }
/** * Create a scenegraph node from the styled string * * @param s * the string * @return a scenegraph node */ public static Node toNode(StyledString s) { List<Text> segList = new ArrayList<>(); for (StyledStringSegment seg : s.getSegmentList()) { Text t = new Text(seg.getText()); t.getStyleClass().addAll(seg.getStyleClass()); segList.add(t); } TextFlow textFlow = new TextFlow(segList.toArray(new Node[0])); textFlow.getStyleClass().add("styled-string"); //$NON-NLS-1$ return textFlow; }
/** * Append a new segment with the given text and styleclasses * * @param text * the text * @param styleClass * the style classes * @see StyledStringSegment#StyledStringSegment(String, String...) */ public void appendSegment(String text, String... styleClass) { this.segmentList.add(new StyledStringSegment(text, styleClass)); }
private final StringBuffer buffer() { StringBuffer rv = this.buffer; if (rv == null) { rv = this.buffer = new StringBuffer(); for (StyledStringSegment s : this.segmentList) { rv.append(s.getText()); } } return rv; }
/** * Append a new segment with the given text and styleclasses * * @param text * the text * @param styleClass * the style classes * @see StyledStringSegment#StyledStringSegment(String, List) */ public void appendSegment(String text, List<String> styleClass) { this.segmentList.add(new StyledStringSegment(text, styleClass)); } }
/** * Append a new segment with the given text and styleclasses * * @param text * the text * @param styleClass * the style classes * @see StyledStringSegment#StyledStringSegment(String, List) */ public void appendSegment(String text, List<String> styleClass) { this.segmentList.add(new StyledStringSegment(text, styleClass)); } }