jcreek.cke.tool
Class BuildTool

java.lang.Object
  extended byjcreek.cke.tool.BuildTool
All Implemented Interfaces:
ConceptViewListener, ConceptViewPaintListener, CreekTool, java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.beans.PropertyChangeListener

public class BuildTool
extends java.lang.Object
implements CreekTool, ConceptViewPaintListener, java.beans.PropertyChangeListener

Title: JavaCreek Description: A Case based Reasoning Approach in java Copyright: Copyright (c) 2002 Company: Phil

Version:
1.0
Author:
Victor

Field Summary
protected  java.awt.BasicStroke dashedStroke
          A dashed line stroke for drawing.
protected  CreekDocument document
          Document this mediator is associated with.
protected  java.awt.Point firstMousePos
          First mouse press position when dragging started.
protected  boolean isAddEdge
          True if we're in the middle of adding a new edge.
protected  java.awt.Point lastMousePos
          Most recent mouse position while dragging.
protected  CreekModel model
          Model that we're associated with.
protected  VertexList movingVertices
          The list of the entities being moved around.
protected  VisualEntity pressVertex
          Vertex the user pressed on in mousePressed().
protected  VisualEntity propVertex
          Vertex the rightClicked.
 PropertyWindow propWin
           
protected  javax.swing.JPopupMenu relationList
           
protected  VertexList selectedList
          List of the selected entities in the order they were selected by the user.
protected  VisualEntity targetVertex
          Vertex the mouse is currently over during the adding of an edge.
protected  boolean wasPressed
          True if mouse was pressed on the view before being released.
protected  ConceptView view
          View that we're associated with.
 
Constructor Summary
BuildTool()
           
 
Method Summary
 VisualEntity activateEntity(Entity ed, VisualEntity activator)
           
protected  void activateRelation(Relation r)
           
protected  void activateRelation(java.lang.String relationType)
           
 void attach(CreekModel model, ConceptView view, javax.swing.JInternalFrame win)
          Attach to the given model and view objects.
protected  javax.swing.JMenuItem createMenuItem(java.lang.String cmd)
           
protected  javax.swing.JMenu createRelationsMenu()
           
 void deactivateRelation(java.lang.String relationName)
           
 void detach()
          Detach from the model and view and prepare to be deactivated.
protected  VisualEntity findNode(int x, int y)
          Find an entity close to the given x,y position.
protected  void finishMoving()
          If we were moving entities, clean up now.
protected  void formPopup(int x, int y)
           
 java.awt.Point getMousePosition()
          Returns the position of the mouse,this will return the first Mouse Position or last Mouse Position depending on the current Tool and the state of the tool
 VertexList getSelected()
          Returns the list of selected vertices, in the order they were selected by the user.
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
          The user is dragging the mouse.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent me)
          User has pressed a mouse button on us.
 void mouseReleased(java.awt.event.MouseEvent me)
          User has released a mouse button on us.
 void paintAfter(ConceptViewPaintEvent event)
          Called after the view draws the graph.
 void paintBefore(ConceptViewPaintEvent event)
          Called before the view draws the graph.
 void propertyChange(java.beans.PropertyChangeEvent e)
          The state of the object we're listening to has changed.
protected  void resetMovingVertices()
          Moves all the moving entities back to their original positions by using the original positions stored in the copy of the entities.
protected  void selectRegion()
          Called when user was defining a rectangular region with which to select entities.
protected  void toggleRelation(VisualEntity e, java.lang.String relationName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected CreekModel model
Model that we're associated with.


view

protected ConceptView view
View that we're associated with.


document

protected CreekDocument document
Document this mediator is associated with.


pressVertex

protected VisualEntity pressVertex
Vertex the user pressed on in mousePressed(). Could be null if the user didn't press on a entity.


propVertex

protected VisualEntity propVertex
Vertex the rightClicked. Could be null if the user didn't rightClick on a entity.


selectedList

protected VertexList selectedList
List of the selected entities in the order they were selected by the user.


targetVertex

protected VisualEntity targetVertex
Vertex the mouse is currently over during the adding of an edge. Could be null if mouse isn't over a vertex or if user is not adding an edge.


wasPressed

protected boolean wasPressed
True if mouse was pressed on the view before being released. Helps avoid some mis-firings of the mouse buttons.


movingVertices

protected VertexList movingVertices
The list of the entities being moved around. These entities are a copy of the originals and can be modified.


isAddEdge

protected boolean isAddEdge
True if we're in the middle of adding a new edge.


firstMousePos

protected java.awt.Point firstMousePos
First mouse press position when dragging started.


lastMousePos

protected java.awt.Point lastMousePos
Most recent mouse position while dragging.


dashedStroke

protected java.awt.BasicStroke dashedStroke
A dashed line stroke for drawing.


propWin

public PropertyWindow propWin

relationList

protected javax.swing.JPopupMenu relationList
Constructor Detail

BuildTool

public BuildTool()
Method Detail

attach

public void attach(CreekModel model,
                   ConceptView view,
                   javax.swing.JInternalFrame win)
Description copied from interface: CreekTool
Attach to the given model and view objects. This begins user interaction and will imply that this tool is the currently active tool. The tool should add itself as a listener to the view object to begin interaction with the user.

Specified by:
attach in interface CreekTool
Parameters:
model - GraphModel to attach to
view - GraphView to attach to

detach

public void detach()
Description copied from interface: CreekTool
Detach from the model and view and prepare to be deactivated. This does not imply that this object is about to be destroyed. The tool should remove itself from the view listener list and cease interaction with the user.

Note that this method may be called more than once between calls to attach()

Specified by:
detach in interface CreekTool

getSelected

public VertexList getSelected()
Description copied from interface: CreekTool
Returns the list of selected vertices, in the order they were selected by the user. Often called by another class that is going to perform some operation on the graph, such as a search.

Specified by:
getSelected in interface CreekTool
Returns:
selected vertex list

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
User has pressed a mouse button on us. Interpret the click as clicking a vertex and save the vertex reference. May be null if the user didn't click on a vertex.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
me - mouse event for this canvas

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
User has released a mouse button on us. Now we check if the user released the mouse on a vertex. This could mean several things, as follows: pressVertex = targetVertex = null, add vertex pressVertex != targetVertex and no edge exists, add one

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
me - mouse event for this canvas

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
The user is dragging the mouse. Check if we are possibly creating a new edge or not.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
me - mouse event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

paintAfter

public void paintAfter(ConceptViewPaintEvent event)
Called after the view draws the graph. Gives the listener a chance to draw something to the view after everything else has been drawn. The order in which listeners are called is non-deterministic.

Specified by:
paintAfter in interface ConceptViewPaintListener
Parameters:
event - view paint event

paintBefore

public void paintBefore(ConceptViewPaintEvent event)
Called before the view draws the graph. Gives the listener a chance to draw something to the view before anything else appears. The order in which listeners are called is non-deterministic.

Specified by:
paintBefore in interface ConceptViewPaintListener
Parameters:
event - view paint event

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
The state of the object we're listening to has changed. This means we should check if any of the selected entities have been removed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - change event

getMousePosition

public java.awt.Point getMousePosition()
Returns the position of the mouse,this will return the first Mouse Position or last Mouse Position depending on the current Tool and the state of the tool

Specified by:
getMousePosition in interface CreekTool
Returns:
Point position of the mouse

selectRegion

protected void selectRegion()
Called when user was defining a rectangular region with which to select entities. Determines which entities are within the rectangle and marks them selected.


resetMovingVertices

protected void resetMovingVertices()
Moves all the moving entities back to their original positions by using the original positions stored in the copy of the entities.


findNode

protected VisualEntity findNode(int x,
                                int y)
Find an entity close to the given x,y position.

Parameters:
x - mouse x position
y - mouse y position

finishMoving

protected void finishMoving()
If we were moving entities, clean up now.


formPopup

protected void formPopup(int x,
                         int y)

createMenuItem

protected javax.swing.JMenuItem createMenuItem(java.lang.String cmd)

createRelationsMenu

protected javax.swing.JMenu createRelationsMenu()

toggleRelation

protected void toggleRelation(VisualEntity e,
                              java.lang.String relationName)

deactivateRelation

public void deactivateRelation(java.lang.String relationName)

activateRelation

protected void activateRelation(java.lang.String relationType)

activateRelation

protected void activateRelation(Relation r)

activateEntity

public VisualEntity activateEntity(Entity ed,
                                   VisualEntity activator)


Created at IDI, NTNU by the Artificial Intelligence and Learning group