From 022b11f7ae213b6fe3d237af232d11bfe9f12f05 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 20 Nov 2021 16:25:04 +0100 Subject: [PATCH 1/9] Use HTTPS URLs --- jzy3d-core/data/objfiles/bunny.url | 2 +- jzy3d-core/data/objfiles/dragon.url | 2 +- .../main/java/org/jzy3d/maths/Coord2d.java | 2 +- .../interpolation/algorithms/Spline3D.java | 2 +- .../jzy3d/plot3d/primitives/LineStrip.java | 22 +++++++++---------- .../plot3d/rendering/lights/LightSet.java | 2 +- .../rendering/view/ViewportConfiguration.java | 2 +- .../plot3d/rendering/shaders/Shaderable.java | 2 +- .../java/org/jzy3d/io/xls/ExcelBuilder.java | 4 ++-- jzy3d-jGL/README.md | 12 +++++----- jzy3d-native-jogl-awt/README.md | 2 +- jzy3d-native-jogl-awt/data/objfiles/bunny.url | 2 +- .../data/objfiles/dragon.url | 2 +- .../org/jzy3d/painters/GLES2CompatUtils.java | 4 ++-- .../primitives/vbo/drawable/DrawableVBO2.java | 2 +- .../primitives/vbo/drawable/SphereVBO.java | 4 ++-- jzy3d-native-jogl-javafx/README.md | 2 +- .../mouse/JavaFXCameraThreadController.java | 2 +- jzy3d-native-jogl-newt/README.md | 2 +- jzy3d-native-jogl-swing/README.md | 2 +- jzy3d-native-jogl-swt/README.md | 2 +- .../org/jzy3d/bridge/swt/SWT_AWT_Bridge.java | 2 +- jzy3d-svm-mapper/doc/datasources.txt | 2 +- jzy3d-tools-libsvm/README.md | 2 +- jzy3d-tools-libsvm/doc/datasources.txt | 2 +- jzy3d-tutorials/README.md | 4 ++-- .../jzy3d/demos/volume/LizardVolumeDemo.java | 2 +- pom.xml | 4 ++-- 28 files changed, 48 insertions(+), 48 deletions(-) diff --git a/jzy3d-core/data/objfiles/bunny.url b/jzy3d-core/data/objfiles/bunny.url index 0cb130b06..0e7d7da7a 100644 --- a/jzy3d-core/data/objfiles/bunny.url +++ b/jzy3d-core/data/objfiles/bunny.url @@ -1 +1 @@ -http://download.jzy3d.org/objfiles/bunny.obj \ No newline at end of file +https://download.jzy3d.org/objfiles/bunny.obj \ No newline at end of file diff --git a/jzy3d-core/data/objfiles/dragon.url b/jzy3d-core/data/objfiles/dragon.url index ae285e8b5..f2141e4c3 100644 --- a/jzy3d-core/data/objfiles/dragon.url +++ b/jzy3d-core/data/objfiles/dragon.url @@ -1 +1 @@ -http://download.jzy3d.org/objfiles/dragon.obj \ No newline at end of file +https://download.jzy3d.org/objfiles/dragon.obj \ No newline at end of file diff --git a/jzy3d-core/src/main/java/org/jzy3d/maths/Coord2d.java b/jzy3d-core/src/main/java/org/jzy3d/maths/Coord2d.java index 9343adffb..340014340 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/maths/Coord2d.java +++ b/jzy3d-core/src/main/java/org/jzy3d/maths/Coord2d.java @@ -214,7 +214,7 @@ public Coord2d polar() { /** * Return a real polar value, with an angle in the range [0;2*PI] - * http://fr.wikipedia.org/wiki/Coordonn%C3%A9es_polaires + * https://en.wikipedia.org/wiki/Polar_coordinate_system */ public Coord2d fullPolar() { double radius = Math.sqrt(x * x + y * y); diff --git a/jzy3d-core/src/main/java/org/jzy3d/maths/algorithms/interpolation/algorithms/Spline3D.java b/jzy3d-core/src/main/java/org/jzy3d/maths/algorithms/interpolation/algorithms/Spline3D.java index e2c256ac0..fd1c6d7c3 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/maths/algorithms/interpolation/algorithms/Spline3D.java +++ b/jzy3d-core/src/main/java/org/jzy3d/maths/algorithms/interpolation/algorithms/Spline3D.java @@ -9,7 +9,7 @@ *

* This is a generic 3D B-Spline class for curves of arbitrary length, control handles and patches * are created and joined automatically as described here: - * ibiblio.org/e-notes/ + * ibiblio.org/e-notes/ * Splines/Bint.htm *

* diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/LineStrip.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/LineStrip.java index 9d404074f..3396de847 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/LineStrip.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/LineStrip.java @@ -25,7 +25,7 @@ * * Dotted line are built using * - * http://www.glprogramming.com/red/images/Image35.gif + * https://www.glprogramming.com/red/images/Image35.gif * * @author Martin Pernollet */ @@ -316,7 +316,7 @@ public void setShowSymbols(boolean showSymbols) { /** * Indicates if stippled rendering is enabled for this line. * - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public boolean isStipple() { return stipple; @@ -325,7 +325,7 @@ public boolean isStipple() { /** * Enable or disable stippled rendering. * - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public void setStipple(boolean stipple) { this.stipple = stipple; @@ -334,8 +334,8 @@ public void setStipple(boolean stipple) { /** * Stippled line factor. * - * @see http://www.glprogramming.com/red/images/Image35.gif - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/images/Image35.gif + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public int getStippleFactor() { return stippleFactor; @@ -344,8 +344,8 @@ public int getStippleFactor() { /** * Stippled line factor. * - * @see http://www.glprogramming.com/red/images/Image35.gif - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/images/Image35.gif + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public void setStippleFactor(int stippleFactor) { this.stippleFactor = stippleFactor; @@ -354,8 +354,8 @@ public void setStippleFactor(int stippleFactor) { /** * Stippled line pattern. * - * @see http://www.glprogramming.com/red/images/Image35.gif - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/images/Image35.gif + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public short getStipplePattern() { return stipplePattern; @@ -364,8 +364,8 @@ public short getStipplePattern() { /** * Stippled line pattern. * - * @see http://www.glprogramming.com/red/images/Image35.gif - * @see http://www.glprogramming.com/red/chapter02.html (Stippled line section) + * @see https://www.glprogramming.com/red/images/Image35.gif + * @see https://www.glprogramming.com/red/chapter02.html (Stippled line section) */ public void setStipplePattern(short stipplePattern) { this.stipplePattern = stipplePattern; diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/lights/LightSet.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/lights/LightSet.java index 76019fed6..b9d013504 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/lights/LightSet.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/lights/LightSet.java @@ -34,7 +34,7 @@ public void apply(IPainter painter, Coord3d scale) { } } - // http://www.sjbaker.org/steve/omniv/opengl_lighting.html + // https://www.sjbaker.org/steve/omniv/opengl_lighting.html protected void initLight(IPainter painter) { painter.glEnable_ColorMaterial(); painter.glEnable_Lighting(); diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/ViewportConfiguration.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/ViewportConfiguration.java index bfc0a31d4..6dd28da9a 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/ViewportConfiguration.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/ViewportConfiguration.java @@ -7,7 +7,7 @@ * * It is define by a width and height, and support an X and Y offset * - * @see http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml + * @see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glViewport.xhtml * @author Martin Pernollet */ public class ViewportConfiguration { diff --git a/jzy3d-depthpeeling/src/api/org/jzy3d/plot3d/rendering/shaders/Shaderable.java b/jzy3d-depthpeeling/src/api/org/jzy3d/plot3d/rendering/shaders/Shaderable.java index bf0f8f1f1..cf6ba9f42 100644 --- a/jzy3d-depthpeeling/src/api/org/jzy3d/plot3d/rendering/shaders/Shaderable.java +++ b/jzy3d-depthpeeling/src/api/org/jzy3d/plot3d/rendering/shaders/Shaderable.java @@ -34,7 +34,7 @@ public void dispose(IPainter painter, GL2 gl) { /* PROGRAM */ - // http://www.opengl.org/wiki/GLSL_:_common_mistakes + // https://www.khronos.org/opengl/wiki/GLSL_:_common_mistakes protected void loadProgram(GL2 gl) { program = new GLSLProgram(); program.loadAndCompileVertexShader(gl, shaders.getVertexURL()); diff --git a/jzy3d-io-xls/src/main/java/org/jzy3d/io/xls/ExcelBuilder.java b/jzy3d-io-xls/src/main/java/org/jzy3d/io/xls/ExcelBuilder.java index bc266f15b..027c62150 100644 --- a/jzy3d-io-xls/src/main/java/org/jzy3d/io/xls/ExcelBuilder.java +++ b/jzy3d-io-xls/src/main/java/org/jzy3d/io/xls/ExcelBuilder.java @@ -47,8 +47,8 @@ * * To add new excel features, see * - * @see http://poi.apache.org/spreadsheet/quick-guide.html (or a copy in /doc) - * @see http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/ + * @see https://poi.apache.org/components/spreadsheet/quick-guide.html (or a copy in /doc) + * @see https://svn.apache.org/repos/asf/poi/trunk/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/ */ public class ExcelBuilder implements IExcelBuilder { static Log log = LogFactory.getLog(ExcelBuilder.class); diff --git a/jzy3d-jGL/README.md b/jzy3d-jGL/README.md index 0f1ce0074..5511cdcb7 100644 --- a/jzy3d-jGL/README.md +++ b/jzy3d-jGL/README.md @@ -1,21 +1,21 @@ # jGL -A pure Java implementation of OpenGL, still [online](http://graphics.im.ntu.edu.tw/~robin/jGL/) with [example gallery](http://graphics.im.ntu.edu.tw/~robin/jGL/Example/index.html) and an [LGPL licence](http://www.gnu.org/licenses/lgpl-3.0.html) +A pure Java implementation of OpenGL, still [online](https://www.cmlab.csie.ntu.edu.tw/~robin/jGL/) with [example gallery](https://www.cmlab.csie.ntu.edu.tw/~robin/jGL/Example/index.html) and an [LGPL licence](https://www.gnu.org/licenses/lgpl-3.0.html) # History -[jGL](http://www.cmlab.csie.ntu.edu.tw/~robin/jGL/) was created by Robin Bing-Yu Chen in 1996 and has been maintained up to 2006. +[jGL](https://www.cmlab.csie.ntu.edu.tw/~robin/jGL/) was created by Robin Bing-Yu Chen in 1996 and has been maintained up to 2006. It is a pure java implementation of OpenGL 1, hence performing 3d rendering with CPU instead of GPU. Some papers about jGL published by Robin have been added to the `doc/papers` folder which clarify all his work. -It comes with [lot of OpenGL Red Book examples](http://www.cmlab.csie.ntu.edu.tw/~robin/jGL/Example-app/index.html) proving how well +It comes with [lot of OpenGL Red Book examples](https://www.cmlab.csie.ntu.edu.tw/~robin/jGL/Example-app/index.html) proving how well this OpenGL implementation works. The examples are released as [AWT applications](https://github.com/jzy3d/jGL/tree/master/src/main/java/examples/apps) and [Applets](https://github.com/jzy3d/jGL/tree/master/src/main/java/examples/applets). In 2020, CPU are much more faster than in 2006 and experiments have showned that one can get very decent rendering performance for simple 3D scenes showing surface or scatter point charts. Despite not exhaustive at all, I was able -to have the following performance on a MacBook Pro (Retina 15 pouces, début 2013), 2,7 GHz Intel Core i7, RAM 16 Go 1600 MHz DDR3 +to have the following performance on a MacBook Pro (Retina 15 pouces, début 2013), 2,7 GHz Intel Core i7, RAM 16 Go 1600 MHz DDR3 - A 60x60 polygon 3D surface in a 500x500 pixels frame is rendered in ~30ms. - A 60x60 polygon 3D surface in a 1440x800 pixel frame is rendered in ~45ms - A 50.000 points 3D scatter in a 500x500 pixels frame is rendered in ~10ms. @@ -103,12 +103,12 @@ Maven artifacts are stored there (you should add this to your pom file root): jzy3d-snapshots Jzy3d Snapshots - http://maven.jzy3d.org/snapshots/ + https://maven.jzy3d.org/snapshots/ jzy3d-releases Jzy3d Releases - http://maven.jzy3d.org/releases/ + https://maven.jzy3d.org/releases/ ``` diff --git a/jzy3d-native-jogl-awt/README.md b/jzy3d-native-jogl-awt/README.md index 7d7815d08..1f52fa180 100644 --- a/jzy3d-native-jogl-awt/README.md +++ b/jzy3d-native-jogl-awt/README.md @@ -21,7 +21,7 @@ Build files Library dependencies -------------- -- jogl2 +- jogl2 - jdt (Java Delaunay Triangulation) - opencsv - log4j diff --git a/jzy3d-native-jogl-awt/data/objfiles/bunny.url b/jzy3d-native-jogl-awt/data/objfiles/bunny.url index 0cb130b06..0e7d7da7a 100644 --- a/jzy3d-native-jogl-awt/data/objfiles/bunny.url +++ b/jzy3d-native-jogl-awt/data/objfiles/bunny.url @@ -1 +1 @@ -http://download.jzy3d.org/objfiles/bunny.obj \ No newline at end of file +https://download.jzy3d.org/objfiles/bunny.obj \ No newline at end of file diff --git a/jzy3d-native-jogl-awt/data/objfiles/dragon.url b/jzy3d-native-jogl-awt/data/objfiles/dragon.url index ae285e8b5..f2141e4c3 100644 --- a/jzy3d-native-jogl-awt/data/objfiles/dragon.url +++ b/jzy3d-native-jogl-awt/data/objfiles/dragon.url @@ -1 +1 @@ -http://download.jzy3d.org/objfiles/dragon.obj \ No newline at end of file +https://download.jzy3d.org/objfiles/dragon.obj \ No newline at end of file diff --git a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/painters/GLES2CompatUtils.java b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/painters/GLES2CompatUtils.java index dd11b9b7d..95b0dd254 100644 --- a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/painters/GLES2CompatUtils.java +++ b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/painters/GLES2CompatUtils.java @@ -230,14 +230,14 @@ public static void glPassThrough(float q) { public static void glVertex3d(double d, float f, float g) { throw new UnsupportedOperationException(); // FIXME ANDROID OPEN7 GL ES - // cf http://pandorawiki.org/Porting_to_GLES_from_GL + // cf https://pandorawiki.org/Porting_to_GLES_from_GL } public static void glLineStipple(int i, short s) { throw new UnsupportedOperationException(); // FIXME ANDROID OPEN GL ES // cf - // http://stackoverflow.com/questions/1806028/how-to-draw-a-dotted-line-using-opengl-es-1 + // https://stackoverflow.com/questions/1806028/how-to-draw-a-dotted-line-using-opengl-es-1 } diff --git a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/DrawableVBO2.java b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/DrawableVBO2.java index 865532b22..699dba437 100644 --- a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/DrawableVBO2.java +++ b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/DrawableVBO2.java @@ -693,7 +693,7 @@ public void draw(IPainter painter) { * * @param painter holds a GL instance to invoke the GPU. * - * @see http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/ + * @see https://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/ * @see https://github.com/opengl-tutorials/ogl/blob/master/tutorial09_vbo_indexing/tutorial09.cpp */ protected void doDrawElements(IPainter painter) { diff --git a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/SphereVBO.java b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/SphereVBO.java index a1bc95f6c..36095a399 100644 --- a/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/SphereVBO.java +++ b/jzy3d-native-jogl-core/src/main/java/org/jzy3d/plot3d/primitives/vbo/drawable/SphereVBO.java @@ -24,7 +24,7 @@ * * This is true when Quality.setAlphaActivated(false), in other word for Quality.Advanced. * - * @uthor David Eck inspired this class with http://math.hws.edu/graphicsbook/source/jogl/ColorCubeOfSpheres.java + * @uthor David Eck inspired this class with https://math.hws.edu/graphicsbook/source/jogl/ColorCubeOfSpheres.java * @author Martin Pernollet */ public class SphereVBO extends DrawableVBO { @@ -85,7 +85,7 @@ public void mount(IPainter painter) { // element array buffer is an index: // @see - // http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/ + // https://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/ @Override public void draw(IPainter painter) { if (hasMountedOnce) { diff --git a/jzy3d-native-jogl-javafx/README.md b/jzy3d-native-jogl-javafx/README.md index 7d7815d08..1f52fa180 100644 --- a/jzy3d-native-jogl-javafx/README.md +++ b/jzy3d-native-jogl-javafx/README.md @@ -21,7 +21,7 @@ Build files Library dependencies -------------- -- jogl2 +- jogl2 - jdt (Java Delaunay Triangulation) - opencsv - log4j diff --git a/jzy3d-native-jogl-javafx/src/main/java/org/jzy3d/javafx/controllers/mouse/JavaFXCameraThreadController.java b/jzy3d-native-jogl-javafx/src/main/java/org/jzy3d/javafx/controllers/mouse/JavaFXCameraThreadController.java index 0131838d7..51c7cd29c 100644 --- a/jzy3d-native-jogl-javafx/src/main/java/org/jzy3d/javafx/controllers/mouse/JavaFXCameraThreadController.java +++ b/jzy3d-native-jogl-javafx/src/main/java/org/jzy3d/javafx/controllers/mouse/JavaFXCameraThreadController.java @@ -6,7 +6,7 @@ /** * Trying to get rid of an exception - * http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar + * https://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar * * @author Martin Pernollet * diff --git a/jzy3d-native-jogl-newt/README.md b/jzy3d-native-jogl-newt/README.md index 7d7815d08..1f52fa180 100644 --- a/jzy3d-native-jogl-newt/README.md +++ b/jzy3d-native-jogl-newt/README.md @@ -21,7 +21,7 @@ Build files Library dependencies -------------- -- jogl2 +- jogl2 - jdt (Java Delaunay Triangulation) - opencsv - log4j diff --git a/jzy3d-native-jogl-swing/README.md b/jzy3d-native-jogl-swing/README.md index 7d7815d08..1f52fa180 100644 --- a/jzy3d-native-jogl-swing/README.md +++ b/jzy3d-native-jogl-swing/README.md @@ -21,7 +21,7 @@ Build files Library dependencies -------------- -- jogl2 +- jogl2 - jdt (Java Delaunay Triangulation) - opencsv - log4j diff --git a/jzy3d-native-jogl-swt/README.md b/jzy3d-native-jogl-swt/README.md index 7d7815d08..1f52fa180 100644 --- a/jzy3d-native-jogl-swt/README.md +++ b/jzy3d-native-jogl-swt/README.md @@ -21,7 +21,7 @@ Build files Library dependencies -------------- -- jogl2 +- jogl2 - jdt (Java Delaunay Triangulation) - opencsv - log4j diff --git a/jzy3d-native-jogl-swt/src/main/java/org/jzy3d/bridge/swt/SWT_AWT_Bridge.java b/jzy3d-native-jogl-swt/src/main/java/org/jzy3d/bridge/swt/SWT_AWT_Bridge.java index d260e7ac0..537a67151 100644 --- a/jzy3d-native-jogl-swt/src/main/java/org/jzy3d/bridge/swt/SWT_AWT_Bridge.java +++ b/jzy3d-native-jogl-swt/src/main/java/org/jzy3d/bridge/swt/SWT_AWT_Bridge.java @@ -41,7 +41,7 @@ *
*
* If problems are encountered with the Bridge, it is possible to check:
- * http://wiki.eclipse.org/Albireo_SWT_AWT_bugs
+ * https://wiki.eclipse.org/Albireo_SWT_AWT_bugs
* http://www.eclipsezone.com/eclipse/forums/t45697.html
* * @author Martin Pernollet diff --git a/jzy3d-svm-mapper/doc/datasources.txt b/jzy3d-svm-mapper/doc/datasources.txt index 07e41e063..da1991003 100644 --- a/jzy3d-svm-mapper/doc/datasources.txt +++ b/jzy3d-svm-mapper/doc/datasources.txt @@ -1,2 +1,2 @@ -http://archive.ics.uci.edu/ml/ +https://archive.ics.uci.edu/ml/ kaviar: http://trac.clermont.cemagref.fr/projets/Kaviar/wiki \ No newline at end of file diff --git a/jzy3d-tools-libsvm/README.md b/jzy3d-tools-libsvm/README.md index 62dbbbc85..29c63503c 100644 --- a/jzy3d-tools-libsvm/README.md +++ b/jzy3d-tools-libsvm/README.md @@ -1,7 +1,7 @@ jzy3d-tools-libsvm =================== -A clone of http://www.csie.ntu.edu.tw/~cjlin/libsvm/ +A clone of https://www.csie.ntu.edu.tw/~cjlin/libsvm/ Contains: - few refactors of libsvm to more easily access internal state of the vector machine. diff --git a/jzy3d-tools-libsvm/doc/datasources.txt b/jzy3d-tools-libsvm/doc/datasources.txt index 07e41e063..da1991003 100644 --- a/jzy3d-tools-libsvm/doc/datasources.txt +++ b/jzy3d-tools-libsvm/doc/datasources.txt @@ -1,2 +1,2 @@ -http://archive.ics.uci.edu/ml/ +https://archive.ics.uci.edu/ml/ kaviar: http://trac.clermont.cemagref.fr/projets/Kaviar/wiki \ No newline at end of file diff --git a/jzy3d-tutorials/README.md b/jzy3d-tutorials/README.md index 5c9aaeb04..b329e79e3 100644 --- a/jzy3d-tutorials/README.md +++ b/jzy3d-tutorials/README.md @@ -19,12 +19,12 @@ See [pom.xml](pom.xml) file as an example. jzy3d-snapshots Jzy3d Snapshots - http://maven.jzy3d.org/snapshots/ + https://maven.jzy3d.org/snapshots/ jzy3d-releases Jzy3d Releases - http://maven.jzy3d.org/releases/ + https://maven.jzy3d.org/releases/ ``` diff --git a/jzy3d-tutorials/src/main/java/org/jzy3d/demos/volume/LizardVolumeDemo.java b/jzy3d-tutorials/src/main/java/org/jzy3d/demos/volume/LizardVolumeDemo.java index 498af5993..808e9207e 100644 --- a/jzy3d-tutorials/src/main/java/org/jzy3d/demos/volume/LizardVolumeDemo.java +++ b/jzy3d-tutorials/src/main/java/org/jzy3d/demos/volume/LizardVolumeDemo.java @@ -15,7 +15,7 @@ import com.jogamp.opengl.util.GLBuffers; /** - * Get lizard file from http://download.jzy3d.org/objfiles/lizard.mat + * Get lizard file from https://download.jzy3d.org/objfiles/lizard.mat * * @author Jacok Filik * diff --git a/pom.xml b/pom.xml index cdf2c2b50..c783fde98 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ The (New) BSD License - http://www.opensource.org/licenses/bsd-license.php + https://opensource.org/licenses/bsd-license.php repo @@ -25,7 +25,7 @@ martin.pernollet Martin Pernollet martin@jzy3d.org - http://twitter.com/jzy3d + https://twitter.com/jzy3d nils.hoffmann From 74d95d1ad566d9942129eb5b0bf53edb09da9582 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 20 Nov 2021 17:07:12 +0100 Subject: [PATCH 2/9] Improve jGL README formatting --- jzy3d-jGL/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/jzy3d-jGL/README.md b/jzy3d-jGL/README.md index 5511cdcb7..ce6661799 100644 --- a/jzy3d-jGL/README.md +++ b/jzy3d-jGL/README.md @@ -85,7 +85,7 @@ rendering at all until the Paint event You should add this to your pom file dependencies node, using the latest Jzy3d version: -``` +```xml org.jzy3d jGL @@ -98,7 +98,7 @@ Note that the repository was formerly standalone and versioned following Robin v Maven artifacts are stored there (you should add this to your pom file root): -``` +```xml jzy3d-snapshots @@ -195,18 +195,17 @@ GL.glFlush() # Javadoc and UML documentation -Javadoc with UML generated with [yFiles Doclet tool](https://www.yworks.com/downloads#yDoc). -Configuration file in doc/yfiles.uml.options.jgl.linux -Run ```javadoc @/Users/martin/Dev/jzy3d/public/jGL/doc/uml/yfiles.uml.options.jgl.linux``` +Javadoc with UML generated with [yFiles Doclet tool](https://www.yworks.com/downloads#yDoc). +Configuration file in `doc/yfiles.uml.options.jgl.linux` +Run `javadoc @/Users/martin/Dev/jzy3d/public/jGL/doc/uml/yfiles.uml.options.jgl.linux` # Features -|Name |Tested |Integrated in Jzy3D|Version| ----------------------------------------------------- -|Alpha blending|Yes |Yes |2.5 | +|Name |Tested |Integrated in Jzy3D|Version| +| ------------ | ----- | ----------------- | ----- | +|Alpha blending|Yes |Yes |2.5 | |Text |Yes |Yes |2.5 | -|Lightning |No |No |2.4 | - +|Lightning |No |No |2.4 | From 3815783068d6de583465165f739bbeed8287523b Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Sat, 30 Apr 2022 08:34:07 +0200 Subject: [PATCH 3/9] Fix TestDepthRange performance by creating mocks manually instead of spying every method --- .../org/jzy3d/plot3d/primitives/Geometry.java | 2 +- .../jzy3d/plot3d/primitives/axis/AxisBox.java | 4 +- .../chart/factories/EmulGLChartFactory.java | 26 +++ .../org/jzy3d/painters/EmulGLPainter.java | 4 +- .../jzy3d/emulgl/opengl/TestDepthRange.java | 3 +- .../TestContinuousAndOnDemandRendering.java | 13 +- .../jzy3d/mocks/jgl/GLMock_DepthRange.java | 56 ++++++ .../jzy3d/plot3d/primitives/TestShape.java | 64 +++++++ .../plot3d/primitives/axis/TestAxisBox.java | 59 ++++++ .../src/main/java/jgl/wt/awt/GLCanvas.java | 174 +++++++++--------- 10 files changed, 308 insertions(+), 97 deletions(-) create mode 100644 jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java create mode 100644 jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java create mode 100644 jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/Geometry.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/Geometry.java index 001448b1f..2d8462aa0 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/Geometry.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/Geometry.java @@ -243,7 +243,7 @@ protected void drawFace(IPainter painter) { polygonOffsetFillDisable(painter); // DISABLE OFFSET if (wireframeDisplayed && polygonWireframeDepthTrick) - applyDepthRangeDefault(painter); // DISAABLE RANGE FOR UNDER + applyDepthRangeDefault(painter); // DISABLE RANGE FOR UNDER } } diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/axis/AxisBox.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/axis/AxisBox.java index 0bd2ee475..daf0da994 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/axis/AxisBox.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/primitives/axis/AxisBox.java @@ -115,7 +115,7 @@ public AxisBox(BoundingBox3d bbox, IAxisLayout layout) { } /** - * Draws the AxeBox. The camera is used to determine which axis is closest to the ur point ov + * Draws the AxisBox. The camera is used to determine which axis is closest to the ur point ov * view, in order to decide for an axis on which to diplay the tick values. */ @Override @@ -144,8 +144,6 @@ protected void drawAnnotations(IPainter painter) { /** * reset to identity and apply scaling - * - * @param painter TODO */ public void doTransform(IPainter painter) { painter.glLoadIdentity(); diff --git a/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/chart/factories/EmulGLChartFactory.java b/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/chart/factories/EmulGLChartFactory.java index 297901812..c85163d5f 100644 --- a/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/chart/factories/EmulGLChartFactory.java +++ b/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/chart/factories/EmulGLChartFactory.java @@ -3,11 +3,14 @@ import org.jzy3d.chart.AWTChart; import org.jzy3d.chart.Chart; import org.jzy3d.chart.controllers.thread.camera.CameraThreadControllerWithTime; +import org.jzy3d.painters.EmulGLPainter; +import org.jzy3d.plot3d.rendering.canvas.EmulGLCanvas; import org.jzy3d.plot3d.rendering.canvas.ICanvas; import org.jzy3d.plot3d.rendering.canvas.Quality; import org.jzy3d.plot3d.rendering.scene.Scene; import org.jzy3d.plot3d.rendering.view.AWTView; import org.jzy3d.plot3d.rendering.view.modes.ViewBoundMode; +import jgl.wt.awt.GL; public class EmulGLChartFactory extends ChartFactory { public EmulGLChartFactory() { @@ -38,5 +41,28 @@ public CameraThreadControllerWithTime newCameraThreadController(Chart chart) { CameraThreadControllerWithTime controller = new CameraThreadControllerWithTime(chart, 60); return controller; } + + /** + * This return a factory with a custom GL instance which can be used for manual mocking + * @return + */ + public static EmulGLChartFactory forGL(GL glMock) { + + // Given a surface chart with a mock GL injected for spying calls to glDepthRange + EmulGLPainterFactory painterF = new EmulGLPainterFactory() { + protected EmulGLCanvas newEmulGLCanvas(IChartFactory factory, Scene scene, Quality quality) { + EmulGLCanvas c = new EmulGLCanvas(factory, scene, quality); + c.setGL(glMock); + return c; + } + }; + + EmulGLChartFactory factory = new EmulGLChartFactory(painterF); + Chart chart = factory.newChart(Quality.Advanced()); + EmulGLPainter painter = (EmulGLPainter)chart.getPainter(); + painter.setGL(glMock); // << spy + + return factory; + } } diff --git a/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/painters/EmulGLPainter.java b/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/painters/EmulGLPainter.java index e33a94cb5..7bc6d5dd5 100644 --- a/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/painters/EmulGLPainter.java +++ b/jzy3d-emul-gl-awt/src/main/java/org/jzy3d/painters/EmulGLPainter.java @@ -695,7 +695,9 @@ public int getTextLengthInPixels(Font font, String string) { // Try getting an offscreen image graphics if(g==null) { BufferedImage image = getGL().getRenderedImage(); - g = image.getGraphics(); + if(image!=null) { + g = image.getGraphics(); + } } // Hope to have a graphics and process string width diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/opengl/TestDepthRange.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/opengl/TestDepthRange.java index 15df5feb9..3adb6b14d 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/opengl/TestDepthRange.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/opengl/TestDepthRange.java @@ -4,6 +4,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; +import org.junit.Ignore; import org.junit.Test; import org.jzy3d.chart.Chart; import org.jzy3d.chart.factories.EmulGLChartFactory; @@ -21,10 +22,10 @@ import org.jzy3d.plot3d.rendering.canvas.Quality; /** - * {@AxisBox} and * @author martin * */ +@Ignore("This test is replaced by TestShape and TestAxisBox which handle mocking more efficiently") public class TestDepthRange { @Test public void whenRenderAxis_DepthRangeModifiedByAxis() { diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java index c1959c667..4b5346f4c 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java @@ -1,13 +1,12 @@ package org.jzy3d.emulgl.unit; import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.awt.event.ComponentEvent; +import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.jzy3d.chart.Chart; -import org.jzy3d.chart.controllers.mouse.camera.AWTCameraMouseController; -import org.jzy3d.chart.controllers.thread.camera.CameraThreadController; import org.jzy3d.chart.factories.EmulGLChartFactory; import org.jzy3d.chart.factories.IChartFactory; import org.jzy3d.colors.Color; @@ -32,6 +31,7 @@ * * @author martin */ +@Ignore("Ignore this test since may take 20seconds to execute!") public class TestContinuousAndOnDemandRendering { @Test public void whenComponentResizeWithoutAnimator_thenViewRender() { @@ -60,17 +60,20 @@ public Camera newCamera(Coord3d center) { Quality q = Quality.Nicest(); q.setAlphaActivated(true); + + Assert.assertFalse(q.isAnimated()); + Chart chart = factory.newChart(q); chart.add(surface()); - CameraThreadController rotation = new CameraThreadController(chart); + /*CameraThreadController rotation = new CameraThreadController(chart); rotation.setStep(0.005f); rotation.setUpdateViewDefault(true); AWTCameraMouseController mouse = (AWTCameraMouseController) chart.addMouseCameraController(); mouse.setUpdateViewDefault(true); - mouse.addSlaveThreadController(rotation); + mouse.addSlaveThreadController(rotation);*/ // ----------------------------------- // When Trigger canvas diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java new file mode 100644 index 000000000..a6f528bed --- /dev/null +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java @@ -0,0 +1,56 @@ +package org.jzy3d.mocks.jgl; + +import java.util.ArrayList; +import java.util.List; +import org.jzy3d.chart.Chart; +import org.jzy3d.chart.factories.EmulGLChartFactory; +import org.jzy3d.chart.factories.EmulGLPainterFactory; +import org.jzy3d.chart.factories.IChartFactory; +import org.jzy3d.maths.Array; +import org.jzy3d.painters.EmulGLPainter; +import org.jzy3d.plot3d.rendering.canvas.EmulGLCanvas; +import org.jzy3d.plot3d.rendering.canvas.Quality; +import org.jzy3d.plot3d.rendering.scene.Scene; +import jgl.wt.awt.GL; + +public class GLMock_DepthRange extends GL{ + List verify_glDepthRange = new ArrayList<>(); + + @Override + public void glDepthRange(double near_val, double far_val) { + super.glDepthRange(near_val, far_val); + + double[] args = {near_val, far_val}; + verify_glDepthRange.add(args); + + //Array.print("GLMock_DepthRange : ", args); + } + + public List verify_glDepthRange() { + return verify_glDepthRange; + } + + public void clear_glDepthRange() { + verify_glDepthRange.clear(); + } + + public static EmulGLChartFactory inFactory(GLMock_DepthRange glMock) { + + // Given a surface chart with a mock GL injected for spying calls to glDepthRange + EmulGLPainterFactory painterF = new EmulGLPainterFactory() { + protected EmulGLCanvas newEmulGLCanvas(IChartFactory factory, Scene scene, Quality quality) { + EmulGLCanvas c = new EmulGLCanvas(factory, scene, quality); + c.setGL(glMock); + return c; + } + }; + + EmulGLChartFactory factory = new EmulGLChartFactory(painterF); + Chart chart = factory.newChart(Quality.Advanced()); + EmulGLPainter painter = (EmulGLPainter)chart.getPainter(); + painter.setGL(glMock); // << spy + + return factory; + } + +} diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java new file mode 100644 index 000000000..fdb45e9e5 --- /dev/null +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java @@ -0,0 +1,64 @@ +package org.jzy3d.plot3d.primitives; + +import java.util.Arrays; +import org.junit.Assert; +import org.junit.Test; +import org.jzy3d.chart.Chart; +import org.jzy3d.chart.factories.EmulGLChartFactory; +import org.jzy3d.emulgl.opengl.TestDepthRange; +import org.jzy3d.mocks.jgl.GLMock_DepthRange; +import org.jzy3d.plot3d.rendering.canvas.Quality; + +/** + * This test "manually" mocks the GL.glDepthRange() method since Mockito.spy() on objects that are + * called frequently (e.g. Painter) are awfully slow (most probably because ALL method calls are + * intercepted, including any call to glVertex, glColor etc). + * + * This replace {@link TestDepthRange} which is kept @Ignore for history. + * + * @author Martin Pernollet + */ +public class TestShape { + @Test + public void whenRenderSurface_DepthRangeModifiedBySurface() { + GLMock_DepthRange glMock = new GLMock_DepthRange(); + + // Given a surface chart with a mock GL injected for spying calls to glDepthRange + EmulGLChartFactory factory = EmulGLChartFactory.forGL(glMock); + Chart chart = factory.newChart(Quality.Advanced()); + + Shape surface = SampleGeom.surface(); + chart.add(surface); + + glMock.clear_glDepthRange(); // reset potential previous calls + + + // When : disabling depth range trick + surface.setPolygonWireframeDepthTrick(false); + surface.draw(chart.getPainter()); + + // Then : no call to depth range + Assert.assertTrue(glMock.verify_glDepthRange().isEmpty()); + + + // When : enabling depth range trick + surface.setPolygonWireframeDepthTrick(true); + surface.draw(chart.getPainter()); + + // Then : no call to depth range + double[] configForFace = {Wireframeable.NO_OVERLAP_DEPTH_RATIO, 1}; + double[] configForWireframe = {0, 1 - Wireframeable.NO_OVERLAP_DEPTH_RATIO}; + double[] configForNothing = {0, 1}; + + // Array.print(glMock.verify_glDepthRange().get(0)); + // Array.print(glMock.verify_glDepthRange().get(1)); + // Array.print(glMock.verify_glDepthRange().get(2)); + // Array.print("configForFace:", configForFace); + + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(0), configForFace)); + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(1), configForNothing)); + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(2), configForWireframe)); + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(3), configForNothing)); + } + +} diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java new file mode 100644 index 000000000..6f2804dfc --- /dev/null +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java @@ -0,0 +1,59 @@ +package org.jzy3d.plot3d.primitives.axis; + +import java.util.Arrays; +import org.junit.Assert; +import org.junit.Test; +import org.jzy3d.chart.Chart; +import org.jzy3d.chart.factories.EmulGLChartFactory; +import org.jzy3d.emulgl.opengl.TestDepthRange; +import org.jzy3d.maths.Array; +import org.jzy3d.mocks.jgl.GLMock_DepthRange; +import org.jzy3d.plot3d.primitives.SampleGeom; +import org.jzy3d.plot3d.primitives.Shape; +import org.jzy3d.plot3d.rendering.canvas.Quality; + +/** + * This test "manually" mocks the GL.glDepthRange() method since Mockito.spy() on objects that are + * called frequently (e.g. Painter) are awfully slow (most probably because ALL method calls are + * intercepted, including any call to glVertex, glColor etc). + * + * This replace {@link TestDepthRange} which is kept @Ignore for history. + * + * @author Martin Pernollet + * + */ +public class TestAxisBox { + @Test + public void whenRenderAxis_DepthRangeModifiedByAxis() { + GLMock_DepthRange glMock = new GLMock_DepthRange(); + + // Given a surface chart with a mock GL injected for spying calls to glDepthRange + EmulGLChartFactory factory = EmulGLChartFactory.forGL(glMock); + Chart chart = factory.newChart(Quality.Advanced()); + Shape surface = SampleGeom.surface(); + chart.add(surface); + glMock.clear_glDepthRange(); + + // ---------------------------------------------- + // When : render axis + chart.getView().getAxis().draw(chart.getPainter()); + + // ---------------------------------------------- + // Then axis will update depth range + + // Called that way to push the depth range farther + double[] configForAxis = {AxisBox.NO_OVERLAP_DEPTH_RATIO, 1}; + double[] configForNothing = {0, 1}; + + Array.print(glMock.verify_glDepthRange().get(0)); + Array.print(glMock.verify_glDepthRange().get(1)); + // Array.print(glMock.verify_glDepthRange().get(2)); + // Array.print("configForFace:", configForFace); + + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(0), configForAxis)); + + // Called that way for reset + Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(1), configForNothing)); + + } +} diff --git a/jzy3d-jGL/jzy3d-jGL-awt/src/main/java/jgl/wt/awt/GLCanvas.java b/jzy3d-jGL/jzy3d-jGL-awt/src/main/java/jgl/wt/awt/GLCanvas.java index 102269ede..1a606835f 100644 --- a/jzy3d-jGL/jzy3d-jGL-awt/src/main/java/jgl/wt/awt/GLCanvas.java +++ b/jzy3d-jGL/jzy3d-jGL-awt/src/main/java/jgl/wt/awt/GLCanvas.java @@ -1,13 +1,12 @@ /* - * @(#)GLCanvas.java 0.1 01/04/18 - * jGL 3-D graphics library for Java Copyright (c) 2001 Robin Bing-Yu Chen (robin@csie.ntu.edu.tw) - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or any later version. the GNU Lesser General Public License should be - * included with this distribution in the file LICENSE. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * @(#)GLCanvas.java 0.1 01/04/18 jGL 3-D graphics library for Java Copyright (c) 2001 Robin Bing-Yu + * Chen (robin@csie.ntu.edu.tw) This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 2.1 of the License, or any later version. the GNU Lesser General + * Public License should be included with this distribution in the file LICENSE. This library is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. */ package jgl.wt.awt; @@ -23,86 +22,89 @@ * GLCanvas is the canvas class of jGL 2.4. * * @version 0.1, 18 Apr 2001 - * @author Robin Bing-Yu Chen + * @author Robin Bing-Yu Chen */ public class GLCanvas extends Canvas { - private static final long serialVersionUID = 6622637113292111062L; - protected GL myGL = new GL(); - protected GLU myGLU = new GLU(myGL); - protected GLUT myUT = new GLUT(myGL); - - /** - * This override let {@link GLUT#processEvent(AWTEvent)} be informed of {@link AWTEvent} - * traversing this canvas (mouse, keyboard, resize). - * - * One should register {@link GLUT#glutDisplayFunc(String)} to register a display callback, - * {@link GLUT#glutMotionFunc(String)} to register a mouse motion callback, etc. - * - * NB : This relies on the fact the GLUT already invoked {@link this#glut_enable_events}. - */ - public void processEvent(AWTEvent e) { - - myUT.processEvent(e); - super.processEvent(e); - } - - public void glut_enable_events(long cap, boolean state) { - - if(state) - enableEvents(cap); - else - disableEvents(cap); - } - - public void update(Graphics g) { - - paint(g); - } - - public void paint(Graphics g) { - - myGL.glXSwapBuffers(g, this); - } - - /** Pixel scale is used to model the pixel ratio introduced by HiDPI */ - protected void getPixelScaleFromG2D(Graphics2D g2d) { - - AffineTransform globalTransform = g2d.getTransform(); - myGL.setPixelScaleX(globalTransform.getScaleX()); - myGL.setPixelScaleY(globalTransform.getScaleY()); - } - // ************ RETRIEVE RENDERING CONTEXT ************ // - - public GL getGL() { - - return myGL; - } - - public GLU getGLU() { - - return myGLU; - } - - public GLUT getGLUT() { - - return myUT; - } - // ************ MANUAL REPAINT ************ // - - /** - * Can be used to update image if camera has changed position. - * - * FIXME : Warning if this is invoked by a thread external to AWT, maybe this will require to - * redraw GL while GL is already used by AWT. - */ - public void forceRepaint() { - - // This makes GLUT invoke the myReshape function - processEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED)); - // This triggers copy of newly generated picture to the GLCanvas - repaint(); - } + private static final long serialVersionUID = 6622637113292111062L; + protected GL myGL; + protected GLU myGLU; + protected GLUT myUT; + + public GLCanvas(){ + setGL(new GL()); + } + + /** + * This override let {@link GLUT#processEvent(AWTEvent)} be informed of {@link AWTEvent} + * traversing this canvas (mouse, keyboard, resize). + * + * One should register {@link GLUT#glutDisplayFunc(String)} to register a display callback, + * {@link GLUT#glutMotionFunc(String)} to register a mouse motion callback, etc. + * + * NB : This relies on the fact the GLUT already invoked {@link this#glut_enable_events}. + */ + public void processEvent(AWTEvent e) { + myUT.processEvent(e); + super.processEvent(e); + } + + public void glut_enable_events(long cap, boolean state) { + if (state) + enableEvents(cap); + else + disableEvents(cap); + } + + public void update(Graphics g) { + paint(g); + } + + public void paint(Graphics g) { + myGL.glXSwapBuffers(g, this); + } + + /** Pixel scale is used to model the pixel ratio introduced by HiDPI */ + protected void getPixelScaleFromG2D(Graphics2D g2d) { + AffineTransform globalTransform = g2d.getTransform(); + myGL.setPixelScaleX(globalTransform.getScaleX()); + myGL.setPixelScaleY(globalTransform.getScaleY()); + } + // ************ RETRIEVE RENDERING CONTEXT ************ // + + public GL getGL() { + return myGL; + } + + public GLU getGLU() { + return myGLU; + } + + public GLUT getGLUT() { + return myUT; + } + + public void setGL(GL gl) { + this.myGL = gl; + this.myGLU = new GLU(myGL); + this.myUT = new GLUT(myGL); + } + + // ************ MANUAL REPAINT ************ // + + /** + * Can be used to update image if camera has changed position. + * + * FIXME : Warning if this is invoked by a thread external to AWT, maybe this will require to + * redraw GL while GL is already used by AWT. + */ + public void forceRepaint() { + + // This makes GLUT invoke the myReshape function + processEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED)); + // This triggers copy of newly generated picture to the GLCanvas + repaint(); + } } From 22b75a98008f013d1e8bebb1d7210bb1a21353f8 Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Sat, 30 Apr 2022 08:46:38 +0200 Subject: [PATCH 4/9] Cleanup --- .../jzy3d/mocks/jgl/GLMock_DepthRange.java | 29 ------------------- .../plot3d/primitives/axis/TestAxisBox.java | 5 ++-- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java index a6f528bed..08b376f75 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/GLMock_DepthRange.java @@ -2,15 +2,6 @@ import java.util.ArrayList; import java.util.List; -import org.jzy3d.chart.Chart; -import org.jzy3d.chart.factories.EmulGLChartFactory; -import org.jzy3d.chart.factories.EmulGLPainterFactory; -import org.jzy3d.chart.factories.IChartFactory; -import org.jzy3d.maths.Array; -import org.jzy3d.painters.EmulGLPainter; -import org.jzy3d.plot3d.rendering.canvas.EmulGLCanvas; -import org.jzy3d.plot3d.rendering.canvas.Quality; -import org.jzy3d.plot3d.rendering.scene.Scene; import jgl.wt.awt.GL; public class GLMock_DepthRange extends GL{ @@ -33,24 +24,4 @@ public List verify_glDepthRange() { public void clear_glDepthRange() { verify_glDepthRange.clear(); } - - public static EmulGLChartFactory inFactory(GLMock_DepthRange glMock) { - - // Given a surface chart with a mock GL injected for spying calls to glDepthRange - EmulGLPainterFactory painterF = new EmulGLPainterFactory() { - protected EmulGLCanvas newEmulGLCanvas(IChartFactory factory, Scene scene, Quality quality) { - EmulGLCanvas c = new EmulGLCanvas(factory, scene, quality); - c.setGL(glMock); - return c; - } - }; - - EmulGLChartFactory factory = new EmulGLChartFactory(painterF); - Chart chart = factory.newChart(Quality.Advanced()); - EmulGLPainter painter = (EmulGLPainter)chart.getPainter(); - painter.setGL(glMock); // << spy - - return factory; - } - } diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java index 6f2804dfc..57a62ff20 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/axis/TestAxisBox.java @@ -6,7 +6,6 @@ import org.jzy3d.chart.Chart; import org.jzy3d.chart.factories.EmulGLChartFactory; import org.jzy3d.emulgl.opengl.TestDepthRange; -import org.jzy3d.maths.Array; import org.jzy3d.mocks.jgl.GLMock_DepthRange; import org.jzy3d.plot3d.primitives.SampleGeom; import org.jzy3d.plot3d.primitives.Shape; @@ -45,8 +44,8 @@ public void whenRenderAxis_DepthRangeModifiedByAxis() { double[] configForAxis = {AxisBox.NO_OVERLAP_DEPTH_RATIO, 1}; double[] configForNothing = {0, 1}; - Array.print(glMock.verify_glDepthRange().get(0)); - Array.print(glMock.verify_glDepthRange().get(1)); + // Array.print(glMock.verify_glDepthRange().get(0)); + // Array.print(glMock.verify_glDepthRange().get(1)); // Array.print(glMock.verify_glDepthRange().get(2)); // Array.print("configForFace:", configForFace); From 7b3b8c249f2267d6be4a16426eb58fe547ad2c09 Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Mon, 2 May 2022 11:27:36 +0200 Subject: [PATCH 5/9] Show mockito performance drop --- .../org/jzy3d/mocks/jgl/PerformanceTest.java | 19 +++++++++++++++++++ .../jzy3d/plot3d/primitives/TestShape.java | 1 - 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java new file mode 100644 index 000000000..098aa6e57 --- /dev/null +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java @@ -0,0 +1,19 @@ +package org.jzy3d.mocks.jgl; +import static org.mockito.Mockito.mock; +import java.io.Closeable; +import java.util.concurrent.TimeUnit; +import org.junit.Test; + + +public class PerformanceTest { + + @Test + public void mockedInterface() { + long start = System.nanoTime(); + //mock(Closeable.class); + long end = System.nanoTime(); + + System.out.println("Took " + TimeUnit.NANOSECONDS.toMillis(end - start) + "ms"); + } + +} \ No newline at end of file diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java index fdb45e9e5..48af3b6a4 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/plot3d/primitives/TestShape.java @@ -60,5 +60,4 @@ public void whenRenderSurface_DepthRangeModifiedBySurface() { Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(2), configForWireframe)); Assert.assertTrue(Arrays.equals(glMock.verify_glDepthRange().get(3), configForNothing)); } - } From 538863453b9431e093d57c58cdd55f90b21cbf74 Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Mon, 9 May 2022 12:25:34 +0200 Subject: [PATCH 6/9] update on demand rendering test to be faster --- .../org/jzy3d/mocks/jzy3d/AWTViewMock.java | 63 ++++++++ .../jzy3d/plot3d/rendering/view/Camera.java | 2 +- .../mocks/jzy3d/{Mocks.java => Mockitos.java} | 2 +- .../TestHiDPIProportionalFontSizePolicy.java | 8 +- jzy3d-emul-gl-awt/pom.xml | 7 + .../TestContinuousAndOnDemandRendering.java | 139 +++++------------- .../rendering/view/TestWindowsHiDPI_Hack.java | 4 +- 7 files changed, 112 insertions(+), 113 deletions(-) create mode 100644 jzy3d-core-awt/src/test/java/org/jzy3d/mocks/jzy3d/AWTViewMock.java rename jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/{Mocks.java => Mockitos.java} (99%) diff --git a/jzy3d-core-awt/src/test/java/org/jzy3d/mocks/jzy3d/AWTViewMock.java b/jzy3d-core-awt/src/test/java/org/jzy3d/mocks/jzy3d/AWTViewMock.java new file mode 100644 index 000000000..5553fa1d0 --- /dev/null +++ b/jzy3d-core-awt/src/test/java/org/jzy3d/mocks/jzy3d/AWTViewMock.java @@ -0,0 +1,63 @@ +package org.jzy3d.mocks.jzy3d; + +import org.jzy3d.chart.factories.IChartFactory; +import org.jzy3d.plot3d.rendering.canvas.ICanvas; +import org.jzy3d.plot3d.rendering.canvas.Quality; +import org.jzy3d.plot3d.rendering.scene.Scene; +import org.jzy3d.plot3d.rendering.view.AWTView; + +public class AWTViewMock extends AWTView { + + public AWTViewMock(IChartFactory factory, Scene scene, ICanvas canvas, Quality quality) { + super(factory, scene, canvas, quality); + } + + protected int counter_shoot = 0; + protected int counter_initInstance = 0; + + @Override + public void initInstance(IChartFactory factory, Scene scene, ICanvas canvas, Quality quality) { + super.initInstance(factory, scene, canvas, quality); + + counter_initInstance+=1; + } + + @Override + public void shoot() { + super.shoot(); + + counter_shoot++; + } + + public int getCounter_shoot() { + return counter_shoot; + } + + public void resetCounter_shoot() { + this.counter_shoot = 0; + } + + public int getCounter_initInstance() { + return counter_initInstance; + } + + //public void resetCounter_initInstance() { + // this.counter_initInstance = 0; + // } + + + + /* + * verify(chart.getView(), atLeast(1)).initInstance(factory, chart.getScene(), canvas, + chart.getQuality()); + verify(chart.getView(), atLeast(1)).shoot(); + + // undesired + verify(chart.getView(), atLeast(1)).shoot(); // VIEW IS CALLED 2 OR 3 TIMES !!!!!!!!!!!!!!!!!!!!!! + + // Then camera was called at least once + verify(chart.getView().getCamera(), atLeast(1)).shoot(chart.getPainter(), + chart.getView().getCameraMode()); + * + */ +} diff --git a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/Camera.java b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/Camera.java index 1cac2fec3..87bb7f63c 100644 --- a/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/Camera.java +++ b/jzy3d-core/src/main/java/org/jzy3d/plot3d/rendering/view/Camera.java @@ -523,7 +523,7 @@ public void shoot(IPainter painter, CameraMode projection, boolean doPushMatrixB public void doShoot(IPainter painter, CameraMode projection) { // Set viewport ViewportConfiguration viewport = applyViewport(painter); - + // Set projection if (projection == CameraMode.PERSPECTIVE) { projectionPerspective(painter, viewport); diff --git a/jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mocks.java b/jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mockitos.java similarity index 99% rename from jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mocks.java rename to jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mockitos.java index 9d7694d79..841d1750e 100644 --- a/jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mocks.java +++ b/jzy3d-core/src/test/java/org/jzy3d/mocks/jzy3d/Mockitos.java @@ -13,7 +13,7 @@ import org.jzy3d.plot3d.rendering.canvas.ICanvasListener; import org.jzy3d.plot3d.rendering.view.View; -public class Mocks { +public class Mockitos { public static View ViewAndPainter(float viewScale) { return ViewAndPainter(viewScale, "macos", "10", null, null); } diff --git a/jzy3d-core/src/test/java/org/jzy3d/plot3d/primitives/axis/layout/fonts/TestHiDPIProportionalFontSizePolicy.java b/jzy3d-core/src/test/java/org/jzy3d/plot3d/primitives/axis/layout/fonts/TestHiDPIProportionalFontSizePolicy.java index 03acd43e0..77f6813b4 100644 --- a/jzy3d-core/src/test/java/org/jzy3d/plot3d/primitives/axis/layout/fonts/TestHiDPIProportionalFontSizePolicy.java +++ b/jzy3d-core/src/test/java/org/jzy3d/plot3d/primitives/axis/layout/fonts/TestHiDPIProportionalFontSizePolicy.java @@ -4,7 +4,7 @@ import org.junit.Ignore; import org.junit.Test; import org.jzy3d.maths.Coord2d; -import org.jzy3d.mocks.jzy3d.Mocks; +import org.jzy3d.mocks.jzy3d.Mockitos; import org.jzy3d.painters.Font; import org.jzy3d.plot3d.primitives.axis.layout.AxisLayout; import org.jzy3d.plot3d.rendering.view.View; @@ -22,7 +22,7 @@ public void whenPixelScaleIsTwo_ThenFontIsResizedByAFactorOfTwo() { Coord2d jvmScale = new Coord2d(1,1); Coord2d gpuScale = new Coord2d(1.5,1.5); - View view = Mocks.ViewAndPainter(viewScale, os, version, jvmScale, gpuScale); + View view = Mockitos.ViewAndPainter(viewScale, os, version, jvmScale, gpuScale); /*ICanvas canvas = mock(ICanvas.class); @@ -61,7 +61,7 @@ public void givenWindows_whenPixelScaleIsTwo_ThenFontIsResizedByAFactorOfTwo() { Coord2d jvmScale = new Coord2d(1.5,1.5); Coord2d gpuScale = new Coord2d(1,1); - View view = Mocks.ViewAndPainter(viewScale, os, version, jvmScale, gpuScale); + View view = Mockitos.ViewAndPainter(viewScale, os, version, jvmScale, gpuScale); // Given a layout with a known font height AxisLayout layout = new AxisLayout(); @@ -87,7 +87,7 @@ public void whenPixelScaleIsNan_ThenFontIsNotResized() { float viewScale = Float.NaN; // Given a view with undefined pixel scale - View view = Mocks.ViewAndPainter(viewScale); + View view = Mockitos.ViewAndPainter(viewScale); // Given a layout with a known font height AxisLayout layout = new AxisLayout(); diff --git a/jzy3d-emul-gl-awt/pom.xml b/jzy3d-emul-gl-awt/pom.xml index 022700d8d..ba35ac426 100644 --- a/jzy3d-emul-gl-awt/pom.xml +++ b/jzy3d-emul-gl-awt/pom.xml @@ -22,6 +22,13 @@ jzy3d-core-awt ${project.version} + + + ${project.groupId} + jzy3d-core-awt + ${project.version} + test-jar + ${project.groupId} diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java index 4b5346f4c..58012ddc4 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java @@ -1,147 +1,76 @@ package org.jzy3d.emulgl.unit; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.verify; -import java.awt.event.ComponentEvent; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; +import org.jzy3d.bridge.awt.FrameAWT; import org.jzy3d.chart.Chart; import org.jzy3d.chart.factories.EmulGLChartFactory; -import org.jzy3d.chart.factories.IChartFactory; -import org.jzy3d.colors.Color; -import org.jzy3d.colors.ColorMapper; -import org.jzy3d.colors.colormaps.ColorMapRainbow; import org.jzy3d.maths.Coord3d; -import org.jzy3d.maths.Range; -import org.jzy3d.plot3d.builder.Mapper; -import org.jzy3d.plot3d.builder.SurfaceBuilder; -import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid; -import org.jzy3d.plot3d.primitives.Shape; -import org.jzy3d.plot3d.rendering.canvas.EmulGLCanvas; -import org.jzy3d.plot3d.rendering.canvas.ICanvas; +import org.jzy3d.painters.IPainter; +import org.jzy3d.plot3d.primitives.SampleGeom; import org.jzy3d.plot3d.rendering.canvas.Quality; -import org.jzy3d.plot3d.rendering.scene.Scene; -import org.jzy3d.plot3d.rendering.view.AWTView; import org.jzy3d.plot3d.rendering.view.Camera; -import org.mockito.Mockito; +import org.jzy3d.plot3d.rendering.view.modes.CameraMode; /** * Warning : execution is slow when using mocks * * @author martin */ -@Ignore("Ignore this test since may take 20seconds to execute!") public class TestContinuousAndOnDemandRendering { @Test public void whenComponentResizeWithoutAnimator_thenViewRender() { - // LoggerUtils.minimal(); - - // --------------------- - // JZY3D CONTENT - // EmulGLChartFactory factory = new SpyEmulGLChartFactory(); EmulGLChartFactory factory = new EmulGLChartFactory() { @Override - public AWTView newView(IChartFactory factory, Scene scene, ICanvas canvas, Quality quality) { - AWTView view = Mockito.spy((AWTView) super.newView(factory, scene, canvas, quality)); - view.initInstance(factory, scene, canvas, quality); - return view; - - } - - @Override - public Camera newCamera(Coord3d center) { - Camera camera = Mockito.spy((Camera) super.newCamera(center)); - return camera; + public CameraMock newCamera(Coord3d center) { + return new CameraMock(center); } - }; Quality q = Quality.Nicest(); q.setAlphaActivated(true); - - Assert.assertFalse(q.isAnimated()); - + Chart chart = factory.newChart(q); - chart.add(surface()); - - /*CameraThreadController rotation = new CameraThreadController(chart); - rotation.setStep(0.005f); - rotation.setUpdateViewDefault(true); - - AWTCameraMouseController mouse = (AWTCameraMouseController) chart.addMouseCameraController(); - mouse.setUpdateViewDefault(true); - mouse.addSlaveThreadController(rotation);*/ - - // ----------------------------------- - // When Trigger canvas - EmulGLCanvas canvas = (EmulGLCanvas) chart.getCanvas(); - - /// needed 7-10 sec up to there - - // this does not change anything - ComponentEvent event = new ComponentEvent(canvas, ComponentEvent.COMPONENT_RESIZED); - if (false) { - canvas.processEvent(event); // 2.5s - canvas.processEvent(event); // 2.5s - canvas.doRender(); // 10 - canvas.doRender(); // 10*/ - // canvas.doDisplay(); // 10 - } + chart.add(SampleGeom.surface()); + FrameAWT frame = (FrameAWT) chart.open(); + CameraMock cam = (CameraMock) chart.getView().getCamera(); - // this change test result - if (false) { - chart.getView().shoot(); - chart.getView().shoot(); - } + // Precondition + Assert.assertFalse(q.isAnimated()); - // ----------------------------------- - // Then view was called - verify(chart.getView(), atLeast(1)).initInstance(factory, chart.getScene(), canvas, - chart.getQuality()); - verify(chart.getView(), atLeast(1)).shoot(); + // When Resize + int nShootBeforeResize = cam.counter_doShoot; + frame.setSize(654, 321); + chart.sleep(200); // let time for resize to happen + int nShootAfterResize = cam.counter_doShoot; - // undesired - verify(chart.getView(), atLeast(1)).shoot(); // VIEW IS CALLED 2 OR 3 TIMES !!!!!!!!!!!!!!!!!!!!!! + // Then camera updates + Assert.assertTrue(nShootAfterResize > nShootBeforeResize); + //System.out.println(nShootBeforeResize); + //System.out.println(nShootAfterResize); - // Then camera was called at least once - verify(chart.getView().getCamera(), atLeast(1)).shoot(chart.getPainter(), - chart.getView().getCameraMode()); - /* - * try { chart.screenshot(new - * File("target/whenComponentResizeWithoutAnimator_thenViewRender.png")); } catch (IOException - * e) { e.printStackTrace(); } - */ } - // @Test - public void whenMouseControlWithoutAnimator_thenViewRender() {} + class CameraMock extends Camera { - private static Shape surface() { - Mapper mapper = new Mapper() { - @Override - public double f(double x, double y) { - return x * Math.sin(x * y); - } - }; - Range range = new Range(-3, 3); - int steps = 60; + public CameraMock() { + super(); + } - SurfaceBuilder builder = new SurfaceBuilder(); + public CameraMock(Coord3d target) { + super(target); + } - Shape surface = builder.orthonormal(new OrthonormalGrid(range, steps, range, steps), mapper); - // surface.setPolygonOffsetFillEnable(false); + @Override + public void doShoot(IPainter painter, CameraMode projection) { + super.doShoot(painter, projection); + counter_doShoot++; + } - ColorMapper colorMapper = new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), - surface.getBounds().getZmax(), new Color(1, 1, 1, 0.650f)); - surface.setColorMapper(colorMapper); - surface.setFaceDisplayed(true); - surface.setWireframeDisplayed(true); - surface.setWireframeColor(Color.BLACK); - return surface; + protected int counter_doShoot = 0; } } diff --git a/jzy3d-native-jogl-awt/src/test/java/org/jzy3d/plot3d/rendering/view/TestWindowsHiDPI_Hack.java b/jzy3d-native-jogl-awt/src/test/java/org/jzy3d/plot3d/rendering/view/TestWindowsHiDPI_Hack.java index 17c4ca2d9..4d7fcbaf9 100644 --- a/jzy3d-native-jogl-awt/src/test/java/org/jzy3d/plot3d/rendering/view/TestWindowsHiDPI_Hack.java +++ b/jzy3d-native-jogl-awt/src/test/java/org/jzy3d/plot3d/rendering/view/TestWindowsHiDPI_Hack.java @@ -3,7 +3,7 @@ import org.junit.Assert; import org.junit.Test; import org.jzy3d.maths.Coord2d; -import org.jzy3d.mocks.jzy3d.Mocks; +import org.jzy3d.mocks.jzy3d.Mockitos; import org.jzy3d.os.OperatingSystem; import org.jzy3d.os.WindowingToolkit; import org.jzy3d.painters.NativeDesktopPainter; @@ -149,7 +149,7 @@ public void glViewport(int x, int y, int width, int height) { } }; - painter.setCanvas(Mocks.Canvas(scaleHard, scaleVM)); + painter.setCanvas(Mockitos.Canvas(scaleHard, scaleVM)); return painter; } From 429b9d090ab59f621159f099c2c93eb6c7eea388 Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Mon, 9 May 2022 12:38:54 +0200 Subject: [PATCH 7/9] speed up swing test --- .../jzy3d/chart/TestAddRemoveFromFrame.java | 20 +++++++++++++------ .../chart/TestSwingChartControllers.java | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestAddRemoveFromFrame.java b/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestAddRemoveFromFrame.java index 6ad82cd00..7fc94bcc2 100644 --- a/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestAddRemoveFromFrame.java +++ b/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestAddRemoveFromFrame.java @@ -15,8 +15,8 @@ public class TestAddRemoveFromFrame { Logger logger = Logger.getLogger(TestAddRemoveFromFrame.class.getSimpleName()); - int PAUSE_MS = 500; - int RENDER_LOOP = 300; + int PAUSE_MS = 200; + int RENDER_LOOP = 1; int FRAME_SIZE = 500; public static void main(String[] args) { @@ -106,12 +106,14 @@ public void addRemove_Scenario(ChartFactory factory, Frame frame, String title) // When : removing chart from the application frame frame.remove((java.awt.Component) chart.getCanvas()); - info(title + " : Should disappear. Now waiting " + PAUSE_MS + " ms"); + info(title + " : Should disappear. Now rendering " + RENDER_LOOP + " times"); for (int i = 0; i < RENDER_LOOP; i++) { chart.render(); - // ((GLCanvas)chart.getCanvas()).display(); } + + info(title + " : Should disappear. Now waiting " + PAUSE_MS + " ms"); + chart.sleep(PAUSE_MS); // Then no exception should occur @@ -120,15 +122,21 @@ public void addRemove_Scenario(ChartFactory factory, Frame frame, String title) // When adding the chart again frame.add((java.awt.Component) chart.getCanvas()); - info(title + " : Should re-appear. Now waiting " + PAUSE_MS + " ms"); + info(title + " : Should re-appear. Now rendering " + RENDER_LOOP + " times"); for (int i = 0; i < RENDER_LOOP; i++) { chart.render(); - // ((GLCanvas)chart.getCanvas()).display(); } + + info(title + " : Should re-appear. Now waiting " + PAUSE_MS + " ms"); + chart.sleep(PAUSE_MS); + info(title + " : done"); + chart.dispose(); + + info(title + " : disposed"); } public void info(String info) { diff --git a/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestSwingChartControllers.java b/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestSwingChartControllers.java index fb197bbd9..a4a2b9cf8 100644 --- a/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestSwingChartControllers.java +++ b/jzy3d-native-jogl-swing/src/test/java/org/jzy3d/chart/TestSwingChartControllers.java @@ -28,7 +28,7 @@ public void givenSwingChart_whenAddMouseCameraController_ThenCanvasHasMouseListe Assert.assertEquals(0, canvas.getMouseMotionListeners().length); // When - chart.addMouseCameraController(); + chart.addMouse(); // Then Assert.assertEquals(1, canvas.getMouseListeners().length); @@ -68,7 +68,7 @@ public void givenSwingChart_whenAddKeyboardCameraController_ThenCanvasHasKeyboar Assert.assertEquals(0, canvas.getKeyListeners().length); // When - chart.addKeyboardCameraController(); + chart.addKeyboard(); // Then Assert.assertEquals(1, canvas.getKeyListeners().length); From bfda5fa5ef52321d71f139a33fcb5fa4feaa9234 Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Mon, 9 May 2022 12:50:30 +0200 Subject: [PATCH 8/9] wait a bit more to let repaint occur --- .../jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java index 58012ddc4..caa2ae0ec 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java @@ -43,7 +43,7 @@ public CameraMock newCamera(Coord3d center) { // When Resize int nShootBeforeResize = cam.counter_doShoot; frame.setSize(654, 321); - chart.sleep(200); // let time for resize to happen + chart.sleep(500); // let time for resize to happen int nShootAfterResize = cam.counter_doShoot; // Then camera updates From ba5acefdf2c60dd591cddbaa5f892bb8354205cc Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Mon, 9 May 2022 15:11:25 +0200 Subject: [PATCH 9/9] commenting a test --- .../emulgl/unit/TestContinuousAndOnDemandRendering.java | 8 ++++++-- .../test/java/org/jzy3d/mocks/jgl/PerformanceTest.java | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java index caa2ae0ec..f0fd8ee91 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/emulgl/unit/TestContinuousAndOnDemandRendering.java @@ -1,6 +1,7 @@ package org.jzy3d.emulgl.unit; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.jzy3d.bridge.awt.FrameAWT; import org.jzy3d.chart.Chart; @@ -18,6 +19,7 @@ * @author martin */ public class TestContinuousAndOnDemandRendering { + @Ignore("This test fail if it is ran from CLI with all other tests in the module, but work when ran standalone (even from CLI)") @Test public void whenComponentResizeWithoutAnimator_thenViewRender() { @@ -43,13 +45,15 @@ public CameraMock newCamera(Coord3d center) { // When Resize int nShootBeforeResize = cam.counter_doShoot; frame.setSize(654, 321); + //frame.repaint(); chart.sleep(500); // let time for resize to happen int nShootAfterResize = cam.counter_doShoot; + System.out.println("cam.shoot Before : " + nShootBeforeResize); + System.out.println("cam.shoot After : " + nShootAfterResize); + // Then camera updates Assert.assertTrue(nShootAfterResize > nShootBeforeResize); - //System.out.println(nShootBeforeResize); - //System.out.println(nShootAfterResize); } diff --git a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java index 098aa6e57..568a38ef9 100644 --- a/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java +++ b/jzy3d-emul-gl-awt/src/test/java/org/jzy3d/mocks/jgl/PerformanceTest.java @@ -1,13 +1,12 @@ package org.jzy3d.mocks.jgl; -import static org.mockito.Mockito.mock; -import java.io.Closeable; import java.util.concurrent.TimeUnit; +import org.junit.Ignore; import org.junit.Test; public class PerformanceTest { - - @Test +//("Just to evaluate the cost of mocks") +// @Test public void mockedInterface() { long start = System.nanoTime(); //mock(Closeable.class);