Skip to content

Commit

Permalink
Avoids a warning because of the deprecation of JApplet
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Aug 20, 2021
1 parent 906d45a commit 71eabbb
Showing 1 changed file with 7 additions and 12 deletions.
@@ -1,8 +1,8 @@
/*********************************************************************************************
*
* 'WorkaroundForIssue2476.java, in plugin ummisco.gama.java2d, is part of the source code of the GAMA modeling and
* simulation platform. (v. 1.8.1)
*
* simulation platform. (v. 1.8.1)
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
Expand All @@ -11,10 +11,9 @@
**********************************************************************************************/
package ummisco.gama.java2d;

import java.awt.Panel;
import java.awt.event.MouseMotionListener;

import javax.swing.JApplet;

import org.eclipse.swt.SWT;

import msi.gama.common.interfaces.IDisplaySurface;
Expand All @@ -32,9 +31,9 @@ private static void setMousePosition(final IDisplaySurface surface, final int x,
GAMA.getGui().setMouseLocationInModel(surface.getModelCoordinates());
}

public static void installOn(final JApplet applet, final IDisplaySurface surface) {
public static void installOn(final Panel applet, final IDisplaySurface surface) {
// Install only on Linux
if (!ummisco.gama.ui.utils.PlatformHelper.isLinux()) { return; }
if (!ummisco.gama.ui.utils.PlatformHelper.isLinux()) return;
applet.addMouseWheelListener(e -> {
if (e.getPreciseWheelRotation() > 0) {
surface.zoomOut();
Expand Down Expand Up @@ -81,15 +80,11 @@ public void mouseEntered(final java.awt.event.MouseEvent e) {

@Override
public void mouseClicked(final java.awt.event.MouseEvent e) {
if (e.getClickCount() == 2) {
surface.zoomFit();
}
if (e.getClickCount() == 2) { surface.zoomFit(); }
if (e.getButton() == 3 && !inMenu) {
inMenu = surface.canTriggerContextualMenu();
setMousePosition(surface, e.getX(), e.getY());
if (inMenu) {
surface.selectAgentsAroundMouse();
}
if (inMenu) { surface.selectAgentsAroundMouse(); }
surface.dispatchMouseEvent(SWT.MenuDetect);
return;
}
Expand Down

0 comments on commit 71eabbb

Please sign in to comment.