下面列出了java.awt.Graphics2D#setBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private BufferedImage expandImage(BufferedImage image, int newWidth, int newHeight, Color frameColor) {
newWidth = Math.max(image.getWidth(), newWidth);
newHeight = Math.max(image.getHeight(), newHeight);
int paddingX = (newWidth - image.getWidth()) / 2;
int paddingY = (newHeight - image.getHeight()) / 2;
if (paddingX == 0 && paddingY == 0) {
return image;
}
BufferedImage newImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = newImage.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.setBackground(frameColor);
graphics.clearRect(0, 0, newWidth, newHeight);
graphics.drawImage(image, paddingX, paddingY, null);
graphics.dispose();
return newImage;
}
public static void main(String[] argv) throws Exception {
BufferedImage im = getWhiteImage(30, 30);
Graphics2D g2 = (Graphics2D)im.getGraphics();
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
g2.setBackground(Color.white);
g2.setColor(Color.black);
Path2D p = getPath(0, 0, 20);
g2.draw(p);
if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
throw new Exception("This pixel should be black");
}
}
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
final int x1, final int y1, final int x2, final int y2,
final BufferCapabilities.FlipContents flipAction) {
final Graphics g = peer.getGraphics();
try {
g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
g.dispose();
}
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
try {
bg.setBackground(peer.getBackground());
bg.clearRect(0, 0, backBuffer.getWidth(null),
backBuffer.getHeight(null));
} finally {
bg.dispose();
}
}
}
public static void main(String[] argv) throws Exception {
BufferedImage im = getWhiteImage(30, 30);
Graphics2D g2 = (Graphics2D)im.getGraphics();
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
g2.setBackground(Color.white);
g2.setColor(Color.black);
Path2D p = getPath(0, 0, 20);
g2.draw(p);
if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
throw new Exception("This pixel should be black");
}
}
public static void main(String[] argv) throws Exception {
BufferedImage im = getWhiteImage(30, 30);
Graphics2D g2 = (Graphics2D)im.getGraphics();
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
g2.setBackground(Color.white);
g2.setColor(Color.black);
Path2D p = getPath(0, 0, 20);
g2.draw(p);
if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
throw new Exception("This pixel should be black");
}
}
private BufferedImage buildImage ()
{
BufferedImage img = (BufferedImage) drawing.createImage(
width.getValue(),
height.getValue());
Graphics2D g2 = img.createGraphics();
g2.setBackground(Color.white);
g2.setColor(Color.white);
g2.fillRect(0, 0, width.getValue(), height.getValue());
g2.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(Color.black);
g2.setFont(musicFont);
g2.drawString(string, xOffset.getValue(), yOffset.getValue());
FontRenderContext frc = g2.getFontRenderContext();
TextLayout layout = new TextLayout(string, musicFont, frc);
Rectangle2D rect = layout.getBounds();
xSym.setValue(rect.getX());
ySym.setValue(rect.getY());
wSym.setValue(rect.getWidth());
hSym.setValue(rect.getHeight());
return img;
}
public static BufferedImage rotateImage(BufferedImage image, double radians) {
BufferedImage rotatedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = rotatedImage.createGraphics();
g2d.rotate(radians);
g2d.setBackground(Color.WHITE);
int maxOfWidthHieght = Math.max(image.getWidth(null), image.getHeight(null));
g2d.clearRect(-5*maxOfWidthHieght, -5*maxOfWidthHieght, 10*maxOfWidthHieght, 10*maxOfWidthHieght);
g2d.drawImage(image, 0, 0, Color.WHITE, null);
g2d.dispose();
return rotatedImage;
}
private String drawImg(ByteArrayOutputStream output){
//final int verifyCodeLength = 10;
final int verifyCodeLength = 4;
String code = getVerifyCode(verifyCodeLength);
//int width = 125;
int width = 70;
int height = 25;
BufferedImage bi = new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
Font font = new Font("Times New Roman",Font.PLAIN,20);
Graphics2D g = bi.createGraphics();
g.setFont(font);
g.setColor(new Color(66,2,82));
g.setBackground(new Color(226,226,240));
g.clearRect(0, 0, width, height);
FontRenderContext context = g.getFontRenderContext();
Rectangle2D bounds = font.getStringBounds(code, context);
double x = (width - bounds.getWidth()) / 2;
double y = (height - bounds.getHeight()) / 2;
double ascent = bounds.getY();
double baseY = y - ascent;
g.drawString(code, (int)x, (int)baseY);
g.dispose();
try {
ImageIO.write(bi, "jpg", output);
} catch (IOException e) {
//do nothing
}
return code;
}
@Override
public Graphics getGraphics() {
if (bbImage == null) return null;
Graphics2D g = bbImage.createGraphics();
g.setBackground(getBackground());
g.setColor(getForeground());
g.setFont(getFont());
g.scale(scaleFactor, scaleFactor);
return g;
}
public BufferedImage createImage() {
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g = (Graphics2D) image.getGraphics();
g.setBackground(Color.white);
g.clearRect(0, 0, width, height);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.75f));
if (tree.root().isPresent()) {
final List<RectangleDepth> nodeDepths = getNodeDepthsSortedByDepth(tree.root().get());
drawNode(g, nodeDepths);
}
return image;
}
@Override
public Graphics getGraphics() {
if (bbImage == null) return null;
Graphics2D g = bbImage.createGraphics();
g.setBackground(getBackground());
g.setColor(getForeground());
g.setFont(getFont());
g.scale(scaleFactor, scaleFactor);
return g;
}
@Override
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform at,
RenderingHints hints) {
// Fill bufferedImage using
final Graphics2D g2d = (Graphics2D) getImage().getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setBackground(Color.PINK);
g2d.clearRect(0, 0, size, size);
g2d.setColor(Color.BLUE);
g2d.drawRect(0, 0, size, size);
g2d.fillOval(size / 10, size / 10,
size * 8 / 10, size * 8 / 10);
} finally {
g2d.dispose();
}
return super.createContext(cm, deviceBounds, userBounds, at, hints);
}
@Override
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform at,
RenderingHints hints) {
// Fill bufferedImage using
final Graphics2D g2d = (Graphics2D) getImage().getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setBackground(Color.PINK);
g2d.clearRect(0, 0, size, size);
g2d.setColor(Color.BLUE);
g2d.drawRect(0, 0, size, size);
g2d.fillOval(size / 10, size / 10,
size * 8 / 10, size * 8 / 10);
} finally {
g2d.dispose();
}
return super.createContext(cm, deviceBounds, userBounds, at, hints);
}
/** Draw visual feedback (rubber band rectangle etc.)
* for current mouse mode
* @param gc GC
*/
@Override
protected void drawMouseModeFeedback(final Graphics2D gc)
{ // Safe copy, then check null (== isPresent())
final Point2D current = mouse_current.orElse(null);
if (current == null)
return;
// Compute values at cursor
final int x = (int) current.getX();
final XTYPE location = x_axis.getValue(x);
List<CursorMarker> markers;
try
{
markers = CursorMarker.compute(this, x, location);
fireCursorsChanged();
}
catch (Exception ex)
{
logger.log(Level.WARNING, "Cannot compute cursor markers", ex);
markers = Collections.emptyList();
}
final Point2D start = mouse_start.orElse(null);
final Rectangle plot_bounds = plot_area.getBounds();
if (mouse_mode == MouseMode.PAN_X || mouse_mode == MouseMode.PAN_Y || mouse_mode == MouseMode.PAN_PLOT ||
(mouse_annotation != null && start != null))
{
// NOP, minimize additional UI thread drawing to allow better 'pan' updates
// and also hide the crosshair when moving an annotation
}
else if (show_crosshair && plot_bounds.contains(current.getX(), current.getY()))
{ // Cross-hair Cursor
gc.setStroke(MOUSE_FEEDBACK_BACK);
gc.setColor(background);
gc.drawLine(plot_bounds.x, (int)current.getY(), plot_bounds.x + plot_bounds.width, (int)current.getY());
gc.drawLine((int)current.getX(), plot_bounds.y, (int)current.getX(), plot_bounds.y + plot_bounds.height);
gc.setStroke(MOUSE_FEEDBACK_FRONT);
gc.setColor(GraphicsUtils.convert(foreground));
gc.drawLine(plot_bounds.x, (int)current.getY(), plot_bounds.x + plot_bounds.width, (int)current.getY());
gc.drawLine((int)current.getX(), plot_bounds.y, (int)current.getX(), plot_bounds.y + plot_bounds.height);
// Corresponding axis ticks
gc.setBackground(background);
x_axis.drawTickLabel(gc, x_axis.getValue((int)current.getX()));
for (YAxisImpl<XTYPE> axis : y_axes)
axis.drawTickLabel(gc, axis.getValue((int)current.getY()));
// Trace markers
CursorMarker.drawMarkers(gc, markers, area);
}
if (mouse_mode == MouseMode.ZOOM_IN_X && start != null)
drawZoomXMouseFeedback(gc, plot_bounds, start, current);
else if (mouse_mode == MouseMode.ZOOM_IN_Y && start != null)
drawZoomYMouseFeedback(gc, plot_bounds, start, current);
else if (mouse_mode == MouseMode.ZOOM_IN_PLOT && start != null)
drawZoomMouseFeedback(gc, plot_bounds, start, current);
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
// FontMetrics fM = pickFont(g2, tree, space);
double width = width(tree, myFont);
double height = height(tree, myFont);
preferredX = (int) width;
preferredY = (int) height;
setSize(new Dimension(preferredX, preferredY));
setPreferredSize(new Dimension(preferredX, preferredY));
setMaximumSize(new Dimension(preferredX, preferredY));
setMinimumSize(new Dimension(preferredX, preferredY));
// setSize(new Dimension((int)Math.round(width),
// (int)Math.round(height)));
g2.setFont(myFont.getFont());
Dimension space = getSize();
double startX = 0.0;
double startY = 0.0;
if (HORIZONTAL_ALIGN == SwingConstants.CENTER) {
startX = (space.getWidth() - width) / 2.0;
}
if (HORIZONTAL_ALIGN == SwingConstants.RIGHT) {
startX = space.getWidth() - width;
}
if (VERTICAL_ALIGN == SwingConstants.CENTER) {
startY = (space.getHeight() - height) / 2.0;
}
if (VERTICAL_ALIGN == SwingConstants.BOTTOM) {
startY = space.getHeight() - height;
}
super.paintComponent(g);
g2.setBackground(Color.white);
g2.clearRect(0, 0, space.width, space.height);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
1.0f));
g2.setPaint(Color.black);
paintTree(tree, new Point2D.Double(startX, startY), g2, myFont);
}
public static void main(String argv[]) {
Locale.setDefault(Locale.US);
// initialize j.u.l Looger:
final Logger log = Logger.getLogger("sun.java2d.marlin");
log.addHandler(new Handler() {
@Override
public void publish(LogRecord record) {
Throwable th = record.getThrown();
// detect any Throwable:
if (th != null) {
System.out.println("Test failed:\n" + record.getMessage());
th.printStackTrace(System.out);
throw new RuntimeException("Test failed: ", th);
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
// enable Marlin logging & internal checks:
System.setProperty("sun.java2d.renderer.log", "true");
System.setProperty("sun.java2d.renderer.useLogger", "true");
System.setProperty("sun.java2d.renderer.doChecks", "true");
final int width = 400;
final int height = 400;
final BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = (Graphics2D) image.getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setBackground(Color.WHITE);
g2d.clearRect(0, 0, width, height);
final Path2D.Double path = new Path2D.Double();
path.moveTo(30, 30);
path.lineTo(100, 100);
for (int i = 0; i < 20000; i++) {
path.lineTo(110 + 0.01 * i, 110);
path.lineTo(111 + 0.01 * i, 100);
}
path.lineTo(NaN, 200);
path.lineTo(200, 200);
path.lineTo(200, NaN);
path.lineTo(300, 300);
path.lineTo(NaN, NaN);
path.lineTo(100, 100);
path.closePath();
final Path2D.Double path2 = new Path2D.Double();
path2.moveTo(0,0);
path2.lineTo(width,height);
path2.lineTo(10, 10);
path2.closePath();
for (int i = 0; i < 1; i++) {
final long start = System.nanoTime();
g2d.setColor(Color.BLUE);
g2d.fill(path);
g2d.fill(path2);
final long time = System.nanoTime() - start;
System.out.println("paint: duration= " + (1e-6 * time) + " ms.");
}
if (SAVE_IMAGE) {
try {
final File file = new File("CrashNaNTest.png");
System.out.println("Writing file: "
+ file.getAbsolutePath());
ImageIO.write(image, "PNG", file);
} catch (IOException ex) {
System.out.println("Writing file failure:");
ex.printStackTrace();
}
}
} finally {
g2d.dispose();
}
}
private static void test(final float lineStroke,
final boolean useDashes,
final float dashMinLen)
throws ArrayIndexOutOfBoundsException
{
System.out.println("---\n" + "test: "
+ "lineStroke=" + lineStroke
+ ", useDashes=" + useDashes
+", dashMinLen=" + dashMinLen
);
final BasicStroke stroke = createStroke(lineStroke, useDashes, dashMinLen);
// TODO: test Dasher.firstSegmentsBuffer resizing ?
// array.dasher.firstSegmentsBuffer.d_float[2] sum: 6 avg: 3.0 [3 | 3]
/*
// Marlin growable arrays:
= new StatLong("array.dasher.firstSegmentsBuffer.d_float");
= new StatLong("array.stroker.polystack.curves.d_float");
= new StatLong("array.stroker.polystack.curveTypes.d_byte");
= new StatLong("array.marlincache.rowAAChunk.d_byte");
= new StatLong("array.marlincache.touchedTile.int");
= new StatLong("array.renderer.alphaline.int");
= new StatLong("array.renderer.crossings.int");
= new StatLong("array.renderer.aux_crossings.int");
= new StatLong("array.renderer.edgeBuckets.int");
= new StatLong("array.renderer.edgeBucketCounts.int");
= new StatLong("array.renderer.edgePtrs.int");
= new StatLong("array.renderer.aux_edgePtrs.int");
*/
// size > 8192 (exceed both tile and buckets arrays)
final int size = 9000;
System.out.println("image size = " + size);
final BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = (Graphics2D) image.getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setClip(0, 0, size, size);
g2d.setBackground(Color.WHITE);
g2d.clearRect(0, 0, size, size);
g2d.setStroke(stroke);
g2d.setColor(Color.BLACK);
final long start = System.nanoTime();
paint(g2d, size - 10f);
final long time = System.nanoTime() - start;
System.out.println("paint: duration= " + (1e-6 * time) + " ms.");
if (SAVE_IMAGE) {
try {
final File file = new File("CrashTest-dash-" + useDashes + ".bmp");
System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "BMP", file);
} catch (IOException ex) {
System.out.println("Writing file failure:");
ex.printStackTrace();
}
}
} finally {
g2d.dispose();
}
}
public final BufferedImage rotate(BufferedImage image, double angle, int cx, int cy) {
int width = image.getWidth(null);
int height = image.getHeight(null);
int minX, minY, maxX, maxY;
minX = minY = maxX = maxY = 0;
int[] corners = { 0, 0, width, 0, width, height, 0, height };
double theta = Math.toRadians(angle);
for (int i = 0; i < corners.length; i += 2) {
int x = (int) (((Math.cos(theta) * (corners[i] - cx)) - (Math.sin(theta) * (corners[i + 1] - cy))) + cx);
int y = (int) ((Math.sin(theta) * (corners[i] - cx))
+ (Math.cos(theta) * (corners[i + 1] - cy)) + cy);
if (x > maxX) {
maxX = x;
}
if (x < minX) {
minX = x;
}
if (y > maxY) {
maxY = y;
}
if (y < minY) {
minY = y;
}
}
cx = (cx - minX);
cy = (cy - minY);
BufferedImage bufferedImage = new BufferedImage((maxX - minX), (maxY - minY), image.getType());
Graphics2D graphics2d = bufferedImage.createGraphics();
graphics2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
graphics2d.setBackground(Color.white);
graphics2d.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight());
AffineTransform at = new AffineTransform();
at.rotate(theta, cx, cy);
graphics2d.setTransform(at);
graphics2d.drawImage(image, -minX, -minY, null);
graphics2d.dispose();
return bufferedImage;
}
/**
* Renders to the specified image.
*
* @param converter converts to the desired output type.
* @param targetImage target for rendered result.
*
* @throws IllegalArgumentException
* if rendering fails for any reason.
*/
private void renderToBufferedImage(final ProcessorWithMasksConverter converter,
final BufferedImage targetImage)
throws IllegalArgumentException {
final int numberOfTileSpecs = renderParameters.numberOfTileSpecs();
LOG.debug("renderToBufferedImage: entry, processing {} tile specifications, numberOfThreads={}",
numberOfTileSpecs, renderParameters.getNumberOfThreads());
final long tileLoopStart = System.currentTimeMillis();
final ImageProcessorWithMasks worldTarget = renderImageProcessorWithMasks();
final long drawImageStart = System.currentTimeMillis();
if (worldTarget != null) {
final Graphics2D targetGraphics = targetImage.createGraphics();
// TODO: see if there is a more efficient way to do the background fill and avoid redraw of image below
final Integer backgroundRGBColor = renderParameters.getBackgroundRGBColor();
if (backgroundRGBColor != null) {
targetGraphics.setBackground(new Color(backgroundRGBColor));
targetGraphics.clearRect(0, 0, targetImage.getWidth(), targetImage.getHeight());
} else if (renderParameters.isFillWithNoise()) {
final ByteProcessor ip = new ByteProcessor(targetImage.getWidth(), targetImage.getHeight());
mpicbg.ij.util.Util.fillWithNoise(ip);
targetGraphics.drawImage(ip.createImage(), 0, 0, null);
}
final BufferedImage image = converter.convertProcessorWithMasksToImage(renderParameters, worldTarget);
targetGraphics.drawImage(image, 0, 0, null);
if (renderParameters.isAddWarpFieldDebugOverlay()) {
WarpFieldDebugRenderer.render(renderParameters,
targetGraphics,
targetImage.getWidth(),
targetImage.getHeight());
}
targetGraphics.dispose();
}
final long drawImageStop = System.currentTimeMillis();
LOG.debug("renderToBufferedImage: exit, {} tiles processed in {} milliseconds, draw image:{}",
numberOfTileSpecs,
System.currentTimeMillis() - tileLoopStart,
drawImageStop - drawImageStart);
}
@Override
public void paint( final Graphics g ) {
final Graphics2D g2 = (Graphics2D) g;
g2.setBackground( Color.BLACK );
g2.clearRect( 0, 0, Consts.WIDTH, Consts.HEIGHT );
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
model = model_;
if ( model == null ) {
paintInfo( g2 );
}
else {
// Clone the model so we can concurrently paint it and have the controller modify it
model = model_.clone();
final boolean colorBind = Settings.getBoolean( Settings.KEY_MOUSE_PRACTICE_COLOR_BLIND );
// Draw objects of the model
for ( final Disc disc : model.discList ) {
if ( rules.paintMaxDiscOutline ) {
g2.setColor( Color.GRAY );
g2.drawOval( (int) ( disc.x - rules.maxDiscRadius ), (int) ( disc.y - rules.maxDiscRadius ), ( rules.maxDiscRadius << 1 ) + 1, ( rules.maxDiscRadius << 1 ) + 1 );
}
g2.setColor( disc.friendly ? PlayerColor.GREEN.color : PlayerColor.RED.color );
if ( disc.friendly || !colorBind )
g2.fillOval( (int) ( disc.x - disc.radius ), (int) ( disc.y - disc.radius ), (int) ( disc.radius*2 ) + 1, (int) ( disc.radius*2 ) + 1 );
else {
final Stroke storedStroke = g2.getStroke();
g2.setStroke( DOUBLE_STROKE );
g2.drawOval( (int) ( disc.x - disc.radius ), (int) ( disc.y - disc.radius ), (int) ( disc.radius*2 ) + 1, (int) ( disc.radius*2 ) + 1 );
g2.setStroke( storedStroke );
}
if ( rules.paintDiscCenterCross && disc.radius > 1 ) {
g2.setColor( Color.WHITE );
g2.drawLine( (int) ( disc.x - disc.radius/2 ), (int) disc.y, (int) ( disc.x + disc.radius/2 ), (int) disc.y );
g2.drawLine( (int) disc.x, (int) ( disc.y - disc.radius/2 ), (int) disc.x, (int) ( disc.y + disc.radius/2 ) );
}
}
final FontMetrics fontMetrics = g2.getFontMetrics();
final int shiftY = fontMetrics.getAscent() >> 1;
for ( final FloatingText floatingText : model.floatingTextList ) {
g2.setColor( floatingText.color );
g2.drawString( floatingText.text, floatingText.x - ( fontMetrics.stringWidth( floatingText.text ) >> 1 ), floatingText.y + shiftY );
}
// Draw texts
paintTexts( g2 );
}
}