From 0dd3552126e52fc04ce70323ea894035f53cf5c0 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 23 Mar 2021 16:55:14 +0100 Subject: [PATCH] Add loading-gif.gif to generate JButton --- build.xml | 8 +++++++- resources/loading-gif.gif | Bin 0 -> 1041 bytes src/lsystem/screen/gl3d/DrawHelper.java | 1 - src/lsystem/screen/main/Listener.java | 7 +++++++ src/lsystem/screen/main/Tab.java | 3 ++- 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 resources/loading-gif.gif diff --git a/build.xml b/build.xml index 31f62d8..635a838 100644 --- a/build.xml +++ b/build.xml @@ -2,6 +2,7 @@ + @@ -12,10 +13,15 @@ + + + + + - + diff --git a/resources/loading-gif.gif b/resources/loading-gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..e06ffc12c7ac0e832b8a73bf293bf74b0813577a GIT binary patch literal 1041 zcmZ?wbhEHblw^=(_{6~Q|Ns9pKy>EJ%$YOOfG91^*w~nXfkE*Go6E zySjqcYs>tbCLQAzWxH$J(xeiZGbv&(b(MbhmTvoBXIoS%9T8n)ouAj)lbs{k7+=sN z#EI$<5e7b>L#%-g`Kmk5@S67N86GQlbuBZEed^G@W8&S;mE8(Dx*Eqm*_4W}d9pM1 zsc8~J>ZDGV898zj&aEi%>Qw`JALcQT$Hf`Af##W4?6Ns$z_syC#L^?C%QtyV%XN2` zeV~}Nq|;9OWaWY#635b_J~lqKnw9nC_e--@rGRakMyaP=nGj~N0?mTB&7@-2rQZT( z8;^AqYGr@C%wAsEr8cSOu&(Pv-{%*%<=;4KyzAkXbr1Hr>;Ev2=xjySF)#u>Ck`|T=%hRU46GCtmcET!W_UkXlsCoFAgy!R@*t6mzpXay zk@yjKzGB_&_IpXoUPvk&Y8R}`Q9%kPZU$DUlOP72@?5>r<3F zYB=Y3y6&QgJ?gWXyu9}rLcPciV+1-25`mT# ztI~cO%)7QEcFR=hV%-OZGESPQTpWBknPq-bn--szedRWJ+f;4qc@I7bZxmU#FrV2* zY3lZ8FD4;*lL78JlZ;(u|2}LKT|N6$R>Y}ovEN-2&3oK6`Q9jIEIqu*iMP5adjI2^ zcY9|t|M|d85$I>O|HZ?we8_6u15}5!Dc=Z=NG8~6L z*>Ftp<^Geby=R_&8ON@s9ekfMQg+24MIi$`3W13s?e}ui6-yQet_!+hBNLvPI3so` n=hPWWTFyHB=XI`|-IZ%<_-e~#utP$q`@prr<2hEEoD9|gc>ajD literal 0 HcmV?d00001 diff --git a/src/lsystem/screen/gl3d/DrawHelper.java b/src/lsystem/screen/gl3d/DrawHelper.java index 4110ee0..840525b 100644 --- a/src/lsystem/screen/gl3d/DrawHelper.java +++ b/src/lsystem/screen/gl3d/DrawHelper.java @@ -2,7 +2,6 @@ package lsystem.screen.gl3d; import com.jogamp.opengl.GL2; import com.jogamp.opengl.util.gl2.GLUT; - import lsystem.screen.gl2d.Point2; import lsystem.screen.gl2d.SwingGLCanvas2D; diff --git a/src/lsystem/screen/main/Listener.java b/src/lsystem/screen/main/Listener.java index d37e9a4..cde62d9 100644 --- a/src/lsystem/screen/main/Listener.java +++ b/src/lsystem/screen/main/Listener.java @@ -5,6 +5,7 @@ import lsystem.engine.Parser; import lsystem.screen.AbstractCanvas; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -18,6 +19,8 @@ public class Listener implements ActionListener, KeyListener { String type; Integer nbAxioms; Thread parserThread = null; + ImageIcon staticIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("loading-gif.gif"))); + public Listener(MainFrame frame, Integer index, String type, Tab tab){ this.tab = tab; @@ -58,6 +61,8 @@ public class Listener implements ActionListener, KeyListener { } else if (!parser.isCorrect()) { openDialog("Vos règles ou votre axiome ne sont pas correctement écrites, veuillez recommencer"); } else { + tab.submitButton.setIcon(staticIcon); + tab.submitButton.setText(""); parserThread = new Thread(() -> { try { Main.joglFrame.setLSystem(axiom, parser.parseRules(), tab.getNbIterations()); @@ -66,6 +71,8 @@ public class Listener implements ActionListener, KeyListener { Main.joglFrame.parsedState = AbstractCanvas.State.FINISH_OR_NULL; openDialog("Une erreur de type " + err.getClass().getSimpleName() + " est survenue lors de l'execution du parser: " + err.getMessage()); } + tab.submitButton.setIcon(null); + tab.submitButton.setText("Générer"); }); parserThread.start(); } diff --git a/src/lsystem/screen/main/Tab.java b/src/lsystem/screen/main/Tab.java index 2a5100e..bb58e33 100644 --- a/src/lsystem/screen/main/Tab.java +++ b/src/lsystem/screen/main/Tab.java @@ -14,6 +14,7 @@ public class Tab extends JPanel{ JTextArea axiomList; JTextArea rulesList; JSpinner itSpinner; + JButton submitButton; public Tab(int nbTabs,int nbRules,JTabbedPane tabs) { this.nbRules = nbRules; @@ -42,7 +43,7 @@ public class Tab extends JPanel{ rulesField.addKeyListener(new Listener(null,nbTabs+10,"Règles",this)); rulesField.setPreferredSize(new Dimension(120,20)); - JButton submitButton = new JButton("Générer"); + submitButton = new JButton("Générer"); JButton clearButton = new JButton("Clear"); clearButton.addActionListener(new Listener(null,nbTabs,"Clear",this)); submitButton.addActionListener(new Listener(null,nbTabs,"Generate",this));