/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). */ public TextLine(final String text, final Font font) { this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font); this.fragments.add(fragment); }
/** * Calculate the offsets required to translate from the specified anchor * position to the left baseline position. * * @param g2 the graphics device. * @param anchor the anchor position. * * @return The offsets. */ private float calculateBaselineOffset(final Graphics2D g2, final TextAnchor anchor) { float result = 0.0f; Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { TextFragment fragment = (TextFragment) iterator.next(); result = Math.max(result, fragment.calculateBaselineOffset(g2, anchor)); } return result; }
final TextLine lastLine = result.getLastLine(); final TextFragment lastFragment = lastLine.getLastTextFragment(); final String oldStr = lastFragment.getText(); String newStr = "..."; if (oldStr.length() > 3) { final TextFragment newFragment = new TextFragment(newStr, lastFragment.getFont(), lastFragment.getPaint()); lastLine.addFragment(newFragment);
while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D d = fragment.calculateDimensions(g2); fragment.draw( g2, x, anchorY + yOffset, TextAnchor.BASELINE_LEFT, rotateX, rotateY, angle
/** * Calculates the width and height of the text line. * * @param g2 the graphics device. * * @return The width and height. */ public Size2D calculateDimensions(final Graphics2D g2) { double width = 0.0; double height = 0.0; final Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D dimension = fragment.calculateDimensions(g2); width = width + dimension.getWidth(); height = Math.max(height, dimension.getHeight()); } return new Size2D(width, height); }
TextLine lastLine = result.getLastLine(); TextFragment lastFragment = lastLine.getLastTextFragment(); String oldStr = lastFragment.getText(); String newStr = "..."; if (oldStr.length() > 3) { TextFragment newFragment = new TextFragment(newStr, lastFragment.getFont(), lastFragment.getPaint()); lastLine.addFragment(newFragment);
while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D d = fragment.calculateDimensions(g2); fragment.draw( g2, x, anchorY + yOffset, TextAnchor.BASELINE_LEFT, rotateX, rotateY, angle
/** * Calculates the width and height of the text line. * * @param g2 the graphics device. * * @return The width and height. */ public Size2D calculateDimensions(final Graphics2D g2) { double width = 0.0; double height = 0.0; final Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D dimension = fragment.calculateDimensions(g2); width = width + dimension.getWidth(); height = Math.max(height, dimension.getHeight()); } return new Size2D(width, height); }
final TextLine lastLine = result.getLastLine(); final TextFragment lastFragment = lastLine.getLastTextFragment(); final String oldStr = lastFragment.getText(); String newStr = "..."; if (oldStr.length() > 3) { final TextFragment newFragment = new TextFragment(newStr, lastFragment.getFont(), lastFragment.getPaint()); lastLine.addFragment(newFragment);
/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). */ public TextLine(final String text, final Font font) { this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font); this.fragments.add(fragment); }
while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D d = fragment.calculateDimensions(g2); fragment.draw(g2, x, anchorY + yOffset, TextAnchor.BASELINE_LEFT, rotateX, rotateY, angle); x = x + (float) d.getWidth();
/** * Calculates the width and height of the text line. * * @param g2 the graphics device. * * @return The width and height. */ public Size2D calculateDimensions(final Graphics2D g2) { double width = 0.0; double height = 0.0; final Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D dimension = fragment.calculateDimensions(g2); width = width + dimension.getWidth(); height = Math.max(height, dimension.getHeight()); } return new Size2D(width, height); }
/** * Calculate the offsets required to translate from the specified anchor * position to the left baseline position. * * @param g2 the graphics device. * @param anchor the anchor position. * * @return The offsets. */ private float calculateBaselineOffset(final Graphics2D g2, final TextAnchor anchor) { float result = 0.0f; Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { TextFragment fragment = (TextFragment) iterator.next(); result = Math.max(result, fragment.calculateBaselineOffset(g2, anchor)); } return result; }
/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). */ public TextLine(final String text, final Font font) { this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font); this.fragments.add(fragment); }
/** * Calculate the offsets required to translate from the specified anchor * position to the left baseline position. * * @param g2 the graphics device. * @param anchor the anchor position. * * @return The offsets. */ private float calculateBaselineOffset(final Graphics2D g2, final TextAnchor anchor) { float result = 0.0f; Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { TextFragment fragment = (TextFragment) iterator.next(); result = Math.max(result, fragment.calculateBaselineOffset(g2, anchor)); } return result; }
/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). * @param paint the text color (<code>null</code> not permitted). */ public TextLine(final String text, final Font font, final Paint paint) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font, paint); this.fragments.add(fragment); }
/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). * @param paint the text color (<code>null</code> not permitted). */ public TextLine(final String text, final Font font, final Paint paint) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font, paint); this.fragments.add(fragment); }
/** * Creates a new text line. * * @param text the text (<code>null</code> not permitted). * @param font the text font (<code>null</code> not permitted). * @param paint the text color (<code>null</code> not permitted). */ public TextLine(final String text, final Font font, final Paint paint) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fragments = new java.util.ArrayList(); final TextFragment fragment = new TextFragment(text, font, paint); this.fragments.add(fragment); }
TextLine line = label.getLastLine(); if (line != null) { line.addFragment(new TextFragment(" " + s, this.sublabelFont, this.sublabelPaint));