Skip to content

Commit

Permalink
Revert "Moves DPIHelper and ViewsHelper to ui.shared, PlatformHelper …
Browse files Browse the repository at this point in the history
…to core."

This reverts commit 89d50e2.
  • Loading branch information
AlexisDrogoul committed Sep 17, 2021
1 parent 5b6d4c6 commit cfccfe7
Show file tree
Hide file tree
Showing 45 changed files with 584 additions and 1,028 deletions.
476 changes: 84 additions & 392 deletions msi.gama.core/src/msi/gama/common/geometry/GeometryUtils.java

Large diffs are not rendered by default.

124 changes: 0 additions & 124 deletions msi.gama.core/src/msi/gama/runtime/PlatformHelper.java

This file was deleted.

Expand Up @@ -15,8 +15,8 @@
import org.eclipse.swt.widgets.Composite;

import ummisco.gama.java2d.swing.SwingControl;
import ummisco.gama.ui.views.WorkaroundForIssue1353;
import ummisco.gama.ui.views.displays.LayeredDisplayView;
import ummisco.gama.ui.views.displays.WorkaroundForIssue1353;

public class AWTDisplayView extends LayeredDisplayView {

Expand Down
Expand Up @@ -71,11 +71,10 @@
import msi.gama.precompiler.GamlAnnotations.doc;
import msi.gama.runtime.GAMA;
import msi.gama.runtime.IScope;
import msi.gama.runtime.PlatformHelper;
import msi.gaml.expressions.IExpression;
import msi.gaml.operators.Cast;
import ummisco.gama.dev.utils.DEBUG;
import ummisco.gama.ui.utils.DPIHelper;
import ummisco.gama.ui.utils.PlatformHelper;
import ummisco.gama.ui.views.displays.DisplaySurfaceMenu;

/**
Expand Down Expand Up @@ -215,8 +214,8 @@ public void dispatchKeyEvent(final char e) {
* @return the int
*/
int autoScaleUp(final int c) {
if (DPIHelper.getDeviceZoom() > 100) return c;
return DPIHelper.autoScaleUp(c);
if (PlatformHelper.getDeviceZoom() > 100) return c;
return PlatformHelper.autoScaleUp(c);
}

@Override
Expand Down Expand Up @@ -851,8 +850,8 @@ public void changed(final Changes property, final Object value) {
@Override
public Font computeFont(final Font f) {
if (f == null) return null;
if (PlatformHelper.isWindows() && DPIHelper.isHiDPI())
return f.deriveFont(DPIHelper.autoScaleUp(f.getSize()));
if (PlatformHelper.isWindows() && PlatformHelper.isHiDPI())
return f.deriveFont(PlatformHelper.autoScaleUp(f.getSize()));
return f;

}
Expand Down
Expand Up @@ -23,7 +23,7 @@ public class WorkaroundForIssue1594 {
public static void installOn(final AWTDisplayView view, final Composite parent, final Composite surfaceComposite,
final Java2DDisplaySurface displaySurface) {
// Install only on Windows
if (!msi.gama.runtime.PlatformHelper.isWindows()) { return; }
if (!ummisco.gama.ui.utils.PlatformHelper.isWindows()) { return; }
final IPartService ps = view.getSite().getService(IPartService.class);
ps.addPartListener(new IPartListener2() {

Expand Down
Expand Up @@ -33,7 +33,7 @@ private static void setMousePosition(final IDisplaySurface surface, final int x,

public static void installOn(final Panel applet, final IDisplaySurface surface) {
// Install only on Linux
if (!msi.gama.runtime.PlatformHelper.isLinux()) return;
if (!ummisco.gama.ui.utils.PlatformHelper.isLinux()) return;
applet.addMouseWheelListener(e -> {
if (e.getPreciseWheelRotation() > 0) {
surface.zoomOut();
Expand Down
Expand Up @@ -15,8 +15,8 @@
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPartReference;

import msi.gama.runtime.PlatformHelper;
import ummisco.gama.dev.utils.DEBUG;
import ummisco.gama.ui.utils.PlatformHelper;
import ummisco.gama.ui.utils.WorkbenchHelper;

public class WorkaroundForIssue2745 {
Expand Down
Expand Up @@ -23,10 +23,10 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;

import msi.gama.runtime.PlatformHelper;
import ummisco.gama.dev.utils.DEBUG;
import ummisco.gama.java2d.Java2DDisplaySurface;
import ummisco.gama.java2d.WorkaroundForIssue2476;
import ummisco.gama.ui.utils.PlatformHelper;
import ummisco.gama.ui.utils.WorkbenchHelper;

public abstract class SwingControl extends Composite {
Expand Down
6 changes: 3 additions & 3 deletions ummisco.gama.opengl/src/ummisco/gama/opengl/OpenGL.java
Expand Up @@ -67,7 +67,7 @@
import ummisco.gama.opengl.scene.mesh.MeshDrawer;
import ummisco.gama.opengl.scene.resources.ResourceDrawer;
import ummisco.gama.opengl.scene.text.TextDrawer;
import ummisco.gama.ui.utils.DPIHelper;
import ummisco.gama.ui.utils.PlatformHelper;

/**
* A class that represents an intermediate state between the rendering and the opengl state. It captures all the
Expand Down Expand Up @@ -270,9 +270,9 @@ private void debugSizes(final int width, final int height, final double initialE
DEBUG.OUT("Ratio width/height in pixels ", 35, envWidth / envHeight);
DEBUG.OUT("Window pixels/env pixels ", 35, width / envWidth + " | " + height / envHeight);
DEBUG.OUT("Current XRatio pixels/env in units ", 35, xRatio + " | " + yRatio);
DEBUG.OUT("Device Zoom = " + DPIHelper.getDeviceZoom());
DEBUG.OUT("Device Zoom = " + PlatformHelper.getDeviceZoom());
DEBUG.OUT("AutoScale down = ", false);
DEBUG.OUT(" " + DPIHelper.autoScaleDown(width) + " " + DPIHelper.autoScaleDown(height));
DEBUG.OUT(" " + PlatformHelper.autoScaleDown(width) + " " + PlatformHelper.autoScaleDown(height));
// DEBUG.OUT("Client area of window:" + getRenderer().getCanvas().getClientArea());
}

Expand Down
Expand Up @@ -25,7 +25,7 @@
import ummisco.gama.opengl.renderer.IOpenGLRenderer;
import ummisco.gama.opengl.renderer.helpers.CameraHelper;
import ummisco.gama.ui.bindings.GamaKeyBindings;
import ummisco.gama.ui.utils.DPIHelper;
import ummisco.gama.ui.utils.PlatformHelper;

public abstract class AbstractCamera implements ICamera {

Expand Down Expand Up @@ -230,8 +230,8 @@ public final void mouseMove(final org.eclipse.swt.events.MouseEvent e) {
}

protected void internalMouseMove(final MouseEvent e) {
mousePosition.x = DPIHelper.autoScaleUp(e.x);
mousePosition.y = DPIHelper.autoScaleUp(e.y);
mousePosition.x = PlatformHelper.autoScaleUp(e.x);
mousePosition.y = PlatformHelper.autoScaleUp(e.y);
setCtrlPressed(GamaKeyBindings.ctrl(e));
setShiftPressed(GamaKeyBindings.shift(e));
}
Expand Down Expand Up @@ -298,8 +298,8 @@ protected GamaPoint getNormalizedCoordinates(final double x, final double y) {
private int clickOnKeystone(final MouseEvent e) {
// int x = e.x;
// int y = e.y;
final int x = DPIHelper.autoScaleUp(e.x);
final int y = DPIHelper.autoScaleUp(e.y);
final int x = PlatformHelper.autoScaleUp(e.x);
final int y = PlatformHelper.autoScaleUp(e.y);
// return the number of the corner clicked. Return -1 if no click on
// keystone.
// final GamaPoint p = getNormalizedCoordinates(e);
Expand All @@ -309,17 +309,17 @@ private int clickOnKeystone(final MouseEvent e) {
protected int hoverOnKeystone(final MouseEvent e) {
// int x = e.x;
// int y = e.y;
final int x = DPIHelper.autoScaleUp(e.x);
final int y = DPIHelper.autoScaleUp(e.y);
final int x = PlatformHelper.autoScaleUp(e.x);
final int y = PlatformHelper.autoScaleUp(e.y);
// return the number of the corner clicked. Return -1 if no click on
// keystone. Return 10 if click on the center.
// final GamaPoint p = getNormalizedCoordinates(e);
return renderer.getKeystoneHelper().cornerHovered(new GamaPoint(x, y));
}

protected void internalMouseDown(final MouseEvent e) {
final int x = DPIHelper.autoScaleUp(e.x);
final int y = DPIHelper.autoScaleUp(e.y);
final int x = PlatformHelper.autoScaleUp(e.x);
final int y = PlatformHelper.autoScaleUp(e.y);
if (firsttimeMouseDown) {
firstMousePressedPosition.setLocation(x, y, 0);
firsttimeMouseDown = false;
Expand Down Expand Up @@ -381,8 +381,8 @@ protected void internalMouseUp(final MouseEvent e) {
}

private void startROI(final org.eclipse.swt.events.MouseEvent e) {
getMousePosition().x = DPIHelper.autoScaleUp(e.x);
getMousePosition().y = DPIHelper.autoScaleUp(e.y);
getMousePosition().x = PlatformHelper.autoScaleUp(e.x);
getMousePosition().y = PlatformHelper.autoScaleUp(e.y);
renderer.getOpenGLHelper().defineROI(new GamaPoint(firstMousePressedPosition), new GamaPoint(mousePosition));
ROICurrentlyDrawn = true;
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
import msi.gaml.operators.Maths;
import ummisco.gama.opengl.renderer.IOpenGLRenderer;
import ummisco.gama.ui.bindings.GamaKeyBindings;
import ummisco.gama.ui.utils.DPIHelper;
import ummisco.gama.ui.utils.PlatformHelper;

public class CameraArcBall extends AbstractCamera {

Expand Down Expand Up @@ -369,8 +369,8 @@ public void internalMouseMove(final org.eclipse.swt.events.MouseEvent e) {
final int selectedCorner = getRenderer().getKeystoneHelper().getCornerSelected();
if (selectedCorner != -1) {
final GamaPoint origin = getNormalizedCoordinates(getMousePosition().x, getMousePosition().y);
x = DPIHelper.autoScaleUp(e.x);
y = DPIHelper.autoScaleUp(e.y);
x = PlatformHelper.autoScaleUp(e.x);
y = PlatformHelper.autoScaleUp(e.y);
GamaPoint p = getNormalizedCoordinates(x, y);
final GamaPoint translation = origin.minus(p).yNegated();
p = getRenderer().getKeystoneHelper().getKeystoneCoordinates(selectedCorner).plus(-translation.x,
Expand All @@ -386,7 +386,7 @@ public void internalMouseMove(final org.eclipse.swt.events.MouseEvent e) {

super.internalMouseMove(e);
if ((e.stateMask & SWT.BUTTON_MASK) == 0) return;
final GamaPoint newPoint = new GamaPoint(DPIHelper.autoScaleUp(x), DPIHelper.autoScaleUp(y));
final GamaPoint newPoint = new GamaPoint(PlatformHelper.autoScaleUp(x), PlatformHelper.autoScaleUp(y));
if (cameraInteraction && GamaKeyBindings.ctrl(e)) {
final int horizMovement = (int) (newPoint.x - lastMousePressedPosition.x);
final int vertMovement = (int) (newPoint.y - lastMousePressedPosition.y);
Expand Down Expand Up @@ -444,8 +444,8 @@ public void internalMouseMove(final org.eclipse.swt.events.MouseEvent e) {
// phi = phi - vertMovement_real * get_sensivity();
updateCartesianCoordinatesFromAngles();
} else if (shiftPressed && isViewInXYPlan()) {
getMousePosition().x = DPIHelper.autoScaleUp(x);
getMousePosition().y = DPIHelper.autoScaleUp(y);
getMousePosition().x = PlatformHelper.autoScaleUp(x);
getMousePosition().y = PlatformHelper.autoScaleUp(y);
getRenderer().getOpenGLHelper().defineROI(
new GamaPoint(firstMousePressedPosition.x, firstMousePressedPosition.y),
new GamaPoint(getMousePosition().x, getMousePosition().y));
Expand All @@ -456,8 +456,8 @@ public void internalMouseMove(final org.eclipse.swt.events.MouseEvent e) {
getRenderer().getOpenGLHelper().getROIEnvelope().translate(p.x, p.y);

} else if (cameraInteraction) {
int horizMovement = (int) (DPIHelper.autoScaleUp(x) - lastMousePressedPosition.x);
int vertMovement = (int) (DPIHelper.autoScaleUp(y) - lastMousePressedPosition.y);
int horizMovement = (int) (PlatformHelper.autoScaleUp(x) - lastMousePressedPosition.x);
int vertMovement = (int) (PlatformHelper.autoScaleUp(y) - lastMousePressedPosition.y);
if (flipped) {
horizMovement = -horizMovement;
vertMovement = -vertMovement;
Expand Down

0 comments on commit cfccfe7

Please sign in to comment.