org.rosuda.klimt.plots
Class TreeCanvas

java.lang.Object
  extended by org.rosuda.ibase.toolkit.PlotComponent
      extended by org.rosuda.ibase.toolkit.PGSCanvas
          extended by org.rosuda.klimt.plots.TreeCanvas
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Printable, java.util.EventListener, Commander, Dependent

public class TreeCanvas
extends PGSCanvas
implements Dependent, Commander, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener

Tree Canvas - implementation of the tree display

Version:
$Id: TreeCanvas.java 1803 2005-12-05 06:37:53Z urbaneks $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.rosuda.ibase.toolkit.PGSCanvas
PGSCanvas.IDlgCL
 
Field Summary
 boolean connMode
          link nodes with 90-deg lines
 double devGainScale
          deviance gain scale
 int dragm
           
 SNode dragn
          node currently being dragged (externally used by mouse listeners)
 boolean finalAlign
          allign all leaves on the bottom
 boolean infoUpdate
          info window has to be updated
 boolean labelBg
          if true node labels (selectable) have background rectangle even if not selected
 int ldx
           
 int ldy
           
 java.util.Vector nod
          vector of nodes of type SNode
 boolean nodeMode
          use node sizes proportional to the # of caes
 boolean PD_goCart
          P.Dirschedl proposed GoCart
 boolean PD_lines
          P.Dirschedl proposed lines
 boolean PD_POE
          P.Dirschedl proposed PlaceOverExpectation
 boolean PD_POE_log
          use log scale for expectations/predictions
 boolean rot90
          rotate tree by 90 deg
 SNode selectedNode
          currently selected node or null if none
 boolean shortLabels
           
 boolean showDetailed
          show detailed or rough info
 boolean showDevGain
          show deviance gain
 boolean showInfo
          showing info about a node currently
 boolean showLabels
          show node labels
 boolean showPathWindow
          state of the path winodw
 boolean showPVAll
          show prediction in inner nodes, too
 boolean showSampleDev
          show sample deviance as well (has no effect in showDevGain=false)
static int Tool_Move
          tool mode constant: move
static int Tool_Node
          tool mode constant: select node
static int Tool_Query
          tool mode constant: query
static int Tool_Select
          tool mode constant: select cases
static int Tool_Zoom
          tool mode constant: zoom
 int toolMode
          tool mode
 double zoomFactor
          zoom factor used to determine logical zoom behavior
 
Fields inherited from class org.rosuda.ibase.toolkit.PGSCanvas
ax, ay, cancel, desc, inProgress, intDlg, myFrame, pageFormat, paintLayerCounter, pm
 
Fields inherited from class org.rosuda.ibase.toolkit.PlotComponent
AWTGrDevID, GrDevID, JOGLGrDevID, layers, SWINGGrDevID
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
TreeCanvas(SNode troot, java.awt.Frame cont)
          construct a new display instance based on the specified tree
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          action listener methods reroutes all request to the commander interface
 void buildLeaf(int parx, int pary, int splitUnit, int yShift, int myWidth, int totalHeight, SNode t, int maxH, boolean updatePlacement)
          builds node structure recursively.
 void drawGroupsRect(PoGraSS g, int x, int y, int w, int h, SMarker m, int[] cases)
          tool: draws all selections including secondary marks in a rectangle from left to right
 java.awt.Dimension getMinimumSize()
          supply minimal resize dimension (needed especially by MacOS X)
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent ev)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent ev)
           
 void mousePressed(java.awt.event.MouseEvent ev)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void moveLeaf(int dx, int dy, SNode t, boolean recursively)
          move node coordinates relative based on the x/y difference
 void Notifying(NotifyMsg msg, java.lang.Object o, java.util.Vector path)
          notify handler (simply repaints the tree) ignores the parameter
 void paintLeaf(PoGraSS g, SNode t)
          paints a node and all its subnodes recursively.
 void paintPoGraSS(PoGraSS p)
          implementation of the abstract method of PGSCanvas calls paintLeaf(org.rosuda.pograss.PoGraSS, org.rosuda.klimt.SNode)(g,root)
 void queryNode(SNode n, boolean detailed)
           
 void redesignNodes()
           
 void redesignNodes(boolean updatePlacement)
          redesign nodes based on the current canvas geometry (result in a call to redesignNodes(Dimension, boolean))
 void redesignNodes(java.awt.Dimension geom, boolean updatePlacement)
          redesign nodes based on the specifie geometry.
 java.lang.Object run(java.lang.Object o, java.lang.String cmd)
          commander interface implementation for all user commands
 void selectNode(SNode n)
          set currently selected node
 void setToolMode(int mode)
          set tool mode and use according cursor shape
 void updateCachedValues()
          updates all cached values of the tree.
 
Methods inherited from class org.rosuda.ibase.toolkit.PGSCanvas
beginPaint, dispose, endPaint, finalize, forcedFlush, getData, getFrame, getGlobalNotifier, getPlotManager, getTitle, getXAxis, getYAxis, nextLayer, paintLayer, print, setFrame, setOption, setOption, setOption, setOption, setOption, setOption, setTitle
 
Methods inherited from class org.rosuda.ibase.toolkit.PlotComponent
addKeyListener, addMouseListener, addMouseMotionListener, getBounds, getComponent, getHeight, getLocation, getParent, getSize, getWidth, newQueryPopup, newQueryPopup, paintLayer, repaint, setBackground, setCursor, setSize, setSize, setToolTipText, setUpdateRoot
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Tool_Select

public static final int Tool_Select
tool mode constant: select cases

See Also:
Constant Field Values

Tool_Move

public static final int Tool_Move
tool mode constant: move

See Also:
Constant Field Values

Tool_Zoom

public static final int Tool_Zoom
tool mode constant: zoom

See Also:
Constant Field Values

Tool_Node

public static final int Tool_Node
tool mode constant: select node

See Also:
Constant Field Values

Tool_Query

public static final int Tool_Query
tool mode constant: query

See Also:
Constant Field Values

nod

public java.util.Vector nod
vector of nodes of type SNode


selectedNode

public SNode selectedNode
currently selected node or null if none


dragm

public int dragm

ldx

public int ldx

ldy

public int ldy

dragn

public SNode dragn
node currently being dragged (externally used by mouse listeners)


showInfo

public boolean showInfo
showing info about a node currently


showDetailed

public boolean showDetailed
show detailed or rough info


infoUpdate

public boolean infoUpdate
info window has to be updated


rot90

public boolean rot90
rotate tree by 90 deg


nodeMode

public boolean nodeMode
use node sizes proportional to the # of caes


connMode

public boolean connMode
link nodes with 90-deg lines


finalAlign

public boolean finalAlign
allign all leaves on the bottom


showDevGain

public boolean showDevGain
show deviance gain


showSampleDev

public boolean showSampleDev
show sample deviance as well (has no effect in showDevGain=false)


showPVAll

public boolean showPVAll
show prediction in inner nodes, too


showLabels

public boolean showLabels
show node labels


shortLabels

public boolean shortLabels

devGainScale

public double devGainScale
deviance gain scale


showPathWindow

public boolean showPathWindow
state of the path winodw


toolMode

public int toolMode
tool mode


zoomFactor

public double zoomFactor
zoom factor used to determine logical zoom behavior


PD_lines

public boolean PD_lines
P.Dirschedl proposed lines


PD_goCart

public boolean PD_goCart
P.Dirschedl proposed GoCart


PD_POE

public boolean PD_POE
P.Dirschedl proposed PlaceOverExpectation


PD_POE_log

public boolean PD_POE_log
use log scale for expectations/predictions


labelBg

public boolean labelBg
if true node labels (selectable) have background rectangle even if not selected

Constructor Detail

TreeCanvas

public TreeCanvas(SNode troot,
                  java.awt.Frame cont)
construct a new display instance based on the specified tree

Parameters:
troot - root of the tree
cont - parent frame
Method Detail

getMinimumSize

public java.awt.Dimension getMinimumSize()
supply minimal resize dimension (needed especially by MacOS X)


updateCachedValues

public void updateCachedValues()
updates all cached values of the tree. Must be called whenever the underlying tree has changed


redesignNodes

public void redesignNodes()

redesignNodes

public void redesignNodes(boolean updatePlacement)
redesign nodes based on the current canvas geometry (result in a call to redesignNodes(Dimension, boolean))


redesignNodes

public void redesignNodes(java.awt.Dimension geom,
                          boolean updatePlacement)
redesign nodes based on the specifie geometry. calls buildLeaf(int, int, int, int, int, int, org.rosuda.klimt.SNode, int, boolean) and #paint implicitely

Parameters:
geom - target geometry to use for design

Notifying

public void Notifying(NotifyMsg msg,
                      java.lang.Object o,
                      java.util.Vector path)
notify handler (simply repaints the tree) ignores the parameter

Specified by:
Notifying in interface Dependent
Overrides:
Notifying in class PGSCanvas
o - Object that sent the notification. The actual content is implementation-dependent.
path - This parameter is null for non-cascaded notify - in that case further calls to NotifyAll are not allowed. Otherwise it contains a Vector with all objects notified so far during cascaded notify. To aviod cyclic notifications every instance must either reject cascaded notifications (i.e. no calls to NotifyAll at all) or check for occurence of itself in the chain before calling NotifyAll. The only valid recursive calls in Notifying are NotifyAll(path) and NotifyAll(..,path), because only these two pass the "path" parameter to avoid cyclic loops.

moveLeaf

public void moveLeaf(int dx,
                     int dy,
                     SNode t,
                     boolean recursively)
move node coordinates relative based on the x/y difference

Parameters:
dx - difference in x direction
dy - difference in y direction
t - the node to be moved
recursively - if set to true all sub-nodes are also moved respectively

buildLeaf

public void buildLeaf(int parx,
                      int pary,
                      int splitUnit,
                      int yShift,
                      int myWidth,
                      int totalHeight,
                      SNode t,
                      int maxH,
                      boolean updatePlacement)
builds node structure recursively. the current node is drawn, then the coordinates of the children

Parameters:
parx - parent x coordinate
pary - parent y coordinate
splitUnit - space between two leaves - smallest granularity unit of the design (in x direction)
yShift - space between tree levels in y direction
myWidth - with of this node
totalHeight - total height of the final tree
t - the node to be painted

paintPoGraSS

public void paintPoGraSS(PoGraSS p)
implementation of the abstract method of PGSCanvas calls paintLeaf(org.rosuda.pograss.PoGraSS, org.rosuda.klimt.SNode)(g,root)

Overrides:
paintPoGraSS in class PGSCanvas
Parameters:
g - graphic context to paint on

paintLeaf

public void paintLeaf(PoGraSS g,
                      SNode t)
paints a node and all its subnodes recursively. all necessary information is stored in the SNode contents of the SNode nodes.

Parameters:
g - graphic context to pain on
t - node to paint

queryNode

public void queryNode(SNode n,
                      boolean detailed)

selectNode

public void selectNode(SNode n)
set currently selected node


run

public java.lang.Object run(java.lang.Object o,
                            java.lang.String cmd)
commander interface implementation for all user commands

Specified by:
run in interface Commander
Overrides:
run in class PGSCanvas
Parameters:
o - origin of the command
cmd - command string
Returns:
any object, the actual interpretation is up to the calling object

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
action listener methods reroutes all request to the commander interface

Specified by:
actionPerformed in interface java.awt.event.ActionListener

setToolMode

public void setToolMode(int mode)
set tool mode and use according cursor shape


mouseDragged

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

mouseMoved

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

mouseClicked

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

mousePressed

public void mousePressed(java.awt.event.MouseEvent ev)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

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

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

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

drawGroupsRect

public void drawGroupsRect(PoGraSS g,
                           int x,
                           int y,
                           int w,
                           int h,
                           SMarker m,
                           int[] cases)
tool: draws all selections including secondary marks in a rectangle from left to right