List of usage examples for java.awt.font TextAttribute FONT
TextAttribute FONT
To view the source code for java.awt.font TextAttribute FONT.
Click Source Link
From source file:Test.java
public NumericShaperPanel() { String text = "java"; HashMap map = new HashMap(); Font font = new Font("Mongolian Baiti", Font.PLAIN, 32); map.put(TextAttribute.FONT, font); map.put(TextAttribute.NUMERIC_SHAPING, NumericShaper.getShaper(NumericShaper.Range.MONGOLIAN)); FontRenderContext fontRenderContext = new FontRenderContext(null, false, false); layout = new TextLayout(text, map, fontRenderContext); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "\"www.java2s.com,\" www.java2s.com"; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font plainFont = new Font("Times New Roman", Font.PLAIN, 24); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, plainFont); as.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 18, 22); g2.drawString(as.getIterator(), 24, 70); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "\"www.java2s.com,\" www.java2s.com"; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font plainFont = new Font("Times New Roman", Font.PLAIN, 24); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, plainFont); as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 1, 11); g2.drawString(as.getIterator(), 24, 70); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "\"www.java2s.com,\" www.java2s.com"; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font plainFont = new Font("Times New Roman", Font.PLAIN, 24); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, plainFont); g2.drawString(as.getIterator(), 24, 70); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "www.java2s.com"; Dimension d = getSize();/* ww w . java 2s .co m*/ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font serifFont = new Font("Serif", Font.PLAIN, 48); Font sansSerifFont = new Font("Monospaced", Font.PLAIN, 48); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, serifFont); as.addAttribute(TextAttribute.FONT, sansSerifFont, 2, 5); as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 5); g2.drawString(as.getIterator(), 40, 80); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font serifFont = new Font("Serif", Font.PLAIN, 32); AttributedString as = new AttributedString("www.java2s.com"); as.addAttribute(TextAttribute.FONT, serifFont); Image image = createImage();//from w w w. j a va 2 s.com ImageGraphicAttribute imageAttribute = new ImageGraphicAttribute(image, GraphicAttribute.TOP_ALIGNMENT); as.addAttribute(TextAttribute.CHAR_REPLACEMENT, imageAttribute, 5, 6); g2.drawString(as.getIterator(), 20, 120); }
From source file:TextLayoutDemo.java
public void paint(Graphics g) { Graphics2D graphics2D = (Graphics2D) g; GraphicsEnvironment.getLocalGraphicsEnvironment(); Font font = new Font("LucidaSans", Font.PLAIN, 14); AttributedString messageAS = new AttributedString(textMessage); messageAS.addAttribute(TextAttribute.FONT, font); AttributedCharacterIterator messageIterator = messageAS.getIterator(); FontRenderContext messageFRC = graphics2D.getFontRenderContext(); LineBreakMeasurer messageLBM = new LineBreakMeasurer(messageIterator, messageFRC); Insets insets = getInsets();/*from www . j a va2s .c om*/ float wrappingWidth = getSize().width - insets.left - insets.right; float x = insets.left; float y = insets.top; while (messageLBM.getPosition() < messageIterator.getEndIndex()) { TextLayout textLayout = messageLBM.nextLayout(wrappingWidth); y += textLayout.getAscent(); textLayout.draw(graphics2D, x, y); y += textLayout.getDescent() + textLayout.getLeading(); x = insets.left; } }
From source file:ParagraphLayout.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "Java components and products Directory for Java components " + "and applications.Hundreds of Java components and applications " + "are organized by topic. You can find what you need easily. " + "You may also compare your product with others. If your component " + "is not listed, just send your url to java2s@java2s.com. " + "http://www.java2s.com"; Font font = new Font("Serif", Font.PLAIN, 24); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, font); AttributedCharacterIterator aci = as.getIterator(); FontRenderContext frc = g2.getFontRenderContext(); LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc); Insets insets = getInsets();/*from w w w .j a v a 2 s. co m*/ float wrappingWidth = getSize().width - insets.left - insets.right; float x = insets.left; float y = insets.top; while (lbm.getPosition() < aci.getEndIndex()) { TextLayout textLayout = lbm.nextLayout(wrappingWidth); y += textLayout.getAscent(); textLayout.draw(g2, x, y); y += textLayout.getDescent() + textLayout.getLeading(); x = insets.left; } }
From source file:LineBreakMeasurerDemo.java
public DisplayPanel() { setBackground(Color.white);//from w w w .j a va2s. c om setSize(350, 400); attribString = new AttributedString(text); attribString.addAttribute(TextAttribute.FOREGROUND, Color.blue, 0, text.length()); Font font = new Font("sanserif", Font.ITALIC, 20); attribString.addAttribute(TextAttribute.FONT, font, 0, text.length()); }
From source file:com.pureinfo.srm.common.ImageHelper.java
private static void draw(String _str, Graphics2D _g2, int _nX0, int _nY0, int _nX1, int _nY1) { Font font = new Font(getFontName(), Font.BOLD, getFontSize()); AttributedString str = new AttributedString(_str); str.addAttribute(TextAttribute.FONT, font); str.addAttribute(TextAttribute.FOREGROUND, getColor()); _g2.drawString(str.getIterator(), getNumber(_nX0, _nX1), (_nY0 + _nY1) * 2 / 3); }