From: Darío T. <dar...@gm...> - 2014-07-24 12:05:15
|
2014-07-24 11:41 GMT+02:00 Darío Tórtola <dar...@gm...>: > Hello > > I have seen that there were not changes on JUNG for a while but there's > still bugs to address. > In particular, this email is motivated by > http://sourceforge.net/p/jung/bugs/168/ > > Please answer to know if this action is futile or otherwise, so I can > modify the sources and build a JUNG without the problems I find a solution, > or if I can expect you to do it (or to include me in the team) > > Here are my thoughts about the bug > > BUG 168 of the sourceforge list (http://sourceforge.net/p/jung/bugs/168/): > Took DirectedGraph g; > Wrap in ObservableGraph og; > Use EditingGraphMousePlugin to add edges to og; > > Since EditingGraphMousePlugin uses instanceof to detect what the default > type of edge, > and ObservableGraph doesn't implement it, it fails to use the right one. > I can immediately think of two solutions: > > 1. Add a new EdgeType Graph.getDefaultEdgeType() method. The default type > can be UNDIRECTED, > for some can be DIRECTED. > Modify EditingGraphMousePlugin to use the default type > Problem of this solution: you can write a DirectedGraph implementation > that returns UNDIRECTED as default type > > 2. Create a DirectedObservableGraph by extending ObservableGraph and > adding the DirectedGraph interface > Hide ObservableGraph's constructor > Use a static factory method to build either an ObservableGraph or > DirectedObservableGraph depending on the interfaces of the graph to be > wrapped > > To implement: > > *change: > public ObservableGraph(Graph<V, E> delegate) { > super(delegate); > } > *to: > private ObservableGraph(Graph<V, E> delegate) { > super(delegate); > } > > > *Add a private static class to ObservableGraph: > > package edu.uci.ics.jung.graph; > > private static class DirectedObservableGraph<V, E> extends > ObservableGraph<V, E> implements DirectedGraph<V, E> { > > /** > * > */ > private static final long serialVersionUID = 8643031744079601269L; > > public DirectedObservableGraph(Graph<V, E> delegate) { > super(delegate); > } > > } > > *Add a public static factory method to ObservableGraph > > public static <V, E> ObservableGraph<V, E> build (Graph<V, E> graph){ > if (graph instanceof DirectedGraph){ > return new DirectedObservableGraph<>(graph); > } > return new ObservableGraph<>(graph); > } > |