Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hanson1 #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3194aa6
DF (DecimalFormatter) fix
BobHanson Aug 6, 2021
96d1772
adds locationByPlatform
BobHanson Aug 6, 2021
6b4b4eb
SwingJS-site.zip update
BobHanson Aug 6, 2021
652a1af
AsyncSwingWorker not firing cancelAsync() when cancel button is pressed
BobHanson Aug 13, 2021
19442e1
AsyncSwingWorker not firing cancelAsync() when cancel button is pressed
BobHanson Aug 13, 2021
3fa8b35
HTML5 improvements, ProgressBar fixes
BobHanson Aug 13, 2021
c410841
HTML5 improvements, ProgressBar fixes
BobHanson Aug 13, 2021
3352042
fix for obscure issue with Interface
BobHanson Aug 17, 2021
0542e7d
adds showMessageDialog with messageType
BobHanson Aug 26, 2021
49feb38
allow JApplet to be added to a Container
BobHanson Aug 26, 2021
956c84e
fix for JMenu too tall, JSTextField not reporting widths
BobHanson Aug 26, 2021
000a64d
more allowances for messages in JavaScript
BobHanson Aug 26, 2021
7992349
SwingJS-site.zip, tests
BobHanson Aug 26, 2021
0668e32
fix of Font. deriveFont(float)
BobHanson Aug 27, 2021
02d0e72
JComboBox, JLabel, JTextField
BobHanson Aug 27, 2021
d957d19
tests and SwingJS-site.zip
BobHanson Aug 27, 2021
037c649
M4 adds .add(T3)
BobHanson Sep 7, 2021
16a3f6d
fix for Integer.decode("text")
BobHanson Sep 8, 2021
5b69622
AbstractButton.isContentAreaFilled fix
BobHanson Sep 8, 2021
a8406e3
P3 newA(float[3])
BobHanson Sep 8, 2021
9394e5b
SwingJS-site.zip
BobHanson Sep 8, 2021
bb05504
j2sApplet default file save as application/octet-stream, not text/plain
BobHanson Sep 22, 2021
a761be5
j2sApplet default file save as application/octet-stream, not text/plain
BobHanson Sep 22, 2021
9f2f64c
Fixes loss of button action when removed and added to its current menu
BobHanson Sep 23, 2021
682511a
DecimalFormat fix for missing minus sign
BobHanson Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20210728172208
20211009053211
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20210728172208
20211009053211
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.EventListener;
import java.util.Set;

import javax.swing.JApplet;
import javax.swing.JInternalFrame;

import javajs.util.Lst;
Expand Down Expand Up @@ -1087,6 +1088,10 @@ protected void addImplCont(Component comp, Object constraints, int index) {
comp.background = comp.foreground = null; // this parent should not set the background color
}
// SwingJS used for all add methods
// When adding an applet, we should just add its content pane
if (comp instanceof JApplet) {
comp = ((JApplet)comp).getLayeredPane();
}

/*
* Check for correct arguments: index in bounds, comp cannot be one of this
Expand Down
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ public Font deriveFont(float sizePts) {
return f;
}
AttributeValues newValues = getAttributeValues().clone();
newValues.setSize(size);
newValues.setSize(sizePts);
return new Font(newValues, null, -1, createdFont, font2DHandle);
}

Expand Down
170 changes: 85 additions & 85 deletions sources/net.sf.j2s.java.core/src/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void setTrayIconWindow(boolean isTrayIconWindow) {
//
// private static final Logger log = Logger.getLogger("java.awt.Window");

// private static final boolean locationByPlatformProp;
private static final boolean locationByPlatformProp = false;

transient boolean isTrayIconWindow = false;

Expand Down Expand Up @@ -536,7 +536,8 @@ public Window(Window owner) {
public Window(Window owner, GraphicsConfiguration gc) {
super();
秘winOrApplet = true;
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
秘paintClass = 秘updateClass = /** @j2sNative C$ || */
null;
setAppContext();
parent = owner;
if (owner != null)
Expand Down Expand Up @@ -567,16 +568,15 @@ public Window(Window owner, GraphicsConfiguration gc) {

/* offset the initial location with the original of the screen */
/* and any insets */
// SwingJS TODO ??
// Rectangle screenBounds = graphicsConfig.getBounds();
// Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
// int x = getX() + screenBounds.x + screenInsets.left;
// int y = getY() + screenBounds.y + screenInsets.top;
// if (x != this.x || y != this.y) {
// setLocation(x, y);
// /* reset after setLocation */
// // setLocationByPlatform(locationByPlatformProp);
// }
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
int x = getX() + screenBounds.x + screenInsets.left;
int y = getY() + screenBounds.y + screenInsets.top;
if (x != ((Container) this).x || y != ((Container) this).y) {
setLocation(x, y);
/* reset after setLocation */
setLocationByPlatform(locationByPlatformProp);
}

modalExclusionType = ModalExclusionType.NO_EXCLUDE;

Expand Down Expand Up @@ -3159,80 +3159,80 @@ protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
}

// private boolean locationByPlatform = locationByPlatformProp;

// /**
// * Sets whether this Window should appear at the default location for the
// * native windowing system or at the current location (returned by
// * <code>getLocation</code>) the next time the Window is made visible.
// * This behavior resembles a native window shown without programmatically
// * setting its location. Most windowing systems cascade windows if their
// * locations are not explicitly set. The actual location is determined once the
// * window is shown on the screen.
// * <p>
// * This behavior can also be enabled by setting the System Property
// * "java.awt.Window.locationByPlatform" to "true", though calls to this method
// * take precedence.
// * <p>
// * Calls to <code>setVisible</code>, <code>setLocation</code> and
// * <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
// * this property of the Window.
// * <p>
// * For example, after the following code is executed:
// * <pre><blockquote>
// * setLocationByPlatform(true);
// * setVisible(true);
// * boolean flag = isLocationByPlatform();
// * </blockquote></pre>
// * The window will be shown at platform's default location and
// * <code>flag</code> will be <code>false</code>.
// * <p>
// * In the following sample:
// * <pre><blockquote>
// * setLocationByPlatform(true);
// * setLocation(10, 10);
// * boolean flag = isLocationByPlatform();
// * setVisible(true);
// * </blockquote></pre>
// * The window will be shown at (10, 10) and <code>flag</code> will be
// * <code>false</code>.
// *
// * @param locationByPlatform <code>true</code> if this Window should appear
// * at the default location, <code>false</code> if at the current location
// * @throws <code>IllegalComponentStateException</code> if the window
// * is showing on screen and locationByPlatform is <code>true</code>.
// * @see #setLocation
// * @see #isShowing
// * @see #setVisible
// * @see #isLocationByPlatform
// * @see java.lang.System#getProperty(String)
// * @since 1.5
// */
// public void setLocationByPlatform(boolean locationByPlatform) {
private boolean locationByPlatform = locationByPlatformProp;

/**
* Sets whether this Window should appear at the default location for the
* native windowing system or at the current location (returned by
* <code>getLocation</code>) the next time the Window is made visible.
* This behavior resembles a native window shown without programmatically
* setting its location. Most windowing systems cascade windows if their
* locations are not explicitly set. The actual location is determined once the
* window is shown on the screen.
* <p>
* This behavior can also be enabled by setting the System Property
* "java.awt.Window.locationByPlatform" to "true", though calls to this method
* take precedence.
* <p>
* Calls to <code>setVisible</code>, <code>setLocation</code> and
* <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
* this property of the Window.
* <p>
* For example, after the following code is executed:
* <pre><blockquote>
* setLocationByPlatform(true);
* setVisible(true);
* boolean flag = isLocationByPlatform();
* </blockquote></pre>
* The window will be shown at platform's default location and
* <code>flag</code> will be <code>false</code>.
* <p>
* In the following sample:
* <pre><blockquote>
* setLocationByPlatform(true);
* setLocation(10, 10);
* boolean flag = isLocationByPlatform();
* setVisible(true);
* </blockquote></pre>
* The window will be shown at (10, 10) and <code>flag</code> will be
* <code>false</code>.
*
* @param locationByPlatform <code>true</code> if this Window should appear
* at the default location, <code>false</code> if at the current location
* @throws <code>IllegalComponentStateException</code> if the window
* is showing on screen and locationByPlatform is <code>true</code>.
* @see #setLocation
* @see #isShowing
* @see #setVisible
* @see #isLocationByPlatform
* @see java.lang.System#getProperty(String)
* @since 1.5
*/
public void setLocationByPlatform(boolean locationByPlatform) {
synchronized (getTreeLock()) {
if (locationByPlatform && isShowing()) {
throw new IllegalComponentStateException("The window is showing on screen.");
}
this.locationByPlatform = locationByPlatform;
}
}

/**
* Returns <code>true</code> if this Window will appear at the default location
* for the native windowing system the next time this Window is made visible.
* This method always returns <code>false</code> if the Window is showing on the
* screen.
*
* @return whether this Window will appear at the default location
* @see #setLocationByPlatform
* @see #isShowing
* @since 1.5
*/
public boolean isLocationByPlatform() {
// synchronized (getTreeLock()) {
// if (locationByPlatform && isShowing()) {
// throw new IllegalComponentStateException("The window is showing on screen.");
// }
// this.locationByPlatform = locationByPlatform;
// }
// }

// /**
// * Returns <code>true</code> if this Window will appear at the default location
// * for the native windowing system the next time this Window is made visible.
// * This method always returns <code>false</code> if the Window is showing on the
// * screen.
// *
// * @return whether this Window will appear at the default location
// * @see #setLocationByPlatform
// * @see #isShowing
// * @since 1.5
// */
// public boolean isLocationByPlatform() {
// synchronized (getTreeLock()) {
// return locationByPlatform;
// }
// }
return locationByPlatform;
// }
}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ public ColorModel getColorModel() {
* @return the <code>WriteableRaster</code> of this <code>BufferedImage</code> .
*/
public WritableRaster getRaster() {
// ok, but raster.getDataBuffer().getData() is going to require a flush();
return raster;
}

Expand Down
5 changes: 2 additions & 3 deletions sources/net.sf.j2s.java.core/src/javajs/async/Assets.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,11 @@ private static InputStream getAssetStream(String path, boolean zipOnly) {
if (url == null && !zipOnly) {
url = Assets.class.getClassLoader().getResource(path);
}
InputStream is = null;
try {
is = url.openStream();
return (url == null ? null : url.openStream());
} catch (Throwable t) {
}
return is;
return null;
}
/**
* Determine the path to an asset. If not found in a zip file asset, return the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ public void showMessageDialog(Component frame, Object message, ActionListener a)
}

public void showMessageDialog(Component frame, Object message, String title, ActionListener a) {
showMessageDialog(frame, message, title, JOptionPane.INFORMATION_MESSAGE, a);
}

public void showMessageDialog(Component frame, Object message, String title, int messageType, ActionListener a) {
setListener(a);
JOptionPane.showMessageDialog(frame, message, title, JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame, message, title, messageType);
unsetListener();
if (/** @j2sNative false || */true)
process("" + message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,13 @@ public void setNote(String note) {
}

/**
* Cancel the asynchronous process.
* Cancel the asynchronous process. This will fire the PROPERTY_STATE property
* change with value CANCELED_ASYNC
*
*/
public void cancelAsync() {
helper.interrupt();
firePropertyChange(PROPERTY_STATE, null, CANCELED_ASYNC);
}

/**
Expand Down Expand Up @@ -348,7 +350,7 @@ public boolean stateLoop() {
case STATE_LOOP:
if (checkCanceled()) {
helper.setState(STATE_DONE);
firePropertyChange(PROPERTY_STATE, null, CANCELED_ASYNC);
cancelAsync();
} else {
int ret = doInBackgroundAsync(progressAsync);
if (!helper.isAlive() || isPaused) {
Expand Down
38 changes: 18 additions & 20 deletions sources/net.sf.j2s.java.core/src/javajs/util/DF.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public static String formatDecimal(float value, int decimalDigits) {
if (decimalDigits == Integer.MAX_VALUE
|| value == Float.NEGATIVE_INFINITY || value == Float.POSITIVE_INFINITY || Float.isNaN(value))
return "" + value;
boolean isNeg = (value < 0);
if (isNeg)
value = -value;
int n;
if (decimalDigits < 0) {
decimalDigits = -decimalDigits;
Expand All @@ -78,28 +81,27 @@ public static String formatDecimal(float value, int decimalDigits) {
n = 0;
double d;
if (Math.abs(value) < 1) {
n = 10;
d = value * 1e-10;
n = 100;
d = value * 1e-100;
} else {
n = -10;
d = value * 1e10;
n = -100;
d = value * 1e100;
}
String s = ("" + d).toUpperCase();
int i = s.indexOf("E");
n = PT.parseInt(s.substring(i + 1)) + n;
int i1 = s.indexOf("E");
String sf;
if (i < 0) {
if (i1 < 0) {
sf = "" + value;
} else {
float f = PT.parseFloat(s.substring(0, i));
if (f == 10 || f == -10) {
//d = 9.99999997465; n = -6 --> 10.00000E-5
f /= 10;
n += (n < 0 ? 1 : -1);
}
n = PT.parseInt(s.substring(i1 + (s.indexOf("E+") == i1 ? 2 : 1))) + n;
float f = PT.parseFloat(s.substring(0, i1));
sf = formatDecimal(f, decimalDigits - 1);
if (sf.startsWith("10.")) {
sf = formatDecimal(1, decimalDigits - 1);
n++;
}
}
return sf + "E" + (n >= 0 ? "+" : "") + n;
return (isNeg ? "-" : "") + sf + "E" + (n >= 0 ? "+" : "") + n;
}

if (decimalDigits >= formattingStrings.length)
Expand All @@ -108,11 +110,6 @@ public static String formatDecimal(float value, int decimalDigits) {
int pt = s1.indexOf(".");
if (pt < 0) // specifically JavaScript "-2" not "-2.0"
return s1 + formattingStrings[decimalDigits].substring(1);
boolean isNeg = s1.startsWith("-");
if (isNeg) {
s1 = s1.substring(1);
pt--;
}
int pt1 = s1.indexOf("E-");
if (pt1 > 0) {
n = PT.parseInt(s1.substring(pt1 + 1));
Expand Down Expand Up @@ -140,7 +137,8 @@ public static String formatDecimal(float value, int decimalDigits) {
int pt2 = decimalDigits + pt + 1;
if (pt2 < len && s1.charAt(pt2) >= '5') {
return formatDecimal(
value + (isNeg ? -1 : 1) * formatAdds[decimalDigits], decimalDigits);
(isNeg ? -1 : 1) * (value + formatAdds[decimalDigits]),
decimalDigits);
}

String s0 = s1.substring(0, (decimalDigits == 0 ? pt
Expand Down
11 changes: 11 additions & 0 deletions sources/net.sf.j2s.java.core/src/javajs/util/M4.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@ public void sub(M4 m1) {
m32 -= m1.m32;
m33 -= m1.m33;
}

/**
* add to translation
*
* @param pt
*/
public void add(T3 pt) {
m03 += pt.x;
m13 += pt.y;
m23 += pt.z;
}

/**
* Sets the value of this matrix to its transpose.
Expand Down
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/src/javajs/util/P3.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ public static P3 new3(float x, float y, float z) {
p.z = z;
return p;
}

public static P3 newA(float[] a) {
return new3(a[0], a[1], a[2]);
}

}
Loading