├── .gitignore ├── LICENSE ├── README.md ├── bin ├── ar2dtool.jar ├── confER.txt └── confTaxonomy.txt ├── doc └── index.html ├── lib └── ar2dtool-0.1.jar ├── mavenProject ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── es │ └── upm │ └── oeg │ └── ar2dtool │ ├── Main.java │ ├── MainOld.java │ ├── RDF2Diagram.java │ ├── exceptions │ ├── ConfigFileNotFoundException.java │ ├── ConfigKeyNotFound.java │ ├── ConfigValueNotAllowed.java │ ├── DOTNotFoundException.java │ ├── NullTripleMember.java │ ├── RDFInputNotValid.java │ └── RDFNotFound.java │ ├── logger │ ├── AR2DToolLogger.java │ ├── DefaultLoggerWriter.java │ └── LoggerWriterInterface.java │ └── utils │ ├── AR2DTriple.java │ ├── ConfigValues.java │ ├── NodeNameMode.java │ ├── NodeNames.java │ ├── dot │ ├── DOTGenerator.java │ ├── DOTTriple.java │ ├── GraphViz.java │ ├── GraphVizIOld.java │ ├── ObjPropPair.java │ └── Rdf2Gv.java │ ├── graphml │ └── GraphMLGenerator.java │ └── gv │ ├── DOTTriple.java │ └── GraphViz.java ├── samples ├── API samples │ └── sample01.java ├── confER.txt ├── confTaxonomy.txt └── sample01.java └── webAppProject ├── .gitignore ├── README.MD ├── pom.xml └── src └── main ├── java └── es │ └── upm │ └── oeg │ └── webAR2DTool │ ├── managers │ └── AR2DToolManager.java │ ├── responses │ └── WebConfig.java │ ├── services │ └── AR2DToolMethods.java │ ├── threads │ └── WebAR2DToolThread.java │ └── utils │ ├── Constants.java │ ├── FileLoggerWriter.java │ ├── MailSender.java │ ├── ParameterNames.java │ ├── PosibleLangsJena.java │ ├── ResponseFormats.java │ ├── WebResponse.java │ └── WebString.java └── webapp ├── WEB-INF ├── defaultConfig.txt ├── mail.properties ├── server.properties └── web.xml ├── file.jsp ├── image.jsp ├── index.jsp └── resources ├── css ├── animations.css ├── configSpecial.css ├── dropDownMenu.css ├── styles.css └── zoomAndPanned.css ├── imageSelect ├── Flat.css ├── ImageSelect.css ├── ImageSelect.jquery.js ├── chosen.jquery.min.js ├── chosen.min.css └── chosen │ ├── chosen-sprite.png │ └── chosen-sprite@2x.png ├── img ├── Logo_AR2DTool.png ├── OEG_Logo.png ├── add.png ├── arrows │ ├── box.gif │ ├── diamond.gif │ ├── dot.gif │ ├── inv.gif │ ├── normal.gif │ ├── obox.gif │ ├── odiamond.gif │ ├── odot.gif │ ├── oinv.gif │ └── onormal.gif ├── checkbox_checked.png ├── checkbox_unchecked.png ├── dropdown.png ├── dropleft.png ├── dropright.png ├── dropup.png ├── edit.png ├── edit_edited.png ├── fondo.png ├── generateIcon.png ├── minus.png └── nav.png ├── js ├── configSpecialContainers.js ├── doubletaptogo.min.js ├── gui.js ├── jquery-handler-toolkit.js ├── jquery-latest.min.js ├── modernizr-custom.js └── zoomAndPanned.js └── sweetAlert ├── sweetalert.css └── sweetalert.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | mavenProject/target/* 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012-2013 Ontology Engineering Group, Universidad Politécnica de Madrid, Spain 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo](https://dl.dropboxusercontent.com/u/4192819/logoard2tool.png) AR2DTool (alpha) 2 | =============== 3 | 4 | Standalone tool 5 | =============== 6 | This tool receives as an input an RDF file and produces as an output a file with a graphical representation of the source RDF file. AR2DTool support RDF/XML and TTL serialization formats. 7 | 8 | Command line syntax: 9 | 10 | java -jar ar2dtool.jar -i PathToInputRdfFile -o FileToOutputFile -t OutputFileType -c PathToConfFile -GENERATE_FLAGS [-d] 11 | 12 | - PathToInputRdfFile: input file. Any RDF file, including local files and URIs. 13 | 14 | - FileToOutputFile: output picture file. 15 | 16 | - OutputFileType: output file type: png, pdf, etc. (check supported file types at http://www.graphviz.org/doc/info/output.html) 17 | 18 | - PathToConfFile: config file location. For more information about config values check the section below. 19 | 20 | - GENERATE_FLAGS: you can specify one or more of the flags below to define which files you want to generate: 21 | 22 | * -gv/GV: using -gv a DOT source file will be generated as FileToOutputFile.gv. Using -GV will also compile the DOT source code into an image with the format specified in OutputFileType. 23 | 24 | * -gml: using -gml a GraphML source file will be generated as FileToOutputFile.graphml. 25 | 26 | - [-d] optional flag for debugging. 27 | 28 | - [-tmp]: option flag to specify the temp folder. 29 | 30 | 31 | AR2DTool Java API 32 | =============== 33 | 34 | You can download the AR2DTool Java API from the lib/ folder on this repository. If you want to use it you have to add the ar2dtool-0.1.jar file to your CLASSPATH/BUILPATH. 35 | 36 | As AR2DTool relies on the Jena API you also need to include it as part of your project (http://jena.apache.org/download/) 37 | 38 | 39 | Configuration file 40 | =============== 41 | 42 | For the standalone version of the tool all the configuration parameters must be specified on a configuration file. On the API library you can either use a configuration file or specify the configuration values by means of the API methods of the ConfigValues class. 43 | 44 | The syntax of the simple parameters is: 45 | 46 | parameterName=parameterValue; 47 | 48 | Be aware that ';' are necessary at the end of each line. For comments you can use '#' at the beginning of each line. 49 | 50 | These are the values that can be specified. 51 | 52 | - pathToDot: path in your filesystem to the DOT exectuable file (e.g. pathToDot=/usr/local/bin/dot;). 53 | 54 | - pathToTempDir: path to the folder where temporary files are going to be created (e.g. pathToTempDir=/tmp;). 55 | 56 | - imageSize: size of the DOT image generated (if any) (e.g. imageSize=1501;). 57 | 58 | - rankdir: direction of the DOT graph image generated (if any) (e.g. rankdir=LR;). 59 | 60 | - classShape, individualShape, and literalShape: shapes of each type of element of the graph. Allowed values are: recatangle (default), ellipse, triangle, and diamond (e.g. classShape=ellipse;). 61 | 62 | 63 | - classColor, individualColor, and literalColor: color of each type of element of the graph. Allowed values so far are: black (default), red, blue, green, orange, yellow (e.g. literalColor=blue;). 64 | 65 | - nodeNameMode: defines the way the resources are named. You can specify 'fulluri' for using the URIs of each resource, 'prefix' for shortened names using the specified prefixes (resources with no mathcing prefix will be displayed with their full URI. By default the base prefix will be displayed as "base:", unless vann:preferredNamespacePrefix is specified, in which case its value will be used as base prefix), or 'localname' for using the localname of the resource. (e.g. nodeNameMode=localname;). 66 | 67 | - ignoreLiterals: if you want to exclude literals from your graph you can set this flag to true (e.g. ignoreLiterals=true;). 68 | 69 | - ignoreRdfType: in case you do not want the rdfs:type property to be displayed you can sent this flag to true (e.g. ignoreRdfType=false;). 70 | 71 | - synthesizeObjectProperties: in general, AR2DTool translates RDF triples directly into graphs nodes and edges. When working with ontologies that means that object properties will be displayed indicating their range and domain, instead of connecting two classes. If you want your properties to connect classes directly you should set this flag to true (e.g. synthesizeObjectProperties=true;) 72 | 73 | Apart from single configuration parameters you can specify lists for processing resources of your RDF dataset in different ways. 74 | 75 | The syntax of a list is: listName=[...]; 76 | 77 | Basically a list is a set of N-tuples. In most cases you will only need 1 tuple for your whole list, but in some cases it will be necessary to include more than one (like in the case of specialElementsList or equivalentElementList parameters). 78 | 79 | These are the list parameters that can be defined: 80 | 81 | - includeOnlyElementList: the tool will only consider RDF triples that have a URI (as subject, object or predicate) defined on the list. 82 | 83 | - ignoreElementsList: the tool will exclude all the RDF triples that contain a URI (as subject, object or predicate) defined on the list. 84 | 85 | - equivalentElementList: each of the elements of a tuple will be replaced by the first element of it on the final diagram. 86 | 87 | - specialElementList: a list composed by tuples of 3 elements () allowing to differenciate/highlight resources on the final diagram.> 88 | 89 | Two sample configuration files are available in the /samples folder. One creates and ER diagram of the ontology. The other one depicts the taxonomy of the classes. 90 | 91 | 92 | ## Contribution 93 | ### To compile and generate the JAR (LINUX) 94 | 1. `cd mavenProject` 95 | 2. `mvn compile; mvn install` 96 | 3. The jar will generated in `mavenProject/target` 97 | 98 | Acknowledgements 99 | =============== 100 | 101 | - In this work we use the GraphViz Java API developed by Laszlo Szathmary (https://github.com/jabbalaci) for generating the diagramas from DOT files https://github.com/jabbalaci/graphviz-java-api 102 | -------------------------------------------------------------------------------- /bin/ar2dtool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/bin/ar2dtool.jar -------------------------------------------------------------------------------- /bin/confER.txt: -------------------------------------------------------------------------------- 1 | pathToDot=/usr/local/bin/dot; 2 | pathToTempDir=/tmp; 3 | imageSize=1501; 4 | rankdir=LR; 5 | 6 | ######## 7 | #shapes# 8 | ######## 9 | 10 | #classShape=diamond; 11 | #individualShape=diamond; 12 | #literalShape=box; 13 | #arrowhead=normal; 14 | #arrowtail=normal; 15 | #arrowdir=forward; 16 | 17 | ######## 18 | #colors# 19 | ######## 20 | 21 | classColor=orange; 22 | #individualColor=orange; 23 | #literalColor=blue; 24 | #arrowColor=blue; 25 | 26 | ############# 27 | #RDF options# 28 | ############# 29 | 30 | nodeNameMode=localname; 31 | ignoreLiterals=true; 32 | ignoreRdfType=true; 33 | synthesizeObjectProperties=true; 34 | 35 | 36 | ####### 37 | #lists# 38 | ####### 39 | 40 | 41 | ignoreElementList=[]; -------------------------------------------------------------------------------- /bin/confTaxonomy.txt: -------------------------------------------------------------------------------- 1 | pathToDot=/usr/local/bin/dot; 2 | pathToTempDir=/tmp; 3 | imageSize=1501; 4 | rankdir=LR; 5 | 6 | ######## 7 | #shapes# 8 | ######## 9 | 10 | #classShape=diamond; 11 | #individualShape=diamond; 12 | #literalShape=box; 13 | #arrowhead=normal; 14 | #arrowtail=normal; 15 | #arrowdir=forward; 16 | 17 | ######## 18 | #colors# 19 | ######## 20 | 21 | #classColor=orange; 22 | #individualColor=orange; 23 | #literalColor=blue; 24 | #arrowColor=blue; 25 | 26 | 27 | ############# 28 | #RDF options# 29 | ############# 30 | 31 | nodeNameMode=localname; 32 | ignoreLiterals=true; 33 | ignoreRdfType=false; 34 | synthesizeObjectProperties=false; 35 | 36 | 37 | ####### 38 | #lists# 39 | ####### 40 | 41 | 42 | includeOnlyElementList=[ 43 | < 44 | http://www.w3.org/2000/01/rdf-schema#subClassOf 45 | > 46 | ]; -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | AR2DTool doc 4 | 5 | 6 |

Coming soon...

7 | 8 | -------------------------------------------------------------------------------- /lib/ar2dtool-0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/lib/ar2dtool-0.1.jar -------------------------------------------------------------------------------- /mavenProject/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .project 3 | .settings 4 | .classpath 5 | 6 | -------------------------------------------------------------------------------- /mavenProject/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | es.upm.oeg 6 | ar2dtool 7 | 1.3.0 8 | jar 9 | 10 | ar2dtool 11 | https://github.com/idafensp/ar2dtool 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.3 22 | 23 | 1.7 24 | 1.7 25 | 26 | 27 | 28 | maven-jar-plugin 29 | 2.4 30 | 31 | 32 | default-jar 33 | package 34 | 35 | jar 36 | 37 | 38 | 39 | 40 | 41 | 42 | es.upm.oeg.ar2dtool.Main 43 | 44 | 45 | 46 | 47 | 48 | maven-assembly-plugin 49 | 50 | 51 | package 52 | 53 | single 54 | 55 | 56 | 57 | 58 | 59 | 60 | es.upm.oeg.ar2dtool.Main 61 | 62 | 63 | 64 | jar-with-dependencies 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.apache.jena 73 | jena-arq 74 | 2.13.0 75 | 76 | 77 | org.apache.jena 78 | jena-core 79 | 2.13.0 80 | 81 | 82 | 83 | OEG 84 | www.oeg-upm.net 85 | 86 | 87 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/Main.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool; 2 | 3 | /* 4 | * Copyright 2012-2013 Ontology Engineering Group, Universidad Politécnica de Madrid, Spain 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance 7 | with the License. You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed under 11 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | either express or implied. See the License for the specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | 16 | import java.util.logging.Level; 17 | 18 | import es.upm.oeg.ar2dtool.exceptions.ConfigKeyNotFound; 19 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 20 | import es.upm.oeg.ar2dtool.exceptions.NullTripleMember; 21 | import es.upm.oeg.ar2dtool.exceptions.RDFInputNotValid; 22 | import es.upm.oeg.ar2dtool.exceptions.RDFNotFound; 23 | import es.upm.oeg.ar2dtool.logger.AR2DToolLogger; 24 | import es.upm.oeg.ar2dtool.utils.dot.DOTGenerator; 25 | import es.upm.oeg.ar2dtool.utils.graphml.GraphMLGenerator; 26 | 27 | public class Main { 28 | 29 | private static final int ARG_LENGTH = 8; 30 | public static String syntaxErrorMsg = "Syntax error. Please use the following syntax \"java -jar ar2dtool.jar -i PathToInputRdfFile -o FileToOutputFile -t OutputFileType -c PathToConfFile [-d] [-mnt MaxNumberOfTriples]\""; 31 | private static String pathToInputFile = ""; 32 | private static String pathToOuputFile = ""; 33 | private static String outputFileType = ""; 34 | private static String pathToConfFile = ""; 35 | private static int maxNumberOfTriples = -1; 36 | 37 | private static boolean DEBUG = false; 38 | 39 | // LOGGING 40 | private static Level logLevelToSee = Level.INFO; 41 | private static Level logLevel = Level.FINE; 42 | private static final AR2DToolLogger log = AR2DToolLogger.getLogger("AR2DTOOL"); 43 | 44 | //GENERATION FLAGS 45 | private static boolean GENERATE_GV = false; 46 | private static boolean GENERATE_GML = false; 47 | private static boolean COMPILE_GV = false; 48 | private static String temp_dir = ""; 49 | 50 | public static void main(String[] args) { 51 | parseArgs(args); 52 | log.getWriter().setLogLevelDefault(logLevel); 53 | if ((pathToInputFile.equals("")) || (outputFileType.equals("")) 54 | || (pathToOuputFile.equals("")) || (pathToConfFile.equals(""))) { 55 | //WebServices.debugWrite(); 56 | dbg(syntaxErrorMsg,Level.WARNING); 57 | return; 58 | } 59 | 60 | if(DEBUG) 61 | { 62 | logLevelToSee =Level.INFO; 63 | //logLevelToSee =Level.ALL; 64 | dbg("now in debug \n\n\n",Level.INFO); 65 | } 66 | else 67 | { 68 | logLevelToSee =Level.FINE; 69 | } 70 | 71 | log.getWriter().setVisibleLogLevel(logLevelToSee); 72 | log("pathToInputFile:" + pathToInputFile); 73 | log("pathToOuputFile:" + pathToOuputFile); 74 | log("outputFileType:" + outputFileType); 75 | log("pathToConfFile:" + pathToConfFile); 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | RDF2Diagram r2d = new RDF2Diagram(); 85 | 86 | try { 87 | 88 | //load config info 89 | r2d.loadConfigValues(pathToConfFile); 90 | if(temp_dir!=""){ 91 | log("Setting the temp dir to: "+temp_dir); 92 | try{ 93 | r2d.getConf().setKeys("pathToTempDir",temp_dir); 94 | } 95 | catch(ConfigKeyNotFound e){ 96 | log("Exception in setting the temp dir"); 97 | e.printStackTrace(); 98 | } 99 | } 100 | 101 | //print config values 102 | log(r2d.getConf().toString()); 103 | 104 | //load model 105 | r2d.loadRdf(pathToInputFile); 106 | 107 | //check if the model has more triples than allowed 108 | if(r2d.exceedsNumberOfTriples(maxNumberOfTriples)) 109 | { 110 | log("The model exceeds the number of max. number of triples specified (" + maxNumberOfTriples + ")"); 111 | return; 112 | } 113 | 114 | //apply the filters specified in config file 115 | r2d.applyFilters(); 116 | log("model:\n" + r2d.printModel()); 117 | 118 | if(GENERATE_GV) 119 | { 120 | log("Generating GV file..."); 121 | 122 | //get the DOTGenerator with the resultant info 123 | DOTGenerator dg = r2d.getDOTGenerator(); 124 | log("Got Dot Generator"); 125 | //apply transformations 126 | dg.applyTransformations(); 127 | log("Applied Transformations"); 128 | //save the DOT source to file 129 | dg.saveSourceToFile(pathToOuputFile+".dot"); 130 | log("Saved the .dot file"); 131 | 132 | log("Generated! Path="+pathToOuputFile+".dot"); 133 | 134 | 135 | if(COMPILE_GV) 136 | { 137 | log("Getting the DOT Source"); 138 | //get source DOT code 139 | String src = dg.generateDOTSource(); 140 | 141 | 142 | log("Compiling GV, this may take a little while..."); 143 | //compile src code into a graph 144 | int gvo = dg.generateDOTDiagram(src,pathToOuputFile,outputFileType); 145 | 146 | if(gvo!=1) { 147 | log("Problem when compiling the DOT image"); 148 | 149 | } else { 150 | log("Compiled! Path="+pathToOuputFile); 151 | } 152 | 153 | } 154 | } 155 | 156 | if(GENERATE_GML) 157 | { 158 | //get the GraphMLGenerator with the resultant info 159 | GraphMLGenerator gg = r2d.getGraphMLGenerator(); 160 | log("Getting GML"); 161 | //apply transformations 162 | gg.applyTransformations(); 163 | 164 | log("GraphML source " + gg.generateGraphMLSource()); 165 | 166 | //save the GraphML source to file 167 | gg.saveSourceToFile(pathToOuputFile+".graphml"); 168 | log("the Graphml is generated"); 169 | } 170 | 171 | 172 | 173 | 174 | 175 | } catch (ConfigFileNotFoundException e) { 176 | // TODO Auto-generated catch block 177 | e.printStackTrace(); 178 | } catch (RDFNotFound e) { 179 | // TODO Auto-generated catch block 180 | e.printStackTrace(); 181 | } catch (RDFInputNotValid e) { 182 | // TODO Auto-generated catch block 183 | e.printStackTrace(); 184 | } catch (NullTripleMember e) { 185 | // TODO Auto-generated catch block 186 | e.printStackTrace(); 187 | } 188 | 189 | 190 | 191 | } 192 | 193 | private static void parseArgs(String[] args) { 194 | if (args.length < ARG_LENGTH) { 195 | //System.err.println(syntaxErrorMsg); 196 | return; 197 | } 198 | 199 | for (int i = 0; i < args.length; i++) { 200 | if (args[i].equals("-i")) { 201 | i++; 202 | pathToInputFile = args[i]; 203 | } else { 204 | 205 | if (args[i].equals("-o")) { 206 | i++; 207 | pathToOuputFile = args[i]; 208 | } else { 209 | 210 | if (args[i].equals("-t")) { 211 | i++; 212 | outputFileType = args[i]; 213 | } else { 214 | 215 | if (args[i].equals("-c")) { 216 | i++; 217 | pathToConfFile = args[i]; 218 | } else { 219 | if (args[i].equals("-d")) { 220 | DEBUG = true; 221 | } else { 222 | if(args[i].equals("-gv")) 223 | { 224 | GENERATE_GV=true; 225 | } 226 | else 227 | { 228 | if(args[i].equals("-gml")) 229 | { 230 | GENERATE_GML=true; 231 | } 232 | else 233 | { 234 | if(args[i].equals("-GV")) 235 | { 236 | GENERATE_GV=true; 237 | COMPILE_GV=true; 238 | } 239 | else 240 | { 241 | if(args[i].equals("-mnt")) 242 | { 243 | i++; 244 | maxNumberOfTriples = Integer.valueOf(args[i]); 245 | } 246 | else{ 247 | if(args[i].equals("-tmp")){ 248 | i++; 249 | temp_dir = args[i]; 250 | } 251 | else 252 | { 253 | dbg(syntaxErrorMsg,Level.WARNING); 254 | return; 255 | } 256 | } 257 | } 258 | } 259 | } 260 | } 261 | } 262 | } 263 | } 264 | } 265 | } 266 | } 267 | 268 | private static void log(String msg) { 269 | log.getWriter().log(msg); 270 | log.getWriter().log(msg,Level.INFO); 271 | } 272 | 273 | private static void dbg(String msg, Level logLevel){ 274 | log.getWriter().log(msg,logLevel); 275 | } 276 | 277 | } 278 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/MainOld.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool; 2 | 3 | /* 4 | * Copyright 2012-2013 Ontology Engineering Group, Universidad Politécnica de Madrid, Spain 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance 7 | with the License. You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed under 11 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | either express or implied. See the License for the specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | import java.io.File; 16 | import java.io.FileNotFoundException; 17 | import java.io.PrintWriter; 18 | 19 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 20 | import es.upm.oeg.ar2dtool.utils.ConfigValues; 21 | import es.upm.oeg.ar2dtool.utils.dot.GraphVizIOld; 22 | import es.upm.oeg.ar2dtool.utils.dot.Rdf2Gv; 23 | import es.upm.oeg.ar2dtool.utils.graphml.GraphMLGenerator; 24 | 25 | public class MainOld { 26 | 27 | private static final int ARG_LENGTH = 8; 28 | public static String syntaxErrorMsg = "Syntax error. Please use the following syntax \"java -jar ar2dtool.jar -i PathToInputRdfFile -o FileToOutputFile -t OutputFileType -c PathToConfFile [-d]\""; 29 | private static String pathToInputFile=""; 30 | private static String pathToOuputFile=""; 31 | private static String outputFileType=""; 32 | private static String pathToConfFile=""; 33 | 34 | private static boolean DEBUG=false; 35 | 36 | public static void main(String[] args) { 37 | 38 | //parsing args 39 | //syntax: 40 | 41 | parseArgs(args); 42 | 43 | if((pathToInputFile.equals(""))||(outputFileType.equals(""))||(pathToOuputFile.equals(""))||(pathToConfFile.equals(""))) 44 | { 45 | System.err.println(syntaxErrorMsg); 46 | return; 47 | } 48 | 49 | dbg("pathToInputFile:" + pathToInputFile); 50 | dbg("pathToOuputFile:" + pathToOuputFile); 51 | dbg("outputFileType:" + outputFileType); 52 | dbg("pathToConfFile:" + pathToConfFile); 53 | 54 | 55 | //read the config file 56 | ConfigValues cv = new ConfigValues(); 57 | try { 58 | cv.readConfigValues(pathToConfFile); 59 | } catch (ConfigFileNotFoundException e1) { 60 | // TODO Auto-generated catch block 61 | e1.printStackTrace(); 62 | } 63 | 64 | dbg("\n"+cv.toString()); 65 | 66 | Rdf2Gv rgv = new Rdf2Gv(pathToInputFile,cv); 67 | 68 | rgv.parseRdf(); 69 | 70 | dbg("Found classes" + rgv.getClasses()); 71 | dbg("Found individuals" + rgv.getIndividuals()); 72 | dbg("Found literals" + rgv.getLiterals()); 73 | 74 | dbg("GraphViz :\n" + rgv.getGvContent()); 75 | 76 | String dotPath = cv.getKeys().get("pathToDot"); 77 | GraphVizIOld gv = new GraphVizIOld(dotPath); 78 | gv.add(rgv.getGvContent()); 79 | 80 | 81 | 82 | //write the GV file 83 | if(cv.getKeys().get("generateGvFile").equals("true")) 84 | { 85 | try { 86 | PrintWriter gvOut = new PrintWriter(pathToOuputFile+".gv"); 87 | gvOut.println(rgv.getGvContent()); 88 | gvOut.close(); 89 | } catch (FileNotFoundException e) { 90 | System.err.println("Error while trying to generate the gv file at "+ pathToOuputFile+".gv"); 91 | e.printStackTrace(); 92 | } 93 | } 94 | 95 | 96 | 97 | //write the image file 98 | File out = new File(pathToOuputFile); 99 | byte[] img = gv.getGraph(gv.getDotSource(), outputFileType); 100 | dbg("img byte[].length="+img.length); 101 | 102 | int code = gv.writeGraphToFile(img , out); 103 | 104 | dbg("writeGraphToFile returns="+code); 105 | if(code==-1) 106 | { 107 | System.err.println("An error ocurred when saving the file " + pathToOuputFile); 108 | } 109 | 110 | 111 | dbg("outputFile length="+out.length()); 112 | if(out.length()==0) 113 | { 114 | System.err.println("File " + pathToOuputFile + " seems to be empty :("); 115 | } 116 | else 117 | { 118 | System.out.println("Done! File " + pathToOuputFile +" generated"); 119 | } 120 | 121 | 122 | // //generate the GraphML file (reading the triples information from the Rdf2Gv object) 123 | // if(cv.keys.get("generateGraphMLFile").equals("true")) 124 | // { 125 | // GraphMLGenerator gml = new GraphMLGenerator(rgv.getDtLines()); 126 | // dbg(gml.generateXML()); 127 | // } 128 | 129 | 130 | 131 | } 132 | 133 | 134 | private static void parseArgs(String[] args) 135 | { 136 | if(args.length loggers=new HashMap(); 29 | public static AR2DToolLogger getLogger(String name){ 30 | if(loggers.containsKey(name)){ 31 | return loggers.get(name); 32 | }else{ 33 | AR2DToolLogger logger = new AR2DToolLogger(name); 34 | loggers.put(name, logger); 35 | return logger; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/logger/DefaultLoggerWriter.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.logger; 2 | 3 | import java.util.logging.Level; 4 | import java.util.logging.Logger; 5 | 6 | public class DefaultLoggerWriter implements LoggerWriterInterface { 7 | 8 | private String loggerName; 9 | private Logger log; 10 | private Level logLevelToSee = Level.INFO; 11 | private Level logLevel = Level.FINE; 12 | 13 | public DefaultLoggerWriter(String loggerName) { 14 | this.loggerName = loggerName; 15 | log = Logger.getLogger(loggerName); 16 | log.setLevel(logLevelToSee); 17 | } 18 | 19 | public DefaultLoggerWriter(String loggerName, Level visibleLevel) { 20 | this.loggerName = loggerName; 21 | log = Logger.getLogger(loggerName); 22 | logLevelToSee = visibleLevel; 23 | log.setLevel(logLevelToSee); 24 | } 25 | public DefaultLoggerWriter(String loggerName,Level visibleLevel, Level logLevelDefault) { 26 | this.loggerName = loggerName; 27 | log = Logger.getLogger(loggerName); 28 | logLevelToSee = visibleLevel; 29 | log.setLevel(logLevelToSee); 30 | logLevel = logLevelDefault; 31 | } 32 | 33 | @Override 34 | public void log(Exception ex, Level logLevel) { 35 | log.log(logLevel, "Exception: ", ex); 36 | } 37 | 38 | @Override 39 | public void log(String msg, Level logLevel) { 40 | log.log(logLevel,msg); 41 | } 42 | 43 | @Override 44 | public void log(String msg) { 45 | log.log(logLevel,msg); 46 | } 47 | 48 | @Override 49 | public void setLogLevelDefault(Level logLevelDefault) { 50 | logLevel = logLevelDefault; 51 | } 52 | 53 | @Override 54 | public void setVisibleLogLevel(Level visibleLevel) { 55 | logLevelToSee = visibleLevel; 56 | log.setLevel(logLevelToSee); 57 | } 58 | 59 | @Override 60 | public Level getVisibleLogLevel() { 61 | return logLevelToSee; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/logger/LoggerWriterInterface.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.logger; 2 | 3 | import java.util.logging.Level; 4 | 5 | public interface LoggerWriterInterface { 6 | public void log(String msg); 7 | 8 | public void log(String msg, Level logLevel); 9 | 10 | public void log(Exception ex, Level logLevel); 11 | 12 | public void setLogLevelDefault(Level logLevelDefault); 13 | 14 | public void setVisibleLogLevel(Level visibleLevel); 15 | 16 | public Level getVisibleLogLevel(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/AR2DTriple.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils; 2 | 3 | import com.hp.hpl.jena.rdf.model.Statement; 4 | 5 | import es.upm.oeg.ar2dtool.exceptions.NullTripleMember; 6 | 7 | 8 | //class for storing each line of the DOT syntax, including the source node, target node and the edge. 9 | public class AR2DTriple 10 | { 11 | private String source; 12 | private String target; 13 | private String edge; 14 | 15 | public AR2DTriple(String s, String t, String e) throws NullTripleMember 16 | { 17 | source = s; 18 | target = t; 19 | edge = e; 20 | 21 | if((source==null)||(edge==null)||(target==null)||(source.equals("null"))||(edge.equals("null"))||(target.equals("null"))) 22 | { 23 | throw new NullTripleMember("Triple with null member: "); 24 | } 25 | } 26 | 27 | public String getSource() { 28 | return source; 29 | } 30 | 31 | public void setSource(String source) { 32 | this.source = source; 33 | } 34 | 35 | public String getTarget() { 36 | return target; 37 | } 38 | 39 | public void setTarget(String target) { 40 | this.target = target; 41 | } 42 | 43 | public String getEdge() { 44 | return edge; 45 | } 46 | 47 | public void setEdge(String edge) { 48 | this.edge = edge; 49 | } 50 | 51 | public String toString() 52 | { 53 | return "[" + source + "-" + edge + "->" + target + "]\n"; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/ConfigValues.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.DataInputStream; 5 | import java.io.FileInputStream; 6 | import java.io.FileNotFoundException; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.Iterator; 13 | import java.util.Map; 14 | import java.util.logging.Level; 15 | 16 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 17 | import es.upm.oeg.ar2dtool.exceptions.ConfigKeyNotFound; 18 | 19 | public class ConfigValues implements Serializable{ 20 | 21 | /** 22 | * 23 | */ 24 | private static final long serialVersionUID = -4522640585732511884L; 25 | private static final String fileNotFoundErrorMsg = "CONFIG FILE ERROR: couldn't open config file at "; 26 | private static final String fileNotCompliantErrorMsg = "CONFIG FILE ERROR: config file is not compliant with the sintax aroun line "; 27 | 28 | private static Level logLevel; 29 | 30 | 31 | private ArrayList> equivalentElementList; 32 | private ArrayList> specialElementsList; 33 | private ArrayList ignoreElementList; 34 | private ArrayList includeOnlyElementList; 35 | 36 | 37 | private Map keys; 38 | 39 | 40 | public ConfigValues() 41 | { 42 | equivalentElementList = new ArrayList>(); 43 | specialElementsList = new ArrayList>(); 44 | ignoreElementList = new ArrayList(); 45 | includeOnlyElementList = new ArrayList(); 46 | 47 | //load the default values of the config simple properties 48 | keys = new HashMap(); 49 | keys.put("pathToDot","noPathToDot"); 50 | keys.put("pathToTempDir","noPathToTemp"); 51 | keys.put("rankdir","LB"); 52 | keys.put("classShape","rectangle"); 53 | keys.put("individualShape","rectangle"); 54 | keys.put("literalShape","rectangle"); 55 | keys.put("arrowhead","normal"); 56 | keys.put("arrowtail","normal"); 57 | keys.put("arrowdir","forward"); 58 | keys.put("classColor","black"); 59 | keys.put("individualColor","black"); 60 | keys.put("literalColor","black"); 61 | keys.put("arrowColor","black"); 62 | keys.put("ignoreLiterals","false"); 63 | keys.put("nodeNameMode","fulluri"); 64 | keys.put("synthesizeObjectProperties","false"); 65 | keys.put("ignoreRdfType","false"); 66 | keys.put("imageSize","500"); 67 | } 68 | 69 | 70 | 71 | public void readConfigValues(String configPath) throws ConfigFileNotFoundException 72 | { 73 | int lineCounter = 1; 74 | 75 | //open the file and read it line by line 76 | try { 77 | 78 | FileInputStream fstream; 79 | fstream = new FileInputStream(configPath); 80 | // Get the object of DataInputStream 81 | DataInputStream in = new DataInputStream(fstream); 82 | BufferedReader br = new BufferedReader(new InputStreamReader(in)); 83 | String strLine; 84 | 85 | 86 | // Read File Line By Line 87 | while ((strLine = br.readLine()) != null) 88 | { 89 | strLine=strLine.replaceAll("\\s+",""); 90 | //dbg(strLine); 91 | processLine(strLine, br); 92 | lineCounter++; 93 | } 94 | 95 | 96 | in.close(); 97 | 98 | } 99 | catch (FileNotFoundException e) { 100 | throw new ConfigFileNotFoundException(fileNotFoundErrorMsg + configPath + "\n" + e.getMessage()); 101 | } catch (IOException e) { 102 | throw new ConfigFileNotFoundException(fileNotFoundErrorMsg + configPath + "\n" + e.getMessage()); 103 | } catch (Exception e) {// Catch exception if any 104 | throw new ConfigFileNotFoundException(fileNotCompliantErrorMsg + lineCounter + "\n" + e.getMessage()); 105 | } 106 | } 107 | 108 | private void processLine(String strLine, BufferedReader br) throws IOException { 109 | if((strLine.startsWith("#"))||(strLine.equals(""))) 110 | return; //skip comment lines 111 | 112 | if(strLine.startsWith("equivalentElementList")) 113 | { 114 | equivalentElementList = loadEquivalentElementList(strLine, br); 115 | return; 116 | } 117 | 118 | 119 | if(strLine.startsWith("specialElementsList")) 120 | { 121 | specialElementsList = loadSpecialElementsList(strLine, br); 122 | return; 123 | } 124 | 125 | 126 | if(strLine.startsWith("includeOnlyElementList")) 127 | { 128 | includeOnlyElementList = loadIncludeOnlyElementList(strLine, br); 129 | return; 130 | } 131 | 132 | 133 | if(strLine.startsWith("ignoreElementList")) 134 | { 135 | ignoreElementList = loadIgnoreElementsList(strLine, br); 136 | return; 137 | } 138 | 139 | //at this point it must be a single property 140 | String k=strLine.substring(0, strLine.indexOf("=")); 141 | if(keys.containsKey(k)) 142 | { 143 | String v = strLine.substring(strLine.indexOf("=")+1,strLine.indexOf(";")); 144 | keys.put(k, v); 145 | } 146 | 147 | } 148 | 149 | private ArrayList> loadEquivalentElementList(String strLine, BufferedReader br) throws IOException 150 | { 151 | ArrayList> res = new ArrayList>(); 152 | String propLine = readPropListLine(strLine,br); 153 | 154 | while(propLine.contains("<")) 155 | { 156 | String st = propLine.substring(propLine.indexOf("<")+1, propLine.indexOf(">")); 157 | propLine = propLine.substring(propLine.indexOf(">")+1); 158 | //dbg("ST:" + st); 159 | res.add(readCommaValues(st)); 160 | } 161 | 162 | return res; 163 | } 164 | 165 | 166 | 167 | private ArrayList> loadSpecialElementsList(String strLine, BufferedReader br) throws IOException 168 | { 169 | ArrayList> res = new ArrayList>(); 170 | String propLine = readPropListLine(strLine,br); 171 | 172 | while(propLine.contains("<")) 173 | { 174 | String st = propLine.substring(propLine.indexOf("<")+1, propLine.indexOf(">")); 175 | propLine = propLine.substring(propLine.indexOf(">")+1); 176 | //dbg("ST:" + st); 177 | res.add(readCommaValues(st)); 178 | } 179 | 180 | return res; 181 | } 182 | 183 | 184 | 185 | private ArrayList loadIncludeOnlyElementList(String strLine, BufferedReader br) throws IOException 186 | { 187 | ArrayList res = new ArrayList(); 188 | String propLine = readPropListLine(strLine,br); 189 | 190 | String st = propLine.substring(propLine.indexOf("<")+1, propLine.indexOf(">")); 191 | res = readCommaValues(st); 192 | 193 | return res; 194 | } 195 | 196 | 197 | 198 | private ArrayList loadIgnoreElementsList(String strLine, BufferedReader br) throws IOException 199 | { 200 | ArrayList res = new ArrayList(); 201 | String propLine = readPropListLine(strLine,br); 202 | 203 | String st = propLine.substring(propLine.indexOf("<")+1, propLine.indexOf(">")); 204 | res = readCommaValues(st); 205 | 206 | return res; 207 | } 208 | 209 | private ArrayList readCommaValues(String st) 210 | { 211 | ArrayList res = new ArrayList(); 212 | 213 | while(st.contains(",")) 214 | { 215 | String prop = st.substring(0,st.indexOf(",")); 216 | res.add(prop); 217 | st = st.substring(st.indexOf(",")+1); 218 | } 219 | 220 | res.add(st); 221 | 222 | return res; 223 | } 224 | 225 | private String readPropListLine(String strLine, BufferedReader br) throws IOException 226 | { 227 | String propListLine = strLine; 228 | 229 | 230 | while ((!strLine.contains("];"))&&(strLine = br.readLine()) != null) 231 | { 232 | strLine=strLine.replaceAll("\\s+",""); 233 | 234 | if(strLine.startsWith("#")) 235 | continue; 236 | 237 | propListLine+=strLine; 238 | } 239 | return propListLine; 240 | } 241 | 242 | 243 | public String toString() 244 | { 245 | String res = "Configuration Values:\n"; 246 | res += "-------------------------------\n"; 247 | res+="equivalentElementList:"+equivalentElementList.toString()+"\n"; 248 | res+="specialElementsList:"+specialElementsList.toString()+"\n"; 249 | res+="ignoreElementList"+ignoreElementList.toString()+"\n"; 250 | res+="includeOnlyElementList"+includeOnlyElementList.toString()+"\n"; 251 | 252 | Iterator it = keys.entrySet().iterator(); 253 | while (it.hasNext()) { 254 | Map.Entry kv = (Map.Entry)it.next(); 255 | res+=kv.getKey()+":"+kv.getValue()+"\n"; 256 | } 257 | 258 | 259 | res += "-------------------------------\n"; 260 | 261 | return res; 262 | } 263 | 264 | public static Level getLogLevel() { 265 | return logLevel; 266 | } 267 | 268 | 269 | 270 | public static void setLogLevel(Level ll) { 271 | logLevel = ll; 272 | } 273 | 274 | public ArrayList> getEquivalentElementList() { 275 | return equivalentElementList; 276 | } 277 | 278 | 279 | 280 | public void setEquivalentElementList( 281 | ArrayList> equivalentElementList) { 282 | this.equivalentElementList = equivalentElementList; 283 | } 284 | 285 | 286 | 287 | public ArrayList> getSpecialElementsList() { 288 | return specialElementsList; 289 | } 290 | 291 | 292 | 293 | public void setSpecialElementsList( 294 | ArrayList> specialElementsList) { 295 | this.specialElementsList = specialElementsList; 296 | } 297 | 298 | 299 | 300 | public ArrayList getIgnoreElementList() { 301 | return ignoreElementList; 302 | } 303 | 304 | 305 | public boolean ignoreElements() { 306 | return !ignoreElementList.isEmpty(); 307 | } 308 | 309 | 310 | public boolean includeOnlyElements() { 311 | return !includeOnlyElementList.isEmpty(); 312 | } 313 | 314 | 315 | 316 | public boolean equivalentElements() { 317 | return !equivalentElementList.isEmpty(); 318 | } 319 | 320 | 321 | 322 | public void setIgnoreElementList(ArrayList ignoreElementList) { 323 | this.ignoreElementList = ignoreElementList; 324 | } 325 | 326 | 327 | 328 | public ArrayList getIncludeOnlyElementList() { 329 | return includeOnlyElementList; 330 | } 331 | 332 | 333 | 334 | public void setIncludeOnlyElementList(ArrayList includeOnlyElementList) { 335 | this.includeOnlyElementList = includeOnlyElementList; 336 | } 337 | 338 | 339 | 340 | public Map getKeys() { 341 | return keys; 342 | } 343 | 344 | 345 | 346 | public void setKeys(String key, String value) throws ConfigKeyNotFound 347 | { 348 | if(this.keys.containsKey(key)) 349 | { 350 | this.keys.put(key, value); 351 | } 352 | else 353 | { 354 | throw new ConfigKeyNotFound("Confing key " + key + " could not be found"); 355 | } 356 | } 357 | 358 | public boolean ignoreLiterals() 359 | { 360 | return keys.get("ignoreLiterals").equals("true"); 361 | } 362 | 363 | public boolean ignoreRDFType() 364 | { 365 | return keys.get("ignoreRdfType").equals("true"); 366 | } 367 | 368 | 369 | public boolean synthesizeObjectProperties() 370 | { 371 | return keys.get("synthesizeObjectProperties").equals("true"); 372 | } 373 | 374 | 375 | 376 | public NodeNameMode getNodeNameMode() 377 | { 378 | if(keys.get("nodeNameMode").equals("fulluri")) 379 | return NodeNameMode.FULLURI; 380 | 381 | if(keys.get("nodeNameMode").equals("localname")) 382 | return NodeNameMode.LOCALNAME; 383 | 384 | if(keys.get("nodeNameMode").equals("prefix")) 385 | return NodeNameMode.PREFIX; 386 | 387 | 388 | //by default we assume fulluri 389 | return NodeNameMode.FULLURI; 390 | } 391 | 392 | 393 | 394 | } 395 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/NodeNameMode.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils; 2 | 3 | public enum NodeNameMode { 4 | FULLURI, 5 | LOCALNAME, 6 | PREFIX 7 | } 8 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/NodeNames.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils; 2 | 3 | public enum NodeNames { 4 | FULLURI, 5 | LOCALNAME, 6 | PREFIX 7 | } 8 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/dot/DOTTriple.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.dot; 2 | 3 | import com.hp.hpl.jena.rdf.model.Statement; 4 | 5 | 6 | //class for storing each line of the DOT syntax, including the source node, target node and the edge. 7 | public class DOTTriple 8 | { 9 | public String source; 10 | public String target; 11 | public String edge; 12 | 13 | public DOTTriple(Statement st) 14 | { 15 | source = st.getSubject().getURI(); 16 | target = st.getPredicate().getURI(); 17 | edge = st.getObject().toString(); 18 | } 19 | 20 | public DOTTriple(String s, String t, String e) 21 | { 22 | source = s; 23 | target = t; 24 | edge = e; 25 | } 26 | 27 | public String getSource() { 28 | return source; 29 | } 30 | 31 | public void setSource(String source) { 32 | this.source = source; 33 | } 34 | 35 | public String getTarget() { 36 | return target; 37 | } 38 | 39 | public void setTarget(String target) { 40 | this.target = target; 41 | } 42 | 43 | public String getEdge() { 44 | return edge; 45 | } 46 | 47 | public void setEdge(String edge) { 48 | this.edge = edge; 49 | } 50 | 51 | public String toString() 52 | { 53 | return "[" + source + "-" + edge + "->" + target + "]\n"; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/dot/GraphViz.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.dot; 2 | 3 | //GraphViz.java - a simple API to call dot from Java programs 4 | 5 | /*$Id$*/ 6 | /* 7 | ****************************************************************************** 8 | * * 9 | * (c) Copyright Laszlo Szathmary * 10 | * * 11 | * This program is free software; you can redistribute it and/or modify it * 12 | * under the terms of the GNU Lesser General Public License as published by * 13 | * the Free Software Foundation; either version 2.1 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | * This program is distributed in the hope that it will be useful, but * 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * 18 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * 19 | * License for more details. * 20 | * * 21 | * You should have received a copy of the GNU Lesser General Public License * 22 | * along with this program; if not, write to the Free Software Foundation, * 23 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 24 | * * 25 | ****************************************************************************** 26 | */ 27 | 28 | import java.io.BufferedReader; 29 | import java.io.DataInputStream; 30 | import java.io.File; 31 | import java.io.FileInputStream; 32 | import java.io.FileOutputStream; 33 | import java.io.FileWriter; 34 | import java.io.InputStreamReader; 35 | import java.util.Arrays; 36 | import java.util.Properties; 37 | import java.util.logging.Level; 38 | 39 | import org.apache.log4j.lf5.LogLevel; 40 | 41 | import es.upm.oeg.ar2dtool.logger.AR2DToolLogger; 42 | 43 | /** 44 | *
45 | *
Purpose: GraphViz Java API 46 | *
47 | * 48 | *
Description: 49 | *
With this Java class you can simply call dot 50 | * from your Java programs. 51 | *
Example usage: 52 | *
53 | *
 54 | *    GraphViz gv = new GraphViz();
 55 | *    gv.addln(gv.start_graph());
 56 | *    gv.addln("A -> B;");
 57 | *    gv.addln("A -> C;");
 58 | *    gv.addln(gv.end_graph());
 59 | *    System.out.println(gv.getDotSource());
 60 | *
 61 | *    String type = "gif";
 62 | *    String representationType="dot";
 63 | *    File out = new File("out." + type);   // out.gif in this example
 64 | *    gv.writeGraphToFile( gv.getGraph(gv.getDotSource(), type, representationType), out );
 65 | * 
66 | *
67 | * 68 | *
69 | * 70 | * @version v0.6, 2013/11/28 (November) -- Patch of Olivier Duplouy is added. Now you 71 | * can specify the representation type of your graph: dot, neato, fdp, sfdp, twopi, circo 72 | * @version v0.5.1, 2013/03/18 (March) -- Patch of Juan Hoyos (Mac support) 73 | * @version v0.5, 2012/04/24 (April) -- Patch of Abdur Rahman (OS detection + start subgraph + 74 | * read config file) 75 | * @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you 76 | * can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc. 77 | * @version v0.3, 2010/11/29 (November) -- Windows support + ability to read the graph from a text file 78 | * @version v0.2, 2010/07/22 (July) -- bug fix 79 | * @version v0.1, 2003/12/04 (December) -- first release 80 | * @author Laszlo Szathmary (jabba.laci@gmail.com) 81 | */ 82 | public class GraphViz 83 | { 84 | /** 85 | * Detects the client's operating system. 86 | */ 87 | private final static String osName = System.getProperty("os.name").replaceAll("\\s",""); 88 | 89 | private final static AR2DToolLogger logger = AR2DToolLogger.getLogger("AR2DTOOL"); 90 | 91 | /** 92 | * Load the config.properties file. 93 | */ 94 | // private final static String cfgProp = "config.properties"; 95 | // private final static Properties configFile = new Properties() { 96 | // private final static long serialVersionUID = 1L; { 97 | // try { 98 | // load(new FileInputStream(cfgProp)); 99 | // } catch (Exception e) { 100 | // System.err.println(e); 101 | // } 102 | // } 103 | // }; 104 | 105 | /** 106 | * The dir. where temporary files will be created. 107 | */ 108 | private static String TEMP_DIR = ""; //= configFile.getProperty("tempDirFor" + osName); 109 | 110 | /** 111 | * Where is your dot program located? It will be called externally. 112 | */ 113 | private static String DOT = ""; //= configFile.getProperty("dotFor" + osName); 114 | 115 | /** 116 | * The image size in dpi. 96 dpi is normal size. Higher values are 10% higher each. 117 | * Lower values 10% lower each. 118 | * 119 | * dpi patch by Peter Mueller 120 | */ 121 | private int[] dpiSizes = {46, 51, 57, 63, 70, 78, 86, 96, 106, 116, 128, 141, 155, 170, 187, 206, 226, 249}; 122 | 123 | /** 124 | * Define the index in the image size array. 125 | */ 126 | private int currentDpiPos = 7; 127 | 128 | /** 129 | * Increase the image size (dpi). 130 | */ 131 | public void increaseDpi() { 132 | if ( this.currentDpiPos < (this.dpiSizes.length - 1) ) { 133 | ++this.currentDpiPos; 134 | } 135 | } 136 | 137 | /** 138 | * Decrease the image size (dpi). 139 | */ 140 | public void decreaseDpi() { 141 | if (this.currentDpiPos > 0) { 142 | --this.currentDpiPos; 143 | } 144 | } 145 | 146 | public int getImageDpi() { 147 | return this.dpiSizes[this.currentDpiPos]; 148 | } 149 | 150 | /** 151 | * The source of the graph written in dot language. 152 | */ 153 | private StringBuilder graph = new StringBuilder(); 154 | 155 | /** 156 | * Constructor: creates a new GraphViz object that will contain 157 | * a graph. 158 | * @param dotPath 159 | * @param tempDirPath 160 | */ 161 | public GraphViz(String dotPath, String tempDirPath) { 162 | // empty 163 | DOT=dotPath; 164 | TEMP_DIR=tempDirPath; 165 | } 166 | 167 | /** 168 | * Returns the graph's source description in dot language. 169 | * @return Source of the graph in dot language. 170 | */ 171 | public String getDotSource() { 172 | return this.graph.toString(); 173 | } 174 | 175 | /** 176 | * Adds a string to the graph's source (without newline). 177 | */ 178 | public void add(String line) { 179 | this.graph.append(line); 180 | } 181 | 182 | /** 183 | * Adds a string to the graph's source (with newline). 184 | */ 185 | public void addln(String line) { 186 | this.graph.append(line + "\n"); 187 | } 188 | 189 | /** 190 | * Adds a newline to the graph's source. 191 | */ 192 | public void addln() { 193 | this.graph.append('\n'); 194 | } 195 | 196 | public void clearGraph(){ 197 | this.graph = new StringBuilder(); 198 | } 199 | 200 | /** 201 | * Returns the graph as an image in binary format. 202 | * @param dot_source Source of the graph to be drawn. 203 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 204 | * @param representationType Type of how you want to represent the graph: 205 | *
    206 | *
  • dot
  • 207 | *
  • neato
  • 208 | *
  • fdp
  • 209 | *
  • sfdp
  • 210 | *
  • twopi
  • 211 | *
  • circo
  • 212 | *
213 | * @see http://www.graphviz.org under the Roadmap title 214 | * @return A byte array containing the image of the graph. 215 | */ 216 | public byte[] getGraph(String dot_source, String type, String representationType) 217 | { 218 | File dot; 219 | byte[] img_stream = null; 220 | 221 | try { 222 | logger.getWriter().log("write dot source to file: "+dot_source, Level.INFO); 223 | dot = writeDotSourceToFile(dot_source); 224 | if (dot != null) 225 | { 226 | img_stream = get_img_stream(dot, type, representationType); 227 | if (dot.delete() == false) 228 | logger.getWriter().log("Warning: " + dot.getAbsolutePath() + " could not be deleted!",Level.WARNING); 229 | return img_stream; 230 | } 231 | return null; 232 | } catch (java.io.IOException ioe) { return null; } 233 | } 234 | 235 | /** 236 | * Writes the graph's image in a file. 237 | * @param img A byte array containing the image of the graph. 238 | * @param file Name of the file to where we want to write. 239 | * @return Success: 1, Failure: -1 240 | */ 241 | public int writeGraphToFile(byte[] img, String file) 242 | { 243 | File to = new File(file); 244 | return writeGraphToFile(img, to); 245 | } 246 | 247 | /** 248 | * Writes the graph's image in a file. 249 | * @param img A byte array containing the image of the graph. 250 | * @param to A File object to where we want to write. 251 | * @return Success: 1, Failure: -1 252 | */ 253 | public int writeGraphToFile(byte[] img, File to) 254 | { 255 | try { 256 | FileOutputStream fos = new FileOutputStream(to); 257 | fos.write(img); 258 | fos.close(); 259 | } catch (java.io.IOException ioe) { return -1; } 260 | return 1; 261 | } 262 | 263 | /** 264 | * It will call the external dot program, and return the image in 265 | * binary format. 266 | * @param dot Source of the graph (in dot language). 267 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 268 | * @param representationType Type of how you want to represent the graph: 269 | *
    270 | *
  • dot
  • 271 | *
  • neato
  • 272 | *
  • fdp
  • 273 | *
  • sfdp
  • 274 | *
  • twopi
  • 275 | *
  • circo
  • 276 | *
277 | * @see http://www.graphviz.org under the Roadmap title 278 | * @return The image of the graph in .gif format. 279 | */ 280 | private byte[] get_img_stream(File dot, String type, String representationType) 281 | { 282 | File img; 283 | byte[] img_stream = null; 284 | 285 | try { 286 | img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR)); 287 | Runtime rt = Runtime.getRuntime(); 288 | 289 | // patch by Mike Chenault 290 | // representation type with -K argument by Olivier Duplouy 291 | //String[] args = {DOT, "-T"+type, "-K"+representationType, "-Gdpi="+dpiSizes[this.currentDpiPos], dot.getAbsolutePath(), "-o", img.getAbsolutePath()}; 292 | //Removed -Gdpi param because it generate a bad SVG file. 293 | String[] args = {DOT, "-T"+type, "-K"+representationType, dot.getAbsolutePath(), "-o", img.getAbsolutePath()}; 294 | Process p = rt.exec(args); 295 | p.waitFor(); 296 | 297 | FileInputStream in = new FileInputStream(img.getAbsolutePath()); 298 | img_stream = new byte[in.available()]; 299 | in.read(img_stream); 300 | // Close it if we need to 301 | if( in != null ) in.close(); 302 | 303 | if (img.delete() == false) 304 | logger.getWriter().log("Warning: " + img.getAbsolutePath() + " could not be deleted!",Level.WARNING); 305 | } 306 | catch (java.io.IOException ioe) { 307 | logger.getWriter().log("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+"\n"+" or in calling external command",Level.SEVERE); 308 | logger.getWriter().log(ioe,Level.SEVERE); 309 | //ioe.printStackTrace(); 310 | } 311 | catch (java.lang.InterruptedException ie) { 312 | logger.getWriter().log("Error: the execution of the external program was interrupted",Level.SEVERE); 313 | logger.getWriter().log(ie,Level.SEVERE); 314 | //ie.printStackTrace(); 315 | } 316 | 317 | return img_stream; 318 | } 319 | 320 | /** 321 | * Writes the source of the graph in a file, and returns the written file 322 | * as a File object. 323 | * @param str Source of the graph (in dot language). 324 | * @return The file (as a File object) that contains the source of the graph. 325 | */ 326 | private File writeDotSourceToFile(String str) throws java.io.IOException 327 | { 328 | File temp; 329 | try { 330 | logger.getWriter().log("TEMP DIR: "+GraphViz.TEMP_DIR, Level.INFO); 331 | temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphViz.TEMP_DIR)); 332 | FileWriter fout = new FileWriter(temp); 333 | fout.write(str); 334 | fout.close(); 335 | } 336 | catch (Exception e) { 337 | System.err.println("Error: I/O error while writing the dot source to temp file!"); 338 | return null; 339 | } 340 | return temp; 341 | } 342 | 343 | /** 344 | * Returns a string that is used to start a graph. 345 | * @return A string to open a graph. 346 | */ 347 | public String start_graph() { 348 | return "digraph G {"; 349 | } 350 | 351 | /** 352 | * Returns a string that is used to end a graph. 353 | * @return A string to close a graph. 354 | */ 355 | public String end_graph() { 356 | return "}"; 357 | } 358 | 359 | /** 360 | * Takes the cluster or subgraph id as input parameter and returns a string 361 | * that is used to start a subgraph. 362 | * @return A string to open a subgraph. 363 | */ 364 | public String start_subgraph(int clusterid) { 365 | return "subgraph cluster_" + clusterid + " {"; 366 | } 367 | 368 | /** 369 | * Returns a string that is used to end a graph. 370 | * @return A string to close a graph. 371 | */ 372 | public String end_subgraph() { 373 | return "}"; 374 | } 375 | 376 | /** 377 | * Read a DOT graph from a text file. 378 | * 379 | * @param input Input text file containing the DOT graph 380 | * source. 381 | */ 382 | public void readSource(String input) 383 | { 384 | StringBuilder sb = new StringBuilder(); 385 | 386 | try 387 | { 388 | FileInputStream fis = new FileInputStream(input); 389 | DataInputStream dis = new DataInputStream(fis); 390 | BufferedReader br = new BufferedReader(new InputStreamReader(dis)); 391 | String line; 392 | while ((line = br.readLine()) != null) { 393 | sb.append(line); 394 | } 395 | dis.close(); 396 | } 397 | catch (Exception e) { 398 | System.err.println("Error: " + e.getMessage()); 399 | } 400 | 401 | this.graph = sb; 402 | } 403 | 404 | } // end of class GraphViz 405 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/dot/GraphVizIOld.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.dot; 2 | 3 | //GraphViz.java - a simple API to call dot from Java programs 4 | 5 | /*$Id$*/ 6 | /* 7 | ****************************************************************************** 8 | * * 9 | * (c) Copyright 2003 Laszlo Szathmary * 10 | * * 11 | * This program is free software; you can redistribute it and/or modify it * 12 | * under the terms of the GNU Lesser General Public License as published by * 13 | * the Free Software Foundation; either version 2.1 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | * This program is distributed in the hope that it will be useful, but * 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * 18 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * 19 | * License for more details. * 20 | * * 21 | * You should have received a copy of the GNU Lesser General Public License * 22 | * along with this program; if not, write to the Free Software Foundation, * 23 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 24 | * * 25 | ****************************************************************************** 26 | */ 27 | 28 | import java.io.BufferedReader; 29 | import java.io.DataInputStream; 30 | import java.io.File; 31 | import java.io.FileInputStream; 32 | import java.io.FileOutputStream; 33 | import java.io.FileWriter; 34 | import java.io.InputStreamReader; 35 | 36 | /** 37 | *
38 | *
Purpose: GraphViz Java API 39 | *
40 | * 41 | *
Description: 42 | *
With this Java class you can simply call dot 43 | * from your Java programs 44 | *
Example usage: 45 | *
46 | *
 47 | *    GraphViz gv = new GraphViz();
 48 | *    gv.addln(gv.start_graph());
 49 | *    gv.addln("A -> B;");
 50 | *    gv.addln("A -> C;");
 51 | *    gv.addln(gv.end_graph());
 52 | *    System.out.println(gv.getDotSource());
 53 | *
 54 | *    String type = "gif";
 55 | *    File out = new File("out." + type);   // out.gif in this example
 56 | *    gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );
 57 | * 
58 | *
59 | * 60 | *
61 | * 62 | * @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you 63 | * can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc. 64 | * @version v0.3, 2010/11/29 (November) -- Windows support + ability 65 | * to read the graph from a text file 66 | * @version v0.2, 2010/07/22 (July) -- bug fix 67 | * @version v0.1, 2003/12/04 (December) -- first release 68 | * @author Laszlo Szathmary (jabba.laci@gmail.com) 69 | */ 70 | public class GraphVizIOld 71 | { 72 | /** 73 | * The dir. where temporary files will be created. 74 | */ 75 | private static String TEMP_DIR = "/tmp"; // Linux 76 | // private static String TEMP_DIR = "c:/temp"; // Windows 77 | 78 | /** 79 | * Where is your dot program located? It will be called externally. 80 | */ 81 | private static String DOT = "/usr/bin/dot"; // Linux 82 | //private static String DOT = "c:/Program Files/Graphviz2.26.3/bin/dot.exe"; // Windows 83 | 84 | /** 85 | * The source of the graph written in dot language. 86 | */ 87 | private StringBuilder graph = new StringBuilder(); 88 | 89 | /** 90 | * Constructor: creates a new GraphViz object that will contain 91 | * a graph. 92 | */ 93 | public GraphVizIOld() { 94 | } 95 | 96 | /** 97 | * Constructor: creates a new GraphViz object that will contain 98 | * a graph. 99 | */ 100 | public GraphVizIOld(String dPath) 101 | { 102 | DOT=dPath; 103 | } 104 | 105 | /** 106 | * Returns the graph's source description in dot language. 107 | * @return Source of the graph in dot language. 108 | */ 109 | public String getDotSource() { 110 | return graph.toString(); 111 | } 112 | 113 | /** 114 | * Adds a string to the graph's source (without newline). 115 | */ 116 | public void add(String line) { 117 | graph.append(line); 118 | } 119 | 120 | /** 121 | * Adds a string to the graph's source (with newline). 122 | */ 123 | public void addln(String line) { 124 | graph.append(line + "\n"); 125 | } 126 | 127 | /** 128 | * Adds a newline to the graph's source. 129 | */ 130 | public void addln() { 131 | graph.append('\n'); 132 | } 133 | 134 | /** 135 | * Returns the graph as an image in binary format. 136 | * @param dot_source Source of the graph to be drawn. 137 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 138 | * @return A byte array containing the image of the graph. 139 | */ 140 | public byte[] getGraph(String dot_source, String type) 141 | { 142 | File dot; 143 | byte[] img_stream = null; 144 | 145 | try { 146 | dot = writeDotSourceToFile(dot_source); 147 | if (dot != null) 148 | { 149 | img_stream = get_img_stream(dot, type); 150 | if (dot.delete() == false) 151 | System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); 152 | return img_stream; 153 | } 154 | System.err.println("Error during getGraph (dot==null"); 155 | return null; 156 | } catch (java.io.IOException ioe) 157 | { 158 | System.err.println("Error during getGraph"); 159 | return null; 160 | } 161 | } 162 | 163 | /** 164 | * Writes the graph's image in a file. 165 | * @param img A byte array containing the image of the graph. 166 | * @param file Name of the file to where we want to write. 167 | * @return Success: 1, Failure: -1 168 | */ 169 | public int writeGraphToFile(byte[] img, String file) 170 | { 171 | File to = new File(file); 172 | return writeGraphToFile(img, to); 173 | } 174 | 175 | /** 176 | * Writes the graph's image in a file. 177 | * @param img A byte array containing the image of the graph. 178 | * @param to A File object to where we want to write. 179 | * @return Success: 1, Failure: -1 180 | */ 181 | public int writeGraphToFile(byte[] img, File to) 182 | { 183 | try { 184 | FileOutputStream fos = new FileOutputStream(to); 185 | fos.write(img); 186 | fos.close(); 187 | } catch (java.io.IOException ioe) { return -1; } 188 | return 1; 189 | } 190 | 191 | /** 192 | * It will call the external dot program, and return the image in 193 | * binary format. 194 | * @param dot Source of the graph (in dot language). 195 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 196 | * @return The image of the graph in .gif format. 197 | */ 198 | private byte[] get_img_stream(File dot, String type) 199 | { 200 | File img; 201 | byte[] img_stream = null; 202 | 203 | try { 204 | img = File.createTempFile("graph_", "."+type, new File(GraphVizIOld.TEMP_DIR)); 205 | Runtime rt = Runtime.getRuntime(); 206 | 207 | // patch by Mike Chenault 208 | String[] args = {DOT, "-T"+type, dot.getAbsolutePath(), "-o", img.getAbsolutePath()}; 209 | Process p = rt.exec(args); 210 | 211 | p.waitFor(); 212 | 213 | FileInputStream in = new FileInputStream(img.getAbsolutePath()); 214 | img_stream = new byte[in.available()]; 215 | in.read(img_stream); 216 | // Close it if we need to 217 | if( in != null ) in.close(); 218 | 219 | if (img.delete() == false) 220 | System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!"); 221 | } 222 | catch (java.io.IOException ioe) { 223 | System.err.println("Error: in I/O processing of tempfile in dir " + GraphVizIOld.TEMP_DIR+"\n"); 224 | System.err.println(" or in calling external command"); 225 | ioe.printStackTrace(); 226 | } 227 | catch (java.lang.InterruptedException ie) { 228 | System.err.println("Error: the execution of the external program was interrupted"); 229 | ie.printStackTrace(); 230 | } 231 | 232 | return img_stream; 233 | } 234 | 235 | /** 236 | * Writes the source of the graph in a file, and returns the written file 237 | * as a File object. 238 | * @param str Source of the graph (in dot language). 239 | * @return The file (as a File object) that contains the source of the graph. 240 | */ 241 | private File writeDotSourceToFile(String str) throws java.io.IOException 242 | { 243 | File temp; 244 | try { 245 | temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphVizIOld.TEMP_DIR)); 246 | FileWriter fout = new FileWriter(temp); 247 | fout.write(str); 248 | fout.close(); 249 | } 250 | catch (Exception e) { 251 | System.err.println("Error: I/O error while writing the dot source to temp file!"); 252 | return null; 253 | } 254 | return temp; 255 | } 256 | 257 | /** 258 | * Returns a string that is used to start a graph. 259 | * @return A string to open a graph. 260 | */ 261 | public String start_graph() { 262 | return "digraph G {"; 263 | } 264 | 265 | /** 266 | * Returns a string that is used to end a graph. 267 | * @return A string to close a graph. 268 | */ 269 | public String end_graph() { 270 | return "}"; 271 | } 272 | 273 | /** 274 | * Read a DOT graph from a text file. 275 | * 276 | * @param input Input text file containing the DOT graph 277 | * source. 278 | */ 279 | public void readSource(String input) 280 | { 281 | StringBuilder sb = new StringBuilder(); 282 | 283 | try 284 | { 285 | FileInputStream fis = new FileInputStream(input); 286 | DataInputStream dis = new DataInputStream(fis); 287 | BufferedReader br = new BufferedReader(new InputStreamReader(dis)); 288 | String line; 289 | while ((line = br.readLine()) != null) { 290 | sb.append(line); 291 | } 292 | dis.close(); 293 | } 294 | catch (Exception e) { 295 | System.err.println("Error: " + e.getMessage()); 296 | } 297 | 298 | this.graph = sb; 299 | } 300 | 301 | } // end of class GraphViz 302 | 303 | 304 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/dot/ObjPropPair.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.dot; 2 | 3 | public class ObjPropPair { 4 | 5 | private T1 left; 6 | private T2 right; 7 | 8 | public T1 getLeft() { 9 | return left; 10 | } 11 | public void setLeft(T1 left) { 12 | this.left = left; 13 | } 14 | public T2 getRight() { 15 | return right; 16 | } 17 | public void setRight(T2 right) { 18 | this.right = right; 19 | } 20 | 21 | public String toString() 22 | { 23 | return "<"+left+","+right+">"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/dot/Rdf2Gv.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.dot; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.HashSet; 6 | import java.util.Iterator; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.tuple.MutablePair; 10 | import org.apache.commons.lang3.tuple.Pair; 11 | 12 | import com.hp.hpl.jena.ontology.OntModel; 13 | import com.hp.hpl.jena.ontology.OntModelSpec; 14 | import com.hp.hpl.jena.rdf.model.ModelFactory; 15 | import com.hp.hpl.jena.rdf.model.RDFNode; 16 | import com.hp.hpl.jena.rdf.model.Resource; 17 | import com.hp.hpl.jena.rdf.model.Statement; 18 | import com.hp.hpl.jena.rdf.model.StmtIterator; 19 | 20 | import es.upm.oeg.ar2dtool.MainOld; 21 | import es.upm.oeg.ar2dtool.utils.ConfigValues; 22 | 23 | public class Rdf2Gv { 24 | 25 | private static final String rdfTypeUri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; 26 | private static final String rdfsRange = "http://www.w3.org/2000/01/rdf-schema#range"; 27 | private static final String rdfsDomain = "http://www.w3.org/2000/01/rdf-schema#domain"; 28 | 29 | 30 | private static String pathToRdf; 31 | private static ConfigValues cv; 32 | 33 | private String gvContent; 34 | 35 | private HashSet classList; 36 | private HashSet individualList; 37 | private HashSet literalList; 38 | 39 | private Map> objProps; 40 | 41 | private ArrayList dtLines; 42 | 43 | public ArrayList getDtLines() { 44 | return dtLines; 45 | } 46 | 47 | private HashSet gvLines; 48 | 49 | public Rdf2Gv(String path, ConfigValues c) 50 | { 51 | pathToRdf = path; 52 | gvContent = ""; 53 | cv = c; 54 | classList = new HashSet(); 55 | individualList = new HashSet(); 56 | literalList = new HashSet(); 57 | gvLines = new HashSet(); 58 | 59 | objProps = new HashMap>(); 60 | 61 | dtLines = new ArrayList(); 62 | } 63 | 64 | public void parseRdf() 65 | { 66 | OntModel cMod = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 67 | cMod.read(pathToRdf, null); 68 | 69 | StmtIterator it = cMod.listStatements(); 70 | 71 | while(it.hasNext()) 72 | { 73 | Statement st = it.next(); 74 | String sUri = st.getSubject().toString(); 75 | String pUri = st.getPredicate().toString(); 76 | String oUri =""; 77 | 78 | 79 | 80 | RDFNode obj = st.getObject(); 81 | if(obj.isLiteral()) 82 | { 83 | if(cv.getKeys().get("ignoreLiterals").equals("true")) //user wants to skip literals 84 | continue; 85 | 86 | oUri = "\"" + st.getString() + "\""; 87 | } 88 | else 89 | { 90 | oUri = st.getObject().asResource().toString(); 91 | } 92 | 93 | 94 | //includeOnlyElementList Check 95 | if((cv.getIncludeOnlyElementList().size()>0)&&((!cv.getIncludeOnlyElementList().contains(sUri))&&(!cv.getIncludeOnlyElementList().contains(pUri))&&(!cv.getIncludeOnlyElementList().contains(oUri)))) 96 | { 97 | //one of the elements is included in the ignore list 98 | dbg("includeOnlyElementList->Skipping triple:" + st); 99 | continue; 100 | } 101 | 102 | 103 | //ignoreElementList Check 104 | if((cv.getIgnoreElementList().contains(sUri))||(cv.getIgnoreElementList().contains(pUri))||(cv.getIgnoreElementList().contains(oUri))) 105 | { 106 | //one of the elements is included in the ignore list 107 | dbg("ignoreElementList->Skipping triple:" + st); 108 | continue; 109 | } 110 | 111 | //looking for equivalent elements 112 | sUri = checkEquivalentElementList(sUri); 113 | pUri = checkEquivalentElementList(pUri); 114 | oUri = checkEquivalentElementList(oUri); 115 | 116 | 117 | //add quotes for formatting reasons 118 | // String s = "\"" + sUri + "\""; 119 | // String p = "\"" + pUri + "\""; 120 | // String o = oUri; //literals already include quotes 121 | // if(!obj.isLiteral()) 122 | // { 123 | // o = "\"" + oUri + "\""; 124 | // } 125 | 126 | 127 | 128 | // REMOVE 129 | // if(cv.getKeys().get("useFullUri").equals("false")) 130 | // { 131 | // //user wants to use local names instead of full URIs 132 | // s="\"" + cMod.getResource(sUri).getLocalName() + "\""; 133 | // p="\"" + cMod.getResource(pUri).getLocalName() + "\""; 134 | // if(!obj.isLiteral()) 135 | // { 136 | // o="\"" + cMod.getResource(oUri).getLocalName() + "\""; 137 | // } 138 | // } 139 | 140 | if(cv.getKeys().get("synthesizeObjectProperties").equals("true")) //user wants to synthesize obj props 141 | { 142 | if(pUri.equals(rdfsRange)) //the triple is defining the range of an obj. prop. 143 | { 144 | if(objProps.containsKey(sUri)) 145 | { 146 | objProps.get(sUri).setRight(oUri); 147 | } 148 | else 149 | { 150 | MutablePair pair = new MutablePair(); 151 | pair.setRight(oUri); 152 | objProps.put(sUri, pair); 153 | } 154 | continue; //we are done with this triple 155 | } 156 | if(pUri.equals(rdfsDomain)) //the triple is defining the domain of an obj. prop. 157 | { 158 | if(objProps.containsKey(sUri)) 159 | { 160 | objProps.get(sUri).setLeft(oUri); 161 | } 162 | else 163 | { 164 | MutablePair pair = new MutablePair(); 165 | pair.setLeft(oUri); 166 | objProps.put(sUri, pair); 167 | } 168 | continue; //we are done with this triple 169 | } 170 | } 171 | 172 | if(obj.isLiteral()) 173 | { 174 | literalList.add(oUri); 175 | } 176 | 177 | 178 | 179 | if(pUri.equals(rdfTypeUri)) 180 | { 181 | individualList.add(sUri); //we have found a new individual 182 | classList.add(oUri); //we have found a new class 183 | 184 | //TODO we should ckeck here if 'o' is a Class, ObjProp or DataTypeProp 185 | //in those cases we are not dealing with an individual 186 | //this happens when representing ontologies instead of individual datasets 187 | 188 | 189 | dbg("adding " + sUri + "to individuals due to triple: [" + st +"]"); 190 | 191 | if(cv.getKeys().get("ignoreRdfType").equals("true")) 192 | { 193 | //is RdfType prop and user wants to ignore it 194 | dbg("ignoreRdfType->Skipping triple:" + st); 195 | continue; 196 | } 197 | } 198 | 199 | 200 | //store the new DOT line 201 | DOTTriple dt = new DOTTriple(sUri,oUri,pUri); 202 | dtLines.add(dt); 203 | } 204 | 205 | 206 | 207 | //defining the styles 208 | String classStyle = "node [shape = "+ cv.getKeys().get("classShape") +", color="+ cv.getKeys().get("classColor") +"]; "; 209 | String individualStyle = "node [shape = "+ cv.getKeys().get("individualShape") +", color="+ cv.getKeys().get("individualColor") +"]; "; 210 | String literalStyle = "node [shape = "+ cv.getKeys().get("literalShape") +", color="+ cv.getKeys().get("literalColor") +"]; "; 211 | String syntObjProp = getSynthesizeObjectPropertiesString(cMod); 212 | 213 | 214 | if(cv.getKeys().get("useFullUri").equals("false")) 215 | { 216 | classList = getLocalNames(cMod,classList); 217 | literalList = getLocalNames(cMod,literalList); 218 | individualList = getLocalNames(cMod,individualList); 219 | } 220 | 221 | //if we are ignoring the Rdf type property we don't include classes style 222 | //to avoid them to appear alone without any link pointing to them 223 | if(cv.getKeys().get("ignoreRdfType").equals("true")) 224 | { 225 | classStyle="/*classes style ignored due to ignoreRdfType*/\n"; 226 | } 227 | else 228 | { 229 | for(String c : classList) 230 | { 231 | classStyle += "\"" + c + "\" "; 232 | } 233 | classStyle += ";/*classes*/\n"; 234 | } 235 | 236 | //if we are ignoring literals we don't include their style 237 | //to avoid them to appear alone without any link pointing to them 238 | if(cv.getKeys().get("ignoreLiterals").equals("true")) 239 | { 240 | literalStyle = "/*literal elements ignored*/\n"; 241 | } 242 | else 243 | { 244 | if(literalList.size()>0) 245 | { 246 | for(String l : literalList) 247 | { 248 | literalStyle += "\"" + l + "\" "; 249 | } 250 | literalStyle += ";/*literals*/\n"; 251 | } 252 | } 253 | 254 | String specialElementsStyle =""; 255 | for(ArrayList se : cv.getSpecialElementsList()) 256 | { 257 | if(cv.getKeys().get("useFullUri").equals("true")) 258 | { 259 | specialElementsStyle +="node [shape = "+ se.get(1) +", color="+ se.get(2) +"]; \"" + se.get(0) + "\";\n"; 260 | } 261 | else 262 | { 263 | Resource r = cMod.getResource(se.get(0)); 264 | if(!r.isLiteral()) 265 | { 266 | specialElementsStyle +="node [shape = "+ se.get(1) +", color="+ se.get(2) +"]; \"" + r.getLocalName() + "\";\n"; 267 | } 268 | else 269 | { 270 | specialElementsStyle +="node [shape = "+ se.get(1) +", color="+ se.get(2) +"]; \"" + r.asLiteral().getString() + "\";\n"; 271 | } 272 | } 273 | } 274 | 275 | 276 | for(String i : individualList) 277 | { 278 | dbg("checking " + i + " that has " + objProps.get(i)); 279 | if(objProps.containsKey(i))//if it is on the synt obj. prop list it doesn't make any sense to define its style 280 | { 281 | dbg("skippingindividualSytle synt.:" + i); 282 | continue; 283 | } 284 | else 285 | { 286 | individualStyle += "\"" + i + "\" "; 287 | } 288 | 289 | } 290 | dbg("individualStyle:" + individualStyle + ":"); 291 | individualStyle += "/*individuals*/\n"; 292 | 293 | 294 | 295 | 296 | if(cv.getKeys().get("useFullUri").equals("false")) 297 | { 298 | //we load all the triple URIs and get their local names and add quotes 299 | ArrayList dtLinesLocal = new ArrayList(); 300 | for(DOTTriple dt : dtLines) 301 | { 302 | String s="\"" + cMod.getResource(dt.getSource()).getLocalName() + "\""; 303 | String t="\"" + cMod.getResource(dt.getTarget()).getLocalName() + "\""; 304 | String e="\"" + cMod.getResource(dt.getEdge()).getLocalName() + "\""; 305 | 306 | DOTTriple dtl = new DOTTriple(s,t,e); 307 | dtLinesLocal.add(dtl); 308 | } 309 | dtLines = dtLinesLocal; 310 | } 311 | else 312 | { 313 | //we add quotes to all URIs 314 | ArrayList dtLinesLocal = new ArrayList(); 315 | for(DOTTriple dt : dtLines) 316 | { 317 | String s="\"" + dt.getSource() + "\""; 318 | String t="\"" + dt.getTarget() + "\""; 319 | String e="\"" + dt.getEdge() + "\""; 320 | 321 | DOTTriple dtl = new DOTTriple(s,t,e); 322 | dtLinesLocal.add(dtl); 323 | } 324 | dtLines = dtLinesLocal; 325 | } 326 | 327 | for(DOTTriple dt : dtLines) 328 | { 329 | String spoviz = "\t"+dt.getSource()+" -> " + dt.getTarget() + " [ label = "+ dt.getEdge() + " ];\n"; 330 | gvContent += spoviz; 331 | } 332 | 333 | String conHead = "digraph ar2dtool_diagram { \n" + 334 | "rankdir=" + cv.getKeys().get("rankdir") + ";\n" + 335 | "size=\"" + cv.getKeys().get("imageSize") + "\"\n" + 336 | specialElementsStyle+ 337 | classStyle+ 338 | individualStyle+ 339 | literalStyle+ 340 | "node [shape = ellipse];\n" + 341 | "edge [color=\"" + cv.getKeys().get("arrowColor") + "\", dir=\"" +cv.getKeys().get("arrowdir") + "\", arrowhead=\"" +cv.getKeys().get("arrowhead") + "\",arrowtail=\"" +cv.getKeys().get("arrowtail") + "\"]\n"; 342 | 343 | String conTail = "\n}"; 344 | gvContent = conHead + gvContent + syntObjProp + conTail ; 345 | 346 | dbg("-------->"+objProps.toString()); 347 | 348 | 349 | } 350 | 351 | 352 | private String getSynthesizeObjectPropertiesString(OntModel cMod) 353 | { 354 | String res =""; 355 | Iterator it = objProps.entrySet().iterator(); 356 | while (it.hasNext()) { 357 | Map.Entry kv = (Map.Entry)it.next(); 358 | String propUri = (String) kv.getKey(); 359 | MutablePair mp = (MutablePair) kv.getValue(); 360 | String rangeUri = mp.getRight(); 361 | String domainUri = mp.getLeft(); 362 | 363 | if(cv.getKeys().get("useFullUri").equals("false")) 364 | { 365 | //user wants to use local names instead of full URIs 366 | propUri="\"" + cMod.getResource(propUri).getLocalName() + "\""; 367 | rangeUri="\"" + cMod.getResource(rangeUri).getLocalName() + "\""; 368 | domainUri="\"" + cMod.getResource(domainUri).getLocalName() + "\""; 369 | } 370 | else 371 | { 372 | propUri="\"" + propUri + "\""; 373 | rangeUri="\"" + rangeUri + "\""; 374 | domainUri="\"" + domainUri + "\""; 375 | } 376 | 377 | res += "\t"+domainUri+" -> " + rangeUri + " [ label = "+ propUri + " ];\n"; 378 | 379 | } 380 | return res; 381 | } 382 | 383 | private static String checkEquivalentElementList(String e) 384 | { 385 | for(ArrayList list : cv.getEquivalentElementList()) 386 | { 387 | if(list.contains(e)) 388 | { 389 | //we have found the element on a list, so we replace it by the list's first element 390 | dbg("equivalentElement->Replace element:" + e + " by " + list.get(0)); 391 | return list.get(0); 392 | } 393 | } 394 | 395 | //we haven't found the element on any list, so we return the same element 396 | return e; 397 | } 398 | 399 | private HashSet getLocalNames(OntModel cMod, HashSet l) 400 | { 401 | HashSet res = new HashSet(); 402 | 403 | for (String uri : l) 404 | { 405 | String ln = cMod.getResource(uri).getLocalName(); 406 | res.add(ln); 407 | } 408 | 409 | return res; 410 | } 411 | 412 | public static void dbg(String msg) 413 | { 414 | MainOld.dbg(msg); 415 | } 416 | 417 | public String getGvContent() 418 | { 419 | return gvContent; 420 | } 421 | 422 | public String getClasses() 423 | { 424 | return classList.toString(); 425 | } 426 | 427 | public String getLiterals() 428 | { 429 | return literalList.toString(); 430 | } 431 | 432 | public String getIndividuals() 433 | { 434 | return individualList.toString(); 435 | } 436 | 437 | } 438 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/gv/DOTTriple.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.gv; 2 | 3 | 4 | //class for storing each line of the DOT syntax, including the source node, target node and the edge. 5 | public class DOTTriple 6 | { 7 | public String source; 8 | public String target; 9 | public String edge; 10 | 11 | public DOTTriple(String s, String t, String e) 12 | { 13 | source = s; 14 | target = t; 15 | edge = e; 16 | } 17 | 18 | public String getSource() { 19 | return source; 20 | } 21 | 22 | public void setSource(String source) { 23 | this.source = source; 24 | } 25 | 26 | public String getTarget() { 27 | return target; 28 | } 29 | 30 | public void setTarget(String target) { 31 | this.target = target; 32 | } 33 | 34 | public String getEdge() { 35 | return edge; 36 | } 37 | 38 | public void setEdge(String edge) { 39 | this.edge = edge; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /mavenProject/src/main/java/es/upm/oeg/ar2dtool/utils/gv/GraphViz.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.ar2dtool.utils.gv; 2 | 3 | //GraphViz.java - a simple API to call dot from Java programs 4 | 5 | /*$Id$*/ 6 | /* 7 | ****************************************************************************** 8 | * * 9 | * (c) Copyright 2003 Laszlo Szathmary * 10 | * * 11 | * This program is free software; you can redistribute it and/or modify it * 12 | * under the terms of the GNU Lesser General Public License as published by * 13 | * the Free Software Foundation; either version 2.1 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | * This program is distributed in the hope that it will be useful, but * 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * 18 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * 19 | * License for more details. * 20 | * * 21 | * You should have received a copy of the GNU Lesser General Public License * 22 | * along with this program; if not, write to the Free Software Foundation, * 23 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 24 | * * 25 | ****************************************************************************** 26 | */ 27 | 28 | import java.io.BufferedReader; 29 | import java.io.DataInputStream; 30 | import java.io.File; 31 | import java.io.FileInputStream; 32 | import java.io.FileOutputStream; 33 | import java.io.FileWriter; 34 | import java.io.InputStreamReader; 35 | 36 | /** 37 | *
38 | *
Purpose: GraphViz Java API 39 | *
40 | * 41 | *
Description: 42 | *
With this Java class you can simply call dot 43 | * from your Java programs 44 | *
Example usage: 45 | *
46 | *
 47 | *    GraphViz gv = new GraphViz();
 48 | *    gv.addln(gv.start_graph());
 49 | *    gv.addln("A -> B;");
 50 | *    gv.addln("A -> C;");
 51 | *    gv.addln(gv.end_graph());
 52 | *    System.out.println(gv.getDotSource());
 53 | *
 54 | *    String type = "gif";
 55 | *    File out = new File("out." + type);   // out.gif in this example
 56 | *    gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );
 57 | * 
58 | *
59 | * 60 | *
61 | * 62 | * @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you 63 | * can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc. 64 | * @version v0.3, 2010/11/29 (November) -- Windows support + ability 65 | * to read the graph from a text file 66 | * @version v0.2, 2010/07/22 (July) -- bug fix 67 | * @version v0.1, 2003/12/04 (December) -- first release 68 | * @author Laszlo Szathmary (jabba.laci@gmail.com) 69 | */ 70 | public class GraphViz 71 | { 72 | /** 73 | * The dir. where temporary files will be created. 74 | */ 75 | private static String TEMP_DIR = "/tmp"; // Linux 76 | // private static String TEMP_DIR = "c:/temp"; // Windows 77 | 78 | /** 79 | * Where is your dot program located? It will be called externally. 80 | */ 81 | private static String DOT = "/usr/bin/dot"; // Linux 82 | //private static String DOT = "c:/Program Files/Graphviz2.26.3/bin/dot.exe"; // Windows 83 | 84 | /** 85 | * The source of the graph written in dot language. 86 | */ 87 | private StringBuilder graph = new StringBuilder(); 88 | 89 | /** 90 | * Constructor: creates a new GraphViz object that will contain 91 | * a graph. 92 | */ 93 | public GraphViz() { 94 | } 95 | 96 | /** 97 | * Constructor: creates a new GraphViz object that will contain 98 | * a graph. 99 | */ 100 | public GraphViz(String dPath) 101 | { 102 | DOT=dPath; 103 | } 104 | 105 | /** 106 | * Returns the graph's source description in dot language. 107 | * @return Source of the graph in dot language. 108 | */ 109 | public String getDotSource() { 110 | return graph.toString(); 111 | } 112 | 113 | /** 114 | * Adds a string to the graph's source (without newline). 115 | */ 116 | public void add(String line) { 117 | graph.append(line); 118 | } 119 | 120 | /** 121 | * Adds a string to the graph's source (with newline). 122 | */ 123 | public void addln(String line) { 124 | graph.append(line + "\n"); 125 | } 126 | 127 | /** 128 | * Adds a newline to the graph's source. 129 | */ 130 | public void addln() { 131 | graph.append('\n'); 132 | } 133 | 134 | /** 135 | * Returns the graph as an image in binary format. 136 | * @param dot_source Source of the graph to be drawn. 137 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 138 | * @return A byte array containing the image of the graph. 139 | */ 140 | public byte[] getGraph(String dot_source, String type) 141 | { 142 | File dot; 143 | byte[] img_stream = null; 144 | 145 | try { 146 | dot = writeDotSourceToFile(dot_source); 147 | if (dot != null) 148 | { 149 | img_stream = get_img_stream(dot, type); 150 | if (dot.delete() == false) 151 | System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); 152 | return img_stream; 153 | } 154 | System.err.println("Error during getGraph (dot==null"); 155 | return null; 156 | } catch (java.io.IOException ioe) 157 | { 158 | System.err.println("Error during getGraph"); 159 | return null; 160 | } 161 | } 162 | 163 | /** 164 | * Writes the graph's image in a file. 165 | * @param img A byte array containing the image of the graph. 166 | * @param file Name of the file to where we want to write. 167 | * @return Success: 1, Failure: -1 168 | */ 169 | public int writeGraphToFile(byte[] img, String file) 170 | { 171 | File to = new File(file); 172 | return writeGraphToFile(img, to); 173 | } 174 | 175 | /** 176 | * Writes the graph's image in a file. 177 | * @param img A byte array containing the image of the graph. 178 | * @param to A File object to where we want to write. 179 | * @return Success: 1, Failure: -1 180 | */ 181 | public int writeGraphToFile(byte[] img, File to) 182 | { 183 | try { 184 | FileOutputStream fos = new FileOutputStream(to); 185 | fos.write(img); 186 | fos.close(); 187 | } catch (java.io.IOException ioe) { return -1; } 188 | return 1; 189 | } 190 | 191 | /** 192 | * It will call the external dot program, and return the image in 193 | * binary format. 194 | * @param dot Source of the graph (in dot language). 195 | * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. 196 | * @return The image of the graph in .gif format. 197 | */ 198 | private byte[] get_img_stream(File dot, String type) 199 | { 200 | File img; 201 | byte[] img_stream = null; 202 | 203 | try { 204 | img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR)); 205 | Runtime rt = Runtime.getRuntime(); 206 | 207 | // patch by Mike Chenault 208 | String[] args = {DOT, "-T"+type, dot.getAbsolutePath(), "-o", img.getAbsolutePath()}; 209 | Process p = rt.exec(args); 210 | 211 | p.waitFor(); 212 | 213 | FileInputStream in = new FileInputStream(img.getAbsolutePath()); 214 | img_stream = new byte[in.available()]; 215 | in.read(img_stream); 216 | // Close it if we need to 217 | if( in != null ) in.close(); 218 | 219 | if (img.delete() == false) 220 | System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!"); 221 | } 222 | catch (java.io.IOException ioe) { 223 | System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+"\n"); 224 | System.err.println(" or in calling external command"); 225 | ioe.printStackTrace(); 226 | } 227 | catch (java.lang.InterruptedException ie) { 228 | System.err.println("Error: the execution of the external program was interrupted"); 229 | ie.printStackTrace(); 230 | } 231 | 232 | return img_stream; 233 | } 234 | 235 | /** 236 | * Writes the source of the graph in a file, and returns the written file 237 | * as a File object. 238 | * @param str Source of the graph (in dot language). 239 | * @return The file (as a File object) that contains the source of the graph. 240 | */ 241 | private File writeDotSourceToFile(String str) throws java.io.IOException 242 | { 243 | File temp; 244 | try { 245 | temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphViz.TEMP_DIR)); 246 | FileWriter fout = new FileWriter(temp); 247 | fout.write(str); 248 | fout.close(); 249 | } 250 | catch (Exception e) { 251 | System.err.println("Error: I/O error while writing the dot source to temp file!"); 252 | return null; 253 | } 254 | return temp; 255 | } 256 | 257 | /** 258 | * Returns a string that is used to start a graph. 259 | * @return A string to open a graph. 260 | */ 261 | public String start_graph() { 262 | return "digraph G {"; 263 | } 264 | 265 | /** 266 | * Returns a string that is used to end a graph. 267 | * @return A string to close a graph. 268 | */ 269 | public String end_graph() { 270 | return "}"; 271 | } 272 | 273 | /** 274 | * Read a DOT graph from a text file. 275 | * 276 | * @param input Input text file containing the DOT graph 277 | * source. 278 | */ 279 | public void readSource(String input) 280 | { 281 | StringBuilder sb = new StringBuilder(); 282 | 283 | try 284 | { 285 | FileInputStream fis = new FileInputStream(input); 286 | DataInputStream dis = new DataInputStream(fis); 287 | BufferedReader br = new BufferedReader(new InputStreamReader(dis)); 288 | String line; 289 | while ((line = br.readLine()) != null) { 290 | sb.append(line); 291 | } 292 | dis.close(); 293 | } 294 | catch (Exception e) { 295 | System.err.println("Error: " + e.getMessage()); 296 | } 297 | 298 | this.graph = sb; 299 | } 300 | 301 | } // end of class GraphViz 302 | 303 | 304 | -------------------------------------------------------------------------------- /samples/API samples/sample01.java: -------------------------------------------------------------------------------- 1 | import es.upm.oeg.ar2dtool.RDF2Diagram; 2 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 3 | import es.upm.oeg.ar2dtool.exceptions.RDFInputNotValid; 4 | import es.upm.oeg.ar2dtool.exceptions.RDFNotFound; 5 | import es.upm.oeg.ar2dtool.utils.dot.DOTGenerator; 6 | import es.upm.oeg.ar2dtool.utils.graphml.GraphMLGenerator; 7 | 8 | 9 | public class Main { 10 | 11 | 12 | /* 13 | * 14 | * Set these variables to specify your input file, the output file diagram to be generated 15 | * the output type (png, pdf, etc.) and your config file. 16 | * 17 | */ 18 | private static String pathToInputFile = "/Users/isantana/Dropbox/DOCTORADO/ar2dtool/samples/pizza/individuals/pizzainds.owl"; 19 | private static String pathToOuputFile = "/Users/isantana/Desktop/pizzares.png"; 20 | private static String outputFileType = "png"; 21 | private static String pathToConfFile = "/Users/isantana/Dropbox/DOCTORADO/ar2dtool/samples/pizza/individuals/conf.txt"; 22 | 23 | public static void main(String[] args) { 24 | // TODO Auto-generated method stub 25 | 26 | RDF2Diagram r2d = new RDF2Diagram(); 27 | 28 | try { 29 | 30 | //load config info 31 | r2d.loadConfigValues(pathToConfFile); 32 | 33 | //print config values 34 | System.out.println(r2d.getConf().toString()); 35 | 36 | //load model 37 | r2d.loadRdf(pathToInputFile); 38 | 39 | //apply the filters specified in config file 40 | r2d.applyFilters(); 41 | 42 | //get the DOTGenerator with the resultant info 43 | DOTGenerator dg = r2d.getDOTGenerator(); 44 | 45 | //apply transformations 46 | dg.applyTransformations(); 47 | 48 | //get source DOT code 49 | String src = dg.generateDOTSource(); 50 | 51 | //compile src code into a graph 52 | dg.generateDOTDiagram(src,pathToOuputFile,outputFileType); 53 | 54 | //get the GraphMLGenerator with the resultant info 55 | GraphMLGenerator gg = r2d.getGraphMLGenerator(); 56 | 57 | //apply transformations 58 | gg.applyTransformations(); 59 | 60 | //save the GraphML source to file 61 | gg.saveSourceToFile(pathToOuputFile+".graphml"); 62 | 63 | 64 | 65 | 66 | 67 | } catch (ConfigFileNotFoundException e) { 68 | // TODO Auto-generated catch block 69 | e.printStackTrace(); 70 | } catch (RDFNotFound e) { 71 | // TODO Auto-generated catch block 72 | e.printStackTrace(); 73 | } catch (RDFInputNotValid e) { 74 | // TODO Auto-generated catch block 75 | e.printStackTrace(); 76 | } 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /samples/confER.txt: -------------------------------------------------------------------------------- 1 | pathToDot=/usr/local/bin/dot; 2 | pathToTempDir=/tmp; 3 | imageSize=1501; 4 | rankdir=LR; 5 | 6 | ######## 7 | #shapes# 8 | ######## 9 | 10 | #classShape=diamond; 11 | #individualShape=diamond; 12 | #literalShape=box; 13 | #arrowhead=normal; 14 | #arrowtail=normal; 15 | #arrowdir=forward; 16 | 17 | ######## 18 | #colors# 19 | ######## 20 | 21 | classColor=orange; 22 | #individualColor=orange; 23 | #literalColor=blue; 24 | #arrowColor=blue; 25 | 26 | ############# 27 | #RDF options# 28 | ############# 29 | 30 | nodeNameMode=localname; 31 | ignoreLiterals=true; 32 | ignoreRdfType=true; 33 | synthesizeObjectProperties=true; 34 | 35 | 36 | ####### 37 | #lists# 38 | ####### 39 | 40 | 41 | ignoreElementList=[]; -------------------------------------------------------------------------------- /samples/confTaxonomy.txt: -------------------------------------------------------------------------------- 1 | pathToDot=/usr/local/bin/dot; 2 | pathToTempDir=/tmp; 3 | imageSize=1501; 4 | rankdir=LR; 5 | 6 | ######## 7 | #shapes# 8 | ######## 9 | 10 | #classShape=diamond; 11 | #individualShape=diamond; 12 | #literalShape=box; 13 | #arrowhead=normal; 14 | #arrowtail=normal; 15 | #arrowdir=forward; 16 | 17 | ######## 18 | #colors# 19 | ######## 20 | 21 | #classColor=orange; 22 | #individualColor=orange; 23 | #literalColor=blue; 24 | #arrowColor=blue; 25 | 26 | 27 | ############# 28 | #RDF options# 29 | ############# 30 | 31 | nodeNameMode=localname; 32 | ignoreLiterals=true; 33 | ignoreRdfType=false; 34 | synthesizeObjectProperties=false; 35 | 36 | 37 | ####### 38 | #lists# 39 | ####### 40 | 41 | 42 | includeOnlyElementList=[ 43 | < 44 | http://www.w3.org/2000/01/rdf-schema#subClassOf 45 | > 46 | ]; -------------------------------------------------------------------------------- /samples/sample01.java: -------------------------------------------------------------------------------- 1 | import es.upm.oeg.ar2dtool.RDF2Diagram; 2 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 3 | import es.upm.oeg.ar2dtool.exceptions.RDFInputNotValid; 4 | import es.upm.oeg.ar2dtool.exceptions.RDFNotFound; 5 | import es.upm.oeg.ar2dtool.utils.dot.DOTGenerator; 6 | import es.upm.oeg.ar2dtool.utils.graphml.GraphMLGenerator; 7 | 8 | 9 | public class Main { 10 | 11 | 12 | /* 13 | * 14 | * Set these variables to specify your input file, the output file diagram to be generated 15 | * the output type (png, pdf, etc.) and your config file. 16 | * 17 | */ 18 | private static String pathToInputFile = "/Users/isantana/Dropbox/DOCTORADO/ar2dtool/samples/pizza/individuals/pizzainds.owl"; 19 | private static String pathToOuputFile = "/Users/isantana/Desktop/pizzares.png"; 20 | private static String outputFileType = "png"; 21 | private static String pathToConfFile = "/Users/isantana/Dropbox/DOCTORADO/ar2dtool/samples/pizza/individuals/conf.txt"; 22 | 23 | public static void main(String[] args) { 24 | // TODO Auto-generated method stub 25 | 26 | RDF2Diagram r2d = new RDF2Diagram(); 27 | 28 | try { 29 | 30 | //load config info 31 | r2d.loadConfigValues(pathToConfFile); 32 | 33 | //print config values 34 | System.out.println(r2d.getConf().toString()); 35 | 36 | //load model 37 | r2d.loadRdf(pathToInputFile); 38 | 39 | //apply the filters specified in config file 40 | r2d.applyFilters(); 41 | 42 | //get the DOTGenerator with the resultant info 43 | DOTGenerator dg = r2d.getDOTGenerator(); 44 | 45 | //apply transformations 46 | dg.applyTransformations(); 47 | 48 | //get source DOT code 49 | String src = dg.generateDOTSource(); 50 | 51 | //compile src code into a graph 52 | dg.generateDOTDiagram(src,pathToOuputFile,outputFileType); 53 | 54 | //get the GraphMLGenerator with the resultant info 55 | GraphMLGenerator gg = r2d.getGraphMLGenerator(); 56 | 57 | //apply transformations 58 | gg.applyTransformations(); 59 | 60 | //save the GraphML source to file 61 | gg.saveSourceToFile(pathToOuputFile+".graphml"); 62 | 63 | 64 | 65 | 66 | 67 | } catch (ConfigFileNotFoundException e) { 68 | // TODO Auto-generated catch block 69 | e.printStackTrace(); 70 | } catch (RDFNotFound e) { 71 | // TODO Auto-generated catch block 72 | e.printStackTrace(); 73 | } catch (RDFInputNotValid e) { 74 | // TODO Auto-generated catch block 75 | e.printStackTrace(); 76 | } 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /webAppProject/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .classpath 3 | .settings 4 | .project 5 | 6 | -------------------------------------------------------------------------------- /webAppProject/README.MD: -------------------------------------------------------------------------------- 1 | 2 | [![Code HTML5](https://img.shields.io/badge/code-HTML5-blue.svg)](https://www.w3.org/TR/html5/) 3 | [![Code CSS3](https://img.shields.io/badge/code-CSS3-blue.svg)](http://www.w3schools.com/css/css3_intro.asp) 4 | [![Code JS](https://img.shields.io/badge/code-JS-blue.svg)](http://www.w3schools.com/js/) 5 | [![Desgin Responsive](https://img.shields.io/badge/design-Responsive-blue.svg)](http://www.w3schools.com/html/html_responsive.asp) 6 | [![Desgin Google Design](https://img.shields.io/badge/design-Google%20Design-blue.svg)](https://design.google.com/) 7 | [![lib jQuery](https://img.shields.io/badge/lib-jQuery-green.svg)](https://jquery.com/) 8 | [![lib jQueryMobile](https://img.shields.io/badge/lib-jQuery%20Mobile-green.svg)](https://jquerymobile.com/) 9 | [![lib sweetAlert](https://img.shields.io/badge/lib-Sweet%20Alert-green.svg)](https://t4t5.github.io/sweetalert/) 10 | [![lib Modernizr](https://img.shields.io/badge/lib-Modernizr-green.svg)](https://modernizr.com/) 11 | [![lib Image Select](https://img.shields.io/badge/lib-Image%20Select-green.svg)](https://github.com/websemantics/Image-Select) 12 | [![lib Chosen](https://img.shields.io/badge/lib-Chosen-green.svg)](https://harvesthq.github.io/chosen/) 13 | [![Java 1.7 or later](https://img.shields.io/badge/Java-1.7%20or%20later-40c4ff.svg)](https://www.java.com/es/download/help/index_installing.xml?j=7) 14 | [![Jersey 2.22.1](https://img.shields.io/badge/Jersey-2.22.1-40c4ff.svg)](https://jersey.java.net/documentation/latest/user-guide.html) 15 | [![Build Maven](https://img.shields.io/badge/build-Maven-lightgrey.svg)](https://maven.apache.org/) 16 | [![Version 1.0](https://img.shields.io/badge/Version-1.0%20Beta-lightgrey.svg)](#version) 17 | 18 | # WebAR2DTool 19 | 20 | This repository contains a web application for use AR2DTool. 21 | 22 | # Table of Contents 23 | 1. [Pre-requisites](#pre-requisites) 24 | 2. [Configuration](#configuration) 25 | 2.1. [Server configuration](#serverConfiguration) 26 | 2.2. [Change mail configuration](#changeMailConfiguration) 27 | 2.3. [Default AR2DTool Config](#editAR2DToolConfig) 28 | 3. [Compile](#compile) 29 | 4. [Deploy](#deploy) 30 | 5. [Development guide](#developmentGuide) 31 | 6. [Version](#version) 32 | 33 | 34 | ## 1) Pre-requisites 35 | * Maven 3.0 or later. 36 | * Java 1.7 or later. 37 | * Tomcat 1.7 or later. 38 | * Internet connection if you use maven (for downloading dependencies). 39 | 40 | ## 2) Configuration 41 | ***2.1) Server configuration*** 42 | The first step is change the server configuration. 43 | Enter the project folder and edit the following file: "src/main/webapp/WEB-INF/server.properties". 44 | 45 | This file have the following properties, which to must edit to meet your server: 46 | * pathToDot: The path where DOT is installed. By default, it is /usr/bin/dot (you can check it by excuting 'wich dot' in UNIX shells). 47 | * pathToTempDir: The path to the webapp temp dir. Example: /home/USER/webAR2DTool/temp 48 | * server.pathToUploadedFiles: The path to the webapp upload dir (webAR2DTool will save the file to this folder, which will need write permissions). Example: /home/USER/webAR2DTool/uploaded 49 | * server.removeDirSession: "true" or "false". If it is "true" all files of user will be removed when session expired. If "false" the file will not be removed. 50 | * server.session.timeout.seconds: Seconds for session to expire since user last action. 51 | * server.generate.timeout.seconds: Maximum execution time (in seconds) for thread that calls AR2DTool (Generate image). 52 | * server.upload.file.size.mb: Maximum size of the uploaded input file. 53 | * server.generate.limit.triples: Maximum triples of the uploaded input file. 54 | 55 | Be aware that file paths must use escaped backslashes (e.g. "\\\\"). 56 | 57 | Example: 58 | > pathToDot=/usr/bin/dot 59 | > pathToTempDir=/home/USER/webAR2DTool/temp 60 | > server.pathToUploadedFiles=/home/USER/webAR2DTool/uploaded 61 | > server.removeDirSession=true 62 | > server.session.timeout.seconds=3600 63 | > server.generate.timeout.seconds=16 64 | > server.upload.file.size.mb=5 65 | > server.generate.limit.triples=5000 66 | 67 | ***2.2) Mail configuration*** 68 | To change the mail properties edit the following file: "src/main/webapp/WEB-INF/mail.properties" 69 | 70 | * mail.server: The URL o IP address of the mail smtp server. 71 | * mail.server.user: The login user for the mail server. 72 | * mail.server.password: The login password for the mail server. 73 | * mail.server.port: The port for the mail smtp server. 74 | * mail.server.ttls.enable: : If smtp server has TTLs enabled then this parameter is "true". 75 | * mail.from: The mail address from which email is sent from. Example: user@gmail.com 76 | * mail.to: The mail address of the destinatary. 77 | * mail.cc: The mail address to be added as a copy on the email. 78 | * mail.bcc: The mail address to be added as hidden copy on the email. 79 | * mail.subject: Subject of the email. Example: [WebAR2DTool] Report send. SessionID=%SESSION_ID% 80 | *%SESSION_ID%: This paramerter is replaced by the app with the user ID. 81 | * mail.message: Body of the email, containing the message to be sent. Example: "A user send report for you.\n%FILES_INFO%\nUser email: %CONTACT_EMAIL%\nUser message:\n%MESSAGE%\n" 82 | * %FILES_INFO%: this parameter is replaced by an array of files (and tell if exists or not). 83 | * %CONTACT_EMAIL%: this parameter is replaced by the user email. 84 | * %MESSAGE%: this parameter is replaced by the user message. 85 | 86 | Example: 87 | > mail.server=gmail.com 88 | > mail.server.user=myuser 89 | > mail.server.password=mypass 90 | > mail.server.port=576 91 | > mail.server.ttls.enable=true 92 | > mail.from=myuser@gmail.com 93 | > mail.to=idafensp@gmail.com 94 | > mail.cc= 95 | > mail.bcc= 96 | > mail.subject=[WebAR2DTool] Report send. SessionID=%SESSION_ID% 97 | > mail.message=A user send report for you.\n%FILES_INFO%\nUser email: %CONTACT_EMAIL%\nUser message:\n%MESSAGE%\n 98 | 99 | 100 | ***2.3) Default AR2DTool config*** 101 | 102 | Edit the next file: "src/main/webapp/WEB-INF/defaultConfig.txt" 103 | For futher information visit: 104 | [Configuration file (AR2DTool)](https://github.com/idafensp/ar2dtool/blob/master/README.md#configuration-file) 105 | 106 | ## 3) Compile 107 | 108 | To compile, type in a cmd or terminal (On project folder, you need see the pom.xml): 109 | ```sh 110 | mvn clean install 111 | ``` 112 | 113 | Generated files are inside "target" folder. 114 | 115 | ## 4) Deploy 116 | 117 | After changing the settings you can compile the tool, generating a WAR file. You will deploy this WAR file on a tomcat manager or copy the folder "webAR2DTool" (in "target" folder) into the webapps folder of tomcat. 118 | For futher information visit: https://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html 119 | 120 | ## 5) Development guide 121 | 122 | For development guide visit the follow link: 123 | [Development Guide](https://github.com/idafensp/ar2dtool/wiki/Development-guide) 124 | 125 | ## 6) Version 126 | 1.0 Beta 127 | -------------------------------------------------------------------------------- /webAppProject/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | es.upm.oeg 7 | webAR2DTool 8 | war 9 | 1.0 10 | webAR2DTool 11 | https://github.com/idafensp/ar2dtool 12 | 13 | OEG 14 | www.oeg-upm.net 15 | 16 | 17 | 1.7 18 | 2.22.1 19 | UTF-8 20 | 21 | 22 | webAR2DTool 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-compiler-plugin 27 | 3.3 28 | true 29 | 30 | ${java.version} 31 | ${java.version} 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.glassfish.jersey 40 | jersey-bom 41 | ${jersey.version} 42 | pom 43 | import 44 | 45 | 46 | 47 | 48 | 49 | org.glassfish.jersey.containers 50 | jersey-container-servlet-core 51 | 52 | 53 | org.glassfish.jersey.media 54 | jersey-media-moxy 55 | 56 | 57 | org.glassfish.jersey.media 58 | jersey-media-multipart 59 | 60 | 61 | org.glassfish.jersey.core 62 | jersey-server 63 | 64 | 65 | javax.servlet 66 | javax.servlet-api 67 | 3.1.0 68 | 69 | 70 | org.glassfish.jersey.media 71 | jersey-media-json-jackson 72 | 73 | 74 | org.glassfish.jersey.media 75 | jersey-media-multipart 76 | 77 | 78 | commons-io 79 | commons-io 80 | 2.4 81 | 82 | 83 | org.apache.jena 84 | apache-jena-libs 85 | pom 86 | 2.13.0 87 | 88 | 89 | es.upm.oeg 90 | ar2dtool 91 | 0.1.0 92 | 93 | 94 | com.owlike 95 | genson 96 | 1.3 97 | 98 | 99 | com.sun.mail 100 | javax.mail 101 | 1.5.5 102 | 103 | 104 | 105 | 106 | oeg-maven 107 | OEG Maven Repository 108 | http://oeg-dev.dia.fi.upm.es/maven/public/ 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/managers/AR2DToolManager.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.managers; 2 | 3 | import java.io.File; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | import java.util.Timer; 7 | import java.util.TimerTask; 8 | import java.util.logging.Level; 9 | import java.util.logging.Logger; 10 | 11 | import org.apache.commons.io.FileUtils; 12 | 13 | import es.upm.oeg.webAR2DTool.responses.WebConfig; 14 | import es.upm.oeg.webAR2DTool.threads.WebAR2DToolThread; 15 | import es.upm.oeg.webAR2DTool.utils.Constants; 16 | 17 | public class AR2DToolManager { 18 | private static final Logger logger = Logger.getLogger(Constants.WEBAPP_NAME); 19 | 20 | private final String sessionID; 21 | private final File file; 22 | private final File workspaceFolder; 23 | private Timer timer; 24 | private WebAR2DToolThread thread; 25 | 26 | public AR2DToolManager(String sessionID,File file, File workspaceFolder){ 27 | this.sessionID = sessionID; 28 | this.file = file; 29 | this.workspaceFolder = workspaceFolder; 30 | this.timer = new Timer(); 31 | this.thread = null; 32 | } 33 | 34 | public void cancelTimeout(){ 35 | try{ 36 | timer.cancel(); 37 | timer = new Timer(); 38 | }catch (Exception e){ 39 | logger.log(Level.SEVERE,"Can not cancel timeout time for sessionID: "+sessionID,e); 40 | } 41 | } 42 | 43 | public boolean removeWorkspaceFolder(){ 44 | try { 45 | FileUtils.deleteDirectory(workspaceFolder); 46 | return true; 47 | } catch (Exception e) { 48 | logger.log(Level.SEVERE, "Can not remove workspace: "+workspaceFolder.getAbsolutePath()+" sessionID:"+sessionID+". Try to force remove it.", e); 49 | return workspaceFolder.delete(); 50 | } 51 | } 52 | 53 | public File getWorkspaceFolder(){ 54 | return workspaceFolder; 55 | } 56 | 57 | public void createNewThread(WebConfig config){ 58 | thread = new WebAR2DToolThread(config, file.getAbsolutePath()); 59 | } 60 | 61 | public File getImage(){ 62 | if(thread==null){ 63 | return null; 64 | } 65 | return thread.getGeneratedImage(); 66 | } 67 | 68 | public File getGrapml(){ 69 | if(thread==null){ 70 | return null; 71 | } 72 | String graphmlPath = file.getAbsolutePath()+".graphml"; 73 | File graphml = new File(graphmlPath); 74 | return graphml; 75 | } 76 | 77 | public File getDot(){ 78 | if(thread==null){ 79 | return null; 80 | } 81 | String dotPath = file.getAbsolutePath()+".dot"; 82 | File dot = new File(dotPath); 83 | return dot; 84 | } 85 | 86 | public File getLog(){ 87 | if(thread==null){ 88 | return null; 89 | } 90 | String logPath = file.getAbsolutePath()+".log"; 91 | File log = new File(logPath); 92 | return log; 93 | } 94 | 95 | public void destroy() { 96 | cancelTimeout(); 97 | try{ 98 | if(thread!=null && thread.isAlive()){ 99 | thread.interrupt(); 100 | } 101 | }catch(Exception e){ 102 | logger.log(Level.SEVERE,"Can not interrupt thread for sessionID: "+sessionID,e); 103 | } 104 | } 105 | 106 | public void schedule(TimerTask timerTask,int sessionTimeoutSeconds) { 107 | timer.schedule(timerTask, getNewTimeoutDate(sessionTimeoutSeconds)); 108 | } 109 | 110 | public String getSessionID() { 111 | return sessionID; 112 | } 113 | 114 | public File getFile() { 115 | return file; 116 | } 117 | 118 | public Timer getTimer() { 119 | return timer; 120 | } 121 | 122 | public WebAR2DToolThread getThread() { 123 | return thread; 124 | } 125 | 126 | private Date getNewTimeoutDate(int sessionTimeoutSeconds) { 127 | Calendar calendar = Calendar.getInstance(); 128 | calendar.add(Calendar.SECOND, sessionTimeoutSeconds); 129 | return calendar.getTime(); 130 | } 131 | 132 | 133 | } 134 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/responses/WebConfig.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.responses; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.io.Serializable; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | import java.util.Properties; 10 | import java.util.logging.Level; 11 | import java.util.logging.Logger; 12 | 13 | import javax.servlet.ServletContext; 14 | import javax.ws.rs.core.Context; 15 | 16 | import com.fasterxml.jackson.annotation.JsonInclude; 17 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 18 | 19 | import es.upm.oeg.ar2dtool.exceptions.ConfigFileNotFoundException; 20 | import es.upm.oeg.ar2dtool.exceptions.ConfigKeyNotFound; 21 | import es.upm.oeg.ar2dtool.utils.ConfigValues; 22 | import es.upm.oeg.webAR2DTool.utils.Constants; 23 | 24 | @JsonInclude(Include.NON_EMPTY) 25 | public class WebConfig implements Serializable{ 26 | 27 | private static final long serialVersionUID = 7856022544247210990L; 28 | private ArrayList> equivalentElementList; 29 | private ArrayList> specialElementsList; 30 | private ArrayList ignoreElementList; 31 | private ArrayList includeOnlyElementList; 32 | private Map keys; 33 | private Logger logger = Logger.getLogger(Constants.WEBAPP_NAME); 34 | 35 | //Invariables, the final user cant change it 36 | private static Map serverKeys; 37 | 38 | //For serialization ignore it. 39 | @SuppressWarnings("unused") 40 | private WebConfig(){ 41 | 42 | } 43 | 44 | 45 | public WebConfig(@Context ServletContext sContext){ 46 | if(serverKeys==null){ 47 | serverKeys = new HashMap(); 48 | Properties prop = new Properties(); 49 | try { 50 | logger.log(Level.INFO, sContext.getRealPath(Constants.SERVER_PROPERTIES)); 51 | prop.load(new FileInputStream(sContext.getRealPath(Constants.SERVER_PROPERTIES))); 52 | for(Object key:prop.keySet()){ 53 | if(key instanceof String){ 54 | serverKeys.put((String)key, prop.getProperty((String) key)); 55 | } 56 | } 57 | } catch (IOException e) { 58 | serverKeys=null; 59 | logger.log(Level.SEVERE, "Can not load server.properties", e); 60 | } 61 | } 62 | equivalentElementList = new ArrayList>(); 63 | specialElementsList = new ArrayList>(); 64 | ignoreElementList = new ArrayList(); 65 | includeOnlyElementList = new ArrayList(); 66 | keys = new HashMap(); 67 | //Server configurations 68 | //keys.put("pathToDot","/usr/local/bin/dot"); 69 | //keys.put("pathToTempDir", "/tmp"); 70 | 71 | //TO PUT FROM A SERVER CONFIG FILE 72 | //keys.put("generateGraphMLFile","false"); 73 | //keys.put("generateGvFile","false"); 74 | 75 | 76 | //FOR TESTING REMOVE IT 77 | //equivalentElementList.add(new ArrayList(Arrays.asList(new String[]{"holaEquivalent","adiosEquivalent"}))); 78 | //specialElementsList.add(new ArrayList(Arrays.asList(new String[]{"holaSpecial","adiosSpecial"}))); 79 | //ignoreElementList.addAll(new ArrayList(Arrays.asList(new String[]{"holaIgnore","adiosIgnore"}))); 80 | //includeOnlyElementList.addAll(new ArrayList(Arrays.asList(new String[]{"holaInclude","adiosInclude"}))); 81 | //END FOR TESTING 82 | 83 | ConfigValues config = new ConfigValues(); 84 | try { 85 | config.readConfigValues(sContext.getRealPath(Constants.DEFAULT_AR2DTOOL_CONFIG)); 86 | this.equivalentElementList.addAll(config.getEquivalentElementList()); 87 | this.ignoreElementList.addAll(config.getIgnoreElementList()); 88 | this.includeOnlyElementList.addAll(config.getIncludeOnlyElementList()); 89 | this.specialElementsList.addAll(config.getSpecialElementsList()); 90 | for(String key:config.getKeys().keySet()){ 91 | if(!serverKeys.containsKey(key)){ 92 | keys.put(key, config.getKeys().get(key)); 93 | } 94 | } 95 | } catch (ConfigFileNotFoundException e) { 96 | logger.log(Level.SEVERE, "Can not load default config.",e); 97 | } 98 | 99 | } 100 | 101 | public ConfigValues toConfigValues(){ 102 | ConfigValues toReturn = new ConfigValues(); 103 | toReturn.setEquivalentElementList(equivalentElementList); 104 | toReturn.setIgnoreElementList(ignoreElementList); 105 | toReturn.setIncludeOnlyElementList(includeOnlyElementList); 106 | toReturn.setSpecialElementsList(specialElementsList); 107 | for(String key:keys.keySet()){ 108 | try { 109 | toReturn.setKeys(key, keys.get(key)); 110 | } catch (ConfigKeyNotFound e) { 111 | logger.log(Level.WARNING, "Not found action for key: "+key+", ignore it.", e); 112 | } 113 | } 114 | for(String key:serverKeys.keySet()){ 115 | try { 116 | if(toReturn.getKeys().containsKey(key)){ 117 | toReturn.setKeys(key, serverKeys.get(key)); 118 | } 119 | } catch (ConfigKeyNotFound e) { 120 | logger.log(Level.WARNING, "Not found action for key: "+key+", ignore it.", e); 121 | } 122 | } 123 | return toReturn; 124 | } 125 | 126 | 127 | //GETTERS AND SETTERS FOR JACKSON serialization 128 | 129 | public ArrayList> getEquivalentElementList() { 130 | return equivalentElementList; 131 | } 132 | 133 | public void setEquivalentElementList(ArrayList> equivalentElementList) { 134 | this.equivalentElementList = equivalentElementList; 135 | } 136 | 137 | public ArrayList> getSpecialElementsList() { 138 | return specialElementsList; 139 | } 140 | 141 | public void setSpecialElementsList(ArrayList> specialElementsList) { 142 | this.specialElementsList = specialElementsList; 143 | } 144 | 145 | public ArrayList getIgnoreElementList() { 146 | return ignoreElementList; 147 | } 148 | 149 | public void setIgnoreElementList(ArrayList ignoreElementList) { 150 | this.ignoreElementList = ignoreElementList; 151 | } 152 | 153 | public ArrayList getIncludeOnlyElementList() { 154 | return includeOnlyElementList; 155 | } 156 | 157 | public void setIncludeOnlyElementList(ArrayList includeOnlyElementList) { 158 | this.includeOnlyElementList = includeOnlyElementList; 159 | } 160 | 161 | public Map getKeys() { 162 | return keys; 163 | } 164 | 165 | public void setKeys(Map keys) { 166 | this.keys = keys; 167 | } 168 | 169 | 170 | } 171 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/threads/WebAR2DToolThread.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.threads; 2 | 3 | import java.io.File; 4 | import java.util.logging.Level; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | import es.upm.oeg.ar2dtool.RDF2Diagram; 9 | import es.upm.oeg.ar2dtool.logger.AR2DToolLogger; 10 | import es.upm.oeg.ar2dtool.utils.ConfigValues; 11 | import es.upm.oeg.ar2dtool.utils.dot.DOTGenerator; 12 | import es.upm.oeg.ar2dtool.utils.graphml.GraphMLGenerator; 13 | import es.upm.oeg.webAR2DTool.responses.WebConfig; 14 | import es.upm.oeg.webAR2DTool.utils.FileLoggerWriter; 15 | 16 | public class WebAR2DToolThread extends Thread { 17 | 18 | private File generatedImage = null; 19 | private ConfigValues config; 20 | private String filePath = ""; 21 | private static Logger logger = Logger.getLogger("WebAR2DTool"); 22 | private final AR2DToolLogger ar2dtoolLog = AR2DToolLogger.getLogger("AR2DTOOL"); 23 | 24 | public WebAR2DToolThread(WebConfig config, String filePath) { 25 | this.config = config.toConfigValues(); 26 | this.filePath = filePath; 27 | } 28 | 29 | @Override 30 | public void run() { 31 | String logFilePath = filePath; 32 | logFilePath += ".log"; 33 | FileLoggerWriter loggerWriter = new FileLoggerWriter("AR2DTOOL_FILE",Level.FINE, logFilePath); 34 | ar2dtoolLog.setWriter(loggerWriter); 35 | RDF2Diagram r2d = new RDF2Diagram(); 36 | try { 37 | String fileName = new File(filePath).getName(); 38 | // load config info 39 | r2d.setConf(config); 40 | 41 | // print config values 42 | log(r2d.getConf().toString()); 43 | 44 | // load model 45 | r2d.loadRdf(filePath); 46 | 47 | // apply the filters specified in config file 48 | r2d.applyFilters(); 49 | log("model:\n" + r2d.printModel()); 50 | log("Generating GV file..."); 51 | 52 | // get the DOTGenerator with the resultant info 53 | DOTGenerator dg = r2d.getDOTGenerator(); 54 | 55 | // apply transformations 56 | dg.applyTransformations(); 57 | 58 | // save the DOT source to file 59 | dg.saveSourceToFile(filePath + ".dot"); 60 | 61 | log("Generated! Path="+fileName+".dot"); 62 | 63 | // get source DOT code 64 | String src = dg.generateDOTSource(); 65 | 66 | // log("Compiling GV, this may take a little while..."); 67 | // compile src code into a graph 68 | dg.generateDOTDiagram(src, filePath+".svg", "svg"); 69 | 70 | generatedImage = new File(filePath+".svg"); 71 | if(!generatedImage.exists() || !generatedImage.canRead() || !generatedImage.isFile()){ 72 | generatedImage = null; 73 | } 74 | // log("Compiled! Path="+pathToOuputFile); 75 | //get the GraphMLGenerator with the resultant info 76 | GraphMLGenerator gg = r2d.getGraphMLGenerator(); 77 | 78 | //apply transformations 79 | gg.applyTransformations(); 80 | 81 | log("GraphML source " + gg.generateGraphMLSource()); 82 | 83 | //save the GraphML source to file 84 | gg.saveSourceToFile(filePath+".graphml"); 85 | loggerWriter.close(); 86 | } catch (Exception e) { 87 | ar2dtoolLog.getWriter().log(e,Level.SEVERE); 88 | loggerWriter.close(); 89 | } 90 | } 91 | 92 | private void log(String string) { 93 | ar2dtoolLog.getWriter().log(string); 94 | } 95 | 96 | public File getGeneratedImage() { 97 | return generatedImage; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | public class Constants { 4 | public static final String WEBAPP_NAME = "WebAR2DTool"; 5 | public static final String VERSION = "0.1.0"; 6 | public static final String SERVER_PROPERTIES = "/WEB-INF/server.properties"; 7 | public static final String MAIL_PROPERTIES = "/WEB-INF/mail.properties"; 8 | public static final String DEFAULT_AR2DTOOL_CONFIG = "/WEB-INF/defaultConfig.txt"; 9 | } 10 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/FileLoggerWriter.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | import java.io.IOException; 4 | import java.util.logging.FileHandler; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | import java.util.logging.SimpleFormatter; 8 | 9 | import es.upm.oeg.ar2dtool.logger.LoggerWriterInterface; 10 | 11 | public class FileLoggerWriter implements LoggerWriterInterface { 12 | 13 | private String loggerName; 14 | private Logger log; 15 | private Level logLevelToSee = Level.INFO; 16 | private Level logLevel = Level.FINE; 17 | private FileHandler fh; 18 | 19 | public FileLoggerWriter(String loggerName,String filePath) { 20 | this.loggerName = loggerName; 21 | log = Logger.getLogger(loggerName); 22 | log.setLevel(logLevelToSee); 23 | setLoggerFile(filePath); 24 | } 25 | 26 | public FileLoggerWriter(String loggerName, Level visibleLevel,String filePath) { 27 | this.loggerName = loggerName; 28 | log = Logger.getLogger(loggerName); 29 | logLevelToSee = visibleLevel; 30 | log.setLevel(logLevelToSee); 31 | setLoggerFile(filePath); 32 | } 33 | public FileLoggerWriter(String loggerName,Level visibleLevel, Level logLevelDefault,String filePath) { 34 | this.loggerName = loggerName; 35 | log = Logger.getLogger(loggerName); 36 | logLevelToSee = visibleLevel; 37 | log.setLevel(logLevelToSee); 38 | logLevel = logLevelDefault; 39 | setLoggerFile(filePath); 40 | } 41 | 42 | @Override 43 | public void log(Exception ex, Level logLevel) { 44 | log.log(logLevel, "Exception: ", ex); 45 | } 46 | 47 | @Override 48 | public void log(String msg, Level logLevel) { 49 | log.log(logLevel,msg); 50 | } 51 | 52 | @Override 53 | public void log(String msg) { 54 | log.log(logLevel,msg); 55 | } 56 | 57 | @Override 58 | public void setLogLevelDefault(Level logLevelDefault) { 59 | logLevel = logLevelDefault; 60 | } 61 | 62 | @Override 63 | public void setVisibleLogLevel(Level visibleLevel) { 64 | logLevelToSee = visibleLevel; 65 | log.setLevel(logLevelToSee); 66 | } 67 | 68 | @Override 69 | public Level getVisibleLogLevel() { 70 | return logLevelToSee; 71 | } 72 | 73 | public void close(){ 74 | fh.flush(); 75 | fh.close(); 76 | } 77 | 78 | private void setLoggerFile(String filePath){ 79 | try { 80 | // This block configure the logger with handler and formatter 81 | fh = new FileHandler(filePath); 82 | log.addHandler(fh); 83 | SimpleFormatter formatter = new SimpleFormatter(); 84 | fh.setFormatter(formatter); 85 | } catch (SecurityException e) { 86 | e.printStackTrace(); 87 | } catch (IOException e) { 88 | e.printStackTrace(); 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/MailSender.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | import java.io.File; 4 | import java.util.Properties; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | 8 | import javax.activation.DataHandler; 9 | import javax.activation.DataSource; 10 | import javax.activation.FileDataSource; 11 | import javax.mail.BodyPart; 12 | import javax.mail.Message; 13 | import javax.mail.MessagingException; 14 | import javax.mail.Multipart; 15 | import javax.mail.PasswordAuthentication; 16 | import javax.mail.Session; 17 | import javax.mail.Transport; 18 | import javax.mail.internet.InternetAddress; 19 | import javax.mail.internet.MimeBodyPart; 20 | import javax.mail.internet.MimeMessage; 21 | import javax.mail.internet.MimeMultipart; 22 | 23 | public class MailSender { 24 | 25 | public static class MailParameterNames { 26 | public static String SERVER = "mail.server"; 27 | public static String SERVER_USER = "mail.server.user"; 28 | public static String SERVER_PASS = "mail.server.password"; 29 | public static String SERVER_PORT = "mail.server.port"; 30 | public static String SERVER_TTLS = "mail.server.ttls.enable"; 31 | public static String FROM_EMAIL = "mail.from"; 32 | public static String TO_EMAIL = "mail.to"; 33 | public static String CC = "mail.cc"; 34 | public static String BCC = "mail.bcc"; 35 | public static String SUBJECT = "mail.subject"; 36 | public static String MESSAGE = "mail.message"; 37 | 38 | } 39 | 40 | public class MailConfException extends Exception { 41 | public MailConfException(String message) { 42 | super(message); 43 | } 44 | 45 | private static final long serialVersionUID = -1533258755097009760L; 46 | } 47 | 48 | private String server = ""; 49 | private String user = ""; 50 | private String pass = ""; 51 | private String port = ""; 52 | private String from = ""; 53 | private String to = ""; 54 | private String subject = ""; 55 | private String originalMessage = ""; 56 | private String ttlsEnable = ""; 57 | private String[] bcc = new String[0]; 58 | private String[] cc = new String[0]; 59 | 60 | private static String[] importantKeys = new String[] { MailParameterNames.SERVER, MailParameterNames.SERVER_USER, 61 | MailParameterNames.SERVER_PASS, MailParameterNames.SERVER_PORT, MailParameterNames.SERVER_TTLS, 62 | MailParameterNames.FROM_EMAIL, MailParameterNames.TO_EMAIL, MailParameterNames.SUBJECT, 63 | MailParameterNames.MESSAGE }; 64 | 65 | public MailSender(Properties prop) throws MailConfException { 66 | StringBuffer errors = new StringBuffer(""); 67 | String[] values = new String[importantKeys.length]; 68 | for (int i = 0; i < importantKeys.length; i++) { 69 | values[i] = prop.getProperty(importantKeys[i]); 70 | } 71 | if (!checkParams(errors, values, importantKeys)) { 72 | throw new MailConfException(errors.toString()); 73 | } 74 | server = prop.getProperty(MailParameterNames.SERVER); 75 | user = prop.getProperty(MailParameterNames.SERVER_USER); 76 | pass = prop.getProperty(MailParameterNames.SERVER_PASS); 77 | port = prop.getProperty(MailParameterNames.SERVER_PORT); 78 | from = prop.getProperty(MailParameterNames.FROM_EMAIL); 79 | to = prop.getProperty(MailParameterNames.TO_EMAIL); 80 | ttlsEnable = prop.getProperty(MailParameterNames.SERVER_TTLS); 81 | subject = prop.getProperty(MailParameterNames.SUBJECT); 82 | originalMessage = prop.getProperty(MailParameterNames.MESSAGE); 83 | String bccString = prop.getProperty(MailParameterNames.BCC); 84 | String ccString = prop.getProperty(MailParameterNames.CC); 85 | if (bccString != null && !bccString.isEmpty() && bccString.split("#").length > 0) { 86 | bcc = bccString.split("#"); 87 | } 88 | if (ccString != null && !ccString.isEmpty() && ccString.split("#").length > 0) { 89 | cc = ccString.split("#"); 90 | } 91 | } 92 | 93 | public boolean sendEmail(String sessionID, String message, String emailPerson,File ontFile, File log, File image, File dot, 94 | File graphml) { 95 | try { 96 | Properties propiedades = new Properties(); 97 | propiedades.put("mail.smtp.auth", "true"); 98 | propiedades.put("mail.smtp.starttls.enable", ttlsEnable); 99 | propiedades.put("mail.smtp.host", server); 100 | propiedades.put("mail.smtp.port", port); 101 | // Obtenemos la sesion 102 | Session sessionMail = Session.getInstance(propiedades, new javax.mail.Authenticator() { 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(user, pass); 105 | } 106 | }); 107 | // Creamos un objeto mensaje tipo MimeMessage por defecto. 108 | MimeMessage mensaje = new MimeMessage(sessionMail); 109 | 110 | // Asignamos el emisor del mensaje al header del correo. 111 | mensaje.setFrom(new InternetAddress(from)); 112 | 113 | // Asignamos el receptor del mensaje al header del correo. 114 | mensaje.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); 115 | for (String bcci : bcc) { 116 | mensaje.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcci)); 117 | } 118 | for (String cci : cc) { 119 | mensaje.addRecipient(Message.RecipientType.CC, new InternetAddress(cci)); 120 | } 121 | 122 | // Asignamos el asunto 123 | mensaje.setSubject(subject.replace("%SESSION_ID%", sessionID)); 124 | 125 | // Create the message part 126 | BodyPart messageBodyPart = new MimeBodyPart(); 127 | 128 | // Now set the actual message 129 | messageBodyPart.setText(getMessage(originalMessage, message, emailPerson,ontFile, log, image, dot, graphml)); 130 | 131 | // Create a multipar message 132 | Multipart multipart = new MimeMultipart(); 133 | 134 | // Set text message part 135 | multipart.addBodyPart(messageBodyPart); 136 | 137 | //attach files 138 | attachFiles(multipart, ontFile ,log, image, dot, graphml); 139 | 140 | // Send the complete message parts 141 | mensaje.setContent(multipart); 142 | 143 | // Enviamos el correo 144 | Transport.send(mensaje); 145 | } catch (Exception e) { 146 | Logger.getLogger(Constants.WEBAPP_NAME).log(Level.SEVERE, "Can not sent message", e); 147 | return false; 148 | } 149 | return true; 150 | } 151 | 152 | private static void attachFiles(Multipart multipart,File ontFile, File log, File image, File dot, File graphml) 153 | throws MessagingException { 154 | if(checkFile(ontFile)){ 155 | BodyPart messageBodyPart = new MimeBodyPart(); 156 | DataSource source = new FileDataSource(ontFile); 157 | messageBodyPart.setDataHandler(new DataHandler(source)); 158 | messageBodyPart.setFileName(ontFile.getName()); 159 | multipart.addBodyPart(messageBodyPart); 160 | } 161 | if(checkFile(log)){ 162 | BodyPart messageBodyPart = new MimeBodyPart(); 163 | DataSource source = new FileDataSource(log); 164 | messageBodyPart.setDataHandler(new DataHandler(source)); 165 | messageBodyPart.setFileName(log.getName()); 166 | multipart.addBodyPart(messageBodyPart); 167 | } 168 | if(checkFile(dot)){ 169 | BodyPart messageBodyPart = new MimeBodyPart(); 170 | DataSource source = new FileDataSource(dot); 171 | messageBodyPart.setDataHandler(new DataHandler(source)); 172 | messageBodyPart.setFileName(dot.getName()); 173 | multipart.addBodyPart(messageBodyPart); 174 | } 175 | if(checkFile(graphml)){ 176 | BodyPart messageBodyPart = new MimeBodyPart(); 177 | DataSource source = new FileDataSource(graphml); 178 | messageBodyPart.setDataHandler(new DataHandler(source)); 179 | messageBodyPart.setFileName(graphml.getName()); 180 | multipart.addBodyPart(messageBodyPart); 181 | } 182 | if(checkFile(image)){ 183 | BodyPart messageBodyPart = new MimeBodyPart(); 184 | DataSource source = new FileDataSource(image); 185 | messageBodyPart.setDataHandler(new DataHandler(source)); 186 | messageBodyPart.setFileName(image.getName()); 187 | multipart.addBodyPart(messageBodyPart); 188 | } 189 | } 190 | 191 | private static String getMessage(String originalMessage, String message, String emailPerson,File ontFile, File log, File image, 192 | File dot, File graphml) { 193 | StringBuffer filesInfo = new StringBuffer(""); 194 | filesInfo.append("\nOntology File available: "); 195 | filesInfo.append(checkFile(ontFile)); 196 | filesInfo.append("\nLog File available: "); 197 | filesInfo.append(checkFile(log)); 198 | filesInfo.append("\nDot File available: "); 199 | filesInfo.append(checkFile(dot)); 200 | filesInfo.append("\nGraphML file available: "); 201 | filesInfo.append(checkFile(graphml)); 202 | filesInfo.append("\nImage File available: "); 203 | filesInfo.append(checkFile(image)); 204 | filesInfo.append("\n"); 205 | return originalMessage.replace("%FILES_INFO%", filesInfo.toString()).replace("%MESSAGE%", message).replace("%CONTACT_EMAIL%", emailPerson); 206 | } 207 | 208 | private static boolean checkFile(File file) { 209 | return file != null && file.exists() && file.isFile() && file.canRead(); 210 | } 211 | 212 | private static boolean checkParams(StringBuffer buffer, String[] args, String[] ids) { 213 | boolean okParams = true; 214 | StringBuffer toAppend = new StringBuffer(); 215 | for (int i = 0; i < args.length; i++) { 216 | if (args[i] == null || args[i].isEmpty()) { 217 | okParams = false; 218 | toAppend.append("KEY="+ids[i]+" parameter is null or empty.\n"); 219 | } 220 | } 221 | if(!okParams){ 222 | buffer.append("Error bad config file.\n"); 223 | buffer.append(toAppend); 224 | } 225 | return okParams; 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/ParameterNames.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | public class ParameterNames { 4 | public static final String PATH_TO_DOT = "pathToDot"; 5 | public static final String PATH_TO_TEMP_DIR = "pathToTempDir"; 6 | public static final String PATH_TO_UPLOADED_FILES = "server.pathToUploadedFiles"; 7 | public static final String SESSION_TIMEOUT_IN_SECONDS = "server.session.timeout.seconds"; 8 | public static final String REMOVE_DIR_SESSION = "server.removeDirSession"; 9 | public static final String UPLOAD_TIMEOUT_SECONDS = "server.generate.timeout.seconds"; 10 | public static final String UPLOAD_FILE_SIZE_MB = "server.upload.file.size.mb"; 11 | public static final String GENERATE_TRIPLETS_LIMIT = "server.generate.limit.triples"; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/PosibleLangsJena.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | import org.apache.jena.riot.Lang; 4 | 5 | public class PosibleLangsJena { 6 | public static final Lang[] posibleLangs = new Lang[]{Lang.RDFXML,Lang.TURTLE,Lang.N3,Lang.NTRIPLES,Lang.JSONLD 7 | ,Lang.NQ,Lang.NQUADS,Lang.NT,Lang.RDFJSON,Lang.RDFJSON,Lang.RDFNULL, 8 | Lang.RDFTHRIFT,Lang.TRIG,Lang.TRIX/*,Lang.CSV*/}; 9 | } 10 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/ResponseFormats.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | public enum ResponseFormats { 4 | JSON 5 | } 6 | -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/WebResponse.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | import java.io.Serializable; 4 | 5 | public class WebResponse implements Serializable{ 6 | private static final long serialVersionUID = 4789743659969588210L; 7 | private Object response; 8 | private String idErrorMessage; 9 | private String errorMessage; 10 | 11 | public WebResponse(Object response,String idErrorMessage,String errorMessage){ 12 | this.response = response; 13 | if(response instanceof String){ 14 | String responseString = String.valueOf(response); 15 | if(responseString.isEmpty()){ 16 | this.response = null; 17 | } 18 | } 19 | this.errorMessage = errorMessage; 20 | this.idErrorMessage = idErrorMessage; 21 | } 22 | 23 | public boolean isErrorResponse(){ 24 | return response==null; 25 | } 26 | 27 | public Object getResponse() { 28 | return response; 29 | } 30 | 31 | public String getIdErrorMessage() { 32 | return idErrorMessage; 33 | } 34 | 35 | public String getErrorMessage() { 36 | return errorMessage; 37 | } 38 | 39 | 40 | } -------------------------------------------------------------------------------- /webAppProject/src/main/java/es/upm/oeg/webAR2DTool/utils/WebString.java: -------------------------------------------------------------------------------- 1 | package es.upm.oeg.webAR2DTool.utils; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.logging.Level; 5 | import java.util.logging.Logger; 6 | 7 | public class WebString { 8 | private String string; 9 | 10 | public WebString(String string){ 11 | this.string = string; 12 | } 13 | 14 | public String getString(){ 15 | return convertToUTF8(string); 16 | } 17 | 18 | private String convertToUTF8(String in){ 19 | try { 20 | in = in.replace("\n", "\\n"); 21 | byte[] bytes = in.getBytes(); 22 | return new String(bytes, "UTF-8"); 23 | } catch (UnsupportedEncodingException ex) { 24 | Logger.getLogger(Constants.WEBAPP_NAME).log(Level.SEVERE, null, ex); 25 | } 26 | return in; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/WEB-INF/defaultConfig.txt: -------------------------------------------------------------------------------- 1 | imageSize=1501; 2 | rankdir=LR; 3 | 4 | ######## 5 | #shapes# 6 | ######## 7 | 8 | #classShape=diamond; 9 | #individualShape=diamond; 10 | #literalShape=box; 11 | #arrowhead=normal; 12 | #arrowtail=normal; 13 | #arrowdir=forward; 14 | 15 | ######## 16 | #colors# 17 | ######## 18 | 19 | classColor=orange; 20 | #individualColor=orange; 21 | #literalColor=blue; 22 | #arrowColor=blue; 23 | 24 | ############# 25 | #RDF options# 26 | ############# 27 | 28 | nodeNameMode=localname; 29 | ignoreLiterals=true; 30 | ignoreRdfType=true; 31 | synthesizeObjectProperties=true; 32 | 33 | 34 | ####### 35 | #lists# 36 | ####### 37 | 38 | 39 | ignoreElementList=[]; 40 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/WEB-INF/mail.properties: -------------------------------------------------------------------------------- 1 | mail.server= 2 | mail.server.user= 3 | mail.server.password= 4 | mail.server.port= 5 | mail.server.ttls.enable= 6 | mail.from= 7 | mail.to= 8 | mail.cc= 9 | mail.bcc= 10 | mail.subject=[WebAR2DTool] Report send. SessionID=%SESSION_ID% 11 | mail.message=A user send report for you.\n%FILES_INFO%\nUser email: %CONTACT_EMAIL%\nUser message:\n%MESSAGE%\n -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/WEB-INF/server.properties: -------------------------------------------------------------------------------- 1 | pathToDot=/usr/bin/dot 2 | 3 | pathToTempDir= 4 | 5 | server.pathToUploadedFiles= 6 | 7 | server.removeDirSession=true 8 | 9 | server.session.timeout.seconds=3600 10 | 11 | server.generate.timeout.seconds=16 12 | 13 | server.upload.file.size.mb=5 14 | 15 | server.generate.limit.triples=5000 -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | CharacterEncoding 9 | org.apache.catalina.filters.SetCharacterEncodingFilter 10 | 11 | encoding 12 | UTF-8 13 | 14 | 15 | 16 | html 17 | text/html;charset=UTF-8 18 | 19 | 20 | css 21 | text/css;charset=UTF-8 22 | 23 | 24 | js 25 | application/javascript;charset=UTF-8 26 | 27 | 28 | jsp 29 | application/html;charset=UTF-8 30 | 31 | 32 | Jersey Web Application 33 | org.glassfish.jersey.servlet.ServletContainer 34 | 35 | com.sun.jersey.api.json.POJOMappingFeature 36 | true 37 | 38 | 39 | jersey.config.server.provider.packages 40 | es.upm.oeg.webAR2DTool.services 41 | 42 | 43 | jersey.config.server.provider.classnames 44 | org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature 45 | 46 | 1 47 | 48 | 49 | Jersey Web Application 50 | /webapi/* 51 | 52 | 53 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/file.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/image.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/css/animations.css: -------------------------------------------------------------------------------- 1 | @-webkit-keyframes openFromRight { 2 | from { right:-100%;} 3 | to {right: 0%;} 4 | } 5 | @-moz-keyframes openFromRight { 6 | from {right: -100%;} 7 | to {right: 0%;} 8 | } 9 | @-o-keyframes openFromRight { 10 | from {right:-100%;} 11 | to {right:0%;} 12 | } 13 | @keyframes openFromRight { 14 | from{right:-100%} 15 | to{right:0%} 16 | } 17 | 18 | @-webkit-keyframes closeToRight { 19 | from {right:0%;} 20 | to {right:-100%;} 21 | } 22 | @-moz-keyframes closeToRight { 23 | from {right:0%;} 24 | to {right:-100%;} 25 | } 26 | @-o-keyframes closeToRight { 27 | from {right:0%;} 28 | to {right:-100%;} 29 | } 30 | @keyframes closeToRight { 31 | from{right:0%;} 32 | to{right:-100%;} 33 | } -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/css/configSpecial.css: -------------------------------------------------------------------------------- 1 | .buttonDisable{ 2 | opacity:0.2; 3 | cursor:default !important; 4 | } 5 | 6 | .configSpecialPanel:not(.open){ 7 | -webkit-animation: closeToRight 1s 1 linear; 8 | -moz-animation: closeToRight 1s 1 linear; 9 | -o-animation: closeToRight 1s 1 linear; 10 | animation: closeToRight 1s 1 linear; 11 | right:-100%; 12 | 13 | } 14 | 15 | .configSpecialPanel.open{ 16 | -webkit-animation: openFromRight 1s 1 linear; 17 | -moz-animation: openFromRight 1s 1 linear; 18 | -o-animation: openFromRight 1s 1 linear; 19 | animation: openFromRight 1s 1 linear; 20 | right:0%; 21 | } 22 | 23 | @media screen and (max-width:600px){ 24 | .configSpecialPanel{ 25 | overflow-y:auto; 26 | } 27 | } 28 | 29 | .configSpecialPanel{ 30 | background-color:#F0F0F0; 31 | z-index:6; 32 | } 33 | 34 | .configListContainer{ 35 | margin:10px 10px 10px 10px; 36 | -webkit-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 37 | -moz-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 38 | box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 39 | background-color:#E0E0E0; 40 | color:rgba(70, 121, 189,1); 41 | } 42 | 43 | @media screen and (min-width:600px){ 44 | .configListContainer{ 45 | overflow-y:auto; 46 | } 47 | } 48 | 49 | .configSpecialMinMaxMobile{ 50 | min-width:250px; 51 | max-width:49%; 52 | min-height:400px; 53 | } 54 | 55 | .configListContainer > div:nth-child(n){ 56 | margin-top:6px; 57 | vertical-align:middle; 58 | display: -ms-flexbox; 59 | display: -webkit-flex; 60 | display: flex; 61 | -webkit-flex-direction: row; 62 | -ms-flex-direction: row; 63 | flex-direction: row; 64 | flex: 0 1 auto; 65 | box-sizing: content-box; 66 | height:100%; 67 | min-height:25px; 68 | padding-top: 2px; 69 | padding-bottom: 4px; 70 | /*-webkit-flex-grow: 1; 71 | -ms-flex-grow: 1; 72 | flex-grow: 1;*/ 73 | } 74 | 75 | .configListContainer > div:nth-child(n) > div:nth-child(2n+1){ 76 | -webkit-flex-grow: 1; 77 | -ms-flex-grow: 1; 78 | flex-grow: 1; 79 | padding-top:3px; 80 | word-wrap:break-word; 81 | word-break:break-all; 82 | margin-right:8px; 83 | margin-top: 0px; 84 | margin-bottom: 0px; 85 | height:100%; 86 | } 87 | 88 | .configListContainer > div:nth-child(n) > div:nth-child(2n+0){ 89 | width: 25px; 90 | min-width:25px; 91 | height: 25px; 92 | min-height:25px; 93 | margin: 2px 2px 2px 2px; 94 | right: 6px; 95 | cursor:pointer; 96 | align-self: center; 97 | } 98 | 99 | .configListContainer > div:nth-child(n) > div:nth-child(2n+0) > img{ 100 | width:25px; 101 | height:25px; 102 | } 103 | 104 | .textTittleConfigSpecial{ 105 | background-color:#E0E0E0; 106 | padding: 5px 5px 5px 5px; 107 | color:rgba(70, 121, 189,1); 108 | min-height:2em; 109 | } 110 | 111 | .configSpecialSubmitButton{ 112 | margin: 0px 10px 10px 10px; 113 | min-height:32px; 114 | vertical-align: middle; 115 | text-align: center; 116 | } 117 | 118 | .equivalentCheckbox:not(.selected){ 119 | -webkit-background-size: cover; 120 | -moz-background-size: cover; 121 | -o-background-size: cover; 122 | background-image: url("../img/checkbox_unchecked.png"); 123 | background-size: cover; 124 | } 125 | 126 | .equivalentCheckbox.selected{ 127 | -webkit-background-size: cover; 128 | -moz-background-size: cover; 129 | -o-background-size: cover; 130 | background-image: url("../img/checkbox_checked.png"); 131 | background-size: cover; 132 | } 133 | 134 | .specialCheckbox:not(.selected){ 135 | -webkit-background-size: cover; 136 | -moz-background-size: cover; 137 | -o-background-size: cover; 138 | background-image: url("../img/checkbox_unchecked.png"); 139 | background-size: cover; 140 | width: 25px; 141 | min-width: 25px; 142 | height: 25px; 143 | min-height: 25px; 144 | margin: 2px 2px 2px 2px; 145 | right: 6px; 146 | cursor: pointer; 147 | align-self: center; 148 | z-index: 20; 149 | } 150 | 151 | .specialCheckbox.selected{ 152 | -webkit-background-size: cover; 153 | -moz-background-size: cover; 154 | -o-background-size: cover; 155 | background-image: url("../img/checkbox_checked.png"); 156 | background-size: cover; 157 | width: 25px; 158 | min-width: 25px; 159 | height: 25px; 160 | min-height: 25px; 161 | margin: 2px 2px 2px 2px; 162 | right: 6px; 163 | cursor: pointer; 164 | align-self: center; 165 | z-index: 20; 166 | } 167 | 168 | .specialListEditContainer{ 169 | margin:10px 10px 10px 10px; 170 | -webkit-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 171 | -moz-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 172 | box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 173 | background-color:#E0E0E0; 174 | color:rgba(70, 121, 189,1); 175 | } 176 | 177 | .specialListEditContainer > div:nth-child(n){ 178 | margin-top:6px; 179 | vertical-align:middle; 180 | display: -ms-flexbox; 181 | display: -webkit-flex; 182 | display: flex; 183 | -webkit-flex-direction: row; 184 | -ms-flex-direction: row; 185 | flex-direction: row; 186 | flex: 0 1 auto; 187 | box-sizing: content-box; 188 | height:100%; 189 | min-height:25px; 190 | padding-top: 2px; 191 | padding-bottom: 4px; 192 | /*-webkit-flex-grow: 1; 193 | -ms-flex-grow: 1; 194 | flex-grow: 1;*/ 195 | } 196 | 197 | .specialListParamContainer{ 198 | margin-top: 5px; 199 | margin-bottom: 5px; 200 | padding-bottom: 7px; 201 | -webkit-flex-wrap: wrap; 202 | -ms-flex-wrap: wrap; 203 | flex-wrap: wrap; 204 | } 205 | 206 | .specialListKey{ 207 | padding-right:15px; 208 | } 209 | 210 | .disableSpecial{ 211 | opacity: 0.4; 212 | cursor: not-allowed; 213 | pointer-events: none; 214 | } 215 | 216 | .equivalentUri{ 217 | cursor:pointer; 218 | margin-right:5px; 219 | margin-left:5px; 220 | padding-left:3px; 221 | } 222 | 223 | .equivalentUri:not(.editing){ 224 | 225 | } 226 | 227 | .equivalentUri.editing{ 228 | -webkit-box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.75); 229 | -moz-box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.75); 230 | box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.75); 231 | } -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/css/dropDownMenu.css: -------------------------------------------------------------------------------- 1 | #nav 2 | { 3 | /* container */ 4 | } 5 | #nav > a 6 | { 7 | display: none; 8 | } 9 | #nav li 10 | { 11 | position: relative; 12 | } 13 | 14 | /* first level */ 15 | 16 | #nav > ul 17 | { 18 | height: 3.75em; 19 | } 20 | #nav > ul > li 21 | { 22 | width: 25%; 23 | height: 100%; 24 | float: left; 25 | } 26 | 27 | /* second level */ 28 | 29 | #nav li ul 30 | { 31 | display: none; 32 | position: absolute; 33 | top: 100%; 34 | } 35 | #nav li:hover ul 36 | { 37 | display: block; 38 | } 39 | 40 | @media only screen and ( max-width: 640px ) /* 640 */ 41 | { 42 | #nav 43 | { 44 | position: relative; 45 | } 46 | #nav > a 47 | { 48 | } 49 | #nav:not( :target ) > a:first-of-type, 50 | #nav:target > a:last-of-type 51 | { 52 | display: block; 53 | } 54 | 55 | /* first level */ 56 | 57 | #nav > ul 58 | { 59 | height: auto; 60 | display: none; 61 | position: absolute; 62 | left: 0; 63 | right: 0; 64 | } 65 | #nav:target > ul 66 | { 67 | display: block; 68 | } 69 | #nav > ul > li 70 | { 71 | width: 100%; 72 | float: none; 73 | } 74 | 75 | /* second level */ 76 | 77 | #nav li ul 78 | { 79 | position: static; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/css/styles.css: -------------------------------------------------------------------------------- 1 | * { box-sizing: border-box; 2 | position: relative; 3 | } 4 | 5 | html,body{ 6 | width: 100%; 7 | height: 100%; 8 | display: -webkit-flex; 9 | display: -moz-flex; 10 | display: -ms-flexbox; 11 | display: flex; 12 | overflow: hidden; 13 | margin: 0px; 14 | font-family: 'Helvetica', sans-serif, 'Arial'; 15 | color: white; 16 | } 17 | 18 | nav > div{ 19 | -ms-align-items: center; 20 | -webkit-align-items: center; 21 | align-items: center; 22 | -webkit-align-self: center; 23 | -ms-flex-item-align: center; 24 | align-self: center; 25 | display: -ms-flexbox; 26 | display: -webkit-flex; 27 | display: flex; 28 | -webkit-flex-direction: column; 29 | -ms-flex-direction: column; 30 | flex-direction: column; 31 | padding: 5px 5px 5px 5px; 32 | margin: 3px 3px 3px 3px; 33 | /*border: solid 3px white; 34 | border-style: outset;*/ 35 | } 36 | 37 | nav div a{ 38 | cursor:pointer; 39 | text-decoration:none; 40 | color:white; 41 | } 42 | 43 | .header{ 44 | -webkit-flex-basis: 75px; 45 | -ms-flex-basis: 75px; 46 | flex-basis: 75px; 47 | -webkit-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 48 | -moz-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 49 | box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.4); 50 | z-index:10; 51 | } 52 | 53 | .menu{ 54 | background:rgba(70, 121, 189,1); 55 | } 56 | 57 | .mainContent{ 58 | overflow: hidden; 59 | } 60 | .navDropDownContainer{ 61 | cursor: pointer; 62 | } 63 | @media screen and (max-width : 1100px){ 64 | .navMenu{ 65 | position:absolute; 66 | right:0px; 67 | top:75px; 68 | z-index:10; 69 | display:none; 70 | display: -ms-flexbox; 71 | display: -webkit-flex; 72 | display: flex; 73 | -webkit-flex-direction: column; 74 | -ms-flex-direction: column; 75 | flex-direction: column; 76 | } 77 | nav > div{ 78 | border-bottom: 1px rgba(255, 255, 255, 0.29) solid; 79 | width:100%; 80 | } 81 | .navDropDownItem{ 82 | background:rgba(70, 121, 189,1); 83 | position:relative; 84 | width:104%; 85 | } 86 | .navDropDownItem div{ 87 | padding: 5px 5px 5px 5px; 88 | margin: 3px 3px 3px 3px; 89 | } 90 | .dropDownImage{ 91 | width:35px; 92 | height:35px; 93 | } 94 | .dropUpImage{ 95 | width:35px; 96 | height:35px; 97 | } 98 | .navDropDownContainer.activateResponsive .dropDownImage{ 99 | display:none; 100 | } 101 | .navDropDownContainer.notActivateResponsive .dropUpImage{ 102 | display:none; 103 | } 104 | .navDropDownContainer.notActivateResponsive .navDropDownItem{ 105 | display:none; 106 | } 107 | nav.notActivateResponsive{ 108 | display:none; 109 | } 110 | .navDropDownContainer.activateResponsive .navDropDownItem{ 111 | display: -ms-flexbox; 112 | display: -webkit-flex; 113 | display: flex; 114 | -webkit-flex-direction: column; 115 | -ms-flex-direction: column; 116 | flex-direction: column; 117 | } 118 | div.imgMenu{ 119 | display: -ms-flexbox; 120 | display: -webkit-flex; 121 | display: flex; 122 | -ms-align-items: center; 123 | -webkit-align-items: center; 124 | align-items: center; 125 | cursor:pointer; 126 | height:100%; 127 | position:absolute; 128 | right:0px; 129 | } 130 | img.imgMenu{ 131 | height:100%; 132 | width:auto; 133 | } 134 | } 135 | 136 | @media screen and (min-width : 1101px){ 137 | .navMenu{ 138 | display: -ms-flexbox; 139 | display: -webkit-flex; 140 | display: flex; 141 | -webkit-flex-direction: row; 142 | -ms-flex-direction: row; 143 | flex-direction: row; 144 | } 145 | .dropDownImage{ 146 | width:1em; 147 | height:1em; 148 | } 149 | .dropUpImage{ 150 | width:1em; 151 | height:1em; 152 | } 153 | .navDropDownContainer:hover .dropDownImage{ 154 | display:none; 155 | } 156 | .navDropDownContainer:not(:hover) .dropUpImage{ 157 | display:none; 158 | } 159 | .navDropDownContainer:not(:hover) .navDropDownItem{ 160 | display:none; 161 | } 162 | .navDropDownContainer:hover .navDropDownItem{ 163 | display: -ms-flexbox; 164 | display: -webkit-flex; 165 | display: flex; 166 | -webkit-flex-direction: column; 167 | -ms-flex-direction: column; 168 | flex-direction: column; 169 | } 170 | .navDropDownItem{ 171 | /*-webkit-box-shadow: 0px 2px 1px 1px rgba(0, 0, 0, 0.4); 172 | -moz-box-shadow: 0px 2px 1px 1px rgba(0, 0, 0, 0.4); 173 | box-shadow: 0px 2px 1px 1px rgba(0, 0, 0, 0.4);*/ 174 | -webkit-box-shadow: 0px 5px 5px -4px rgba(50, 50, 50, 0.75), 175 | 15px 10px 5px -14px rgba(50, 50, 50, 0.75); 176 | -moz-box-shadow: 0px 5px 5px -4px rgba(50, 50, 50, 0.75), 177 | 15px 10px 5px -14px rgba(50, 50, 50, 0.75); 178 | box-shadow: 0px 5px 5px -4px rgba(50, 50, 50, 0.75), 179 | 15px 10px 5px -14px rgba(50, 50, 50, 0.75); 180 | background:rgba(70, 121, 189,1); 181 | position:absolute; 182 | min-width: 114%; 183 | padding-right: 22px; 184 | width: auto; 185 | left: 0px; 186 | border-top: 14px solid rgba(255,255,255,0); 187 | -moz-background-clip: padding; 188 | -webkit-background-clip: padding; 189 | background-clip: padding-box; 190 | } 191 | .navDropDownItem div{ 192 | padding: 5px 5px 5px 5px; 193 | margin: 3px 3px 3px 3px; 194 | } 195 | .imgMenu{ 196 | display:none; 197 | } 198 | .navMenuButton{ 199 | margin-left:10px; 200 | background-color: rgba(80, 140, 189,1); 201 | border-radius:4px; 202 | padding: 4px 10px 4px 10px; 203 | cursor:pointer; 204 | -webkit-box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 205 | -moz-box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 206 | box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 207 | } 208 | } 209 | .navMenu{ 210 | color: #FFFFFF; 211 | background:rgba(70, 121, 189,1); 212 | } 213 | 214 | 215 | .padT5{ 216 | padding-top:5px; 217 | } 218 | 219 | .padL5{ 220 | padding-left:5px; 221 | } 222 | 223 | .dropMenuContentContainer{ 224 | word-wrap: break-word; 225 | word-break: break-all; 226 | overflow-y: auto; 227 | } 228 | 229 | .dropMenuContainerOpen{ 230 | background:rgba(70, 121, 189,0.9); 231 | /*-webkit-box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.6); 232 | -moz-box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.6); 233 | box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.6);*/ 234 | z-index:5; 235 | position: absolute; 236 | height: 100%; 237 | } 238 | 239 | @media screen and (min-width : 861px){ 240 | .dropMenuContainerClose{ 241 | background:rgba(70, 121, 189,0.9); 242 | z-index:5; 243 | position: absolute; 244 | height: 100%; 245 | left: -30em; 246 | 247 | } 248 | 249 | .dropMenuContentContainerOpen{ 250 | width:30em; 251 | } 252 | 253 | .dropMenuContentContainerClose{ 254 | width:30em; 255 | } 256 | } 257 | 258 | @media screen and (max-width : 860px) and (min-width: 641px){ 259 | .dropMenuContainerClose{ 260 | background:rgba(70, 121, 189,0.9); 261 | z-index:5; 262 | position: absolute; 263 | height: 100%; 264 | left: -25em; 265 | } 266 | 267 | .dropMenuContentContainerOpen{ 268 | width:25em; 269 | } 270 | 271 | .dropMenuContentContainerClose{ 272 | width:25em; 273 | } 274 | } 275 | 276 | @media screen and (max-width : 640px) and (min-width: 431px){ 277 | .dropMenuContainerClose{ 278 | background:rgba(70, 121, 189,0.9); 279 | z-index:5; 280 | position: absolute; 281 | height: 100%; 282 | left: -20em; 283 | } 284 | 285 | .dropMenuContentContainerOpen{ 286 | width:20em; 287 | } 288 | 289 | .dropMenuContentContainerClose{ 290 | width:20em; 291 | } 292 | } 293 | @media screen and (max-width : 430px){ 294 | .dropMenuContainerClose{ 295 | background:rgba(70, 121, 189,0.9); 296 | z-index:5; 297 | position: absolute; 298 | height: 100%; 299 | left: -10em; 300 | } 301 | 302 | .dropMenuContentContainerOpen{ 303 | width:10em; 304 | } 305 | 306 | .dropMenuContentContainerClose{ 307 | width:10em; 308 | } 309 | } 310 | 311 | div.dropClickMenu{ 312 | background:rgba(70, 121, 189,0.5); 313 | cursor: pointer; 314 | flex-shrink: 0; 315 | /*margin-right:-2px;*/ 316 | } 317 | 318 | @media screen and (min-width : 1024px){ 319 | img.dropClickMenu{ 320 | width: 23px; 321 | height:23px; 322 | } 323 | .dropClickMenu{ 324 | -webkit-flex-basis: 25px; 325 | -ms-flex-basis: 25px; 326 | flex-basis: 25px; 327 | } 328 | .imageContainer{ 329 | position: relative; 330 | left: 23px; 331 | padding-right: 23px; 332 | } 333 | } 334 | 335 | @media screen and (max-width : 1023px){ 336 | img.dropClickMenu{ 337 | width: 35px; 338 | height: 35px; 339 | } 340 | .dropClickMenu{ 341 | -webkit-flex-basis: 37px; 342 | -ms-flex-basis: 37px; 343 | flex-basis: 37px; 344 | } 345 | .imageContainer{ 346 | position: relative; 347 | left: 35px; 348 | padding-right: 35px; 349 | } 350 | } 351 | 352 | @media screen and (max-width : 450px){ 353 | img.Logo{ 354 | max-width:100px; 355 | max-height:64px; 356 | } 357 | img.LogoMin{ 358 | height:32px; 359 | max-height:32px; 360 | } 361 | div.Logo{ 362 | padding: 3px 3px 3px 3px; 363 | display: -ms-flexbox; 364 | display: -webkit-flex; 365 | display: flex; 366 | -webkit-flex-direction: row; 367 | -ms-flex-direction: row; 368 | flex-direction: row; 369 | -ms-align-items: center; 370 | -webkit-align-items: center; 371 | align-items: center; 372 | } 373 | } 374 | @media screen and (min-width : 451px){ 375 | img.Logo{ 376 | height: 64px; 377 | } 378 | div.Logo{ 379 | padding: 3px 3px 3px 3px; 380 | } 381 | } 382 | 383 | .overflowYAuto{ 384 | overflow-y:auto; 385 | } 386 | 387 | .imageImg{ 388 | width: 100%; 389 | height:auto; 390 | } 391 | 392 | .generateDiv{ 393 | position: absolute; 394 | width: 64px; 395 | height: 64px; 396 | bottom: 2px; 397 | right: 5px; 398 | margin-right: 5px; 399 | margin-bottom: 5px; 400 | border-radius:32px; 401 | -webkit-box-shadow: 0px 5px 8px 0px rgba(50, 50, 50, 0.75); 402 | -moz-box-shadow: 0px 5px 8px 0px rgba(50, 50, 50, 0.75); 403 | box-shadow: 0px 5px 8px 0px rgba(50, 50, 50, 0.75); 404 | cursor:pointer; 405 | /*-webkit-box-shadow: 0px 0px 6px 0px rgba(50, 50, 50, 0.75); 406 | -moz-box-shadow: 0px 0px 6px 0px rgba(50, 50, 50, 0.75); 407 | box-shadow: 0px 0px 6px 0px rgba(50, 50, 50, 0.75);*/ 408 | } 409 | 410 | .configColor{ 411 | width:35px; 412 | height:35px; 413 | margin:0px 5px 0px 5px; 414 | cursor: pointer; 415 | padding: 3px 3px 3px 3px; 416 | background-clip:content-box; 417 | } 418 | 419 | .arrowImage{ 420 | width:64px; 421 | height:14px; 422 | margin-right:4px; 423 | margin-top:4px; 424 | } 425 | 426 | .colorSelect{ 427 | width:64px !important; 428 | height:14px !important; 429 | margin-right:2px !important; 430 | margin-top:4px; 431 | } 432 | 433 | .arrowText{ 434 | word-wrap:normal; 435 | word-bread:keep-all; 436 | } 437 | 438 | .imageSelectBackground{ 439 | background-color:white; 440 | border-radius: 6px; 441 | } 442 | 443 | .colorSelectBackground{ 444 | background-color:white; 445 | border-radius: 6px; 446 | } 447 | 448 | .configColor.selected{ 449 | border:solid 2px white; 450 | } 451 | 452 | .configColor.notSelected{ 453 | /*border:outset 3px;*/ 454 | } 455 | 456 | .configKeyParamContainer{ 457 | margin-top: 5px; 458 | margin-bottom:5px; 459 | padding-bottom:7px; 460 | border-bottom: solid 1px; 461 | -webkit-flex-wrap: wrap; 462 | -ms-flex-wrap: wrap; 463 | flex-wrap: wrap; 464 | } 465 | 466 | .maxWidthAndHeightAbsolute{ 467 | position:absolute; 468 | width:100%; 469 | height:100%; 470 | } 471 | 472 | .maxWidthAndHeight{ 473 | width:100%; 474 | height:100%; 475 | } 476 | 477 | .notAnimationOnLoad{ 478 | -webkit-animation: none !important; 479 | -moz-animation: none !important; 480 | -ms-animation: none !important; 481 | -o-animation: none !important; 482 | animation: none !important; 483 | } 484 | 485 | .configListButton{ 486 | margin-left:10px; 487 | background-color: rgba(80, 140, 189,1); 488 | border-radius:4px; 489 | padding: 4px 10px 4px 10px; 490 | cursor:pointer; 491 | -webkit-box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 492 | -moz-box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 493 | box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.75); 494 | } 495 | 496 | .displayNone{ 497 | display:none; 498 | } 499 | 500 | .crossAxisFlexCenter{ 501 | -ms-align-items: center; 502 | -webkit-align-items: center; 503 | align-items: center; 504 | } 505 | 506 | .mainAxisFlexCenter{ 507 | -ms-justify-content: center; 508 | -webkit-justify-content: center; 509 | justify-content: center; 510 | } 511 | 512 | .maxCrossAxisFlexSize{ 513 | -webkit-align-self: stretch; 514 | -ms-flex-item-align: stretch; 515 | align-self: stretch; 516 | } 517 | 518 | .maxMainAxisFlexSize{ 519 | -webkit-flex-basis: 100%; 520 | -ms-flex-basis: 100%; 521 | flex-basis: 100%; 522 | } 523 | 524 | .flex-container-column{ 525 | display: -ms-flexbox; 526 | display: -webkit-flex; 527 | display: flex; 528 | -webkit-flex-direction: column; 529 | -ms-flex-direction: column; 530 | flex-direction: column; 531 | /*-webkit-flex-wrap: nowrap; 532 | -ms-flex-wrap: nowrap; 533 | flex-wrap: nowrap;*/ 534 | } 535 | 536 | .flex-container-row{ 537 | display: -ms-flexbox; 538 | display: -webkit-flex; 539 | display: flex; 540 | -webkit-flex-direction: row; 541 | -ms-flex-direction: row; 542 | flex-direction: row; 543 | /*-webkit-flex-wrap: nowrap; 544 | -ms-flex-wrap: nowrap; 545 | flex-wrap: nowrap;*/ 546 | } 547 | 548 | .flex-wrap{ 549 | -webkit-flex-wrap: wrap; 550 | -ms-flex-wrap: wrap; 551 | flex-wrap: wrap; 552 | } 553 | 554 | .flex-nowrap{ 555 | -webkit-flex-wrap: nowrap; 556 | -ms-flex-wrap: nowrap; 557 | flex-wrap: nowrap; 558 | } 559 | 560 | .flex-order0{ 561 | -webkit-order: 0; 562 | -ms-flex-order: 0; 563 | order: 0; 564 | } 565 | 566 | .flex-item{ 567 | -webkit-flex-grow: 0; 568 | -ms-flex-grow: 0; 569 | flex-grow: 0; 570 | } 571 | 572 | .flex-item-main{ 573 | -webkit-flex-grow: 1; 574 | -ms-flex-grow: 1; 575 | flex-grow: 1; 576 | } 577 | 578 | .flex-shrink0{ 579 | -webkit-flex-shrink: 0; 580 | -ms-flex-shrink: 0; 581 | flex-shrink: 0; 582 | } 583 | 584 | .flex-align-center{ 585 | -webkit-align-self: center; 586 | -ms-flex-item-align: center; 587 | align-self: center; 588 | } 589 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/css/zoomAndPanned.css: -------------------------------------------------------------------------------- 1 | .containerPanAndZoom{ 2 | position: relative; 3 | cursor: all-scroll; 4 | overflow:hidden; 5 | } 6 | 7 | .zoomTextContainer{ 8 | color: white; 9 | position: absolute; 10 | top: 0%; 11 | left:48%; 12 | -webkit-box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75); 13 | -moz-box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75); 14 | box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75); 15 | padding: 2px; 16 | margin: 5px 0px 0px 0px; 17 | background: rgba(70, 121, 189,1); 18 | z-index:10; 19 | } 20 | 21 | .noDraggablePanAndZoom{ 22 | /* For Opera and <= IE9, we need to add unselectable="on" attribute onto each element */ 23 | /* Check this site for more details: http://help.dottoro.com/lhwdpnva.php */ 24 | -moz-user-select: none; /* These user-select properties are inheritable, used to prevent text selection */ 25 | -moz-user-drag: none; 26 | -webkit-user-select: none; 27 | -ms-user-select: none; /* From IE10 only */ 28 | user-select: none; /* Not valid CSS yet, as of July 2012 */ 29 | 30 | -webkit-user-drag: none; /* Prevents dragging of images/divs etc */ 31 | user-drag: none; 32 | } 33 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/Flat.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Additional styles correct images location and change to flat style 3 | * 4 | * @author Web Semantics, Inc. Dev Team 5 | * @copyright 2011-2015 Web Semantics, Inc. 6 | * @link http://websemantics.ca 7 | * @license https://opensource.org/licenses/MIT 8 | */ 9 | 10 | .chosen-container-multi .chosen-choices, 11 | .chosen-container-single .chosen-single { 12 | position: relative; 13 | display: block; 14 | overflow: hidden; 15 | /* padding: 7px 0 0 8px; 16 | height: 42px;*/ 17 | border: 2px solid #acb4b9; 18 | border-radius: 5px; 19 | background: none; 20 | width:100%; 21 | box-shadow: none; 22 | margin-bottom: 0px!important; 23 | } 24 | 25 | .chosen-container-multi .chosen-choices{ 26 | padding: 5px 8px; 27 | } 28 | 29 | .chosen-container { 30 | width:100%!important; 31 | margin-bottom: 10px; 32 | } 33 | 34 | .chosen-container-active .chosen-single { 35 | border: 2px solid #acb4b9; 36 | box-shadow: none; 37 | } 38 | 39 | .chosen-container-single .chosen-search input[type="text"] { 40 | border: 1px solid #acb4b9; 41 | } 42 | 43 | .chosen-container-active.chosen-container-multi.chosen-with-drop .chosen-choices, 44 | .chosen-container-active.chosen-with-drop .chosen-single { 45 | border: 2px solid #acb4b9; 46 | border-bottom-color: white; 47 | background-image: none; 48 | box-shadow: none; 49 | } 50 | 51 | .chosen-container-multi .chosen-choices li.search-choice { 52 | border: 2px solid #acb4b9; 53 | background: none; 54 | } 55 | 56 | .chosen-container-multi .chosen-drop { 57 | margin-top: -4px; 58 | } 59 | 60 | .chosen-container-single .chosen-drop { 61 | margin-top: -2px; 62 | } 63 | 64 | .chosen-container .chosen-drop { 65 | border: 2px solid #acb4b9; 66 | border-top: 0; 67 | box-shadow: none; 68 | } 69 | 70 | .chosen-container .chosen-results li.highlighted { 71 | background-color: #3875d7; 72 | background-image: none; 73 | background-color: #acb4b9; 74 | color: #fff; 75 | } 76 | 77 | .chosen-container-single .chosen-single div { 78 | /*padding: 7px 3px 0px 0px; 79 | width: 16px;*/ 80 | } 81 | 82 | .chosen-container-single .chosen-single abbr { 83 | background: url('chosen/chosen-sprite.png') -42px 1px no-repeat; 84 | } 85 | 86 | .chosen-container-single .chosen-single div b { 87 | background: url('chosen/chosen-sprite.png') no-repeat 0px 2px; 88 | } 89 | .chosen-container-single .chosen-search input[type="text"] { 90 | background: white url('chosen/chosen-sprite.png') no-repeat 100% -20px; 91 | background: url('chosen/chosen-sprite.png') no-repeat 100% -20px; 92 | } 93 | .chosen-container-multi .chosen-choices li.search-choice .search-choice-close { 94 | background: url('chosen/chosen-sprite.png') -42px 1px no-repeat; 95 | } 96 | .chosen-rtl .chosen-search input[type="text"] { 97 | background: white url('chosen/chosen-sprite.png') no-repeat -30px -20px; 98 | background: url('chosen/chosen-sprite.png') no-repeat -30px -20px; 99 | } 100 | 101 | @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi), only screen and (min-resolution: 1.5dppx) { 102 | .chosen-rtl .chosen-search input[type="text"], 103 | .chosen-container-single .chosen-single abbr, 104 | .chosen-container-single .chosen-single div b, 105 | .chosen-container-single .chosen-search input[type="text"], 106 | .chosen-container-multi .chosen-choices .search-choice .search-choice-close, 107 | .chosen-container .chosen-results-scroll-down span, 108 | .chosen-container .chosen-results-scroll-up span { 109 | background-image: url('chosen/chosen-sprite@2x.png') !important; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/ImageSelect.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Image Select Styles 3 | * 4 | * @author Web Semantics, Inc. Dev Team 5 | * @copyright 2011-2015 Web Semantics, Inc. 6 | * @link http://websemantics.ca 7 | * @license https://opensource.org/licenses/MIT 8 | */ 9 | 10 | /* Tag image */ 11 | .chose-image { 12 | width:55px; 13 | max-height:55px; 14 | padding: 2px 5px 3px 0px; 15 | vertical-align:middle; 16 | } 17 | 18 | .chose-image.rtl { 19 | padding: 2px 0px 3px 5px; 20 | } 21 | 22 | /* Image for Single mode */ 23 | .chose-image-small { 24 | width:18px; 25 | max-height:18px; 26 | vertical-align: middle; 27 | margin: -3px 0 0 0; 28 | padding: 0 3px 0 0; 29 | } 30 | 31 | .chose-image-small.rtl { 32 | padding: 0 0 0 3px; 33 | } 34 | 35 | /* Images appended to the li(s) */ 36 | .chose-image-list { 37 | width:18px; 38 | max-height:18px; 39 | vertical-align: middle; 40 | margin: -3px 0 0 0; 41 | padding: 0 3px 0 0; 42 | } 43 | 44 | .chose-image-list.rtl { 45 | padding: 0 0 0 3px; 46 | } 47 | 48 | /* Grey-out image for Multi mode */ 49 | .chosen-container-multi .result-selected img { 50 | opacity: 0.3; 51 | } 52 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/ImageSelect.jquery.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Image Select (Version 1.7) 3 | * 4 | * Image Select is an extention to the Chosen, a Select Box Enhancer for 5 | * jQuery and Prototype, full source at https://github.com/harvesthq/chosen 6 | * 7 | * This plugin extension was designed as a humanized UI element for social networking 8 | * sites that need to faciliate relations between people. Research shows that people 9 | * are extremely sensitvie to photos of others, so we needed to revamp the traditional 10 | * UI elements to make them more intuitive and human. 11 | * 12 | * Hope you find it helpful, and get back if you have any feedback/improvements. 13 | * 14 | * @author Adnan Sagar, PhD 15 | * @copyright 2002-2015 Web Semantics, Inc. (http://websemantics.ca) & AlterSpark Corp. (http://www.alterspark.com) 16 | * @license http://www.opensource.org/licenses/mit-license.php MIT 17 | * @link http://websemantics.ca 18 | * @package websemantics/image-select 19 | */ 20 | 21 | (function($) { 22 | 23 | // Image template, this can be overridden from the constructor (options.template), 24 | // must contains {src} placeholder. Ther eare two class names 25 | // 'chose-image' or 'chose-image-small', modifiy in CSS 26 | var fn_template = ''; 27 | 28 | function prependTemplate(element, option, template, rtl, multiple, cls){ 29 | // summery: 30 | // This will fill-in the provided template with image source and css class 31 | // then add it to the element. 32 | // 33 | // element: Dom 34 | // This is the span node 35 | // object: Object, 36 | // The select option to get image url 37 | // template: String 38 | // Html content 39 | // rtl: Boolean, 40 | // Right to Left 41 | // multiple: Boolean 42 | // Used to select the approperiate css class, default to 'true' 43 | // cls*: String (optional) 44 | // Css styles class 45 | 46 | var src = $(option).data('img-src'); 47 | 48 | if(src != undefined && src > ''){ 49 | 50 | element = $(element); 51 | 52 | text = $(option).text(); 53 | multiple = (multiple != undefined) ? multiple : true; 54 | cls = cls || (multiple ? 'chose-image' : 'chose-image-small'); 55 | cls = rtl ? cls + ' rtl' : cls; 56 | template = template.replace('{url}',src) 57 | .replace('{class_name}',cls) 58 | .replace('{text}',text); 59 | 60 | // Empty the element 61 | element.empty(); 62 | 63 | // Insert after if ltr or multiple select, otherwise, insert before 64 | if(rtl && multiple){ 65 | element.append(template); 66 | } 67 | else { 68 | element.prepend(template); 69 | } 70 | } 71 | } 72 | 73 | function getSelectedOptions(chosen){ 74 | // summery: 75 | // Return a list of selected items/options with the selected 'option' elements 76 | // and chosen 'span' elements. 77 | // 78 | // chosen: Chosen 79 | // The Chosen object 80 | 81 | var items = []; 82 | if(chosen){ 83 | var options = $(chosen.form_field).find('option:selected') || []; 84 | var spans = (chosen.is_multiple) ? $(chosen.container).find('.chosen-choices span'): 85 | $(chosen.container).find('.chosen-single span'); 86 | 87 | for(var i = 0 ; i < options.length; i++) 88 | for (var j = 0; j < spans.length; j++) 89 | if($(spans[j]).text() == $(options[i]).text()) 90 | items.push({span:spans[j],option:options[i]}); 91 | } 92 | return items; 93 | } 94 | 95 | // Store the original 'chosen' method 96 | var fn_chosen = $.fn.chosen; 97 | 98 | $.fn.extend({ 99 | // summery: 100 | // Extend the original 'chosen' method to support images 101 | chosen: function(params) { 102 | 103 | params = params || {}; 104 | 105 | // Original behavior - use function.apply to preserve context 106 | var ret = fn_chosen.apply(this, arguments); 107 | 108 | // Process all select elements to attach event handlers 109 | // (change, hiding_dropdown and showing_dropdown) 110 | 111 | this.each(function() { 112 | 113 | var $this = $(this), chosen = $this.data('chosen'); 114 | 115 | $this.on("chosen:hiding_dropdown", function(e, chosen){ 116 | // summery 117 | // Triggers when hidding dropdown, explain why:TODO. 118 | // 119 | // evt: Event 120 | // The event object 121 | // _chosen: Object {chosen:Chosen} 122 | // Contains the current instance of Chosen class 123 | if(chosen.chosen){ 124 | var options = getSelectedOptions(chosen.chosen); 125 | var rtl = chosen.chosen.is_rtl; 126 | var multiple = chosen.chosen.is_multiple; 127 | var html_template = params.html_template || 128 | (rtl && multiple ? '{text}' + fn_template : fn_template + '{text}'); 129 | 130 | for (var i = 0; i < options.length; i++){ 131 | prependTemplate(options[i].span, options[i].option, html_template, rtl, multiple); 132 | } 133 | } 134 | }) 135 | 136 | $this.on("chosen:showing_dropdown", function showing_dropdown(evt, chosen){ 137 | // summery 138 | // This function is triggered when the chosen instance dropdown list 139 | // becomes visible. http://forwebonly.com/jquery-chosen-custom-events-and-how-to-use-them/ 140 | // 141 | // evt: Event 142 | // The event object 143 | // chosen: Object {chosen:Chosen} 144 | // Contains the current instance of Chosen class 145 | 146 | var chosen = chosen.chosen; 147 | var options = chosen.form_field.options || []; 148 | var rtl = chosen.is_rtl; 149 | if(params.template && params.template>''){ 150 | var html_template = params.template; 151 | }else{ 152 | var html_template = params.html_template || 153 | rtl ? '{text}'+fn_template : fn_template+'{text}'; 154 | } 155 | 156 | var lis = $(chosen.container).find('.chosen-drop ul li:not(:has(img))') 157 | 158 | for(var i = 0; i < lis.length; i++){ 159 | var li = lis[i]; 160 | var option = $(options[i]); 161 | var idx = $(li).attr('data-option-array-index'); 162 | 163 | if (idx) /* correct option index */ 164 | option = options[chosen.results_data[idx].options_index]; 165 | 166 | prependTemplate(li, option, html_template, rtl, true, 'chose-image-list'); 167 | } 168 | }); 169 | 170 | $this.on("chosen:ready", function change(e, chosen){ 171 | // summery: 172 | // Trigger hide dropdown when ready. 173 | // This never triggers. TODO: remove. 174 | $this.trigger('chosen:hiding_dropdown',chosen); 175 | }); 176 | 177 | $this.on('chosen:filter', function(evt, chosen){ 178 | // summery; 179 | // Support search, pending: https://github.com/harvesthq/chosen/pull/2373 180 | $this.trigger('chosen:showing_dropdown',{chosen:chosen.chosen}); 181 | }); 182 | 183 | // Finally, trigger hiding_dropdown on all select elements 184 | $this.trigger('chosen:hiding_dropdown',{chosen:chosen}); 185 | }); 186 | } 187 | }); 188 | 189 | 190 | })(jQuery); 191 | -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/chosen.min.css: -------------------------------------------------------------------------------- 1 | /* Chosen v1.5.1 | (c) 2011-2016 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */ 2 | 3 | .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container .search-choice .group-name,.chosen-container .chosen-single .group-name{margin-right:4px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:400;color:#999}.chosen-container .search-choice .group-name:after,.chosen-container .chosen-single .group-name:after{content:":";padding-left:2px;vertical-align:top}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:25px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{color:#444;position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;word-wrap:break-word;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{color:#777;display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;margin:0;padding:0 5px;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:0;height:25px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#999;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 5px 3px 0;padding:3px 20px 3px 5px;border:1px solid #aaa;max-width:100%;border-radius:3px;background-color:#eee;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-size:100% 19px;background-repeat:repeat-x;background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice span{word-wrap:break-word}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#222!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi),only screen and (min-resolution:1.5dppx){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}} -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/chosen/chosen-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/imageSelect/chosen/chosen-sprite.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/imageSelect/chosen/chosen-sprite@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/imageSelect/chosen/chosen-sprite@2x.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/Logo_AR2DTool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/Logo_AR2DTool.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/OEG_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/OEG_Logo.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/add.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/box.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/box.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/diamond.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/diamond.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/dot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/dot.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/inv.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/inv.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/normal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/normal.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/obox.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/obox.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/odiamond.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/odiamond.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/odot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/odot.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/oinv.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/oinv.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/arrows/onormal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/arrows/onormal.gif -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/checkbox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/checkbox_checked.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/checkbox_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/checkbox_unchecked.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/dropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/dropdown.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/dropleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/dropleft.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/dropright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/dropright.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/dropup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/dropup.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/edit.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/edit_edited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/edit_edited.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/fondo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/fondo.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/generateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/generateIcon.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/minus.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/img/nav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idafensp/ar2dtool/c1b6c11537aaddc8f79527da385766cad4157f68/webAppProject/src/main/webapp/resources/img/nav.png -------------------------------------------------------------------------------- /webAppProject/src/main/webapp/resources/js/doubletaptogo.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | By Osvaldas Valutis, www.osvaldas.info 3 | Available for use under the MIT License 4 | */ 5 | 6 | 7 | 8 | ;(function(e,t,n,r){e.fn.doubleTapToGo=function(r){if(!("ontouchstart"in t)&&!navigator.msMaxTouchPoints&&!navigator.userAgent.toLowerCase().match(/windows phone os 7/i))return false;this.each(function(){var t=false;e(this).on("click",function(n){var r=e(this);if(r[0]!=t[0]){n.preventDefault();t=r}});e(n).on("click touchstart MSPointerDown",function(n){var r=true,i=e(n.target).parents();for(var s=0;sc;c++)if(h=e[c],g=E.style[h],f(h,"-")&&(h=l(h)),E.style[h]!==t){if(i||o(r,"undefined"))return a(),"pfx"==n?h:!0;try{E.style[h]=r}catch(y){}if(E.style[h]!=g)return a(),"pfx"==n?h:!0}return a(),!1}function v(e,n,t,r,i){var s=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+N.join(s+" ")+s).split(" ");return o(n,"string")||o(n,"undefined")?g(a,n,r,i):(a=(e+" "+k.join(s+" ")+s).split(" "),d(a,n,t))}function y(e,n,o){return v(e,t,t,n,o)}var w=[],_=[],x={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){_.push({name:e,fn:n,options:t})},addAsyncTest:function(e){_.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=x,Modernizr=new Modernizr,Modernizr.addTest("cookies",function(){try{n.cookie="cookietest=1";var e=-1!=n.cookie.indexOf("cookietest=");return n.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}catch(t){return!1}}),Modernizr.addTest("json","JSON"in e&&"parse"in JSON&&"stringify"in JSON),Modernizr.addTest("svg",!!n.createElementNS&&!!n.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect);var C=n.documentElement,T="svg"===C.nodeName.toLowerCase();Modernizr.addTest("inlinesvg",function(){var e=s("div");return e.innerHTML="","http://www.w3.org/2000/svg"==("undefined"!=typeof SVGRect&&e.firstChild&&e.firstChild.namespaceURI)});var S;!function(){var e={}.hasOwnProperty;S=o(e,"undefined")||o(e.call,"undefined")?function(e,n){return n in e&&o(e.constructor.prototype[n],"undefined")}:function(n,t){return e.call(n,t)}}(),x._l={},x.on=function(e,n){this._l[e]||(this._l[e]=[]),this._l[e].push(n),Modernizr.hasOwnProperty(e)&&setTimeout(function(){Modernizr._trigger(e,Modernizr[e])},0)},x._trigger=function(e,n){if(this._l[e]){var t=this._l[e];setTimeout(function(){var e,o;for(e=0;e7)),Modernizr.addTest("flexbox",y("flexBasis","1px",!0)),Modernizr.addTest("flexboxlegacy",y("boxDirection","reverse",!0));var P=function(e){if("undefined"==typeof XMLHttpRequest)return!1;var n=new XMLHttpRequest;n.open("get","/",!0);try{n.responseType=e}catch(t){return!1}return"response"in n&&n.responseType==e};Modernizr.addTest("xhrresponsetypejson",P("json")),r(),i(w),delete x.addTest,delete x.addAsyncTest;for(var z=0;z-1){ 18 | img = jQuery("
"); 19 | }else{ 20 | img = jQuery(""); 21 | } 22 | //Init containers 23 | container.empty(); 24 | container.unbind('mousedown touchstart mousemove touchmove touchend mouseup mouseout wheel'); 25 | container.addClass('containerPanAndZoom noDraggablePanAndZoom'); 26 | if(!(option && (typeof option === 'string' || option instanceof String) && option.toLowerCase().indexOf("svg")>-1)){ 27 | img.attr("src", imageURL); 28 | } 29 | 30 | img.attr("style", "position:relative; width:100%;height:auto; left:0px;top:0px"); 31 | img.attr('class','noDraggablePanAndZoom'); 32 | 33 | container.append(img); 34 | if(option && (typeof option === 'string' || option instanceof String) && option.toLowerCase().indexOf("svg")>-1){ 35 | img.load(imageURL,function(){ 36 | jQuery(img).find("svg").attr("width","100%"); 37 | jQuery(img).find("svg").attr("height","100%"); 38 | }); 39 | } 40 | function removeLastZoom(){ 41 | if(zoomContainer !== null){ 42 | zoomContainer.remove(); 43 | zoomContainer = null; 44 | } 45 | if(zoomTimeout !== null){ 46 | window.clearTimeout(zoomTimeout); 47 | zoomTimeout = null; 48 | } 49 | } 50 | 51 | 52 | function updateTotalOffSets(){ 53 | minX = (img.width()*-1)+50; 54 | if(totalOffSetXPan < minX){ 55 | totalOffSetXPan = minX; 56 | } 57 | minY = (img.height()*-1)+50; 58 | if(totalOffSetYPan < minY){ 59 | totalOffSetYPan = minY; 60 | } 61 | maxX = container.width()-50; 62 | if(totalOffSetXPan > maxX){ 63 | totalOffSetXPan = maxX; 64 | } 65 | maxY = container.height()-50; 66 | if(totalOffSetYPan > maxY){ 67 | totalOffSetYPan = maxY; 68 | } 69 | img.css('left',totalOffSetXPan+'px'); 70 | img.css('top',totalOffSetYPan+'px'); 71 | } 72 | 73 | 74 | 75 | function updateZoom(){ 76 | removeLastZoom(); 77 | zoomContainer = jQuery('
'+widthPercentPan+'%
'); 78 | zoomContainer.attr('class','zoomTextContainer'); 79 | container.append(zoomContainer); 80 | zoomTimeout = window.setTimeout(removeLastZoom, 1200); 81 | img.css('width',widthPercentPan+'%'); 82 | updateTotalOffSets(); 83 | } 84 | 85 | container.on('mousedown',function(event){ 86 | if(event.preventDefault){ 87 | event.preventDefault() 88 | } 89 | mouseDownPan = true; 90 | mouseXPan = event.pageX; 91 | mouseYPan = event.pageY; 92 | }); 93 | 94 | container.on('touchstart',function(event){ 95 | event.stopImmediatePropagation(); 96 | if(event.preventDefault){ 97 | event.preventDefault() 98 | } 99 | var ev = event.originalEvent; 100 | if (ev.targetTouches.length == 1) { 101 | var touch = ev.targetTouches[0]; 102 | mouseDownPan = true; 103 | mouseXPan = touch.pageX; 104 | mouseYPan = touch.pageY; 105 | } 106 | if (ev.targetTouches.length == 2) { 107 | zoomTouch0 = ev.targetTouches[0]; 108 | zoomTouch1 = ev.targetTouches[1]; 109 | } 110 | }); 111 | 112 | container.on('mousemove',function(event){ 113 | if(mouseDownPan === true){ 114 | var offSetX = event.pageX - mouseXPan; 115 | var offSetY = event.pageY - mouseYPan; 116 | totalOffSetXPan += offSetX; 117 | totalOffSetYPan += offSetY; 118 | mouseXPan = event.pageX; 119 | mouseYPan = event.pageY; 120 | updateTotalOffSets(); 121 | } 122 | }); 123 | container.on('touchmove',function(event){ 124 | event.stopImmediatePropagation(); 125 | if(event.preventDefault){ 126 | event.preventDefault() 127 | } 128 | if(mouseDownPan === true){ 129 | var ev = event.originalEvent; 130 | if (ev.targetTouches.length == 1) { 131 | var touch = ev.targetTouches[0]; 132 | var offSetX = touch.pageX - mouseXPan; 133 | var offSetY = touch.pageY - mouseYPan; 134 | totalOffSetXPan += offSetX; 135 | totalOffSetYPan += offSetY; 136 | mouseXPan = touch.pageX; 137 | mouseYPan = touch.pageY; 138 | updateTotalOffSets(); 139 | } 140 | } 141 | if (ev.targetTouches.length == 2) { 142 | var touch0 = ev.targetTouches[0]; 143 | var touch1 = ev.targetTouches[1]; 144 | var originalDistance = Math.sqrt(Math.pow(zoomTouch1.pageX - zoomTouch0.pageX,2)+Math.pow(zoomTouch1.pageY - zoomTouch0.pageY,2)); 145 | var newDistance = Math.sqrt(Math.pow(touch1.pageX - touch0.pageX,2)+Math.pow(touch1.pageY - touch0.pageY,2)); 146 | if(newDistance-originalDistance >= distanceToIncZoom){ 147 | //Increment Zoom 148 | zoomTouch0 = touch0; 149 | zoomTouch1 = touch1; 150 | widthPercentPan += 25; 151 | updateZoom(); 152 | }else if(originalDistance-newDistance >= distanceToIncZoom){ 153 | //Decrement Zoom 154 | zoomTouch0 = touch0; 155 | zoomTouch1 = touch1; 156 | if(widthPercentPan > 25){ 157 | widthPercentPan -= 25; 158 | } 159 | updateZoom(); 160 | } 161 | } 162 | }); 163 | 164 | container.on('touchend mouseup',function(event){ 165 | mouseDownPan = false; 166 | }); 167 | 168 | container.on('mouseout',function(event){ 169 | mouseDownPan = false; 170 | }); 171 | 172 | container.bind('wheel', function(event){ 173 | if(event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0){ 174 | widthPercentPan += 25; 175 | }else{ 176 | if(event.originalEvent.wheelDelta){ 177 | if(widthPercentPan > 25){ 178 | widthPercentPan -= 25; 179 | } 180 | }else{//For MAC Touchpad 181 | if(event.originalEvent.deltaY > 0){ 182 | widthPercentPan += 25; 183 | }else if(event.originalEvent.deltaY < 0){ 184 | if(widthPercentPan > 25){ 185 | widthPercentPan -= 25; 186 | } 187 | } 188 | 189 | } 190 | } 191 | updateZoom(); 192 | }); 193 | } 194 | }; 195 | 196 | function runScriptZoomAndPanned() { 197 | if( window.jQuery ) { 198 | initZoomAndPanned(); 199 | } else { 200 | window.setTimeout( runScriptZoomAndPanned, 100 ); 201 | } 202 | } 203 | runScriptZoomAndPanned(); 204 | 205 | --------------------------------------------------------------------------------