Java Code Examples for java.text.AttributedString#addAttributes()
The following examples show how to use
java.text.AttributedString#addAttributes() .
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: LogAxis.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 2
Source File: LogAxis.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 3
Source File: LogAxis.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 4
Source File: LogAxis.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 5
Source File: LogAxis.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 6
Source File: AttributedStringSerializer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Reads the object from the object input stream. * * @param stream the object input stream from where to read the serialized data. * @return the generated object. * @throws IOException if reading the stream failed. * @throws ClassNotFoundException if serialized object class cannot be found. */ public Object readObject( final ObjectInputStream stream ) throws IOException, ClassNotFoundException { // read string and attributes then create result final String plainStr = (String) stream.readObject(); final AttributedString result = new AttributedString( plainStr ); char c = stream.readChar(); int start = 0; while ( c != CharacterIterator.DONE ) { final int limit = stream.readInt(); final Map<AttributedCharacterIterator.Attribute, Object> atts = (Map<AttributedCharacterIterator.Attribute, Object>) stream.readObject(); result.addAttributes( atts, start, limit ); start = limit; c = stream.readChar(); } return result; }
Example 7
Source File: LogAxis.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Creates a tick label for the specified value based on the current * tick unit (used for formatting the exponent). * * @param value the value. * * @return The label. * * @since 1.0.18 */ protected AttributedString createTickLabel(double value) { if (this.numberFormatOverride != null) { return new AttributedString( this.numberFormatOverride.format(value)); } else { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } double logy = calculateLog(value); String exponentStr = getTickUnit().valueToString(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; } }
Example 8
Source File: LogAxis3D.java From orson-charts with GNU General Public License v3.0 | 5 votes |
private AttributedString createTickLabelAttributedString(double logy, Format exponentFormatter) { String baseStr = this.baseSymbol; if (baseStr == null) { baseStr = this.baseFormatter.format(this.base); } String exponentStr = exponentFormatter.format(logy); AttributedString as = new AttributedString(baseStr + exponentStr); as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + exponentStr).length()); as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), baseStr.length() + exponentStr.length()); return as; }
Example 9
Source File: RichTextSpec.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private AttributedString createText() { AttributedString str = new AttributedString( text ); str.addAttribute( TextAttribute.RUN_DIRECTION, TextDirection.RTL.equals( runDirection ) ); int startPosition = 0; for ( final StyledChunk chunk : styleChunks ) { int length = chunk.getText().length(); int endIndex = startPosition + length; str.addAttributes( chunk.getAttributes(), startPosition, endIndex ); startPosition = endIndex; } return str; }
Example 10
Source File: ByteCodeDisplay.java From ApkToolPlus with Apache License 2.0 | 5 votes |
private void newLine() { String text = getCurrentLineText(); AttributedString attrString = new AttributedString(text, STYLE_BASE); Iterator it = currentLineCache.iterator(); int startCharIndex = 0; while (it.hasNext()) { LineCacheEntry entry = (LineCacheEntry)it.next(); int endCharIndex = startCharIndex + entry.text.length(); attrString.addAttributes(entry.attributes, startCharIndex, endCharIndex); startCharIndex = endCharIndex; } lines.add(attrString); textLines.add(text); if (lineHeight == 0) { TextLayout textLayout = new TextLayout(attrString.getIterator(), frc); lineHeight = (int)(textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); ascent = (int)textLayout.getAscent(); textLayout = new TextLayout("0", STYLE_BASE, frc); characterWidth = (int)textLayout.getAdvance(); } currentHeight += lineHeight; currentWidth = Math.max(currentWidth, characterWidth * text.length()); currentLineCache.clear(); }
Example 11
Source File: Axis.java From ECG-Viewer with GNU General Public License v2.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 12
Source File: Axis.java From SIMVA-SoS with Apache License 2.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 13
Source File: Axis.java From buffer_bci with GNU General Public License v3.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 14
Source File: Axis.java From buffer_bci with GNU General Public License v3.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 15
Source File: Axis.java From ccu-historian with GNU General Public License v3.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 16
Source File: Axis.java From openstock with GNU General Public License v3.0 | 3 votes |
/** * Creates and returns an <code>AttributedString</code> with the specified * text and the labelFont and labelPaint applied as attributes. * * @param label the label ({@code null} permitted). * * @return An attributed string or {@code null}. * * @since 1.0.16 */ public AttributedString createAttributedLabel(String label) { if (label == null) { return null; } AttributedString s = new AttributedString(label); s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); return s; }
Example 17
Source File: AttributedStringBuilder.java From stendhal with GNU General Public License v2.0 | 2 votes |
/** * Apply the attributes to the appropriate range of an AttributedString. * * @param str string to be annotated with the attributes */ void apply(AttributedString str) { str.addAttributes(attrs.contents(), beginIndex, endIndex); }