@Override public void mouseClicked(MouseEvent me){
  int x, y;
  Rectangle r=new Rectangle(0,0,(int)(m_nPaddedNodeWidth * m_fScale),(int)(m_nNodeHeight * m_fScale));
  x=me.getX();
  y=me.getY();
  for (int iNode=0; iNode < m_BayesNet.getNrOfNodes(); iNode++) {
    r.x=(int)(m_BayesNet.getPositionX(iNode) * m_fScale);
    r.y=(int)(m_BayesNet.getPositionY(iNode) * m_fScale);
    if (r.contains(x,y)) {
      m_nCurrentNode=iNode;
      if (me.getButton() == MouseEvent.BUTTON3) {
        handleRightNodeClick(me);
      }
      if (me.getButton() == MouseEvent.BUTTON1) {
        if ((me.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) {
          m_Selection.toggleSelection(m_nCurrentNode);
        }
 else         if ((me.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) {
          m_Selection.addToSelection(m_nCurrentNode);
        }
 else {
          m_Selection.clear();
          m_Selection.addToSelection(m_nCurrentNode);
        }
        repaint();
      }
      return;
    }
  }
  if (me.getButton() == MouseEvent.BUTTON3) {
    handleRightClick(me,(int)(x / m_fScale),(int)(y / m_fScale));
  }
}

@ Override public void mouseClicked ( MouseEvent me ) { int x , y ; Rectangle r = new Rectangle ( 0 , 0 , ( int ) ( m_nPaddedNodeWidth * m_fScale ) , ( int ) ( m_nNodeHeight * m_fScale ) ) ; x = me . getX ( ) ; y = me . getY ( ) ; for ( int iNode = 0 ; iNode < m_BayesNet . getNrOfNodes ( ) ; iNode ++ ) { r . x = ( int ) ( m_BayesNet . getPositionX ( iNode ) * m_fScale ) ; r . y = ( int ) ( m_BayesNet . getPositionY ( iNode ) * m_fScale ) ; if ( r . contains ( x , y ) ) { m_nCurrentNode = iNode ; if ( me . getButton ( ) == MouseEvent . BUTTON3 ) { handleRightNodeClick ( me ) ; } if ( me . getButton ( ) == MouseEvent . BUTTON1 ) { if ( ( me . getModifiersEx ( ) & MouseEvent . CTRL_DOWN_MASK ) != 0 ) { m_Selection . toggleSelection ( m_nCurrentNode ) ; } else if ( ( me . getModifiersEx ( ) & MouseEvent . SHIFT_DOWN_MASK ) != 0 ) { m_Selection . addToSelection ( m_nCurrentNode ) ; } else { m_Selection . clear ( ) ; m_Selection . addToSelection ( m_nCurrentNode ) ; } repaint ( ) ; } return ; } } if ( me . getButton ( ) == MouseEvent . BUTTON3 ) { handleRightClick ( me , ( int ) ( x / m_fScale ) , ( int ) ( y / m_fScale ) ) ; } }
a left mouseclick on a node adds node to selection ( depending on shift and ctrl keys ) . a right mouseclick on a node pops up menu with actions to be performed on the node . a right mouseclick outside another node pops up menu .
