Example usage for java.awt Graphics2D shear

List of usage examples for java.awt Graphics2D shear

Introduction

In this page you can find the example usage for java.awt Graphics2D shear.

Prototype

public abstract void shear(double shx, double shy);

Source Link

Document

Concatenates the current Graphics2D Transform with a shearing transform.

Usage

From source file:Main.java

public void paint(Graphics g) {
    g.fillRect(0, 0, 20, 20);//from  ww  w .j  av  a 2 s.co m

    Graphics2D g2 = (Graphics2D) g;

    g2.shear(5.3, 5.4);
    g2.rotate(30.0 * Math.PI / 180.0);

    g2.scale(2.0, 2.0);

    g.setColor(Color.red);

    g.fillRect(0, 0, 20, 20);
}

From source file:TextBouncer.java

protected void setTransform(Graphics2D g2) {
    Dimension d = getSize();/*w w  w. j av a 2s  . c o  m*/
    int cx = d.width / 2;
    int cy = d.height / 2;
    g2.translate(cx, cy);
    if (mShear)
        g2.shear(mShearX, mShearY);
    if (mRotate)
        g2.rotate(mTheta);
    g2.translate(-cx, -cy);
}

From source file:forseti.JUtil.java

public static synchronized Image generarImagenMensaje(String mensaje, String nombreFuente, int tamanioFuente) {
    Frame f = new Frame();
    f.addNotify();//  ww  w  . j  a  v a2  s.  co  m
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    env.getAvailableFontFamilyNames();
    Font fuente = new Font(nombreFuente, Font.PLAIN, tamanioFuente);
    FontMetrics medidas = f.getFontMetrics(fuente);
    int anchoMensaje = medidas.stringWidth(mensaje);
    int lineaBaseX = anchoMensaje / 10;
    int ancho = anchoMensaje + 2 * (lineaBaseX + tamanioFuente);
    int alto = tamanioFuente * 7 / 2;
    int lineaBaseY = alto * 8 / 10;
    Image imagenMensaje = f.createImage(ancho, alto);
    Graphics2D g2d = (Graphics2D) imagenMensaje.getGraphics();
    g2d.setFont(fuente);
    g2d.translate(lineaBaseX, lineaBaseY);
    g2d.setPaint(Color.lightGray);
    AffineTransform origTransform = g2d.getTransform();
    g2d.shear(-0.95, 0);
    g2d.scale(1, 3);
    g2d.drawString(mensaje, 0, 0);
    g2d.setTransform(origTransform);
    g2d.setPaint(Color.black);
    g2d.drawString(mensaje, 0, 0);

    return (imagenMensaje);
}