$
This commit is contained in:
parent
d8b7a4767f
commit
a357b0ec5d
BIN
build/Console/DisplayConsole.class
Normal file
BIN
build/Console/DisplayConsole.class
Normal file
Binary file not shown.
BIN
build/Core.class
Normal file
BIN
build/Core.class
Normal file
Binary file not shown.
BIN
build/Graphics/GraphicFile.class
Normal file
BIN
build/Graphics/GraphicFile.class
Normal file
Binary file not shown.
BIN
build/Graphics/GraphicsCore.class
Normal file
BIN
build/Graphics/GraphicsCore.class
Normal file
Binary file not shown.
BIN
build/Graphics/Traitable.class
Normal file
BIN
build/Graphics/Traitable.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Array.class
Normal file
BIN
build/Graphics/Type/Array.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Bool.class
Normal file
BIN
build/Graphics/Type/Bool.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Chaine.class
Normal file
BIN
build/Graphics/Type/Chaine.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Entier.class
Normal file
BIN
build/Graphics/Type/Entier.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Flottant.class
Normal file
BIN
build/Graphics/Type/Flottant.class
Normal file
Binary file not shown.
BIN
build/Graphics/Type/Type.class
Normal file
BIN
build/Graphics/Type/Type.class
Normal file
Binary file not shown.
9
rapport.tex
Normal file
9
rapport.tex
Normal file
@ -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}
|
@ -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<String, Type<?>> 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");
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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<List<Type<?>>> {
|
||||
private String valueRaw;
|
||||
private List<Type<?>> 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<List<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<List<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();
|
||||
}
|
||||
|
@ -1,14 +1,27 @@
|
||||
package Graphics.Type;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* Representation du type boolean
|
||||
*/
|
||||
|
||||
public class Bool implements Type<Boolean> {
|
||||
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
|
||||
|
@ -1,14 +1,23 @@
|
||||
package Graphics.Type;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* Representation du type string
|
||||
*/
|
||||
|
||||
public class Chaine implements Type<String> {
|
||||
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
|
||||
|
@ -1,14 +1,23 @@
|
||||
package Graphics.Type;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* Representation du type int
|
||||
*/
|
||||
|
||||
public class Entier implements Type<Integer> {
|
||||
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
|
||||
|
@ -1,14 +1,23 @@
|
||||
package Graphics.Type;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* Representation du type double
|
||||
*/
|
||||
|
||||
public class Flottant implements Type<Double> {
|
||||
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
|
||||
|
@ -1,5 +1,7 @@
|
||||
package Graphics.Type;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public interface Type<T> {
|
||||
/**
|
||||
* Retourner le type de la variable
|
||||
@ -15,6 +17,11 @@ public interface Type<T> {
|
||||
*/
|
||||
public T getValue();
|
||||
|
||||
/**
|
||||
* Recuperer la couleur de syntaxe d'un type
|
||||
*/
|
||||
public Color getColor();
|
||||
|
||||
/**
|
||||
* Afficher la valeur / toutes les valeurs
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user