Class sfclasses.DragDrop
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sfclasses.DragDrop

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----sfclasses.DragDrop

public class DragDrop
extends Panel
This class is used for graphically displaying and drag-and-drop editing of graphs. Vertex objects must implement DragDropObj.
The drag and drop panel consists of a canvas to display and edit the topology, two scrollbars and a status line. Object dependent methods are defined in DragDropObj.
This is a GUI class.
See Also:
DragDropObj, Graph

Variable Index

 o graph
 o offset_x
 o offset_y

Constructor Index

 o DragDrop(Graph, Class)
Create a canvas and two scrollbars and lay them out in the panel
 o DragDrop(Graph, Class, boolean)
Create a canvas and two scrollbars and lay them out in the panel

Method Index

 o disableEdit()
Diable editing functions
 o drawEdge(Graphics, DragDropObj, DragDropObj)
Draw edge between two objects.
 o enableEdit()
Enable editing functions
 o getGraph()
Get graph object; note that you have to call repaint() after making changes in the graph topology manually
 o getSelected()
Get highlighted object
 o handleEvent(Event)
Event handler
mouse click on background creates new object
left mouse button to draw lines
right mouse button (or button + META) to drag objects
double click on object to call object's execute() method
 o reshape(int, int, int, int)
Called when panel size changes (e.g.
 o setClass(Class)
Set the class for creation of new objects

Variables

 o graph
  protected Graph graph
 o offset_x
  protected int offset_x
 o offset_y
  protected int offset_y

Constructors

 o DragDrop
  public DragDrop(Graph g,
                  Class newObjectClass)
Create a canvas and two scrollbars and lay them out in the panel
Parameters:
g - graph to store objects and edges
newObjectClass - class for object creation (must be public and implement DragDropObj)
 o DragDrop
  public DragDrop(Graph g,
                  Class newObjectClass,
                  boolean edit)
Create a canvas and two scrollbars and lay them out in the panel
Parameters:
g - graph to store objects and edges
newObjectClass - class for object creation (must be public and implement DragDropObj)
edit - enable / disable editing functions on startup

Methods

 o handleEvent
  public boolean handleEvent(Event e)
Event handler
mouse click on background creates new object
left mouse button to draw lines
right mouse button (or button + META) to drag objects
double click on object to call object's execute() method
Overrides:
handleEvent in class Component
 o reshape
  public synchronized void reshape(int x,
                                   int y,
                                   int width,
                                   int height)
Called when panel size changes (e.g. on startup)
Overrides:
reshape in class Component
 o enableEdit
  public void enableEdit()
Enable editing functions
 o disableEdit
  public boolean disableEdit()
Diable editing functions
Returns:
true if successful, false if state != STATE_NONE
 o getSelected
  public DragDropObj getSelected()
Get highlighted object
Returns:
selected object or null if no object has been selected
 o setClass
  public void setClass(Class newObjectClass)
Set the class for creation of new objects
Parameters:
newObjectClass - class for object creation
 o getGraph
  public Graph getGraph()
Get graph object; note that you have to call repaint() after making changes in the graph topology manually
Returns:
graph object
See Also:
Graph
 o drawEdge
  protected void drawEdge(Graphics g,
                          DragDropObj V1,
                          DragDropObj V2)
Draw edge between two objects.
Parameters:
g - Graphics context
V1 - First object
V1 - Second object

All Packages  Class Hierarchy  This Package  Previous  Next  Index