Skip to content

Commit

Permalink
feat: Cria atributo para gerenciar ferramenta selecionada
Browse files Browse the repository at this point in the history
  • Loading branch information
giovaneneves7 committed Mar 30, 2024
1 parent 82d2740 commit 280b214
Showing 1 changed file with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class MenuFerramentasController {
private Map<String, List<?>> equipamentos = new HashMap<>();

private JLabel lblFerramentaSelecionada;
private JLabel lblFerramentaSelecionadaParaInteracao;
private boolean ferramentaEstaSelecionada = false;

// *************************************************//
Expand Down Expand Up @@ -271,6 +272,7 @@ public void mouseClicked(MouseEvent me){
}

lblFerramentaSelecionada = lbl;
lblFerramentaSelecionadaParaInteracao = lbl;
ferramentaEstaSelecionada = true;
}
});
Expand All @@ -282,36 +284,38 @@ public void mouseClicked(MouseEvent me){
double suavizacao = 1.01;

public void adicionarListenerDeMovimentoAAFerramenta(JLabel lbl) {
Timer timer = new Timer(100, e -> {
int deltaX = lbl.getX() + mouseX;
int deltaY = lbl.getY() + mouseY;
lbl.setLocation(deltaX, deltaY);
});

Timer timer = new Timer(100, e -> {
int deltaX = lbl.getX() + mouseX;
int deltaY = lbl.getY() + mouseY;
lbl.setLocation(deltaX, deltaY);
});

lbl.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
mouseX = me.getX();
mouseY = me.getY();
if (!timer.isRunning()) {
timer.start();
lbl.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
mouseX = me.getX();
mouseY = me.getY();
if (!timer.isRunning()) {
timer.start();
}
}
}

@Override
public void mouseReleased(MouseEvent me) {
timer.stop();
}
});
@Override
public void mouseReleased(MouseEvent me) {
timer.stop();
}
});

lbl.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
mouseX = e.getX();
mouseY = e.getY();
}
});
} // adicionarListenerDeMovimentoAAFerramenta
lbl.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
mouseX = e.getX();
mouseY = e.getY();
}
});

} // adicionarListenerDeMovimentoAAFerramenta


public void adicionarFerramentaAAAreaDeTrabalho(){
Expand Down

0 comments on commit 280b214

Please sign in to comment.