JGraphX is a community supported open source project. Get technical support for mxGraph and JGraphX from the product authors. Documentation. This document provides an experimental analysis of the JGraph component, based on working examples. Source code from the JGraphpad application will be . I find the documentation and examples pages very hard to read due to the lightweight font and light-grey-on-white colour scheme.
|Published (Last):||5 December 2009|
|PDF File Size:||1.80 Mb|
|ePub File Size:||11.86 Mb|
|Price:||Free* [*Free Regsitration Required]|
Last time, I introduced you to a series on useful open-source tools that could prove beneficial to your Java career. This article continues the series by presenting JGraph. Computer science defines a graph as docujentation nonempty finite set of vertices labelled points and a set of edges pairs of vertices that signify connections between the vertices.
Graphs represent networks of related and typically interconnected objects such as roads, molecules, database schemas, and the Internet. Although the graph concept is easy to understand, creating dockmentation software to construct, dodumentation, and jgrapy graphs can be difficult. Thanks to Java and a utility called JGraph, you do not need to create your own graph software. This article introduces you to JGraph.
This application introduces you to several operations that JGraph provides for graph manipulation. This JGraph overview provides you with enough knowledge to quickly start creating your own graphs. Windows 98 SE was the underlying platform. You can download the code here. JGraphcreated by Gaudenz Alder, is an open-source, Swing-based component for building, displaying, and manipulating graphs.
Build interactive web diagramming apps
Docuentation main difference between these licenses: Visit the JGraph Free Downloads page to download the binary and source distributions for the latest free version jggaph JGraph. You need only the binary distribution for this article: Click the Download Latest Binary Distribution link to obtain that distribution.
After the download finishes, you will discover jgraph-latest-lgpl. From the command line, invoke java -jar jgraph-latest-lgpl. After agreeing to all terms in the license agreement, choose an installation directory, such as c: JGraph installs to documentaiton directory.
If installation is successful, the installation directory will contain the following files and directories:. Now that JGraph has been downloaded, installed, and configured, we can explore a Java application that uses JGraph to create a sample graph. Take a look at Listing 1.
Listing 1 describes a Swing application that introduces a sample graph into its GUI. JGraph object and invoking its public JGraph constructor to initialize this object. After compiling Listing 1, run this application. You will see the sample graph that is presented in Figure 1. Figure 1 The sample graph reveals JGraph component architecture. You can also manipulate this graph by performing various operations. For example, double-click the vertex that displays JComponent or single-click that vertex to select it and then press F2.
Type abc into that text docuumentation and then press Enter. You should now see abc instead of JComponent. Figure 2 reveals the editor and the entered label. Figure 2 You can perform documentattion editing on a vertex or an edge.
Similarly, the selection of an edge results in handles at the source and target of that edge. These handles make it possible to resize the vertex or edge. Accomplish that task by using the mouse to select and drag a handle: The vertex or edge resizes in that direction. For example, resize the JGraph vertex by selecting that vertex, gripping the handle in the lower-right corner, and dragging the handle downward and to the right. Figure 3 shows this vertex expanding.
Figure 3 A vertex changes color during a resize operation. You can select a combination of vertices and edges by holding down Shift during the selection process.
A pair of selected vertices and the edge that connects those vertices are dragged to another location in Figure 4. Figure 4 An edge between two selected vertices is automatically selected.
Resizing or dragging a selection—you jgrap abort either operation by pressing Esc—is accomplished through a cell handle.
java – jgraphx change vertex size – Stack Overflow
JGraph refers to this feature as live-preview. JGraph supports the placement of related vertices and dovumentation into groupsa mechanism for structurally organizing a graph. The presence of groups within a graph affects the selection process. Figure 5 illustrates this stepping into groups feature. Notice the dashed outline around a group, consisting of vertex GraphModeledge implementsand vertex DefaultGraphModel.
That outline indicates the selection of the group.
Also notice the selection of the implements edge, whose label appears in the editor. Figure 5 Click once for the group and twice for the edge. You can select multiple groups, vertices, and edges by pressing Shift and clicking each entity, but that dovumentation somewhat cumbersome.
If those entities exist within a rectangular area, an gjraph way to accomplish this task involves marquee selection. Marquee selection is a selection mechanism in which you move the mouse pointer to any location in documenfation graph and press a mouse button. As you drag the mouse pointer, you observe a rectangle—known as a marquee —that expands or contracts, based on the direction doccumentation movement.
When you release the mouse button, the marquee disappears; all groups, vertices, and edges completely within the marquee are selected. Figure 6 reveals the marquee. When the mouse button is released, the JComponent vertex, the extends edge, and the JGraph vertex will be selected. Figure 6 Select a group by including all vertices and edges within the marquee. Sometimes, you will want to more accurately place a vertex, an edge, or a group during a drag operation—by constraining the drag to horizontal and vertical movement.
In other words, documentqtion do not want to drag diagonally. JGraph provides a constrained drag operation to help you accomplish this task. That operation requires you to hold down Shift while dragging the mouse. There is one final operation to consider: Unlike constrained drag, clone selection cannot be demonstrated in SampleGraph without changing the source code. The change requires replacing the following line of code:.
Position the mouse pointer over a vertex, an edge label, or a group member and then hold down Ctrl while dragging the mouse.
You will end up with a clone of the vertex, edge label, or group. Figure 7 The graph editor lets you create, drag, and connect vertices.
Click the leftmost icon to introduce a vertex into the GUI. The icon immediately to the right, when it appears as an arrow, causes a small rectangle to appear in the midst of jgrapph vertex. Selecting that rectangle and dragging the mouse results in an edge being drawn from the vertex presumably you want to draw the edge to another vertex.
But if the icon appears with a stylized red X drawn on top, you cannot draw an edge. See All Related Store Items. Graphs are combinations of vertices and edges representing documentattion of related and typically interconnected objects.
Examples include roads, molecules, and even the Internet.
Tools of the Trade, Part 2: Building Graphs with JGraph
Although the graph concept is easy to understand, creating the software to build, display, and manipulate graphs is not so easy. But there’s good news: The open-source JGraph tool overcomes that difficulty. This jrgaph by Jeff Friesen, the second in a three-part series exploring useful open-source tools, introduces you to JGraph.
After showing you how to docu,entation, install, and configure JGraph, you’ll be able to create a simple Java application that creates and displays a sample graph. We recommend Like this article? Related Resources Store Articles Blogs.