$
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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,6 +74,11 @@ 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();
|
||||
@@ -82,6 +89,9 @@ public class Array implements Type<List<Type<?>>> {
|
||||
str.append(this.value.get(i).display() + ", ");
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user