Commit 4d7952c7 authored by Antoine Dutot's avatar Antoine Dutot

Merge pull request #129 from trajar/master

Removed system.out/err messages.
parents 4e76d955 1828c48f
/* /*
* Copyright 2006 - 2013 * Copyright 2006 - 2013
* Stefan Balev <stefan.balev@graphstream-project.org> * Stefan Balev <stefan.balev@graphstream-project.org>
* Julien Baudry <julien.baudry@graphstream-project.org> * Julien Baudry <julien.baudry@graphstream-project.org>
* Antoine Dutot <antoine.dutot@graphstream-project.org> * Antoine Dutot <antoine.dutot@graphstream-project.org>
* Yoann Pigné <yoann.pigne@graphstream-project.org> * Yoann Pigné <yoann.pigne@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org> * Guilhelm Savin <guilhelm.savin@graphstream-project.org>
* *
* This file is part of GraphStream <http://graphstream-project.org>. * This file is part of GraphStream <http://graphstream-project.org>.
* *
* GraphStream is a library whose purpose is to handle static or dynamic * GraphStream is a library whose purpose is to handle static or dynamic
* graph, create them from scratch, file or any source and display them. * graph, create them from scratch, file or any source and display them.
* *
* This program is free software distributed under the terms of two licenses, the * This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public * CeCILL-C license that fits European law, and the GNU Lesser General Public
* License. You can use, modify and/ or redistribute the software under the terms * License. You can use, modify and/ or redistribute the software under the terms
* of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
* URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
* the Free Software Foundation, either version 3 of the License, or (at your * the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* The fact that you are presently reading this means that you have had * The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
*/ */
package org.graphstream.graph; package org.graphstream.graph;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* An interface aimed at dynamically creating graph objects based on a class * An interface aimed at dynamically creating graph objects based on a class
* name. * name.
...@@ -38,6 +41,9 @@ package org.graphstream.graph; ...@@ -38,6 +41,9 @@ package org.graphstream.graph;
* @since september 2007 * @since september 2007
*/ */
public class GraphFactory { public class GraphFactory {
private static final Logger logger = Logger.getLogger(GraphFactory.class.getSimpleName());
/** /**
* Create a new instance of graph. * Create a new instance of graph.
*/ */
...@@ -65,28 +71,9 @@ public class GraphFactory { ...@@ -65,28 +71,9 @@ public class GraphFactory {
Graph res = (Graph) clazz.getConstructor(String.class).newInstance( Graph res = (Graph) clazz.getConstructor(String.class).newInstance(
id); id);
return res; return res;
} catch (InstantiationException e) { } catch (final Exception e) {
System.out logger.log(Level.SEVERE, "Error executing GraphFactory#newInstance.", e);
.println("GraphFactory newInstance InstantiationException : " }
+ e.getMessage());
} catch (ClassNotFoundException e) {
System.out
.println("GraphFactory newInstance ClassNotFoundException : "
+ e.getMessage());
} catch (IllegalAccessException e) {
System.out
.println("GraphFactory newInstance IllegalAccessException : "
+ e.getMessage());
} catch (NoSuchMethodException e) {
System.out
.println("GraphFactory newInstance NoSuchMethodException : "
+ e.getMessage());
} catch (java.lang.reflect.InvocationTargetException e) {
System.out
.println("GraphFactory newInstance InvocationTargetException : "
+ e.getMessage());
}
return null; return null;
} }
} }
\ No newline at end of file
...@@ -35,6 +35,7 @@ import java.util.Collection; ...@@ -35,6 +35,7 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import java.util.logging.Logger;
/** /**
* Path description. * Path description.
...@@ -65,6 +66,12 @@ import java.util.Stack; ...@@ -65,6 +66,12 @@ import java.util.Stack;
* *
*/ */
public class Path implements Structure { public class Path implements Structure {
/**
* class level logger
*/
private static final Logger logger = Logger.getLogger(Path.class.getSimpleName());
// ------------- ATTRIBUTES ------------ // ------------- ATTRIBUTES ------------
/** /**
...@@ -114,10 +121,8 @@ public class Path implements Structure { ...@@ -114,10 +121,8 @@ public class Path implements Structure {
this.root = root; this.root = root;
nodePath.push(root); nodePath.push(root);
} else { } else {
System.err logger.warning("Root node is not null - first use the clear method.");
.printf("Error in org.miv.graphstream.graph.Path: root is not null. First use the clear method.%n");
} }
} }
/** /**
...@@ -207,9 +212,7 @@ public class Path implements Structure { ...@@ -207,9 +212,7 @@ public class Path implements Structure {
public void add(Node from, Edge edge) { public void add(Node from, Edge edge) {
if (root == null) { if (root == null) {
if (from == null) { if (from == null) {
System.err throw new IllegalArgumentException("From node cannot be null.");
.print("Error using org.miv.graphstream.graph.Path: Use setRoot( ) first. %n");
System.exit(0);
} else { } else {
setRoot(from); setRoot(from);
} }
...@@ -227,8 +230,7 @@ public class Path implements Structure { ...@@ -227,8 +230,7 @@ public class Path implements Structure {
nodePath.push(edge.getOpposite(from)); nodePath.push(edge.getOpposite(from));
edgePath.push(edge); edgePath.push(edge);
} else { } else {
System.err logger.warning("Cannot add the specified edge, it cannot be part of the path! %n");
.printf("Path: Cannot add the specified edge, it cannot be part of the path! %n");
} }
} }
...@@ -335,13 +337,6 @@ public class Path implements Structure { ...@@ -335,13 +337,6 @@ public class Path implements Structure {
*/ */
public void removeLoops() { public void removeLoops() {
int n = nodePath.size(); int n = nodePath.size();
/*
* System.err.printf( "removeLoop()%n" ); System.err.printf(
* " path size = %d==%d%n [ ", n, edgePath.size() );
*
* for( int i=0; i<n; i++ ) { System.err.printf( "%d=%s ", i,
* nodePath.get(i).getId() ); } System.err.printf( "]%n" );
*/
// For each node-edge pair // For each node-edge pair
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
// Lookup each other following node. We start // Lookup each other following node. We start
...@@ -351,7 +346,6 @@ public class Path implements Structure { ...@@ -351,7 +346,6 @@ public class Path implements Structure {
if (nodePath.get(i) == nodePath.get(j)) { if (nodePath.get(i) == nodePath.get(j)) {
// We found a loop between i and j. // We found a loop between i and j.
// Remove ]i,j]. // Remove ]i,j].
// System.err.printf( "removed ]%d,%d]%n", i, j );
for (int k = i + 1; k <= j; k++) { for (int k = i + 1; k <= j; k++) {
nodePath.remove(i + 1); nodePath.remove(i + 1);
edgePath.remove(i); edgePath.remove(i);
...@@ -361,13 +355,7 @@ public class Path implements Structure { ...@@ -361,13 +355,7 @@ public class Path implements Structure {
} }
} }
} }
/* }
* System.err.printf( " NEW path size = %d==%d%n NEW [ ", n,
* edgePath.size() );
*
* for( int i=0; i<n; i++ ) { System.err.printf( "%d=%s ", i,
* nodePath.get(i).getId() ); } System.err.printf( "]%n" );
*/}
/** /**
* Compare the content of the current path and the specified path to decide * Compare the content of the current path and the specified path to decide
......
...@@ -31,16 +31,6 @@ ...@@ -31,16 +31,6 @@
*/ */
package org.graphstream.graph.implementations; package org.graphstream.graph.implementations;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import org.graphstream.graph.Edge; import org.graphstream.graph.Edge;
import org.graphstream.graph.EdgeFactory; import org.graphstream.graph.EdgeFactory;
import org.graphstream.graph.EdgeRejectedException; import org.graphstream.graph.EdgeRejectedException;
...@@ -59,8 +49,21 @@ import org.graphstream.stream.file.FileSink; ...@@ -59,8 +49,21 @@ import org.graphstream.stream.file.FileSink;
import org.graphstream.stream.file.FileSource; import org.graphstream.stream.file.FileSource;
import org.graphstream.ui.view.Viewer; import org.graphstream.ui.view.Viewer;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
public class Graphs { public class Graphs {
private static final Logger logger = Logger.getLogger(Graphs.class.getSimpleName());
public static Graph unmutableGraph(Graph g) { public static Graph unmutableGraph(Graph g) {
return null; return null;
} }
...@@ -104,9 +107,7 @@ public class Graphs { ...@@ -104,9 +107,7 @@ public class Graphs {
Class<? extends Graph> cls = graphs[0].getClass(); Class<? extends Graph> cls = graphs[0].getClass();
result = cls.getConstructor(String.class).newInstance(id); result = cls.getConstructor(String.class).newInstance(id);
} catch (Exception e) { } catch (Exception e) {
System.err.printf("*** WARNING *** can not create a graph of %s\n", logger.warning(String.format("Cannot create a graph of %s.", graphs[0].getClass().getName()));
graphs[0].getClass().getName());
result = new MultiGraph(id); result = new MultiGraph(id);
} }
...@@ -154,9 +155,7 @@ public class Graphs { ...@@ -154,9 +155,7 @@ public class Graphs {
Class<? extends Graph> cls = g.getClass(); Class<? extends Graph> cls = g.getClass();
copy = cls.getConstructor(String.class).newInstance(g.getId()); copy = cls.getConstructor(String.class).newInstance(g.getId());
} catch (Exception e) { } catch (Exception e) {
System.err.printf("*** WARNING *** can not create a graph of %s\n", logger.warning(String.format("Cannot create a graph of %s.", g.getClass().getName()));
g.getClass().getName());
copy = new AdjacencyListGraph(g.getId()); copy = new AdjacencyListGraph(g.getId());
} }
......
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
*/ */
package org.graphstream.graph.implementations; package org.graphstream.graph.implementations;
import org.graphstream.graph.Element;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.graphstream.graph.Element;
/** /**
* An implementation of an {@link org.graphstream.graph.Element}. * An implementation of an {@link org.graphstream.graph.Element}.
* *
...@@ -177,20 +177,15 @@ public abstract class OneAttributeElement implements Element { ...@@ -177,20 +177,15 @@ public abstract class OneAttributeElement implements Element {
public void addAttribute(String attribute, Object value) { public void addAttribute(String attribute, Object value) {
this.attribute = value; this.attribute = value;
// System.out.println(attribute+" = "+value.toString());
} }
public void changeAttribute(String attribute, Object value) { public void changeAttribute(String attribute, Object value) {
addAttribute(attribute, value); addAttribute(attribute, value);
// System.out.println(attribute+" = "+value.toString());
} }
public void addAttributes(Map<String, Object> attributes) { public void addAttributes(Map<String, Object> attributes) {
// System.out.println(attributes.toString());
if (attributes.size() >= 1) if (attributes.size() >= 1)
addAttribute("", attributes.get((attributes.keySet().toArray()[0]))); addAttribute("", attributes.get((attributes.keySet().toArray()[0])));
} }
public void removeAttribute(String attribute) { public void removeAttribute(String attribute) {
......
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
*/ */
package org.graphstream.stream.thread; package org.graphstream.stream.thread;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import org.graphstream.graph.Graph; import org.graphstream.graph.Graph;
import org.graphstream.stream.ProxyPipe; import org.graphstream.stream.ProxyPipe;
import org.graphstream.stream.Replayable; import org.graphstream.stream.Replayable;
...@@ -44,6 +39,12 @@ import org.graphstream.stream.Sink; ...@@ -44,6 +39,12 @@ import org.graphstream.stream.Sink;
import org.graphstream.stream.Source; import org.graphstream.stream.Source;
import org.graphstream.stream.SourceBase; import org.graphstream.stream.SourceBase;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
/** /**
* Filter that allows to pass graph events between two threads without explicit * Filter that allows to pass graph events between two threads without explicit
* synchronization. * synchronization.
...@@ -83,6 +84,11 @@ import org.graphstream.stream.SourceBase; ...@@ -83,6 +84,11 @@ import org.graphstream.stream.SourceBase;
*/ */
public class ThreadProxyPipe extends SourceBase implements ProxyPipe { public class ThreadProxyPipe extends SourceBase implements ProxyPipe {
/**
* class level logger
*/
private static final Logger logger = Logger.getLogger(ThreadProxyPipe.class.getSimpleName());
/** /**
* Proxy id. * Proxy id.
*/ */
...@@ -608,7 +614,7 @@ public class ThreadProxyPipe extends SourceBase implements ProxyPipe { ...@@ -608,7 +614,7 @@ public class ThreadProxyPipe extends SourceBase implements ProxyPipe {
sendGraphCleared(graphId, timeId); sendGraphCleared(graphId, timeId);
break; break;
default: default:
System.err.printf("ThreadProxy : Unknown message %s !!%n", e); logger.warning(String.format("Unknown message %s.", e));
break; break;
} }
} }
......
...@@ -43,6 +43,9 @@ import org.miv.mbox.MBox; ...@@ -43,6 +43,9 @@ import org.miv.mbox.MBox;
import org.miv.mbox.MBoxListener; import org.miv.mbox.MBoxListener;
import org.miv.mbox.MBoxStandalone; import org.miv.mbox.MBoxStandalone;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Filter that allows to pass graph events between two threads without explicit * Filter that allows to pass graph events between two threads without explicit
* synchronization. * synchronization.
...@@ -84,8 +87,12 @@ import org.miv.mbox.MBoxStandalone; ...@@ -84,8 +87,12 @@ import org.miv.mbox.MBoxStandalone;
* {@link org.graphstream.stream.thread.ThreadProxyPipe}. * {@link org.graphstream.stream.thread.ThreadProxyPipe}.
*/ */
@Deprecated @Deprecated
public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe, public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe, MBoxListener {
MBoxListener {
/**
* class level logger
*/
private static final Logger logger = Logger.getLogger(ThreadProxyPipe.class.getSimpleName());
/** /**
* Proxy id. * Proxy id.
...@@ -323,9 +330,7 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe, ...@@ -323,9 +330,7 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe,
Thread.yield(); Thread.yield();
} }
} catch (CannotPostException e) { } catch (CannotPostException e) {
System.err logger.log(Level.WARNING, "Unable to post message to listeners.", e);
.printf("GraphRendererRunner: cannot post message to listeners: %s%n",
e.getMessage());
} }
} }
...@@ -527,8 +532,6 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe, ...@@ -527,8 +532,6 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe,
// MBoxListener // MBoxListener
public void processMessage(String from, Object[] data) { public void processMessage(String from, Object[] data) {
// System.err.printf( " %s.msg(%s, %s, %s, %s)%n", from, data[1],
// data[2], data[0], data[3] );
if (data[0].equals(GraphEvents.ADD_NODE)) { if (data[0].equals(GraphEvents.ADD_NODE)) {
String graphId = (String) data[1]; String graphId = (String) data[1];
Long timeId = (Long) data[2]; Long timeId = (Long) data[2];
...@@ -640,8 +643,7 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe, ...@@ -640,8 +643,7 @@ public class ThreadProxyPipeOld extends SourceBase implements ProxyPipe,
sendGraphCleared(graphId, timeId); sendGraphCleared(graphId, timeId);
} else { } else {
System.err.printf("ThreadProxyFilter : Unknown message %s !!%n", logger.warning(String.format("Unknown message %s.", data[0]));
data[0]);
} }
} }
} }
\ No newline at end of file
...@@ -39,6 +39,8 @@ import org.graphstream.ui.geom.Point3; ...@@ -39,6 +39,8 @@ import org.graphstream.ui.geom.Point3;
import org.graphstream.ui.geom.Vector2; import org.graphstream.ui.geom.Vector2;
import org.graphstream.ui.geom.Vector3; import org.graphstream.ui.geom.Vector3;
import java.util.logging.Logger;
/** /**
* Lots of small often used measuring algorithms on graphs. * Lots of small often used measuring algorithms on graphs.
* *
...@@ -47,6 +49,12 @@ import org.graphstream.ui.geom.Vector3; ...@@ -47,6 +49,12 @@ import org.graphstream.ui.geom.Vector3;
* </p> * </p>
*/ */
public class GraphPosLengthUtils { public class GraphPosLengthUtils {
/**
* class level logger
*/
private static final Logger logger = Logger.getLogger(GraphPosLengthUtils.class.getSimpleName());
/** /**
* Retrieve a node position from its attributes ("x", "y", "z", or "xy", or * Retrieve a node position from its attributes ("x", "y", "z", or "xy", or
* "xyz"). * "xyz").
...@@ -324,7 +332,7 @@ public class GraphPosLengthUtils { ...@@ -324,7 +332,7 @@ public class GraphPosLengthUtils {
xyz[1] = oo.data[1]; xyz[1] = oo.data[1];
xyz[2] = 0; xyz[2] = 0;
} else { } else {
System.err.printf("Do not know how to handle xyz attribute %s%n", o.getClass().getName()); logger.warning(String.format("Do not know how to handle xyz attribute %s.", o.getClass().getName()));
} }
} }
...@@ -399,7 +407,7 @@ public class GraphPosLengthUtils { ...@@ -399,7 +407,7 @@ public class GraphPosLengthUtils {
pos.y = oo.data[1]; pos.y = oo.data[1];
pos.z = 0; pos.z = 0;
} else { } else {
System.err.printf("Do not know how to handle xyz attribute %s%n", o.getClass().getName()); logger.warning(String.format("Do not know how to handle xyz attribute %s%n", o.getClass().getName()));
} }
} }
......
...@@ -31,13 +31,15 @@ ...@@ -31,13 +31,15 @@
*/ */
package org.graphstream.ui.graphicGraph; package org.graphstream.ui.graphicGraph;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.graphstream.graph.implementations.AbstractElement; import org.graphstream.graph.implementations.AbstractElement;
import org.graphstream.ui.graphicGraph.stylesheet.Selector; import org.graphstream.ui.graphicGraph.stylesheet.Selector;
import org.graphstream.ui.graphicGraph.stylesheet.StyleConstants; import org.graphstream.ui.graphicGraph.stylesheet.StyleConstants;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Super class of all graphic node, edge, and sprite elements. * Super class of all graphic node, edge, and sprite elements.
* *
...@@ -68,6 +70,12 @@ import org.graphstream.ui.graphicGraph.stylesheet.StyleConstants; ...@@ -68,6 +70,12 @@ import org.graphstream.ui.graphicGraph.stylesheet.StyleConstants;
* </p> * </p>
*/ */
public abstract class GraphicElement extends AbstractElement { public abstract class GraphicElement extends AbstractElement {
/**
* class level logger
*/
private static final Logger logger = Logger.getLogger(GraphicElement.class.getSimpleName());
/** /**
* Interface for renderers registered in each style group. * Interface for renderers registered in each style group.
*/ */
...@@ -219,17 +227,12 @@ public abstract class GraphicElement extends AbstractElement { ...@@ -219,17 +227,12 @@ public abstract class GraphicElement extends AbstractElement {
mygraph.styleSheet.parseStyleFromString( mygraph