All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sksamuel.scrimage.canvas.drawables.Text Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
package com.sksamuel.scrimage.canvas.drawables;

import com.sksamuel.scrimage.canvas.Drawable;
import com.sksamuel.scrimage.canvas.GraphicsContext;
import com.sksamuel.scrimage.graphics.RichGraphics2D;

public class Text implements Drawable {

    private final String text;
    private final int x;
    private final int y;
    private final GraphicsContext context;

    public Text(String text, int x, int y, GraphicsContext context) {
        this.text = text;
        this.x = x;
        this.y = y;
        this.context = context;
    }

    @Override
    public void draw(RichGraphics2D g2) {
        context.configure(g2);
        g2.drawString(text, x, y);
    }

    @Override
    public GraphicsContext context() {
        return context;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy