New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problems with sample code #113
Comments
I have been looking into how the refactoring of BasicEdgeRenderer,
BasicRenderer, etc broke this code (TwoLayoutDemo).
I hope to get a chance to fix it. I'm not sure why some of the changes
were made (meaning: someone changed things for a reason, and just changing them back may not be the best solution)
…On Mon, Aug 7, 2017 at 12:08 AM, jrtom ***@***.***> wrote:
- ShowLayouts, SubLayoutDemo don’t work (layout creation needs
refactoring as with VertexCollapseDemoWithLayouts)
- TwoModelDemo is busted (NPE in BasicEdgeRenderer.paintEdge;
GraphicsDecorator is null)
- VertexCollapseDemo is busted (attempts to reuse an edge object
already in use)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#113>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGbB7oj5Ks0VU4QwNNOzLTA30A6KU2Fks5sVo24gaJpZM4Ou-VW>
.
|
Changes to be committed: modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/GraphFromGraphMLDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/SatelliteViewDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/ShortestPathDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/VertexImageShaperDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/VertexLabelAsShapeDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/VisualizationImageServerDemo.java modified: jung-samples/src/main/java/edu/uci/ics/jung/samples/WorldMapGraphDemo.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/BasicVisualizationServer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/DefaultVisualizationModel.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/layout/LayoutChangeListener.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/layout/LayoutEvent.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/layout/LayoutEventSupport.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/layout/ObservableCachingLayout.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/BasicEdgeLabelRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/BasicEdgeRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/BasicRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/BasicVertexLabelRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/BasicVertexRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/CachingEdgeRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/CachingRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/CachingVertexRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/GradientVertexRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/Renderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/ReshapingEdgeRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/renderers/VertexLabelAsShapeRenderer.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/transform/shape/MagnifyImageLensSupport.java modified: jung-visualization/src/main/java/edu/uci/ics/jung/visualization/transform/shape/ViewLensSupport.java
I pushed a branch that fixes TwoModelDemo. I will make a PR for it after I have a look at some of the other failed demos to see if the fix is related, otherwise I'll make a different PR for issues related to graph creation. |
While it may have been a bad idea (at least in the sense that it broke something), the reason I made the renderer classes (for example) stateful is that I was trying to make them easier to work with. It's not like a given renderer is likely to be used with multiple render contexts, after all, and it makes the API cleaner if they have state rather than having to supply it for each method call. The obvious potential risk (which it looks like I fell prey to) is that you fail to update the state when it needs updating, and for that we could consider using listeners. I'm willing to consider going to back to making the renderers stateless, though. |
In the original design, I (sort of) followed the java drawing classes in that some context is passed to every draw command. It's more of a functional programming design. We could leave the renderers stateful as long as we don't mind recreating the renderers in every draw loop iteration (bad idea). I really, really don't like that the RenderContext now holds the Network as part of its state. I will continue to work on the branch that fixes all the demos. I understand that going back to a functional design may not sit well with everyone. Part of my misgivings about doing this at all is that for a long time I've felt that the need for a java/java2d/swing based rendering module is kind of old fashioned. I suspect that more people would like a javascript implementation these days. |
Following the lead of the Java drawing classes is a reasonable basis for an argument that the renderers should be stateless, definitely. I'm not sure I see how making them stateful means that we have to recreate them in every draw loop iteration (which I agree would be an incredibly bad idea, for sure); can you expand on that a bit? I don't have access to decent cross-references for JUNG at the moment (no IDE on this machine) so I'd have to see what use (if any) is being made of RenderContext.getNetwork(). (Side point: it makes me somewhat unhappy that the current visualization system is Network-centric, i.e., it doesn't support Graphs or ValueGraphs. I don't yet have a good solution for this, though, and there may not be a good solution absent changing the public type hierarchy...again.) I don't necessarily object in principle to returning to a more functional design. As for the old-fashionedness of the rendering module: to be perfectly honest, I'm not wedded to JUNG continuing to provide a visualization module at all, at least as long as I'm the main person responsible for maintenance (if others including you start to take a more active role again, that would change the calculus). Many people have found it useful to have a visualization system as part of JUNG, and--thanks in large part to you and @danyelf--the one we have is fairly flexible in a number of ways. However, I don't have as good a grasp on the intricacies of the visualization system as I should, it's highly inefficient in some ways (e.g. it lacks proper spatial data structures), and it's definitely an added maintenance burden. So if there were a good general-purpose graph visualization system that used the same (common.graph) data model as JUNG 3.0 now does, but I'm not aware of one, I'd be perfectly happy to point to it and say "this is a good choice if you want to visualize your graph". At that point I'd support flushing the JUNG visualization capabilities entirely; that would allow me to focus on maintaining and extending the parts of the system that I'm more familiar with. Hope this clarifies a few things. :) |
So I did a bit of poking around re: RenderContext.getNetwork() and where it's currently used. The uses can be summarized as follows: Part of the issue is that the Layout used to be more stateful than it is: that used to be what was responsible in many cases for hanging on to a reference to the graph for purpose of the visualization system. I changed that to make it easier for the layout algorithms to work with It seems to me that the right object to hang onto the graph instance is ultimately the VisualizationModel, and everything else (layout, renderers, render context, etc.) should get the graph from that. Note, however, that the Layouts are still stateful in the sense that they maintain node positions (and a set of nodes for which they are responsible) so they'd need to be explicitly notified if the VisualizationModel's graph is updated. |
A lot of the visualization code sprang from thoughts like 'i wonder if we can do this...'. |
The reason to keep the generics is the main reason why one uses generics in the first place: for type safety. I mean, the graph types themselves don't care about the node and edge types, because they are (as you say) effectively just keys. But that's the intent. Maps and Collections don't care about their element types, either, but it's still useful for them to have APIs that are defined in terms of those types. Yes, there are demos where the graph itself is untyped (because in the various collapse demos, the nodes can be either individual objects or collections of objects) but that strikes me as being an edge case (as it were) that we don't want to design around--and we can't, really, anyway. If the VisualizationModel is to keep a handle to the graph, then it needs to have the same generic types as the graph, I think, or we lose information. That said, I'm happy to kick ideas around, or to take a look at whatever design you have in mind (although a design doc might be helpful at this point). |
I still look at this from time to time. Until I see how things end up with regard to Layout and Nework/Graph, I feel disinclined to do a lot of work that may be irrelevant. We have to do something, though. I see that Network is 'final' in DefaultVisualizationModel, yet it is carried as mutable state in many other places. If we intend to support demos that let the user pick different graphs to display, we certainly don't want it to be 'final' anywhere. |
Are you still interested in flushing the jung-visualization and jung-samples modules? |
Status update:
I'm going to close this issue and open a separate one focused on |
ShowLayouts
,SubLayoutDemo
don’t work (layout creation needs refactoring as withVertexCollapseDemoWithLayouts
)TwoModelDemo
is busted (NPE inBasicEdgeRenderer.paintEdge
;GraphicsDecorator
is null)VertexCollapseDemo
is busted (attempts to reuse an edge object already in use)The text was updated successfully, but these errors were encountered: