List of utility methods to do Graphics Draw String
void | drawClippedString(Graphics g, String t, int x, int y, int width) _more_ g.drawString(clipString(g, t, width), x, y); |
void | drawEmphasizedString(Graphics g, Color foreground, Color emphasis, String s, int underlinedIndex, int x, int y) draw Emphasized String Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setColor(emphasis); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, s, underlinedIndex, x, y + 1); g2d.setColor(foreground); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, s, underlinedIndex, x, y); |
void | drawFitText(Graphics2D g2, int x, int y, int width, int height, String text) Draws text centered at the given position. FontMetrics metrics = g2.getFontMetrics(g2.getFont()); int hgt = metrics.getHeight(); int yOffset = hgt; if (width < 10) { width = 10; String remainingText = text; while (remainingText.length() > 0) { ... |
void | drawFormattedString(Graphics2D g2, String htmlStr, int x, int y, int w, int h) draw Formatted String g2.translate(x, y); htmlAssist.setFont(g2.getFont()); htmlAssist.setForeground(g2.getColor()); htmlAssist.setVerticalAlignment(JLabel.TOP); htmlAssist.setBounds(0, 0, w, h); htmlAssist.invalidate(); htmlAssist.setText(htmlStr); htmlAssist.paint(g2); ... |
void | drawGradient(Graphics g, JComponent c, String prefix) draw Gradient drawGradient(g, c.getWidth(), c.getHeight(), (Color) c.getClientProperty(prefix + ".gradientStart"), (Color) c.getClientProperty(prefix + ".gradientEnd")); |
void | drawGradientText(Graphics g, String text, int x, int y, Color c) draw Gradient Text g.setFont(new Font("Calibri", 13, Font.PLAIN)); Graphics2D g2 = (Graphics2D) g; Color color3 = new Color(51, 51, 51, 205); Font font1 = new Font("Arial", 0, 12); g.setFont(font1); FontMetrics FONTMETRICS = g.getFontMetrics(); Rectangle textBox = new Rectangle(x, y - g.getFont().getSize(), (int) FONTMETRICS.getStringBounds(text, g).getWidth() + 8, ... |
void | drawLine(String pLine, Graphics2D pG, int pX, int pY, int pWidth, String pJustification) Draw a line of text with justification FontMetrics lFontMetrics = pG.getFontMetrics(); if (pLine.trim().length() > 0) { if ("RIGHT".equals(pJustification.toUpperCase())) { pG.drawString(pLine.trim(), pX + pWidth - lFontMetrics.stringWidth(pLine.trim()), pY); } else if ("CENTRE".equals(pJustification.toUpperCase())) { pG.drawString(pLine.trim(), pX + (pWidth / 2) - (lFontMetrics.stringWidth(pLine.trim()) / 2), pY); } else { pG.drawString(pLine.trim(), pX, pY); ... |
void | drawLineDrawChar(Graphics g, int x, int y, int bi, char c, int charWidth, int charHeight) draw Line Draw Char int x2 = (x + (charWidth / 2)); int y2 = (y + (charHeight / 2)); int xx = (x + charWidth); int yy = (y + charHeight); switch (c) { case ' ': case '_': break; ... |
void | drawMessage(Graphics2D g, String message) draw Message final int gap = 5; Rectangle2D textArea = g.getFont().getStringBounds(message, g.getFontRenderContext()); int x = gap - (int) textArea.getMinX(); int y = gap - (int) textArea.getMinY(); StringTokenizer messageTokenizer = new StringTokenizer(message, "\n"); while (messageTokenizer.hasMoreTokens()) { String currentLine = messageTokenizer.nextToken(); drawOutlinedString(g, currentLine, x, y, 0); ... |
void | drawRightJustifiedText(String text, int right, int y, Graphics g) Draw a block of text right justified to the given location FontMetrics fontMetrics = g.getFontMetrics(); Rectangle2D textBounds = fontMetrics.getStringBounds(text, g); int x = right - (int) textBounds.getWidth(); g.drawString(text, x, y); |