View Javadoc
1   /*
2    * Copyright (c) 2003, The JUNG Authors
3    * All rights reserved.
4    * 
5    * This software is open-source under the BSD license; see either "license.txt"
6    * or https://github.com/jrtom/jung/blob/master/LICENSE for a description.
7    * 
8    */
9   package edu.uci.ics.jung.visualization.control;
10  
11  import java.awt.event.MouseEvent;
12  import java.awt.event.MouseListener;
13  
14  public abstract class AbstractPopupGraphMousePlugin extends AbstractGraphMousePlugin 
15      implements MouseListener {
16      
17      public AbstractPopupGraphMousePlugin() {
18          this(MouseEvent.BUTTON3_MASK);
19      }
20      public AbstractPopupGraphMousePlugin(int modifiers) {
21          super(modifiers);
22      }
23      public void mousePressed(MouseEvent e) {
24          if(e.isPopupTrigger()) {
25              handlePopup(e);
26              e.consume();
27          }
28      }
29      
30      /**
31       * if this is the popup trigger, process here, otherwise
32       * defer to the superclass
33       */
34      public void mouseReleased(MouseEvent e) {
35          if(e.isPopupTrigger()) {
36              handlePopup(e);
37              e.consume();
38          }
39      }
40      
41      protected abstract void handlePopup(MouseEvent e);
42      
43      public void mouseClicked(MouseEvent e) {
44      }
45      
46      public void mouseEntered(MouseEvent e) {
47      }
48      
49      public void mouseExited(MouseEvent e) {
50      }
51  }