JAL-1953 some more comments, moved JalviewBinding
[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   /**
41    * Method for adding a tree node to the Set of nodes that are associated with
42    * some operation outside of the tree, such as nodes belonging to currently
43    * selected Jalview alignment sequences.
44    * 
45    * @param matchedNode
46    */
47   public void addToMatchingNodes(TreeNodeI matchedNode);
48
49   public abstract Set<Long> getMatchingNodesIds();
50
51   public MouseListener[] getMouseListeners();
52
53   /**
54    * Gets the current partitioning threshold which is the ratio of the
55    * partitioning x coordinate to the total panel width.
56    * 
57    * @return The partition threshold.
58    */
59   public float getPartitionThreshold();
60
61   public abstract TreeI getTree();
62
63   /**
64    * Gets the File from where the Tree originates.
65    * 
66    * @return
67    */
68   public abstract File getTreeFile();
69
70   public abstract Rectangle getVisibleArea();
71
72   public int getWidth();
73
74   /**
75    * Method for triggering PaintRefresher refreshes with the actual tree panel
76    * using the sequence set id the panel was registered with.
77    * 
78    * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
79    *      boolean, boolean)
80    * @param alignmentChanged
81    * @param validateSequences
82    */
83   public void notifyPaintRefresher(boolean alignmentChanged,
84           boolean validateSequences);
85
86   /**
87    * Method for triggering PaintRefresher refreshes with the actual tree panel
88    * using a new sequence set id.
89    * 
90    * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
91    *      boolean, boolean)
92    * @param newSeqSetIdentifier
93    * @param alignmentChanged
94    * @param validateSequences
95    */
96   public void notifyPaintRefresher(String newSeqSetIdentifier,
97           boolean alignmentChanged, boolean validateSequences);
98
99   public abstract void paintToFile(Graphics2D pg, int width, int height);
100
101   /**
102    * Registers the actual tree viewing panel used with PaintRefresher, this
103    * method is necessary as panels cannot be registered at this interface level
104    * because there is no guarantee an implementation will be a Component.
105    * 
106    * @see jalview.gui.PaintRefresher#Register(java.awt.Component, String)
107    * @param sequenceSetIdentifier
108    */
109   public void registerWithPaintRefresher(String sequenceSetIdentifier);
110
111   public void removeMouseListener(MouseListener listener);
112
113   public void repaint();
114
115   public abstract void setMatchingNodes(Set<Long> matchingNodes);
116
117   public void setMaximumSize(Dimension maximumSize);
118
119   public void setMinimumSize(Dimension minimumSize);
120
121   public void setPreferredSize(Dimension preferredSize);
122
123   public abstract void setTreeFile(File file);
124
125   /**
126    * Checks if the tree has been cut to display just a sub tree.
127    * 
128    * @return True if the panel is currently showing only a subtree, otherwise
129    *         false.
130    */
131   public boolean showingSubTree();
132
133 }