diff --git a/build/Console/DisplayConsole.class b/build/Console/DisplayConsole.class new file mode 100644 index 0000000..4700b3c Binary files /dev/null and b/build/Console/DisplayConsole.class differ diff --git a/build/Core.class b/build/Core.class new file mode 100644 index 0000000..06e49f4 Binary files /dev/null and b/build/Core.class differ diff --git a/build/Graphics/GraphicFile.class b/build/Graphics/GraphicFile.class new file mode 100644 index 0000000..28b4821 Binary files /dev/null and b/build/Graphics/GraphicFile.class differ diff --git a/build/Graphics/GraphicsCore.class b/build/Graphics/GraphicsCore.class new file mode 100644 index 0000000..28de1b9 Binary files /dev/null and b/build/Graphics/GraphicsCore.class differ diff --git a/build/Graphics/Traitable.class b/build/Graphics/Traitable.class new file mode 100644 index 0000000..3fa9325 Binary files /dev/null and b/build/Graphics/Traitable.class differ diff --git a/build/Graphics/Type/Array.class b/build/Graphics/Type/Array.class new file mode 100644 index 0000000..5902cc6 Binary files /dev/null and b/build/Graphics/Type/Array.class differ diff --git a/build/Graphics/Type/Bool.class b/build/Graphics/Type/Bool.class new file mode 100644 index 0000000..2d6cf95 Binary files /dev/null and b/build/Graphics/Type/Bool.class differ diff --git a/build/Graphics/Type/Chaine.class b/build/Graphics/Type/Chaine.class new file mode 100644 index 0000000..be3f0da Binary files /dev/null and b/build/Graphics/Type/Chaine.class differ diff --git a/build/Graphics/Type/Entier.class b/build/Graphics/Type/Entier.class new file mode 100644 index 0000000..8b091da Binary files /dev/null and b/build/Graphics/Type/Entier.class differ diff --git a/build/Graphics/Type/Flottant.class b/build/Graphics/Type/Flottant.class new file mode 100644 index 0000000..906a8cf Binary files /dev/null and b/build/Graphics/Type/Flottant.class differ diff --git a/build/Graphics/Type/Type.class b/build/Graphics/Type/Type.class new file mode 100644 index 0000000..38e343b Binary files /dev/null and b/build/Graphics/Type/Type.class differ diff --git a/rapport.tex b/rapport.tex new file mode 100644 index 0000000..022d884 --- /dev/null +++ b/rapport.tex @@ -0,0 +1,9 @@ +\documentclass[11pt,a4paper]{article} +\usepackage[utf8]{inputenc} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\author{Bilal Boudemline & Romain Besson} + +\begin{document} +\end{document} diff --git a/src/Graphics/GraphicFile.java b/src/Graphics/GraphicFile.java index 0c74caf..6917c8f 100644 --- a/src/Graphics/GraphicFile.java +++ b/src/Graphics/GraphicFile.java @@ -3,11 +3,15 @@ package Graphics; import java.io.InputStream; import java.io.IOException; import java.util.HashMap; + +import javax.swing.JLabel; import javax.swing.JPanel; - import Graphics.Type.*; - +import java.awt.FlowLayout; import java.awt.GridLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Color; import java.net.URL; /** @@ -23,21 +27,51 @@ public class GraphicFile extends JPanel { super(); try { System.out.println("[+] Lecture de " + url); - this.setLayout(new GridLayout(100, 1)); + this.setLayout(new FlowLayout(FlowLayout.LEFT)); + this.setLocation(500, 500); InputStream jsonReader = url.openStream(); - - /** - * C'est ici que le hashmap est stocke - */ Traitable fileTraited = new Traitable(jsonReader); + jsonReader.close(); + HashMap> allVariables = fileTraited.getVariableMap(); + JPanel core = new JPanel(new GridBagLayout()); + GridBagConstraints settings = new GridBagConstraints(); + settings.gridx = 0; + settings.gridy = 0; + settings.anchor = GridBagConstraints.WEST; + + core.add(new JLabel("{"), settings); + + int rows = 1; + settings.gridy = 1; + settings.gridx = 2; for (String key : allVariables.keySet()) { - System.out.println("\"" + key + "\": " + allVariables.get(key).display()); + settings.gridy = rows; + + JLabel name = new JLabel("\"" + key + "\": "); + name.setForeground(new Color(163, 90, 0)); + + JLabel value = new JLabel(allVariables.get(key).display()); + value.setForeground(allVariables.get(key).getColor()); + + JPanel fusion = new JPanel(new GridLayout(1, 1)); + fusion.add(name); + + fusion.add(value); + + core.add(fusion, settings); + rows++; } - jsonReader.close(); + settings.gridx = 0; + settings.gridy = rows; + core.add(new JLabel("}"), settings); + + this.add(core); + + this.setVisible(true); } catch (IOException e) { System.out.println("[!] Fichier " + url.getFile() + " n'existe pas"); } diff --git a/src/Graphics/Traitable.java b/src/Graphics/Traitable.java index d87a562..e5a84d7 100644 --- a/src/Graphics/Traitable.java +++ b/src/Graphics/Traitable.java @@ -129,9 +129,7 @@ public class Traitable { * @return Le type */ private String getType(String value) { - if (value.contains("\"")) { - return "string"; - } else if (value.contains("{")) { + if (value.contains("{")) { return "object"; } else if (value.contains("[")) { return "array"; @@ -141,6 +139,8 @@ public class Traitable { return "double"; } else if (value.contains("null")) { return "null"; + } else if (value.contains("\"")) { + return "string"; } else { return "int"; } diff --git a/src/Graphics/Type/Array.java b/src/Graphics/Type/Array.java index b4a4787..f3cc123 100644 --- a/src/Graphics/Type/Array.java +++ b/src/Graphics/Type/Array.java @@ -1,5 +1,6 @@ package Graphics.Type; +import java.awt.Color; import Graphics.Type.*; import java.util.LinkedList; import java.util.List; @@ -11,6 +12,7 @@ import java.util.List; public class Array implements Type>> { private String valueRaw; private List> value; + private Color color; public Array(String valueRaw) { this.valueRaw = valueRaw.substring(1, valueRaw.length() - 1); @@ -51,12 +53,12 @@ public class Array implements Type>> { } public String getType(String value) { - if (value.contains("\"")) { - return "string"; - } else if (value.contains("{")) { + if (value.contains("{")) { return "object"; } else if (value.contains("[")) { return "array"; + } else if (value.contains("\"")) { + return "string"; } else if (value.contains("true") || value.contains("false")) { return "boolean"; } else if (value.contains(".")) { @@ -72,17 +74,25 @@ public class Array implements Type>> { return this.valueRaw; } + @Override + public Color getColor() { + return this.color; + } + @Override public String display() { StringBuilder str = new StringBuilder(); - str.append("["); + str.append("[ "); for (int i = 0; i <= this.value.size() - 1; i++) { str.append(this.value.get(i).display() + ", "); } - str.append("]"); + str.deleteCharAt(str.length() - 1); + str.deleteCharAt(str.length() - 1); + + str.append(" ]"); return str.toString(); } diff --git a/src/Graphics/Type/Bool.java b/src/Graphics/Type/Bool.java index 75d8498..b95aa77 100644 --- a/src/Graphics/Type/Bool.java +++ b/src/Graphics/Type/Bool.java @@ -1,14 +1,27 @@ package Graphics.Type; +import java.awt.Color; + /** * Representation du type boolean */ public class Bool implements Type { private Boolean value; + private Color color; public Bool(Boolean value) { this.value = value; + if (value) { + this.color = Color.GREEN; + } else { + this.color = Color.RED; + } + } + + @Override + public Color getColor() { + return this.color; } @Override diff --git a/src/Graphics/Type/Chaine.java b/src/Graphics/Type/Chaine.java index 554afe2..04ccfdb 100644 --- a/src/Graphics/Type/Chaine.java +++ b/src/Graphics/Type/Chaine.java @@ -1,14 +1,23 @@ package Graphics.Type; +import java.awt.Color; + /** * Representation du type string */ public class Chaine implements Type { private String value; + private Color color; public Chaine(String value) { this.value = value; + this.color = Color.PINK; + } + + @Override + public Color getColor() { + return this.color; } @Override diff --git a/src/Graphics/Type/Entier.java b/src/Graphics/Type/Entier.java index 5d123d9..f040e33 100644 --- a/src/Graphics/Type/Entier.java +++ b/src/Graphics/Type/Entier.java @@ -1,14 +1,23 @@ package Graphics.Type; +import java.awt.Color; + /** * Representation du type int */ public class Entier implements Type { public Integer value; + private Color color; public Entier(Integer value) { this.value = value; + this.color = Color.BLUE; + } + + @Override + public Color getColor() { + return this.color; } @Override diff --git a/src/Graphics/Type/Flottant.java b/src/Graphics/Type/Flottant.java index a51a318..8930d0e 100644 --- a/src/Graphics/Type/Flottant.java +++ b/src/Graphics/Type/Flottant.java @@ -1,14 +1,23 @@ package Graphics.Type; +import java.awt.Color; + /** * Representation du type double */ public class Flottant implements Type { private Double value; + private Color color; public Flottant(Double value) { this.value = value; + this.color = Color.BLUE; + } + + @Override + public Color getColor() { + return this.color; } @Override diff --git a/src/Graphics/Type/Type.java b/src/Graphics/Type/Type.java index 4ece8aa..e205ac1 100644 --- a/src/Graphics/Type/Type.java +++ b/src/Graphics/Type/Type.java @@ -1,5 +1,7 @@ package Graphics.Type; +import java.awt.Color; + public interface Type { /** * Retourner le type de la variable @@ -15,6 +17,11 @@ public interface Type { */ public T getValue(); + /** + * Recuperer la couleur de syntaxe d'un type + */ + public Color getColor(); + /** * Afficher la valeur / toutes les valeurs */