public void paint(Graphics2D g) {
Border border = displayStyle.getBorder();
Rectangle b = (border != null)
? deflateRect((Rectangle) getBounds().clone(), border.getInsets()) : getBounds(); Graphics2D gcopy = (Graphics2D) g.create(); Shape save = gcopy.getClip();
gcopy.clip(b); String text = getText(); if ((text != null) && !text.equals("")) { TextLine[] lines = getWrappedLines(); if (lines.length > 1) {
int ay = getHorizentalAdvance(lines[lines.length - 1].y); for (int i = 0; i < lines.length; i++) {
TextLine line = lines[i];
gcopy.drawString(line.text, line.x + b.x, line.y + b.y + ay);
}
} else {
FontMetrics fm = gcopy.getFontMetrics(); Point base = TextView.layoutText(fm.stringWidth(text), fm,
displayStyle.getHorizontalAlignment(), displayStyle.getVerticalAlignment(),
b);
gcopy.drawString(text, base.x, base.y);
}
} gcopy.setClip(save); if (getBorder() != null) {
getBorder().paint(gcopy, getBounds());
} gcopy.dispose();
}
Border border = displayStyle.getBorder();
Rectangle b = (border != null)
? deflateRect((Rectangle) getBounds().clone(), border.getInsets()) : getBounds(); Graphics2D gcopy = (Graphics2D) g.create(); Shape save = gcopy.getClip();
gcopy.clip(b); String text = getText(); if ((text != null) && !text.equals("")) { TextLine[] lines = getWrappedLines(); if (lines.length > 1) {
int ay = getHorizentalAdvance(lines[lines.length - 1].y); for (int i = 0; i < lines.length; i++) {
TextLine line = lines[i];
gcopy.drawString(line.text, line.x + b.x, line.y + b.y + ay);
}
} else {
FontMetrics fm = gcopy.getFontMetrics(); Point base = TextView.layoutText(fm.stringWidth(text), fm,
displayStyle.getHorizontalAlignment(), displayStyle.getVerticalAlignment(),
b);
gcopy.drawString(text, base.x, base.y);
}
} gcopy.setClip(save); if (getBorder() != null) {
getBorder().paint(gcopy, getBounds());
} gcopy.dispose();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货