Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2015-12-18 06:14:17 +0000
committerAlexander Kurtakov2015-12-18 06:15:35 +0000
commit971702072d3a583643cce28ee4c01191cf2083d3 (patch)
treef441545b676f02f49b2ec0c20d42b28a8e390d42
parentc9754749744dc29a3f39ccdec08730e874ce10e9 (diff)
downloadeclipse.platform.swt-971702072d3a583643cce28ee4c01191cf2083d3.tar.gz
eclipse.platform.swt-971702072d3a583643cce28ee4c01191cf2083d3.tar.xz
eclipse.platform.swt-971702072d3a583643cce28ee4c01191cf2083d3.zip
Bug 484484 - Remove org.eclipse.swt.internal.Compatibility class
Forgotten Mac/Win conversions. Change-Id: I9236b2bf5a516279077da5969e08ce99662f0078 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java53
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java6
6 files changed, 61 insertions, 50 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
index 38ab9594f3..3d12f1b96a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
@@ -10,33 +10,21 @@
*******************************************************************************/
package org.eclipse.swt.awt;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
+/* AWT Imports */
+import java.awt.*;
+import java.awt.Canvas;
+import java.awt.event.*;
+import java.lang.reflect.*;
/* SWT Imports */
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Event;
-/* AWT Imports */
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Canvas;
-import java.awt.Frame;
-import java.awt.Toolkit;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.FocusEvent;
-
/**
* This class provides a bridge between SWT and AWT, so that it
* is possible to embed AWT components in SWT and vice versa.
@@ -218,7 +206,7 @@ public static Frame new_Frame (final Composite parent) {
}
}
if (interrupted) {
- Compatibility.interrupt();
+ Thread.currentThread().interrupt();
}
}
if (exception[0] != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
index 720b89136c..0f47db142a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
@@ -11,7 +11,6 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cocoa.*;
/**
@@ -380,10 +379,10 @@ public FontData[] getFontList (String faceName, boolean scalable) {
int style = SWT.NORMAL;
if ((traits & OS.NSItalicFontMask) != 0) style |= SWT.ITALIC;
if (weight == 9) style |= SWT.BOLD;
- if (faceName == null || Compatibility.equalsIgnoreCase(faceName, name)) {
+ if (faceName == null || faceName.equalsIgnoreCase(name)) {
FontData data = new FontData(name, 0, style);
data.nsName = nsName;
- if (Compatibility.equalsIgnoreCase(systemFontName, name)) {
+ if (systemFontName.equalsIgnoreCase(name)) {
systemFontIncluded = true;
}
if (count == fds.length) {
@@ -397,7 +396,7 @@ public FontData[] getFontList (String faceName, boolean scalable) {
}
}
}
- if (!systemFontIncluded && (faceName == null || Compatibility.equalsIgnoreCase(faceName, systemFontName))) {
+ if (!systemFontIncluded && (faceName == null || faceName.equalsIgnoreCase(systemFontName))) {
/*
* Feature in Mac OS X 10.10: The default system font ".Helvetica Neue DeskInterface"
* is not available from the NSFontManager. The fix is to include it manually if necessary.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index bd4621819d..2e95d5279d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -12,7 +12,6 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -575,7 +574,7 @@ static long /*int*/ createGdipFont(long /*int*/ hDC, long /*int*/ hFont, long /*
index++;
}
String name = new String (chars, 0, index);
- if (Compatibility.equalsIgnoreCase(name, "Courier")) { //$NON-NLS-1$
+ if (name.equalsIgnoreCase("Courier")) { //$NON-NLS-1$
name = "Courier New"; //$NON-NLS-1$
}
char[] buffer = new char[name.length() + 1];
@@ -779,8 +778,8 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int ar
int cteY = 2 * y + height;
int index = 0;
for (int i = 0; i <= arcAngle; i++) {
- points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
- points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
+ points[index++] = (cos(startAngle + i, width) + cteX) >> 1;
+ points[index++] = (cteY - sin(startAngle + i, height)) >> 1;
}
OS.Polyline(handle, points, points.length / 2);
} else {
@@ -799,11 +798,11 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int ar
startAngle = arcAngle;
arcAngle = tmp;
}
- x1 = Compatibility.cos(startAngle, width) + x + width/2;
- y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
+ x1 = cos(startAngle, width) + x + width/2;
+ y1 = -1 * sin(startAngle, height) + y + height/2;
- x2 = Compatibility.cos(arcAngle, width) + x + width/2;
- y2 = -1 * Compatibility.sin(arcAngle, height) + y + height/2;
+ x2 = cos(arcAngle, width) + x + width/2;
+ y2 = -1 * sin(arcAngle, height) + y + height/2;
}
OS.Arc(handle, x, y, x + width + 1, y + height + 1, x1, y1, x2, y2);
}
@@ -2734,8 +2733,8 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int ar
int cteY = 2 * y + height;
int index = (drawSegments ? 2 : 0);
for (int i = 0; i <= arcAngle; i++) {
- points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
- points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
+ points[index++] = (cos(startAngle + i, width) + cteX) >> 1;
+ points[index++] = (cteY - sin(startAngle + i, height)) >> 1;
}
if (drawSegments) {
points[0] = points[points.length - 2] = cteX >> 1;
@@ -2758,11 +2757,11 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int ar
startAngle = arcAngle;
arcAngle = tmp;
}
- x1 = Compatibility.cos(startAngle, width) + x + width/2;
- y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
+ x1 = cos(startAngle, width) + x + width/2;
+ y1 = -1 * sin(startAngle, height) + y + height/2;
- x2 = Compatibility.cos(arcAngle, width) + x + width/2;
- y2 = -1 * Compatibility.sin(arcAngle, height) + y + height/2;
+ x2 = cos(arcAngle, width) + x + width/2;
+ y2 = -1 * sin(arcAngle, height) + y + height/2;
}
OS.Pie(handle, x, y, x + width + 1, y + height + 1, x1, y1, x2, y2);
}
@@ -5109,4 +5108,30 @@ public static GC win32_new(long /*int*/ hDC, GCData data) {
return gc;
}
+/**
+ * Answers the length of the side adjacent to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * cos (angle).
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * cos (angle)
+ */
+private static int cos(int angle, int length) {
+ return (int)(Math.cos(angle * (Math.PI/180)) * length);
+}
+
+/**
+ * Answers the length of the side opposite to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * sin (angle).
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * sin (angle)
+ */
+public static int sin(int angle, int length) {
+ return (int)(Math.sin(angle * (Math.PI/180)) * length);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
index be806db841..2aa3d11fb0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
/**
* <code>TextLayout</code> is a graphic object that represents
@@ -2144,10 +2144,10 @@ int _getOffset(int offset, int movement, boolean forward) {
if (!logAttr.fInvalid && logAttr.fWordStop) return untranslateOffset(offset);
} else {
if (offset > 0) {
- boolean letterOrDigit = Compatibility.isLetterOrDigit(segmentsText.charAt(offset));
- boolean previousLetterOrDigit = Compatibility.isLetterOrDigit(segmentsText.charAt(offset - 1));
+ boolean letterOrDigit = Character.isLetterOrDigit(segmentsText.charAt(offset));
+ boolean previousLetterOrDigit = Character.isLetterOrDigit(segmentsText.charAt(offset - 1));
if (letterOrDigit != previousLetterOrDigit || !letterOrDigit) {
- if (!Compatibility.isWhitespace(segmentsText.charAt(offset))) {
+ if (!Character.isWhitespace(segmentsText.charAt(offset))) {
return untranslateOffset(offset);
}
}
@@ -2157,8 +2157,8 @@ int _getOffset(int offset, int movement, boolean forward) {
}
case SWT.MOVEMENT_WORD_END: {
if (offset > 0) {
- boolean isLetterOrDigit = Compatibility.isLetterOrDigit(segmentsText.charAt(offset));
- boolean previousLetterOrDigit = Compatibility.isLetterOrDigit(segmentsText.charAt(offset - 1));
+ boolean isLetterOrDigit = Character.isLetterOrDigit(segmentsText.charAt(offset));
+ boolean previousLetterOrDigit = Character.isLetterOrDigit(segmentsText.charAt(offset - 1));
if (!isLetterOrDigit && previousLetterOrDigit) {
return untranslateOffset(offset);
}
@@ -2735,7 +2735,7 @@ StyleItem[] merge (long /*int*/ items, int itemCount) {
if (start < itemLimit && 0 < start && start < end) {
char pChar = segmentsText.charAt(start - 1);
char tChar = segmentsText.charAt(start);
- if (Compatibility.isLetter(pChar) && Compatibility.isLetter(tChar)) {
+ if (Character.isLetter(pChar) && Character.isLetter(tChar)) {
item.analysis.fLinkAfter = true;
linkBefore = true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 7e96bab4f3..2b73c84c19 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -16,7 +16,6 @@ import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -2978,7 +2977,7 @@ boolean sendGestureEvent (GESTUREINFO gi) {
* If the current rotation is the same as the last one received don't send the event.
*/
if (display.rotationAngle == rotationInRadians && event.detail == SWT.GESTURE_ROTATE) return true;
- event.rotation = rotationInRadians * 180.0 / Compatibility.PI;
+ event.rotation = rotationInRadians * 180.0 / Math.PI;
display.rotationAngle = rotationInRadians;
break;
default:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index df0259adf1..008e30bf2f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -5103,7 +5103,7 @@ String wrapText (String text, long /*int*/ handle, int width) {
boolean noLf = lineEnd == -1;
if (noLf) lineEnd = length;
int nextStart = lineEnd + Lf.length ();
- while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
+ while (lineEnd > lineStart + 1 && Character.isWhitespace (text.charAt (lineEnd - 1))) {
lineEnd--;
}
int wordStart = lineStart, wordEnd = lineStart;
@@ -5111,13 +5111,13 @@ String wrapText (String text, long /*int*/ handle, int width) {
while (i < lineEnd) {
int lastStart = wordStart, lastEnd = wordEnd;
wordStart = i;
- while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
+ while (i < lineEnd && !Character.isWhitespace (text.charAt (i))) {
i++;
}
wordEnd = i - 1;
String line = text.substring (lineStart, wordEnd + 1);
int lineWidth = textWidth (line, handle);
- while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
+ while (i < lineEnd && Character.isWhitespace (text.charAt (i))) {
i++;
}
if (lineWidth > width) {

Back to the top