This commit is contained in:
Martin Pernollet 2022-05-24 11:56:06 +02:00
commit ca2cdd2a54
44 changed files with 462 additions and 255 deletions

View File

@ -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());
*
*/
}

View File

@ -1 +1 @@
http://download.jzy3d.org/objfiles/bunny.obj
https://download.jzy3d.org/objfiles/bunny.obj

View File

@ -1 +1 @@
http://download.jzy3d.org/objfiles/dragon.obj
https://download.jzy3d.org/objfiles/dragon.obj

View File

@ -214,7 +214,7 @@ public class Coord2d implements Serializable {
/**
* 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);

View File

@ -9,7 +9,7 @@ import org.jzy3d.maths.Coord3d;
* <p>
* 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:
* <a href="http://www.ibiblio.org/e-notes/Splines/Bint.htm">ibiblio.org/e-notes/
* <a href="https://www.ibiblio.org/e-notes/Splines/Bint.htm">ibiblio.org/e-notes/
* Splines/Bint.htm</a>
* </p>
*

View File

@ -243,7 +243,7 @@ public abstract class Geometry extends Wireframeable implements ISingleColorable
polygonOffsetFillDisable(painter); // DISABLE OFFSET
if (wireframeDisplayed && polygonWireframeDepthTrick)
applyDepthRangeDefault(painter); // DISAABLE RANGE FOR UNDER
applyDepthRangeDefault(painter); // DISABLE RANGE FOR UNDER
}
}

View File

@ -25,7 +25,7 @@ import org.jzy3d.plot3d.transform.space.SpaceTransformer;
*
* 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 class LineStrip extends Wireframeable {
/**
* 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 class LineStrip extends Wireframeable {
/**
* 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 class LineStrip extends Wireframeable {
/**
* 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 class LineStrip extends Wireframeable {
/**
* 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 class LineStrip extends Wireframeable {
/**
* 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 class LineStrip extends Wireframeable {
/**
* 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;

View File

@ -113,7 +113,7 @@ public class AxisBox implements IAxis {
}
/**
* 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
@ -142,8 +142,6 @@ public class AxisBox implements IAxis {
/**
* reset to identity and apply scaling
*
* @param painter TODO
*/
public void doTransform(IPainter painter) {
painter.glLoadIdentity();

View File

@ -34,7 +34,7 @@ public class LightSet {
}
}
// 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();

View File

@ -592,7 +592,7 @@ public class Camera extends AbstractViewportManager {
public void doShoot(IPainter painter, CameraMode projection) {
// Set viewport
ViewportConfiguration viewport = applyViewport(painter);
// Set projection
if (projection == CameraMode.PERSPECTIVE) {
projectionPerspective(painter, viewport);

View File

@ -7,7 +7,7 @@ import org.jzy3d.plot3d.rendering.canvas.ICanvas;
*
* 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 {

View File

@ -15,13 +15,12 @@ import org.jzy3d.plot3d.rendering.canvas.ICanvas;
import org.jzy3d.plot3d.rendering.canvas.ICanvasListener;
import org.jzy3d.plot3d.rendering.view.View;
import org.mockito.Mockito;
import org.smurn.jply.util.Axis;
public class Mocks {
public static AxisLayout AxisLayout() {
return mock(AxisLayout.class);
}
public static AxisBox Axis() {
return mock(AxisBox.class);
}
@ -31,17 +30,17 @@ public class Mocks {
when(axis.getLayout()).thenReturn(layout);
return axis;
}
public static View View2D() {
View view = mock(View.class);
when(view.is2D()).thenReturn(true);
return view;
}
public static View View() {
return Mockito.mock(View.class);
}
public static View View(AxisBox axis, IPainter painter) {
return View(axis, painter, null);
}
@ -55,7 +54,7 @@ public class Mocks {
return view;
}
public static View ViewAndPainter(float viewScale) {
return ViewAndPainter(viewScale, "macos", "10", null, null);
}
@ -68,7 +67,7 @@ public class Mocks {
IPainter painter = Painter(os, version);
ICanvas canvas = mock(ICanvas.class);
if (gpuScale != null)
when(canvas.getPixelScale()).thenReturn(gpuScale);
if (jvmScale != null)
@ -101,7 +100,7 @@ public class Mocks {
when(canvas.isNative()).thenReturn(isNative);
return canvas;
}
public static ICanvas Canvas(Coord2d scaleHard, Coord2d scaleVM) {
return new ICanvas() {
@Override
@ -178,7 +177,7 @@ public class Mocks {
public List<ICanvasListener> getCanvasListeners() {
return null;
}
@Override
public boolean isNative() {
return true;

View File

@ -22,6 +22,13 @@
<artifactId>jzy3d-core-awt</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jzy3d-core-awt</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>

View File

@ -3,11 +3,14 @@ package org.jzy3d.chart.factories;
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 class EmulGLChartFactory extends ChartFactory {
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;
}
}

View File

@ -695,7 +695,9 @@ public class EmulGLPainter extends AbstractPainter implements IPainter {
// 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

View File

@ -4,6 +4,7 @@ import static org.mockito.Mockito.atLeast;
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.primitives.axis.AxisBox;
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() {

View File

@ -1,31 +1,17 @@
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.bridge.awt.FrameAWT;
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;
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
@ -33,112 +19,62 @@ import org.mockito.Mockito;
* @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() {
// 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;
public CameraMock newCamera(Coord3d center) {
return new CameraMock(center);
}
@Override
public Camera newCamera(Coord3d center) {
Camera camera = Mockito.spy((Camera) super.newCamera(center));
return camera;
}
};
Quality q = Quality.Nicest();
q.setAlphaActivated(true);
Chart chart = factory.newChart(q);
chart.add(surface());
chart.add(SampleGeom.surface());
FrameAWT frame = (FrameAWT) chart.open();
CameraMock cam = (CameraMock) chart.getView().getCamera();
CameraThreadController rotation = new CameraThreadController(chart);
rotation.setStep(0.005f);
rotation.setUpdateViewDefault(true);
// Precondition
Assert.assertFalse(q.isAnimated());
AWTCameraMouseController mouse = (AWTCameraMouseController) chart.addMouseCameraController();
mouse.setUpdateViewDefault(true);
mouse.addSlaveThreadController(rotation);
// 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;
// -----------------------------------
// When Trigger canvas
EmulGLCanvas canvas = (EmulGLCanvas) chart.getCanvas();
System.out.println("cam.shoot Before : " + nShootBeforeResize);
System.out.println("cam.shoot After : " + nShootAfterResize);
/// needed 7-10 sec up to there
// Then camera updates
Assert.assertTrue(nShootAfterResize > nShootBeforeResize);
// 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
}
// this change test result
if (false) {
chart.getView().shoot();
chart.getView().shoot();
}
// -----------------------------------
// Then view was called
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());
/*
* 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;
}
}

View File

@ -0,0 +1,27 @@
package org.jzy3d.mocks.jgl;
import java.util.ArrayList;
import java.util.List;
import jgl.wt.awt.GL;
public class GLMock_DepthRange extends GL{
List<double[]> 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<double[]> verify_glDepthRange() {
return verify_glDepthRange;
}
public void clear_glDepthRange() {
verify_glDepthRange.clear();
}
}

View File

@ -0,0 +1,18 @@
package org.jzy3d.mocks.jgl;
import java.util.concurrent.TimeUnit;
import org.junit.Ignore;
import org.junit.Test;
public class PerformanceTest {
//("Just to evaluate the cost of mocks")
// @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");
}
}

View File

@ -0,0 +1,63 @@
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));
}
}

View File

@ -0,0 +1,58 @@
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.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));
}
}

View File

@ -47,8 +47,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
*
* 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);

View File

@ -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.
@ -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
<dependency>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-jGL-awt</artifactId>
@ -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
<repositories>
<repository>
<id>jzy3d-snapshots</id>
@ -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 |

View File

@ -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 @@ import java.awt.geom.AffineTransform;
* 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);
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) {
/**
* 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);
}
myUT.processEvent(e);
super.processEvent(e);
}
public void glut_enable_events(long cap, boolean state) {
if (state)
enableEvents(cap);
else
disableEvents(cap);
}
public void glut_enable_events(long cap, boolean state) {
public void update(Graphics g) {
paint(g);
}
if(state)
enableEvents(cap);
else
disableEvents(cap);
}
public void paint(Graphics g) {
myGL.glXSwapBuffers(g, this);
}
public void update(Graphics g) {
/** 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 ************ //
paint(g);
}
public GL getGL() {
return myGL;
}
public void paint(Graphics g) {
public GLU getGLU() {
return myGLU;
}
myGL.glXSwapBuffers(g, this);
}
public GLUT getGLUT() {
return myUT;
}
/** Pixel scale is used to model the pixel ratio introduced by HiDPI */
protected void getPixelScaleFromG2D(Graphics2D g2d) {
public void setGL(GL gl) {
this.myGL = gl;
this.myGLU = new GLU(myGL);
this.myUT = new GLUT(myGL);
}
AffineTransform globalTransform = g2d.getTransform();
myGL.setPixelScaleX(globalTransform.getScaleX());
myGL.setPixelScaleY(globalTransform.getScaleY());
}
// ************ RETRIEVE RENDERING CONTEXT ************ //
// ************ MANUAL REPAINT ************ //
public GL getGL() {
/**
* 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() {
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();
}
// 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();
}
}

View File

@ -21,7 +21,7 @@ Build files
Library dependencies
--------------
- <a href="http://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-jdt-core">jdt</a> (Java Delaunay Triangulation)
- opencsv
- log4j

View File

@ -1 +1 @@
http://download.jzy3d.org/objfiles/bunny.obj
https://download.jzy3d.org/objfiles/bunny.obj

View File

@ -1 +1 @@
http://download.jzy3d.org/objfiles/dragon.obj
https://download.jzy3d.org/objfiles/dragon.obj

View File

@ -230,14 +230,14 @@ public class GLES2CompatUtils {
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
}

View File

@ -694,7 +694,7 @@ public class DrawableVBO2 extends Wireframeable implements IGLBindedResource {
*
* @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) {

View File

@ -24,7 +24,7 @@ import com.jogamp.opengl.util.GLBuffers;
*
* 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 class SphereVBO extends DrawableVBO {
// 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) {

View File

@ -21,7 +21,7 @@ Build files
Library dependencies
--------------
- <a href="http://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-jdt-core">jdt</a> (Java Delaunay Triangulation)
- opencsv
- log4j

View File

@ -6,7 +6,7 @@ import javafx.application.Platform;
/**
* 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
*

View File

@ -21,7 +21,7 @@ Build files
Library dependencies
--------------
- <a href="http://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-jdt-core">jdt</a> (Java Delaunay Triangulation)
- opencsv
- log4j

View File

@ -21,7 +21,7 @@ Build files
Library dependencies
--------------
- <a href="http://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-jdt-core">jdt</a> (Java Delaunay Triangulation)
- opencsv
- log4j

View File

@ -15,8 +15,8 @@ import org.jzy3d.plot3d.rendering.canvas.Quality;
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 class TestAddRemoveFromFrame {
// 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 class TestAddRemoveFromFrame {
// 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) {

View File

@ -28,7 +28,7 @@ public class TestSwingChartControllers {
Assert.assertEquals(0, canvas.getMouseMotionListeners().length);
// When
chart.addMouseCameraController();
chart.addMouse();
// Then
Assert.assertEquals(1, canvas.getMouseListeners().length);
@ -68,7 +68,7 @@ public class TestSwingChartControllers {
Assert.assertEquals(0, canvas.getKeyListeners().length);
// When
chart.addKeyboardCameraController();
chart.addKeyboard();
// Then
Assert.assertEquals(1, canvas.getKeyListeners().length);

View File

@ -21,7 +21,7 @@ Build files
Library dependencies
--------------
- <a href="http://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://jogamp.org/jogl/www/">jogl2</a>
- <a href="https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-jdt-core">jdt</a> (Java Delaunay Triangulation)
- opencsv
- log4j

View File

@ -41,7 +41,7 @@ import org.eclipse.swt.widgets.Composite;
* </code><br>
* <br>
* If problems are encountered with the Bridge, it is possible to check:<br>
* http://wiki.eclipse.org/Albireo_SWT_AWT_bugs<br>
* https://wiki.eclipse.org/Albireo_SWT_AWT_bugs<br>
* http://www.eclipsezone.com/eclipse/forums/t45697.html<br>
*
* @author Martin Pernollet

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -19,12 +19,12 @@ See [pom.xml](pom.xml) file as an example.
<repository>
<id>jzy3d-snapshots</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/snapshots/</url>
<url>https://maven.jzy3d.org/snapshots/</url>
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Releases</name>
<url>http://maven.jzy3d.org/releases/</url>
<url>https://maven.jzy3d.org/releases/</url>
</repository>
</repositories>
```

View File

@ -16,7 +16,7 @@ import com.jmatio.types.MLNumericArray;
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
*

View File

@ -13,7 +13,7 @@
<licenses>
<license>
<name>The (New) BSD License</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<url>https://opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
@ -23,7 +23,7 @@
<id>martin.pernollet</id>
<name>Martin Pernollet</name>
<email>martin@jzy3d.org</email>
<url>http://twitter.com/jzy3d</url>
<url>https://twitter.com/jzy3d</url>
</developer>
<developer>
<id>nils.hoffmann</id>