Class ViewGraph
java.lang.Object
ViewGraph
public class ViewGraph
- extends java.lang.Object
This is and interactive graphical program for viewing and editing a graph.
Usage : java ViewGraph < input.graph
where
- input.graph is a file containing a graph specified as an adjacency list.
More specifically, each vertex is represented by a unique string. For each line of
input the vertex represented by the first string on the line is connected to the
vertices represented by any following strings.
A complete description of the mouse and button controls for the program
is given at this
link.
As an example, the following two listings specifiy the graph shown in the
picture below.
A B
C D
C E
B E
D F
F G
A G
G H
G C
B C
I
C B D E
B A E
F D G
G A H C
I
ViewGraph mouse, button and key instructions
ViewGraph is controled by a slide bar, some buttons, the arrow, home and shift keys,
but mostly by mouse operations.
All three mouse buttons are used.
For mice with 1 or 2 buttons, left mouse with the control key held down should have the
same effect as middle mouse, and left mouse with the meta key held down should have
the same effect as right mouse.
(Warning for my PC the control key fix works but the meta key one doesn't. I'm
not even sure which the meta key is. However, the right mouse button of the two on the
PC works like the right one of three.)
-
The slide bar on the right hand side controls the repulsive force in
the energy equation used to set the coordinates. Slide up to
reduce repulsion and down to increase it.
-
At the bottom of the frame there are 5 controls. From left to right they
are as follows.
-
The page control pull down menu controls the appearance, orientation and
size of a page of paper. The top left hand corner of the page is always
at the origin. This is useful to preview how a print out will look.
-
The print button calls up the system's print frame.
The hard copy produced should look the same as what shows on the paper
chosen by the pull down menu above.
-
The run/stop button starts and stops the thread that optimised the
positions of the vertices. You should stop the thread if you need to print.
-
The view/edit button changes the effect of mouse operations in the
main canvas. See below for what they do.
-
The text input space on the right hand side allows you to type
in the name of a vertex. When you then press return the vertex moves to
the origin. If the vertex has previously been deleted it is put back into
the graph.
-
Mouse operations in view mode with no shift key pressed .
- Left mouse.
Drags a vertex. Vertex is free on release.
- Middle mouse.
Drags a vertex. Vertex is fixed at release position.
- Right mouse.
Translates the view by the amount dragged.
A bit like putting your finger on a piece of paper and moving it.
- Double click with any mouse button in the background resets the
vertices to their initial positions.
-
Mouse operations in view mode with shift key pressed .
- Left mouse.
Drags a vertex and the component it is in. Vertex and component free
on release.
- Middle mouse.
Drags a vertex and the component it is in. Vertex and component are
fixed at release positions.
- Right mouse.
Translates the positions of the vertices relative to the position
of the paper by the amount dragged.
This is useful to center the picture on the paper ready for outputing.
- Double click with any mouse button in the background same as
view mode without shift.
-
Mouse operations in edit mode with no shift key pressed .
- Left mouse.
Click on a vertex to add its neighbours to the graph.
- Middle mouse.
Click on a vertex to delete it from the graph.
- Right mouse.
Same as view mode without shift.
- Double click left mouse replaces all deleted
vertices in the graph.
- Double click middle mouse deletes all vertices from the
graph.
- Double click right mouse has no effect.
-
Mouse operations in edit mode with shift key pressed .
- Left mouse.
Click on a vertex to replace all vertices in the same component
to the graph.
- Middle mouse.
Click on a vertex to delete it and the component it is in from
the graph.
- Right mouse.
Does nothing.
-
Double click left mouse is the same as edit mode without shift key.
-
Double click middle mouse is the same as edit mode without shift key.
-
Double click right mouse is the same as edit mode without shift key.
-
Arrow key functions with no shift key pressed .
Mouse has to be in the picture canvas.
- Up arrow. Increases the scale of viewing by 10%.
- Down arrow. Decreased the scale of viewing by 10%.
- Left arrow. Rotates the view by 15 degrees clockwise.
- Right arrow. Rotates the view by 15 degrees anticlockwise.
-
Arrow key functions with shift key pressed .
Mouse has to be in the picture canvas.
- Up arrow. Increases the vertex positions by 10% relative to the
scale of the paper.
- Down arrow. Decreases the vertex positions by 10% relative to the
scale of the paper.
- Left arrow. Rotates the vertex positions by 15 degrees clockwise relative
to the paper orientation.
- Right arrow. Rotates the vertex poritions by 15 degrees anticlockwise
relative to the paper orientation.
-
Pressing the home key undoes all transformations and
replaces the origin at the top left of the screen.
|
Method Summary |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ViewGraph
public ViewGraph()
main
public static void main(java.lang.String[] args)