import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Frame;
-import java.awt.Image;
import java.awt.Panel;
-import java.awt.Point;
import java.awt.PopupMenu;
-import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
-import javax.swing.ImageIcon;
-
public class OverviewPanel extends Panel implements Runnable,
MouseMotionListener, MouseListener, ViewportListenerI
{
- protected Image dragImage = new ImageIcon(
- getClass().getResource("/images/dragcursor.png")).getImage();
-
private OverviewDimensions od;
private OverviewCanvas oviewCanvas;
private boolean draggingBox = false;
- private Cursor dragCursor;
-
public OverviewPanel(AlignmentPanel alPanel)
{
this.av = alPanel.av;
av.getRanges().addPropertyChangeListener(this);
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- Image image = toolkit.getImage("images/dragcursor.png");
-
- if (Platform.isAMac())
- {
- dragCursor = toolkit.createCustomCursor(image, new Point(15, 15),
- "drag cursor");
- }
- else
- {
- dragCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
- }
-
addComponentListener(new ComponentAdapter()
{
{
showPopupMenu(evt);
}
- else if (od.isPositionInBox(evt.getX(), evt.getY()))
- {
- // display drag cursor at mouse position
- this.getParent().setCursor(dragCursor);
- }
- else
- {
- // reset cursor
- this.getParent()
- .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
}
@Override
public void mouseMoved(MouseEvent evt)
{
- System.out.println(evt.getY());
if (od.isPositionInBox(evt.getX(), evt.getY()))
{
- // display drag cursor at mouse position
- this.getParent().setCursor(dragCursor);
+ this.getParent()
+ .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else
{
- // reset cursor
this.getParent()
- .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ .setCursor(
+ Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
}
od.updateViewportFromMouse(evt.getX(), evt.getY(),
av.getAlignment().getHiddenSequences(),
av.getAlignment().getHiddenColumns());
+ getParent()
+ .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else
{
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
-import java.awt.Image;
-import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
-import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
public class OverviewPanel extends JPanel
implements Runnable, ViewportListenerI
{
- protected Image dragImage = new ImageIcon(
- getClass().getResource("/images/dragcursor.png"))
- .getImage();
-
private OverviewDimensions od;
private OverviewCanvas oviewCanvas;
// without this the overview window does not size to fit the overview canvas
setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
- // set up custom cursor for use on Mac...
- Point hotSpot = new Point(16, 16);
- String cursorName = "Custom drag cursor";
-
- Cursor tempCursor;
- if (Platform.isAMac())
- {
- tempCursor = getToolkit().createCustomCursor(dragImage, hotSpot,
- cursorName);
- }
- else
- {
- tempCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
- }
- final Cursor dragCursor = tempCursor;
addComponentListener(new ComponentAdapter()
{
{
if (od.isPositionInBox(evt.getX(), evt.getY()))
{
- // display drag cursor at mouse position
- getParent().setCursor(dragCursor);
+ /*
+ * using HAND_CURSOR rather than DRAG_CURSOR
+ * as the latter is not supported on Mac
+ */
+ getParent().setCursor(
+ Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else
{
// reset cursor
getParent().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
}
od.updateViewportFromMouse(evt.getX(), evt.getY(),
av.getAlignment().getHiddenSequences(),
av.getAlignment().getHiddenColumns());
+ getParent().setCursor(
+ Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else
{
{
showPopupMenu(evt);
}
- // click in box should also reset the cursor
- else if (od.isPositionInBox(evt.getX(), evt.getY()))
- {
- // display drag cursor at mouse position
- getParent().setCursor(dragCursor);
- }
- else
- {
- // reset cursor
- getParent().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
}
});
}