Simplify controller to let them target a single chart at a time. Disabled CI

This commit is contained in:
martin 2022-09-15 15:17:49 +02:00
parent fad52d751c
commit 5e805bd021
14 changed files with 52 additions and 73 deletions

View File

@ -16,6 +16,8 @@ jobs:
# Main Build & Test Matrix
macos-10-15-x86_64:
if: ${{ false }} # disable for now
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -120,6 +122,8 @@ jobs:
# ====================================
win10-x86_64:
if: ${{ false }} # disable for now
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -154,6 +158,8 @@ jobs:
# ====================================
ubuntu-20-04-x86_64:
if: ${{ false }} # disable for now
runs-on: ${{ matrix.os }}
strategy:
matrix:

View File

@ -28,9 +28,7 @@ public class AWTCameraKeyController extends AbstractCameraController
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeKeyController(this);
}
getChart().getCanvas().removeKeyController(this);
super.dispose(); // i.e. target=null
}

View File

@ -112,10 +112,8 @@ public class AWTCameraMouseController extends AbstractCameraController
@Override
public void dispose() {
for (Chart chart : targets) {
unregister(chart);
unregister(target);
// chart.getCanvas().removeMouseController(this);
}
super.dispose();
}

View File

@ -6,9 +6,10 @@ import java.util.Vector;
import org.jzy3d.chart.Chart;
import org.jzy3d.events.ControllerEvent;
import org.jzy3d.events.ControllerEventListener;
import org.jzy3d.maths.Lists;
public class AbstractController {
protected List<Chart> targets;
protected Chart target;
protected List<ControllerEventListener> controllerListeners = new ArrayList<ControllerEventListener>(1);
public AbstractController() {}
@ -18,29 +19,24 @@ public class AbstractController {
}
public void register(Chart chart) {
if (targets == null)
targets = new ArrayList<Chart>(1);
targets.add(chart);
target = chart;
}
public void unregister(Chart chart) {
if (targets != null) {
targets.remove(chart);
}
target = null;
}
public Chart getChart() {
if(targets.size()!=0)
return targets.get(0);
return null;
return target;
}
@Deprecated
public List<Chart> getCharts() {
return targets;
return Lists.of(target);
}
public void dispose() {
targets.clear();
unregister(target);
controllerListeners.clear();
}

View File

@ -51,8 +51,7 @@ public abstract class AbstractCameraController extends AbstractController
}
protected void rotate(final Coord2d move, boolean updateView) {
for (Chart c : targets)
c.getView().rotate(move, updateView);
getChart().getView().rotate(move, updateView);
fireControllerEvent(ControllerType.ROTATE, move);
}
@ -61,8 +60,7 @@ public abstract class AbstractCameraController extends AbstractController
}
protected void shift(final float factor, boolean updateView) {
for (Chart c : targets)
c.getView().shift(factor, updateView);
getChart().getView().shift(factor, updateView);
fireControllerEvent(ControllerType.SHIFT, factor);
}
@ -71,8 +69,7 @@ public abstract class AbstractCameraController extends AbstractController
}
protected void zoomX(final float factor, boolean updateView) {
for (Chart c : targets)
c.getView().zoomX(factor, updateView);
getChart().getView().zoomX(factor, updateView);
fireControllerEvent(ControllerType.ZOOM, factor);
}
@ -81,8 +78,7 @@ public abstract class AbstractCameraController extends AbstractController
}
protected void zoomY(final float factor, boolean updateView) {
for (Chart c : targets)
c.getView().zoomY(factor, updateView);
getChart().getView().zoomY(factor, updateView);
fireControllerEvent(ControllerType.ZOOM, factor);
}
@ -91,8 +87,7 @@ public abstract class AbstractCameraController extends AbstractController
}
protected void zoomZ(final float factor, boolean updateView) {
for (Chart c : targets)
c.getView().zoomZ(factor, updateView);
getChart().getView().zoomZ(factor, updateView);
fireControllerEvent(ControllerType.ZOOM, factor);
}

View File

@ -27,9 +27,7 @@ public class AbstractScreenshotKeyController extends AbstractController
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeKeyController(this);
}
getChart().getCanvas().removeKeyController(this);
super.dispose();
}

View File

@ -264,6 +264,9 @@ public abstract class AbstractPainter implements IPainter {
* obtained is the distance of the point from the plane being tested.
* <li>The point is on the plane - The result will, quite obviously, be zero.
* </ul>
*
* A good explanation on vector form of a plane equation :
* @see https://www.youtube.com/watch?v=4GJiz6jxOac&list=PLkZjai-2JcxnYmkg6fpzz4WFumGVl7MOa&index=7
*
* @param eq
* @param value

View File

@ -24,7 +24,6 @@ public class AWTMousePickingController extends AbstractCameraController
protected Coord3d prevMouse3d;
protected PickingSupport picking;
protected Chart chart;
protected Coord2d prevMouse;
protected AbstractCameraThreadController threadController;
@ -53,16 +52,13 @@ public class AWTMousePickingController extends AbstractCameraController
@Override
public void register(Chart chart) {
super.register(chart);
this.chart = chart;
this.prevMouse = Coord2d.ORIGIN;
chart.getCanvas().addMouseController(this);
}
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeMouseController(this);
}
getChart().getCanvas().removeMouseController(this);
if (threadController != null)
threadController.stop();
@ -107,7 +103,7 @@ public class AWTMousePickingController extends AbstractCameraController
float factor = 1 + (e.getWheelRotation() / 10.0f);
zoomX(factor);
zoomY(factor);
chart.getView().shoot();
getChart().getView().shoot();
}
public void mouseMoved(MouseEvent e) {
@ -122,16 +118,16 @@ public class AWTMousePickingController extends AbstractCameraController
}
public void pick(MouseEvent e) {
int yflip = -e.getY() + targets.get(0).getCanvas().getRendererHeight();
int yflip = -e.getY() + getChart().getCanvas().getRendererHeight();
prevMouse.x = e.getX();
prevMouse.y = e.getY();// yflip;
View view = targets.get(0).getView();
View view = getChart().getView();
prevMouse3d = view.projectMouse(e.getX(), yflip);
Graph graph = getChart().getScene().getGraph();
// will trigger vertex selection event to those subscribing to PickingSupport
picking.pickObjects(chart.getView().getPainter(), view, graph,
picking.pickObjects(getChart().getView().getPainter(), view, graph,
new IntegerCoord2d(e.getX(), yflip));
}

View File

@ -30,9 +30,9 @@ public class AWTMousePickingPan2dController extends AWTMousePickingController {
@Override
public void mouseDragged(MouseEvent e) {
int yflip = -e.getY() + targets.get(0).getCanvas().getRendererHeight();
int yflip = -e.getY() + getChart().getCanvas().getRendererHeight();
Coord2d mouse = new Coord2d(e.getX(), yflip);
View view = targets.get(0).getView();
View view = getChart().getView();
Coord3d thisMouse3d = view.projectMouse(e.getX(), yflip);
// 1/2 pan for cleaner rendering
@ -52,7 +52,7 @@ public class AWTMousePickingPan2dController extends AWTMousePickingController {
lastInc = (e.getWheelRotation() / 10.0f);
factor = factor + lastInc;
View view = targets.get(0).getView();
View view = getChart().getView();
mouse3d = view.projectMouse(lastMouseX, lastMouseY);
zoom(1 + lastInc);
@ -62,17 +62,17 @@ public class AWTMousePickingPan2dController extends AWTMousePickingController {
/**********************/
protected void zoom(final float factor) {
Chart chart = targets.get(0);
Chart chart = getChart();
BoundingBox3d viewBounds = chart.getView().getBounds();
BoundingBox3d newBounds = viewBounds.scale(new Coord3d(factor, factor, 1));
chart.getView().setBoundManual(newBounds);
chart.getView().setBoundsManual(newBounds);
chart.getView().shoot();
fireControllerEvent(ControllerType.ZOOM, factor);
}
protected void pan(Coord3d from, Coord3d to) {
Chart chart = targets.get(0);
Chart chart = getChart();
BoundingBox3d viewBounds = chart.getView().getBounds();
Coord3d offset = to.sub(from).div(-PAN_FACTOR);

View File

@ -24,9 +24,7 @@ public class NewtCameraKeyController extends AbstractCameraController
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeKeyController(this);
}
getChart().getCanvas().removeKeyController(this);
super.dispose();
}

View File

@ -31,9 +31,7 @@ public class NewtCameraMouseController extends AbstractCameraController implemen
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeMouseController(this);
}
getChart().getCanvas().removeMouseController(this);
super.dispose();
}

View File

@ -40,16 +40,13 @@ public class NewtMousePickingController extends AbstractCameraController
@Override
public void register(Chart chart) {
super.register(chart);
this.chart = chart;
this.prevMouse = Coord2d.ORIGIN;
chart.getCanvas().addMouseController(this);
}
@Override
public void dispose() {
for (Chart c : targets) {
c.getCanvas().removeMouseController(this);
}
getChart().getCanvas().removeMouseController(this);
if (threadController != null)
threadController.stop();
@ -105,7 +102,7 @@ public class NewtMousePickingController extends AbstractCameraController
float factor = NewtMouseUtilities.convertWheelRotation(e, 1.0f, 10.0f);
zoomX(factor);
zoomY(factor);
chart.getView().shoot();
getChart().getView().shoot();
}
@Override
@ -128,19 +125,19 @@ public class NewtMousePickingController extends AbstractCameraController
}
protected void pick(int x, int y) {
int yflip = -y + targets.get(0).getCanvas().getRendererHeight();
int yflip = -y + getChart().getCanvas().getRendererHeight();
prevMouse.x = x;
prevMouse.y = y;// yflip;
View view = targets.get(0).getView();
View view = getChart().getView();
prevMouse3d = view.projectMouse(x, yflip);
GL gl = ((NativeDesktopPainter) chart.getView().getPainter()).getCurrentGL(chart.getCanvas());
//GL gl = ((NativeDesktopPainter) getChart().getPainter()).getCurrentGL(getChart().getCanvas());
Graph graph = getChart().getScene().getGraph();
// will trigger vertex selection event to those subscribing to
// PickingSupport.
picking.pickObjects(chart.getView().getPainter(), view, graph, new IntegerCoord2d(x, yflip));
picking.pickObjects(getChart().getPainter(), view, graph, new IntegerCoord2d(x, yflip));
}
public boolean handleSlaveThread(MouseEvent e) {
@ -164,8 +161,6 @@ public class NewtMousePickingController extends AbstractCameraController
protected PickingSupport picking;
protected GLU glu = new GLU();
protected Chart chart;
protected Coord2d prevMouse;
protected AbstractCameraThreadController threadController;

View File

@ -32,9 +32,9 @@ public class NewtMousePickingPan2dController extends NewtMousePickingController
*/
@Override
public void mouseDragged(MouseEvent e) {
int yflip = -e.getY() + targets.get(0).getCanvas().getRendererHeight();
int yflip = -e.getY() + getChart().getCanvas().getRendererHeight();
Coord2d mouse = new Coord2d(e.getX(), yflip);
View view = targets.get(0).getView();
View view = getChart().getView();
Coord3d thisMouse3d = view.projectMouse(e.getX(), yflip);
// 1/2 pan for cleaner rendering
@ -55,7 +55,7 @@ public class NewtMousePickingPan2dController extends NewtMousePickingController
lastInc = NewtMouseUtilities.convertWheelRotation(e, 0.0f, 10.0f);
factor = factor + lastInc;
View view = targets.get(0).getView();
View view = getChart().getView();
mouse3d = view.projectMouse(lastMouseX, lastMouseY);
zoom(1 + lastInc);
@ -65,22 +65,22 @@ public class NewtMousePickingPan2dController extends NewtMousePickingController
* *******************
*/
protected void zoom(final float factor) {
Chart chart = targets.get(0);
Chart chart = getChart();
BoundingBox3d viewBounds = chart.getView().getBounds();
BoundingBox3d newBounds = viewBounds.scale(new Coord3d(factor, factor, 1));
chart.getView().setBoundManual(newBounds);
chart.getView().setBoundsManual(newBounds);
chart.getView().shoot();
fireControllerEvent(ControllerType.ZOOM, factor);
}
protected void pan(Coord3d from, Coord3d to) {
Chart chart = targets.get(0);
Chart chart = getChart();
BoundingBox3d viewBounds = chart.getView().getBounds();
Coord3d offset = to.sub(from).div(-PAN_FACTOR);
BoundingBox3d newBounds = viewBounds.shift(offset);
chart.getView().setBoundManual(newBounds);
chart.getView().setBoundsManual(newBounds);
chart.getView().shoot();
fireControllerEvent(ControllerType.PAN, offset);

View File

@ -25,9 +25,7 @@ public class FallbackPainterFactory extends AWTPainterFactory {
return new AWTCameraMouseController(chart) {
@Override
public void register(Chart chart) {
if (targets == null)
targets = new ArrayList<Chart>(1);
targets.add(chart);
super.register(chart);
// TODO : CREATE FallbackCanvas wrapping/extending
// ImagePanel, rather than injecting in FallbackChart