Girar JLabel

0 respostas
P

ola, vou tentar explicar:

tenho um label, e nele eh desenhado um Graphics 2D
dai criei 2 SLIDER, um para aumentar o desenho, e outro para rotacionar.
porem não consigo implementar o metodo, alguem poderia ajudar, segue o codigo da criação e aumento do label:

Desenho da gravatinha, o label chama o metodo!

public ImageIcon desenharGravata(){
        int[] xv = new int[8];
        int[] yv = new int[8];
        xv[0] = 0;
        yv[0] = 0;
        xv[1] = 0;
        yv[1] = 0 + this.label_gravatinha.getBounds().height;
        xv[2] = 0 + (int)this.label_gravatinha.getBounds().width/2;
        yv[2] = 0 + (int)this.label_gravatinha.getBounds().height*2/3;
        xv[3] = 0 + this.label_gravatinha.getBounds().width;
        yv[3] = 0 + (int)this.label_gravatinha.getBounds().height*5/6;
        xv[4] = 0 + this.label_gravatinha.getBounds().width;
        yv[4] = 0 + (int)this.label_gravatinha.getBounds().height/6;
        xv[5] = 0 + (int)this.label_gravatinha.getBounds().width/2;
        yv[5] = 0 + (int)this.label_gravatinha.getBounds().height/3;
        xv[6] = 0;
        yv[6] = 0;

        int width = label_gravatinha.getSize().width;
        int height = label_gravatinha.getSize().height;
        
        BufferedImage buffer = new BufferedImage(width, height, BufferedImage.BITMASK );
        Graphics2D g4 = buffer.createGraphics();
        g4.setColor( Color.MAGENTA );
        g4.drawPolyline(xv, yv, 7);

        ImageIcon im = new ImageIcon(buffer);
        return im;
    }

Aumento usando Slider

private void slider_raioMouseDragged(java.awt.event.MouseEvent evt) {
        g=(slider_raio.getValue()*20)/50;
        int locationX = label_gravatinha.getBounds().x;
        int locationY = label_gravatinha.getBounds().y;
        label_gravatinha.setBounds(locationX, locationY, g+1, (int)g/2 + 1);
        label_gravatinha.setIcon(desenharGravata());
            
        label_imagem.remove(label_gravatinha);
        label_imagem.add(label_gravatinha);
        label_imagem.repaint();
}

aguardo resposta de como fazer o mesmo porém com a rotacao do label!

Criado 1 de dezembro de 2011
Respostas 0
Participantes 1