001/* 002 * Copyright 2006 - 2013 003 * Stefan Balev <stefan.balev@graphstream-project.org> 004 * Julien Baudry <julien.baudry@graphstream-project.org> 005 * Antoine Dutot <antoine.dutot@graphstream-project.org> 006 * Yoann Pigné <yoann.pigne@graphstream-project.org> 007 * Guilhelm Savin <guilhelm.savin@graphstream-project.org> 008 * 009 * This file is part of GraphStream <http://graphstream-project.org>. 010 * 011 * GraphStream is a library whose purpose is to handle static or dynamic 012 * graph, create them from scratch, file or any source and display them. 013 * 014 * This program is free software distributed under the terms of two licenses, the 015 * CeCILL-C license that fits European law, and the GNU Lesser General Public 016 * License. You can use, modify and/ or redistribute the software under the terms 017 * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following 018 * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by 019 * the Free Software Foundation, either version 3 of the License, or (at your 020 * option) any later version. 021 * 022 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 023 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 024 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 025 * 026 * You should have received a copy of the GNU Lesser General Public License 027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 028 * 029 * The fact that you are presently reading this means that you have had 030 * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. 031 */ 032package org.graphstream.stream.file; 033 034import java.io.Reader; 035 036import org.graphstream.stream.file.tlp.TLPParser; 037import org.graphstream.util.parser.Parser; 038import org.graphstream.util.parser.ParserFactory; 039 040/** 041 * Source for the Tulip file format (TLP). 042 * 043 * TLP files begins with : 044 * 045 * <pre> 046 * (tlp "2.0" 047 * ; file content 048 * ) 049 * </pre> 050 * 051 * Some meta informations can be done : 052 * 053 * <pre> 054 * (tlp "2.0" 055 * (author "author name") 056 * (date "...") 057 * (comments "...") 058 * ... 059 * ) 060 * </pre> 061 * 062 * Node indexes are integer. They can be declared in a "nodes" tag : 063 * 064 * <pre> 065 * (tlp "2.0" 066 * (nodes 1 2 3) 067 * (edge 1 1 2) 068 * (edge 2 1 3) 069 * (edge 3 2 3) 070 * ) 071 * </pre> 072 * 073 * Then edge can be defined with an int index followed by the index of the 074 * source node and the target nodes. 075 * 076 * Clusters can be created with an index and a name: 077 * <pre> 078 * (tlp "2.0" 079 * (nodes 1 2 3) 080 * (edge 1 1 2) 081 * (edge 2 1 3) 082 * (edge 3 2 3) 083 * (cluster 1 "cluster name" 084 * (nodes 1 3) 085 * (edges 2) 086 * ) 087 * ) 088 * </pre> 089 * 090 * Cluster 0 is the root graph. 091 * 092 * Properties can be applied to cluster: 093 * <pre> 094 * (tlp "2.0" 095 * (nodes 1 2 3) 096 * (edge 1 1 2) 097 * (edge 2 1 3) 098 * (edge 3 2 3) 099 * (property cluster_id type "name" 100 * (default "node_default" "edge_default") 101 * (node node_id "value") 102 * (edge edge_id "value") 103 * ) 104 * ) 105 * </pre> 106 * 107 * Type of properties can be one of : 108 * <ul> 109 * <li>bool</li> 110 * <li>double</li> 111 * <li>int</li> 112 * <li>string</li> 113 * <li>color</li> 114 * <li>layout</li> 115 * <li>size</li> 116 * </ul> 117 */ 118public class FileSourceTLP extends FileSourceParser { 119 /* 120 * (non-Javadoc) 121 * @see org.graphstream.stream.file.FileSourceParser#getNewFactory() 122 */ 123 public ParserFactory getNewParserFactory() { 124 return new ParserFactory() { 125 public Parser newParser(Reader reader) { 126 return new TLPParser(FileSourceTLP.this, reader); 127 } 128 }; 129 } 130}