ogallagher / fxgraph Goto Github PK
View Code? Open in Web Editor NEWThis project forked from col-e/fxgraph
A JavaFX graph editor
License: Do What The F*ck You Want To Public License
This project forked from col-e/fxgraph
A JavaFX graph editor
License: Do What The F*ck You Want To Public License
Depending on the order that they’re added to the graph, edges can sometimes display in front of cells instead of always being behind them (see demo video).
This could be fixed by specializing the cartesian graph and its canvas to group cells and edges separately, or by modifying those base classes directly to do so. I plan to do the latter, updating Graph
and PannableCanvas
to separate edges and cells into distinct groups, with a customizable z order.
The zoom scrolling doesn’t quite change the scale relative to the cursor location; it looks like something should be changed here:
fxgraph/src/main/java/com/fxgraph/graph/ViewportGestures.java
Lines 102 to 143 in 4643e37
I can be difficult to get the node dragging to work with cartesian point cells. See demo video.
The CorneredEdge.EdgeGraphic
class defines getGraphic
and getText
methods that were already defined the same way in the abstract superclass AbstractEdgeGraphic
. The other cornered edge graphic classes (double, loop) also have similar methods.
See Col-E#3 (comment). RenameGraph.beginUpdate
and Graph.endUpdate
to more clearly reflect these methods’ purposes.
In a cartesian graph, between the data coordinates for a point (raw x,y) and the viewport coordinates (camera pan, zoom), there should be a transform for display coordinates, given the desired viewport space versus the data space. For example, this transform could optionally flip the y axis and scale the data to fit in the initial viewport (pan=0,0 zoom=1) when displayed.
Use the FitToContentLayout
class for this, and make a difference in the placement of a point between the point’s coordinates and the displayed location (CartesianPoint.getGraphic
).
Create a specialized CartesianAxis
with the following features:
Branch: nodegesture-hover
In addition to having the drag translation node gesture (and drag handle resize cell gesture), a hover node gesture could be used to make graph nodes (cells or messages) hoverable.
One application for such a gesture would be sequence diagram message edge details, as suggested at sirolf2009/fxgraph #10.
Another would be for Cartesian plot points, which could show x,y coordinates on hover.
I originally found this graphing library looking to use it for Cartesian graphs/plots and not for making a a diagramming editor, but it has enough functionality to have my purposes in mind as well.
In order to follow the current direction of the project, I'll incorporate optional interaction (editing) features as I go.
Below are classes to be created to enable basic Cartesian graphs:
CartesianGraph
A graph that plots points in three major display modes: points (disconnected/scattered points), lines (connected lines), or connected points. Other display types could be added later as well (ex. bar heights), perhaps in subclasses. This graph has axes (directed perpendicular edges) with potential unit marks/ticks. When scroll panning the graph viewport, the axes should remain, but their ticks change to reflect the current viewport position.FitToContentLayout
Modifies the viewport of the graph so that all points are visible, and according to the placement of the graph axes.MultiplotModel
Organizes cells and edges into plots, such that each cell represents a point in an ordered sequence by x-value, and each edge connects adjacent cells in a plot.CartesianPoint
A plot point with x,y coordinates, a text to show its coordinates, and a bullet (default is small circle). Ideally I would want points to not be hierarchical as they exist in sequence rather than a tree, but I could probably use the child-parent members to reference leading and following points, where the "tree level" of a point is determined with its x coordinate.SimpleEdge
A line between cells, extends AbstractEdge
. It will have no text, be a straight diagonal, and still have optional direction.CartesianAxis
An x or y axis at along the edge of the viewport, with a text and optional unit marks.CartesianGraphDemo
A test driver app that creates and updates a cartesian graph.fxgraph/src/main/java/com/fxgraph/edges/AbstractEdgeGraphic.java
Lines 16 to 18 in ec8beb4
fxgraph/src/main/java/com/fxgraph/edges/MessageEdge.java
Lines 52 to 62 in ec8beb4
As discussed in sirolf2009/fxgraph issue #7, the mouse buttons to use for node translation vs the button to use for viewport translation (panning) should be customizable.
However, the implementation is not yet complete, as setting both node translation and viewport pan to the same button causes behavior like so:
An com.fxgraph.edges.AbstractEdgeGraphic
constructor with some arguments could define which of the default widget components in the edge graphic (group, text, arrow) are automatically added to the Pane.getChildren()
superclass member, without every subclass having to redundantly implement this detail.
fxgraph/src/main/java/com/fxgraph/edges/AbstractEdgeGraphic.java
Lines 17 to 19 in ec8beb4
Given there are also methods to set and get the values of these properties, and the properties themselves are private
members, I think it makes sense to wrap these properties in read-only classes when returning them from getter methods.
Examples:
PannableCanvas.scaleProperty
Arrow.startXProperty
Edge.textProperty
In cases where the property should be write-accessible, then the property scope could be public
instead of private
, though I suppose that does open the member up to reassignment and loss of bindings.
Currently the defaults for arrow length and width on a directed edge are hard-coded into one of the constructors:
fxgraph/src/main/java/com/fxgraph/graph/Arrow.java
Lines 19 to 23 in ec8beb4
It could be better to create constants in the Arrow
class to hold these values instead, so they can be referenced and documented easily.
The way that SequenceDiagram extends Graph
overrides Graph.layout
implicitly by using a slightly different method signature is confusing, so I propose making the override explicit by having the layout
parameter be optional.
There isn’t much documentation within the source code, so as I sift through how everything works I’ll be adding javadoc comments. Below is a file list to keep track of progress:
The Graph
class handles enabling and disabling viewport and node gestures in its constructor, but not cell gestures.
fxgraph/src/main/java/com/fxgraph/graph/Graph.java
Lines 65 to 97 in 80ef7dc
Currently, ICell
and IEdge
are both defined in the com.fxgraph.graph
package, but should probably be in the com.fxgraph.cells
and com.fxgraph.edges
packages, respectively.
Incorporate (try merge?) what was changed for arrow key panning here.
The fxgraph.graph.ICell
interface can add and remove child cells, but only add parents. I think removal of parents makes sense as well, if they can be added.
Add a coordinate label to the CartesianPoint
class, which will display or hide using a hover gesture.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.