return false;
}
// DEBUG Hint: can test embedded menus by inserting true here.
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
// Build the embedded menu panel, allowing override with system font
embeddedMenu = makeEmbeddedPopupMenu(topMenuBar, true, false);
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
+import javax.swing.SwingUtilities;
+
public class OverviewPanel extends Panel implements Runnable,
MouseMotionListener, MouseListener, ViewportListenerI
{
if ((evt.getModifiers()
& InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
- if (!Platform.isAMac())
+ if (!Platform.isAMacAndNotJS())
{
showPopupMenu(evt);
}
@Override
public void mouseDragged(MouseEvent evt)
{
- if ((evt.getModifiers()
- & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+ if (Platform.isWinRightButton(evt))
{
- if (!Platform.isAMac())
- {
- showPopupMenu(evt);
- }
+ showPopupMenu(evt);
+ return;
}
- else
- {
- if (draggingBox)
- {
- // set the mouse position as a fixed point in the box
- // and drag relative to that position
- od.adjustViewportFromMouse(evt.getX(), evt.getY(),
- av.getAlignment().getHiddenSequences(),
- av.getAlignment().getHiddenColumns());
- }
- else
- {
- od.updateViewportFromMouse(evt.getX(), evt.getY(),
- av.getAlignment().getHiddenSequences(),
- av.getAlignment().getHiddenColumns());
- }
- ap.paintAlignment(false, false);
+
+ if (SwingUtilities.isRightMouseButton(evt))
+ {
+ return;
}
+
+ if (draggingBox)
+ {
+ // set the mouse position as a fixed point in the box
+ // and drag relative to that position
+ od.adjustViewportFromMouse(evt.getX(), evt.getY(),
+ av.getAlignment().getHiddenSequences(),
+ av.getAlignment().getHiddenColumns());
+ }
+ else
+ {
+ od.updateViewportFromMouse(evt.getX(), evt.getY(),
+ av.getAlignment().getHiddenSequences(),
+ av.getAlignment().getHiddenColumns());
+ }
+ ap.paintAlignment(false, false);
}
/**
// For now, ignore the mouseWheel font resizing on Macs
// As the Button2_mask always seems to be true
- if ((evt.getModifiers()
- & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK
- && !Platform.isAMac())
+
+ if (Platform.isWinMiddleButton(evt))
{
mouseWheelPressed = true;
return;
System.err.println("Unexpected Look and Feel Exception");
ex.printStackTrace();
}
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
* hscroll, status bar, insets.
*/
int stuff = (ap.getViewName() != null ? 30 : 0)
- + (Platform.isAMac() ? 120 : 140);
+ + (Platform.isAMacAndNotJS() ? 120 : 140);
int availableHeight = ap.alignFrame.getHeight() - stuff;
int rowHeight = av.getCharHeight();
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktop.setDesktopManager(new MyDesktopManager(
- (Platform.isWindows() ? new DefaultDesktopManager()
- : Platform.isAMac()
+ (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager()
+ : Platform.isAMacAndNotJS()
? new AquaInternalFrameManager(
desktop.getDesktopManager())
: desktop.getDesktopManager())));
}
else
{
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
System.err.println(
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
}
}
- if (Platform.isWindows())
-
+ if (Platform.isWindowsAndNotJS())
{
Cache.log.debug("Scanning dropped content for Windows Link Files");
frame = new JInternalFrame();
frame.setContentPane(this);
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
Desktop.addInternalFrame(frame,
MessageManager.getString("label.sequence_feature_settings"),
* (where isPopupTrigger() will answer true)
* NB isRightMouseButton is also true for Cmd-click on Mac
*/
- if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac())
+ if (Platform.isWinRightButton(e))
{
return;
}
* @author $author$
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class OverviewPanel extends JPanel
implements Runnable, ViewportListenerI
{
- private OverviewDimensions od;
+ protected OverviewDimensions od;
private OverviewCanvas oviewCanvas;
- private AlignViewport av;
+ protected AlignViewport av;
private AlignmentPanel ap;
- private JCheckBoxMenuItem displayToggle;
+ protected JCheckBoxMenuItem displayToggle;
- private boolean showHidden = true;
+ protected boolean showHidden = true;
- private boolean draggingBox = false;
+ protected boolean draggingBox = false;
- private ProgressPanel progressPanel;
+ protected ProgressPanel progressPanel;
/**
* Creates a new OverviewPanel object.
{
if (SwingUtilities.isRightMouseButton(evt))
{
- if (!Platform.isAMac())
+ if (!Platform.isAMacAndNotJS())
{
+ // BH - MAC L&F here - forces popup and cancels any drag operation
showPopupMenu(evt);
}
}
/*
* Displays the popup menu and acts on user input
*/
- private void showPopupMenu(MouseEvent e)
+ protected void showPopupMenu(MouseEvent e)
{
JPopupMenu popup = new JPopupMenu();
ActionListener menuListener = new ActionListener()
/*
* Toggle overview display between showing hidden columns and hiding hidden columns
*/
- private void toggleHiddenColumns()
+ protected void toggleHiddenColumns()
{
if (showHidden)
{
wsTab.add(wsPrefs, BorderLayout.CENTER);
}
int width = 500, height = 450;
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
width = 570;
height = 480;
if (evt.isPopupTrigger()) // Mac: mousePressed
{
rightMouseButtonPressed(evt, res);
+ return;
}
- else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+ if (Platform.isWinRightButton(evt))
{
/*
* defer right-mouse click handling to mouse up on Windows
*/
return;
}
- else
- {
- leftMouseButtonPressed(evt, res);
- }
+ leftMouseButtonPressed(evt, res);
}
/**
}
}
- if (evt.isPopupTrigger()) // Mac: mousePressed
- {
- showPopupMenu(evt);
- return;
- }
-
/*
* defer right-mouse click handling to mouseReleased on Windows
* (where isPopupTrigger() will answer true)
* NB isRightMouseButton is also true for Cmd-click on Mac
*/
- if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+ if (Platform.isWinRightButton(evt))
{
return;
}
+ if (evt.isPopupTrigger()) // Mac: mousePressed
+ {
+ showPopupMenu(evt);
+ return;
+ }
+
if (av.cursorMode)
{
seqCanvas.cursorX = findColumn(evt);
frame = new JInternalFrame();
frame.setContentPane(this);
- int height = Platform.isAMac() ? 240 : 180;
+ int height = Platform.isAMacAndNotJS() ? 240 : 180;
Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, height);
}
* estimate width and height of SplitFrame; this.getInsets() doesn't seem to
* give the full additional size (a few pixels short)
*/
- int widthFudge = Platform.isAMac() ? MAC_INSETS_WIDTH
+ int widthFudge = Platform.isAMacAndNotJS() ? MAC_INSETS_WIDTH
: WINDOWS_INSETS_WIDTH;
- int heightFudge = Platform.isAMac() ? MAC_INSETS_HEIGHT
+ int heightFudge = Platform.isAMacAndNotJS() ? MAC_INSETS_HEIGHT
: WINDOWS_INSETS_HEIGHT;
int width = ((AlignFrame) getTopFrame()).getWidth() + widthFudge;
int height = ((AlignFrame) getTopFrame()).getHeight()
/*
* estimate ratio of (topFrameContent / bottomFrameContent)
*/
- int insets = Platform.isAMac() ? MAC_INSETS_HEIGHT
+ int insets = Platform.isAMacAndNotJS() ? MAC_INSETS_HEIGHT
: WINDOWS_INSETS_HEIGHT;
// allow 3 'rows' for scale, scrollbar, status bar
int topHeight = insets + (3 + topCount) * topCharHeight
layout.putConstraint(SpringLayout.NORTH, scroller, 5,
SpringLayout.NORTH, this);
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
scroller.setPreferredSize(new Dimension(500, 100));
}
System.err.println(e.toString());
}
- if (!Platform.isAMac())
+ if (!Platform.isAMacAndNotJS())
{
closeMenuItem.setMnemonic('C');
outputTextboxMenu.setMnemonic('T');
e.printStackTrace();
}
- if (!Platform.isAMac())
+ if (!Platform.isAMacAndNotJS())
{
FileMenu.setMnemonic('F');
inputLocalFileMenuItem.setMnemonic('L');
*/
protected void hideTitleBars()
{
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
// this saves some space - but doesn't hide the title bar
topFrame.putClientProperty("JInternalFrame.isPalette", true);
private FontMetrics fm;
- private final boolean USE_FILL_ROUND_RECT = Platform.isAMac();
+ private final boolean USE_FILL_ROUND_RECT = Platform.isAMacAndNotJS();
boolean av_renderHistogram = true, av_renderProfile = true,
av_normaliseProfile = false;
package jalview.util;
import java.awt.Toolkit;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
+import javax.swing.SwingUtilities;
+
/**
* System platform information used by Applet and Application
*
public class Platform
{
- private static Boolean isAMac = null, isWindows = null;
+ private static Boolean isNoJSMac = null, isNoJSWindows = null;
private static Boolean isHeadless = null;
*
* @return true if we do things in a special way.
*/
- public static boolean isAMac()
+ public static boolean isAMacAndNotJS()
{
- if (isAMac == null)
+ if (isNoJSMac == null)
{
- isAMac = /** @j2sNative false && */
+ isNoJSMac = /** @j2sNative false && */
System.getProperty("os.name").indexOf("Mac") > -1;
}
- return isAMac.booleanValue();
+ return isNoJSMac.booleanValue();
}
*
* @return true if we have to cope with another platform variation
*/
- public static boolean isWindows()
+ public static boolean isWindowsAndNotJS()
{
- if (isWindows == null)
+ if (isNoJSWindows == null)
{
- isWindows = /** @j2sNative false && */
+ isNoJSWindows = /** @j2sNative false && */
System.getProperty("os.name").indexOf("Win") > -1;
}
- return isWindows.booleanValue();
+ return isNoJSWindows.booleanValue();
}
// BH - preferred:
/**
* Answers true if the mouse event has Meta-down (Command key on Mac) or
* Ctrl-down (on other o/s). Note this answers _false_ if the Ctrl key is
- * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-click on Mac,
+ * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-pressed on Mac,
* you can use e.isPopupTrigger().
*
* @param e
*/
public static boolean isControlDown(MouseEvent e)
{
- boolean aMac = isAMac();
+ boolean aMac = isAMacAndNotJS();
return isControlDown(e, aMac);
}
}
return e.isControlDown();
}
+
+ public static boolean isWinRightButton(MouseEvent e)
+ {
+ return !isAMacAndNotJS() && SwingUtilities.isRightMouseButton(e);
+ }
+
+ public static boolean isWinMiddleButton(MouseEvent evt)
+ {
+ return !isAMacAndNotJS() && ((evt.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
+ }
}