*/
package jalview.gui;
-import jalview.analysis.Conservation;
-import jalview.analysis.TreeModel;
-import jalview.api.AlignViewportI;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.datamodel.SequenceNode;
-import jalview.gui.JalviewColourChooser.ColourChooserListener;
-import jalview.schemes.ColourSchemeI;
-import jalview.structure.SelectionSource;
-import jalview.util.Format;
-import jalview.util.MessageManager;
-
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
-import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Vector;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
+import jalview.analysis.Conservation;
+import jalview.analysis.TreeModel;
+import jalview.api.AlignViewportI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.SequenceNode;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
+import jalview.schemes.ColourSchemeI;
+import jalview.structure.SelectionSource;
+import jalview.util.Format;
+import jalview.util.MessageManager;
+
/**
* DOCUMENT ME!
*
int labelLength = -1;
- Hashtable nameHash = new Hashtable();
+ Map<Object, Rectangle> nameHash = new Hashtable<>();
- Hashtable nodeHash = new Hashtable();
+ Map<SequenceNode, Rectangle> nodeHash = new Hashtable<>();
SequenceNode highlightNode;
*/
public Object findElement(int x, int y)
{
- Enumeration keys = nameHash.keys();
-
- while (keys.hasMoreElements())
+ for (Entry<Object, Rectangle> entry : nameHash.entrySet())
{
- Object ob = keys.nextElement();
- Rectangle rect = (Rectangle) nameHash.get(ob);
+ Rectangle rect = (Rectangle) nameHash.get(entry.getValue());
if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y)
&& (y <= (rect.y + rect.height)))
{
- return ob;
+ return entry.getKey();
}
}
- keys = nodeHash.keys();
-
- while (keys.hasMoreElements())
+ for (Entry<SequenceNode, Rectangle> entry : nodeHash.entrySet())
{
- Object ob = keys.nextElement();
- Rectangle rect = (Rectangle) nodeHash.get(ob);
+ Rectangle rect = entry.getValue();
if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y)
&& (y <= (rect.y + rect.height)))
{
- return ob;
+ return entry.getKey();
}
}
if ((node.left() == null) && (node.right() == null))
{
double height = node.height;
- double dist = node.dist;
-
- int xstart = (int) ((height - dist) * wscale) + offx;
+// double dist = node.dist;
+// int xstart = (int) ((height - dist) * wscale) + offx;
int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
{
fm = g.getFontMetrics(font);
- if (nameHash.size() == 0)
+ int nameCount = nameHash.size();
+ if (nameCount == 0)
{
repaint();
}
if (fitToWindow || (!fitToWindow && (scrollPane
- .getHeight() > ((fm.getHeight() * nameHash.size()) + offy))))
+ .getHeight() > ((fm.getHeight() * nameCount) + offy))))
{
draw(g, scrollPane.getWidth(), scrollPane.getHeight());
setPreferredSize(null);
else
{
setPreferredSize(new Dimension(scrollPane.getWidth(),
- fm.getHeight() * nameHash.size()));
- draw(g, scrollPane.getWidth(), fm.getHeight() * nameHash.size());
+ fm.getHeight() * nameCount));
+ draw(g, scrollPane.getWidth(), fm.getHeight() * nameCount);
}
scrollPane.revalidate();