JavaDoc
This commit is contained in:
@@ -7,11 +7,23 @@ import java.io.IOException;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe Definissant de manière static les méthodes pour créer un fichier SVG de nos graphiques
|
||||||
|
*/
|
||||||
public class SVGFactory {
|
public class SVGFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chemin d'export et Extension du fichier
|
||||||
|
*/
|
||||||
static final private String EXPORT_PATH = "export/";
|
static final private String EXPORT_PATH = "export/";
|
||||||
static final private String EXTENSION = ".svg";
|
static final private String EXTENSION = ".svg";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fonction createSVG permettant de créer le fichier SVG dans le dossier du chemin d'export.
|
||||||
|
* Le nom du fichier est defini automatiquement.
|
||||||
|
* @param mesElements tableau composé des différents éléments de notre graphique
|
||||||
|
* @return True si la fonction a réussi à créer le fichier, False sinon
|
||||||
|
*/
|
||||||
public static boolean createSVG(HashSet<Element> mesElements){
|
public static boolean createSVG(HashSet<Element> mesElements){
|
||||||
|
|
||||||
String code = createSVGCode(mesElements);
|
String code = createSVGCode(mesElements);
|
||||||
@@ -24,7 +36,12 @@ public class SVGFactory {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Fonction createSVG permettant de créer le fichier SVG dans le dossier du chemin d'export.
|
||||||
|
* @param mesElements tableau composé des différents éléments de notre graphique
|
||||||
|
* @param filename String contenant le nom du fichier voulu
|
||||||
|
* @return True si la fonction a réussi à créer le fichier, False sinon
|
||||||
|
*/
|
||||||
public static boolean createSVG(HashSet<Element> mesElements, String filename) {
|
public static boolean createSVG(HashSet<Element> mesElements, String filename) {
|
||||||
|
|
||||||
String code = createSVGCode(mesElements);
|
String code = createSVGCode(mesElements);
|
||||||
@@ -38,6 +55,11 @@ public class SVGFactory {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet la création du code de notre SVG
|
||||||
|
* @param mesElements tableau d'élement de notre graphiques
|
||||||
|
* @return une String contenant le code complet de notre SVG
|
||||||
|
*/
|
||||||
public static String createSVGCode(HashSet<Element> mesElements){
|
public static String createSVGCode(HashSet<Element> mesElements){
|
||||||
|
|
||||||
String code = "<svg height=\"800\" width=\"800\" >";
|
String code = "<svg height=\"800\" width=\"800\" >";
|
||||||
@@ -53,11 +75,22 @@ public class SVGFactory {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de lancer la création du fichier. Cette version ne prend pas de filename mais à la place créer un UUID random pour.
|
||||||
|
* @param data String contenant le code de notre SVG
|
||||||
|
* @throws IOException C'est une création de fichier, il peut y avoir des erreurs
|
||||||
|
*/
|
||||||
public static void createFile(String data) throws IOException {
|
public static void createFile(String data) throws IOException {
|
||||||
String id = UUID.randomUUID().toString();
|
String id = UUID.randomUUID().toString();
|
||||||
createFile(data,id);
|
createFile(data,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de créer un fichier SVG contenant notre graphique
|
||||||
|
* @param data String contenant le code de notre SVG
|
||||||
|
* @param filename String contenant le nom de notre fichier
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
public static void createFile(String data, String filename) throws IOException {
|
public static void createFile(String data, String filename) throws IOException {
|
||||||
|
|
||||||
// create a FileWriter object with the file name
|
// create a FileWriter object with the file name
|
||||||
|
|||||||
Reference in New Issue
Block a user