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

Skip to content

omnibus pull from hansonr to java2script main #210

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 17 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@
20220915081800
20230124211103
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 @@
20220915081800
20230124211103
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -4730,9 +4730,9 @@ public synchronized void addMouseListener(MouseListener l) {

// // if this is a lightweight component, enable mouse events
// // in the native container.
// if (peer instanceof LightweightPeer) {
// parent.proxyEnableEvents(AWTEvent.MOUSE_EVENT_MASK);
// }
if (peer instanceof LightweightPeer && parent != null) {
parent.proxyEnableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
}

/**
Expand Down
98 changes: 49 additions & 49 deletions sources/net.sf.j2s.java.core/src/java/awt/Toolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -1493,66 +1493,66 @@ public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
// }
}

// /**
// * Returns the supported cursor dimension which is closest to the desired
// * sizes. Systems which only support a single cursor size will return that
// * size regardless of the desired sizes. Systems which don't support custom
// * cursors will return a dimension of 0, 0. <p>
// * Note: if an image is used whose dimensions don't match a supported size
// * (as returned by this method), the Toolkit implementation will attempt to
// * resize the image to a supported size.
// * Since converting low-resolution images is difficult,
// * no guarantees are made as to the quality of a cursor image which isn't a
// * supported size. It is therefore recommended that this method
// * be called and an appropriate image used so no image conversion is made.
// *
// * @param preferredWidth the preferred cursor width the component would like
// * to use.
// * @param preferredHeight the preferred cursor height the component would like
// * to use.
// * @return the closest matching supported cursor size, or a dimension of 0,0 if
// * the Toolkit implementation doesn't support custom cursors.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see java.awt.GraphicsEnvironment#isHeadless
// * @since 1.2
// */
// public Dimension getBestCursorSize(int preferredWidth,
// int preferredHeight) {
/**
* Returns the supported cursor dimension which is closest to the desired
* sizes. Systems which only support a single cursor size will return that
* size regardless of the desired sizes. Systems which don't support custom
* cursors will return a dimension of 0, 0. <p>
* Note: if an image is used whose dimensions don't match a supported size
* (as returned by this method), the Toolkit implementation will attempt to
* resize the image to a supported size.
* Since converting low-resolution images is difficult,
* no guarantees are made as to the quality of a cursor image which isn't a
* supported size. It is therefore recommended that this method
* be called and an appropriate image used so no image conversion is made.
*
* @param preferredWidth the preferred cursor width the component would like
* to use.
* @param preferredHeight the preferred cursor height the component would like
* to use.
* @return the closest matching supported cursor size, or a dimension of 0,0 if
* the Toolkit implementation doesn't support custom cursors.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.2
*/
public Dimension getBestCursorSize(int preferredWidth,
int preferredHeight) {
// // Override to implement custom cursor support.
// if (this != Toolkit.getDefaultToolkit()) {
// return Toolkit.getDefaultToolkit().
// getBestCursorSize(preferredWidth, preferredHeight);
// } else {
// return new Dimension(0, 0);
return new Dimension(0, 0);
// }
// }
}

// /**
// * Returns the maximum number of colors the Toolkit supports in a custom cursor
// * palette.<p>
// * Note: if an image is used which has more colors in its palette than
// * the supported maximum, the Toolkit implementation will attempt to flatten the
// * palette to the maximum. Since converting low-resolution images is difficult,
// * no guarantees are made as to the quality of a cursor image which has more
// * colors than the system supports. It is therefore recommended that this method
// * be called and an appropriate image used so no image conversion is made.
// *
// * @return the maximum number of colors, or zero if custom cursors are not
// * supported by this Toolkit implementation.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see java.awt.GraphicsEnvironment#isHeadless
// * @since 1.2
// */
// public int getMaximumCursorColors() {
// // Override to implement custom cursor support.
/**
* Returns the maximum number of colors the Toolkit supports in a custom cursor
* palette.<p>
* Note: if an image is used which has more colors in its palette than
* the supported maximum, the Toolkit implementation will attempt to flatten the
* palette to the maximum. Since converting low-resolution images is difficult,
* no guarantees are made as to the quality of a cursor image which has more
* colors than the system supports. It is therefore recommended that this method
* be called and an appropriate image used so no image conversion is made.
*
* @return the maximum number of colors, or zero if custom cursors are not
* supported by this Toolkit implementation.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.2
*/
public int getMaximumCursorColors() {
// Override to implement custom cursor support.
// if (this != Toolkit.getDefaultToolkit()) {
// return Toolkit.getDefaultToolkit().getMaximumCursorColors();
// } else {
// return 0;
return 0;
// }
// }
}

/**
* Returns whether Toolkit supports this state for
Expand Down
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/src/java/io/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ else if ((p = uri.getPath()).equals(""))
this.path = //fs.normalize
(p);
this.prefixLength = fs.prefixLength(this.path);
秘bytes = uri.秘bytes;
return;
}
throw new IllegalArgumentException(err);
Expand Down
19 changes: 9 additions & 10 deletions sources/net.sf.j2s.java.core/src/javajs/img/GifEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@

package javajs.img;

import java.io.IOException;
import java.util.Hashtable;
import java.util.Map;

import javajs.util.CU;
import javajs.util.Lst;
import javajs.util.M3;
import javajs.util.P3;

import java.util.Hashtable;
import java.util.Map;
import java.io.IOException;

/**
*
* GifEncoder extensively adapted for Jmol by Bob Hanson
Expand Down Expand Up @@ -152,11 +152,9 @@ protected void setParams(Map<String, Object> params) {
return;
interlaced = false;
capturing = true;
try {
byteCount = ((Integer) params.get("captureByteCount")).intValue();
} catch (Exception e) {
// ignore
}
Integer c = (Integer) params.get("captureByteCount");
if (c != null)
byteCount = c.intValue();
switch ("maec"
.indexOf(((String) params.get("captureMode")).substring(0, 1))) {
case 0: //"movie"
Expand Down Expand Up @@ -214,6 +212,7 @@ protected void close() {
* a color point in normalized L*a*b space with a flag indicating whether it
* is the background color
*/
@SuppressWarnings("serial")
private class ColorItem extends P3 {
/**
*
Expand Down Expand Up @@ -608,7 +607,7 @@ else if (errp.x == Float.MAX_VALUE) // reuse
// these could be static, but that just makes for more JavaScript code

protected P3 toLABnorm(int rgb) {
P3 lab = CU.colorPtFromInt(rgb, null);
P3 lab = P3.new3((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
rgbToXyz(lab, lab);
xyzToLab(lab, lab);
// normalize to 0-100
Expand Down
6 changes: 6 additions & 0 deletions sources/net.sf.j2s.java.core/src/javajs/util/AU.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@ public static Object doubleLength(Object array) {
return arrayCopyObject(array, (array == null ? 16 : 2 * getLength(array)));
}



public static String[] doubleLengthS(String[] array) {
return arrayCopyS(array, (array == null ? 16 : 2 * array.length));
}

public static double[] doubleLengthD(double[] array) {
return arrayCopyD(array, (array == null ? 16 : 2 * array.length));
}

public static float[] doubleLengthF(float[] array) {
return arrayCopyF(array, (array == null ? 16 : 2 * array.length));
}
Expand Down
66 changes: 33 additions & 33 deletions sources/net.sf.j2s.java.core/src/javajs/util/CU.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ public static int getArgbFromString(String strColor) {
.length() - 1), ",");
if (tokens.length != 3)
return 0;
float red = PT.parseFloat(tokens[0]);
float grn = PT.parseFloat(tokens[1]);
float blu = PT.parseFloat(tokens[2]);
double red = PT.parseDouble(tokens[0]);
double grn = PT.parseDouble(tokens[1]);
double blu = PT.parseDouble(tokens[2]);
return colorTriadToFFRGB(red, grn, blu);
}
switch (len) {
Expand Down Expand Up @@ -429,7 +429,7 @@ public static int getArgbFromString(String strColor) {
return (boxedArgb == null ? 0 : boxedArgb.intValue());
}

public static int colorTriadToFFRGB(float x, float y, float z) {
public static int colorTriadToFFRGB(double x, double y, double z) {
if (x <= 1 && y <= 1 && z <= 1) {
if (x > 0)
x = x * 256 - 1;
Expand All @@ -445,13 +445,13 @@ public static int rgb(int red, int grn, int blu) {
return 0xFF000000 | (red << 16) | (grn << 8) | blu;
}

public final static P3 colorPtFromString(String colorName) {
public final static P3d colorPtFromString(String colorName) {
return colorPtFromInt(getArgbFromString(colorName), null);
}

public final static P3 colorPtFromInt(int color, P3 pt) {
public final static P3d colorPtFromInt(int color, P3d pt) {
if (pt == null)
pt = new P3();
pt = new P3d();
pt.set((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF);
return pt;
}
Expand All @@ -460,7 +460,7 @@ public static int colorPtToFFRGB(T3 pt) {
return colorTriadToFFRGB(pt.x, pt.y, pt.z);
}

public static void toRGB3f(int c, float[] f) {
public static void toRGB3f(int c, double[] f) {
f[0] = ((c >> 16) & 0xFF) / 255f; // red
f[1] = ((c >> 8) & 0xFF) / 255f;
f[2] = (c & 0xFF) / 255f;
Expand Down Expand Up @@ -492,62 +492,62 @@ public static int toFFGGGfromRGB(int rgb) {
* set to false when just using this for
* for RGB -- HSL -- HSL' -- RGB' conversion
*
* @return the HSL as P3 range 360 100 100
* @return the HSL as P3d range 360 100 100
* @author hansonr
*/

public static P3 rgbToHSL(P3 rgb, boolean doRound) {
public static P3d rgbToHSL(P3d rgb, boolean doRound) {
// adapted from http://tips4java.wordpress.com/2009/07/05/hsl-color/
// see http://en.wikipedia.org/wiki/HSL_color_space
float r = rgb.x / 255;
float g = rgb.y / 255;
float b = rgb.z / 255;
float min = Math.min(r, Math.min(g, b));
float max = Math.max(r, Math.max(g, b));
double r = rgb.x / 255;
double g = rgb.y / 255;
double b = rgb.z / 255;
double min = Math.min(r, Math.min(g, b));
double max = Math.max(r, Math.max(g, b));

// lightness is just p * 50

float p = (max + min);
float q = (max - min);
double p = (max + min);
double q = (max - min);

float h = (60 * ((q == 0 ? 0 : max == r ? ((g - b) / q + 6)
double h = (60 * ((q == 0 ? 0 : max == r ? ((g - b) / q + 6)
: max == g ? (b - r) / q + 2 : (r - g) / q + 4))) % 360;

float s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p);
double s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p);

// we round to tenths for HSL so that we can return enough
// precision to get back 1-255 in RGB
return (doRound ? P3.new3(Math.round(h*10)/10f, Math.round(s * 1000)/10f,
Math.round(p * 500)/10f) : P3.new3(h, s * 100, p * 50));
return (doRound ? P3d.new3(Math.round(h*10)/10f, Math.round(s * 1000)/10f,
Math.round(p * 500)/10f) : P3d.new3(h, s * 100, p * 50));
}

/**
* Convert HSL (hue/saturation/luninance) values to RGB
*
* @param hsl in the range 360, 100, 100
* @return the RGB as P3 range 0 to 255
* @return the RGB as P3d range 0 to 255
* @author hansonr
*/
public static P3 hslToRGB(P3 hsl) {
public static P3d hslToRGB(P3d hsl) {
// adapted from http://tips4java.wordpress.com/2009/07/05/hsl-color/
// see http://en.wikipedia.org/wiki/HSL_color_space

// highly condensed

float h = Math.max(0, Math.min(360, hsl.x)) / 60;
float s = Math.max(0, Math.min(100, hsl.y)) / 100;
float l = Math.max(0, Math.min(100, hsl.z)) / 100;
double h = Math.max(0, Math.min(360, hsl.x)) / 60;
double s = Math.max(0, Math.min(100, hsl.y)) / 100;
double l = Math.max(0, Math.min(100, hsl.z)) / 100;

float p = l - (l < 0.5 ? l : 1 - l) * s;
float q = 2 * (l - p);
double p = l - (l < 0.5 ? l : 1 - l) * s;
double q = 2 * (l - p);

float r = toRGB(p, q, h + 2);
float g = toRGB(p, q, h);
float b = toRGB(p, q, h - 2);
return P3.new3(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255));
double r = toRGB(p, q, h + 2);
double g = toRGB(p, q, h);
double b = toRGB(p, q, h - 2);
return P3d.new3(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255));
}

private static float toRGB(float p, float q, float h) {
private static double toRGB(double p, double q, double h) {
return ((h = (h + (h < 0 ? 6 : h > 6 ? -6 : 0))) < 1 ? p + q * h
: h < 3 ? p + q : h < 4 ? p + q * (4 - h) : p);
}
Expand Down
13 changes: 0 additions & 13 deletions sources/net.sf.j2s.java.core/src/javajs/util/M34d.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public void rotate(T3d t) {
rotate2(t, t);
}

public void rotate(T3 t) {
rotate2(t, t);
}

/**
* Transform the vector vec using this Matrix3f and place the result into
* vecOut.
Expand All @@ -125,15 +121,6 @@ public void rotate2(T3d t, T3d result) {
* t.z, m20 * t.x + m21 * t.y + m22 * t.z);
}

public void rotate2(T3 t, T3 result) {
// alias-safe
result.set((float) (m00 * t.x + m01 * t.y + m02 * t.z),
(float) (m10 * t.x + m11 * t.y + m12
* t.z),
(float) (m20 * t.x + m21 * t.y + m22 * t.z));
}


/**
* Sets the value of this matrix to the double value of the Matrix3f argument.
*
Expand Down
Loading