|
Java Example Program / Sample Source Code
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.text.AttributedString;
public class LineBreakMeasurerExample {
public static void main(String[] args) {
Frame frame = new Frame("LineBreakMeasurerExample");
frame.setSize(400, 400);
frame.add(new CanvasToDisplay());
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
class CanvasToDisplay extends Component {
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
FontRenderContext fontRenderContext = g2d.getFontRenderContext();
Font plainFont = new Font("Times New Roman", Font.PLAIN, 24);
AttributedString attributedString = new AttributedString("JavaTips.net");
attributedString.addAttribute(TextAttribute.FONT, plainFont);
LineBreakMeasurer measurer = new LineBreakMeasurer(attributedString.getIterator(), fontRenderContext);
g2d.setColor(java.awt.Color.blue);
g2d.setFont(plainFont);
TextLayout layout = measurer.nextLayout(50);
layout.draw(g2d, 10, 60);
}
} |
|
|
GlyphVector
- How To Use GlyphVector
- getFont() In GlyphVector
- getFontRenderContext() In GlyphVector
- getGlyphCharIndex(int glyphIndex) In GlyphVector
- getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn) In GlyphVector
- getGlyphCode(int glyphIndex) In GlyphVector
- getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn) In GlyphVector
- getGlyphJustificationInfo(int glyphIndex) In GlyphVector
- getGlyphLogicalBounds(int glyphIndex) In GlyphVector
- getGlyphMetrics(int glyphIndex) In GlyphVector
- getGlyphOutline(int glyphIndex) In GlyphVector
- getGlyphOutline(int glyphIndex, float x, float y) In GlyphVector
- getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) In GlyphVector
- getGlyphPosition(int glyphIndex) In GlyphVector
- getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn) In GlyphVector
- getGlyphTransform(int glyphIndex) In GlyphVector
- getGlyphVisualBounds(int glyphIndex) In GlyphVector
- getLayoutFlags() In GlyphVector
- getLogicalBounds() In GlyphVector
- getNumGlyphs() In GlyphVector
- getOutline() In GlyphVector
- getOutline(float x, float y) In GlyphVector
- getPixelBounds(FontRenderContext renderFRC, float x, float y) In GlyphVector
- getVisualBounds() In GlyphVector
- performDefaultLayout() In GlyphVector
- setGlyphPosition(int glyphIndex, Point2D newPos) In GlyphVector
- setGlyphTransform(int glyphIndex, AffineTransform newTX) In GlyphVector
TextLayout
- How To Use TextLayout
- Getting The Shape From The Outline Of Text
- draw(Graphics2D g2, float x, float y) In TextLayout
- getAdvance() In TextLayout
- getAscent() In TextLayout
- getBaseline() In TextLayout
- getBaselineOffsets() In TextLayout
- getBlackBoxBounds(int firstEndpoint, int secondEndpoint) In TextLayout
- getBounds() In TextLayout
- getCaretInfo(TextHitInfo hit) In TextLayout
- getCaretInfo(TextHitInfo hit, Rectangle2D bounds) In TextLayout
- getCaretShape(TextHitInfo hit) In TextLayout
- getCaretShape(TextHitInfo hit, Rectangle2D bounds) In TextLayout
- getCaretShapes(int offset) In TextLayout
- getCaretShapes(int offset, Rectangle2D bounds) In TextLayout
- getCaretShapes(int offset, Rectangle2D bounds, TextLayout.CaretPolicy policy) In TextLayout
- getCharacterCount() In TextLayout
- getCharacterLevel(int index) In TextLayout
- getDescent() In TextLayout
- getJustifiedLayout(float justificationWidth) In TextLayout
- getLayoutPath() In TextLayout
- getLeading() In TextLayout
- getLogicalHighlightShape(int firstEndpoint, int secondEndpoint) In TextLayout
- getLogicalHighlightShape(int firstEndpoint, int secondEndpoint, Rectangle2D bounds) In TextLayout
- getLogicalRangesForVisualSelection(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint) In TextLayout
- getNextLeftHit(int offset) In TextLayout
- getNextLeftHit(int offset, TextLayout.CaretPolicy policy) In TextLayout
- getNextLeftHit(TextHitInfo hit) In TextLayout
- getNextRightHit(int offset) In TextLayout
- getNextRightHit(int offset, TextLayout.CaretPolicy policy) In TextLayout
- getNextRightHit(TextHitInfo hit) In TextLayout
- getOutline(AffineTransform tx) In TextLayout
- getPixelBounds(FontRenderContext frc, float x, float y) In TextLayout
- getVisibleAdvance() In TextLayout
- getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint) In TextLayout
- getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint, Rectangle2D bounds) In TextLayout
- getVisualOtherHit(TextHitInfo hit) In TextLayout
- handleJustify(float justificationWidth) In TextLayout
- hitTestChar(float x, float y) In TextLayout
- hitTestChar(float x, float y, Rectangle2D bounds) In TextLayout
- hitToPoint(TextHitInfo hit, Point2D point) In TextLayout
- isLeftToRight() In TextLayout
- isVertical() In TextLayout
|
|
|
|
|