Skip to content

Commit

Permalink
feat: Adiciona pilha para guardar equipamentos a serem conectados
Browse files Browse the repository at this point in the history
  • Loading branch information
giovaneneves7 committed Mar 31, 2024
1 parent 0a1e19c commit 5e76376
Showing 1 changed file with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// *************************************************//
// ************ { COME�O - Imports } ***************//
// *************************************************//
import br.com.ifba.ipss.common.infrastructure.interfaces.Ferramenta;
import br.com.ifba.ipss.common.infrastructure.interfaces.IEquipamentoService;
import br.com.ifba.ipss.feature.conexao.domain.model.Conexao;
import br.com.ifba.ipss.feature.conexao.domain.service.ConexaoServiceImpl;
Expand All @@ -22,28 +21,25 @@
import br.com.ifba.ipss.feature.tubulacao.domain.service.ITubulacaoService;
import br.com.ifba.ipss.feature.tubulacao.domain.service.TubulacaoServiceImpl;
import br.com.ifba.ipss.feature.equipamento.widget.FerramentaContainer;
import br.com.ifba.ipss.feature.label.domain.model.Label;
import br.com.ifba.ipss.util.Constantes;
import br.com.ifba.ipss.util.NomeEquipamento;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.border.Border;
import lombok.Data;
// *************************************************//
// ************** { FIM - Imports } ****************//
Expand Down Expand Up @@ -75,6 +71,10 @@ public class MenuFerramentasController {
private JLabel lblFerramentaSelecionadaParaInteracao;
private boolean ferramentaEstaSelecionada = false;

private Label lblOrigemConexao;
private Label lblAlvoConexao;
private Stack<Label> pilhaConexaoEquipamento = new Stack();

// *************************************************//
// ***************** { Construtor } ****************//
// *************************************************//
Expand Down Expand Up @@ -213,7 +213,7 @@ public void selecionarFerramenta(JPanel pnlEspacoTrabalho, String tipo, String n
if(eq instanceof Tubulacao tub){

ImageIcon imgTub = new ImageIcon(this.getClass().getResource(eq.get_caminhoImagem()));
JLabel lblTub = new LabelBuilder()
Label lblTub = new LabelBuilder()
.setImagem(imgTub)
.setTitulo("")
.build();
Expand All @@ -229,7 +229,7 @@ public void selecionarFerramenta(JPanel pnlEspacoTrabalho, String tipo, String n
if(eq instanceof Conexao con){

ImageIcon imgTub = new ImageIcon(this.getClass().getResource(eq.get_caminhoImagem()));
JLabel lblTub = new LabelBuilder()
Label lblTub = new LabelBuilder()
.setImagem(imgTub)
.setTitulo("")
.build();
Expand Down Expand Up @@ -263,7 +263,7 @@ public <T extends Equipamento>T pegarEquipamentoSelecionado(String tipo, String

} // pegarEquipamentoSelecionado

public void adicionarListenerDeCliqueAAFerramenta(JLabel lbl){
public void adicionarListenerDeCliqueAAFerramenta(Label lbl){

lbl.addMouseListener(new MouseAdapter(){

Expand All @@ -277,6 +277,23 @@ public void mouseClicked(MouseEvent me){

}

if(pilhaConexaoEquipamento.size() < 2){

if(pilhaConexaoEquipamento.isEmpty()){

pilhaConexaoEquipamento.push(lbl);
System.out.println("Selecionando " + lbl.getName() + " como primeiro item");
} else if(pilhaConexaoEquipamento.get(0) == lbl){

pilhaConexaoEquipamento.pop();
System.out.println("Removendo " + lbl.getName() + " como primeiro item");
} else{

pilhaConexaoEquipamento.push(lbl);
System.out.println("Selecionando " + lbl.getName() + " como segundo item");
}
}

lblFerramentaSelecionada = lbl;
lblFerramentaSelecionadaParaInteracao = lbl;
ferramentaEstaSelecionada = true;
Expand All @@ -289,7 +306,7 @@ public void mouseClicked(MouseEvent me){
int mouseX, mouseY;
double suavizacao = 1.01;

public void adicionarListenerDeMovimentoAAFerramenta(JLabel lbl) {
public void adicionarListenerDeMovimentoAAFerramenta(Label lbl) {

Timer timer = new Timer(100, e -> {
int deltaX = lbl.getX() + mouseX;
Expand Down

0 comments on commit 5e76376

Please sign in to comment.