bfd321187f05bd456dd10b2a7d2dd55de5e70412
[jalview.git] / src / jalview / ext / treeviewer / TreePanelI.java
1 package jalview.ext.treeviewer;
2
3 import java.awt.Dimension;
4 import java.awt.Graphics2D;
5 import java.awt.MenuContainer;
6 import java.awt.Rectangle;
7 import java.awt.event.MouseListener;
8 import java.io.File;
9 import java.util.Set;
10
11 import javax.accessibility.Accessible;
12
13 /**
14  * Interface for a panel that supports viewing a phylogenetic tree, should
15  * probably be part of a {@link TreeFrameI}. Does not necessarily have to be a
16  * Swing JPanel.
17  * 
18  * Implementations must always contain a {@link TreeI}.
19  * 
20  * @author kjvanderheide
21  *
22  */
23 public interface TreePanelI extends Accessible, MenuContainer
24 {
25   public void addMouseListener(MouseListener listener);
26
27   /**
28    * Look for a tree node at the specified coordinates inside the panel.
29    * 
30    * @param x
31    *          X coordinate on the panel to look at.
32    * @param y
33    *          Y coordinate on the panel to look at.
34    * @return The tree node if one was found, otherwise null.
35    */
36   public abstract TreeNodeI findNode(int x, int y);
37
38   public int getHeight();
39
40   public void addToMatchingNodes(TreeNodeI matchedNode);
41
42   public abstract Set<Long> getMatchingNodesIds();
43
44   public MouseListener[] getMouseListeners();
45
46   /**
47    * Gets the current partitioning threshold which is the ratio of the
48    * partitioning x coordinate to the total panel width.
49    * 
50    * @return The partition threshold.
51    */
52   public float getPartitionThreshold();
53
54   public abstract TreeI getTree();
55
56   public abstract File getTreeFile();
57
58   public abstract Rectangle getVisibleArea();
59
60   public int getWidth();
61
62   /**
63    * Method for triggering PaintRefresher refreshes with the actual tree panel
64    * using the sequence set id the panel was registered with.
65    * 
66    * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
67    *      boolean, boolean)
68    * @param alignmentChanged
69    * @param validateSequences
70    */
71   public void notifyPaintRefresher(boolean alignmentChanged,
72           boolean validateSequences);
73
74   /**
75    * Method for triggering PaintRefresher refreshes with the actual tree panel
76    * using a new sequence set id.
77    * 
78    * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
79    *      boolean, boolean)
80    * @param newSeqSetIdentifier
81    * @param alignmentChanged
82    * @param validateSequences
83    */
84   public void notifyPaintRefresher(String newSeqSetIdentifier,
85           boolean alignmentChanged, boolean validateSequences);
86
87   public abstract void paintToFile(Graphics2D pg, int width, int height);
88
89   /**
90    * Registers the actual tree viewing panel used with PaintRefresher, this
91    * method is necessary as panels cannot be registered at this interface level
92    * because there is no guarantee an implementation will be a Component.
93    * 
94    * @see jalview.gui.PaintRefresher#Register(java.awt.Component, String)
95    * @param sequenceSetIdentifier
96    */
97   public void registerWithPaintRefresher(String sequenceSetIdentifier);
98
99   public void removeMouseListener(MouseListener listener);
100
101   public void repaint();
102
103   public abstract void setMatchingNodes(Set<Long> matchingNodes);
104
105   public void setMaximumSize(Dimension maximumSize);
106
107   public void setMinimumSize(Dimension minimumSize);
108
109   public void setPreferredSize(Dimension preferredSize);
110
111   /**
112    * 
113    * @param file
114    */
115   public abstract void setTreeFile(File file);
116
117   /**
118    * 
119    * @return
120    */
121   public boolean showingSubTree();
122
123 }