private void removeAddControllers() {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
synchronized (this) {
List<AbstractCameraController> controllerList = getControllers();
for (AbstractCameraController tempController : controllerList) {
removeController(tempController);
}
addController(new CameraKeyController());
addController(new CameraMouseController());
}
}
});
}
'for (AbstractCameraController tempController : controllerList) {'
for (int i = 0; i < controllerList.size(); i++) {
AbstractCameraController tempController = controllerList.get(i);
removeController(tempController);
}
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Jzy3d.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
case SCATER :
//Code to display the current scatter drawable I created
ScatterPickingController<String, String> mouseController = new ScatterPickingController<String, String>(this, 5);
mouseController.getPickingSupport().addObjectPickedListener(new IObjectPickedListener() {
@Override
public void objectPicked(List<? extends Object> vertices, PickingSupport picking) {
if (vertices.size() > 0) {
System.out.println("Vertex : " + vertices.get(0));
}
}
});
for (DrawablePickableCoord3d tempDPC : dpcList) {
mouseController.getPickingSupport().registerDrawableObject(tempDPC, tempDPC);
}
//Other cases, end of switch statement
List<AbstractCameraController> controllerList = getControllers();
AbstractCameraController[] controllerArray = new AbstractCameraController[controllerList.size()];
controllerArray = controllerList.toArray(controllerArray);
for (int i = 0; i < controllerArray.length; i++) {
AbstractCameraController tempController = controllerArray[i];
removeController(tempController);
}
addController(new CameraKeyController());
addController(new CameraMouseController());
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if(threadController!=null)
threadController.stop();
float factor = 1 + (e.getWheelRotation()/10.0f);
zoomZ(factor);
}
List<AbstractCameraController> controllerList = getControllers();
AbstractCameraController[] controllerArray = new AbstractCameraController[controllerList.size()];
controllerArray = controllerList.toArray(controllerArray);
for (int i = 0; i < controllerArray.length; i++) {
AbstractCameraController tempController = controllerArray[i];
removeController(tempController);
}
addController(new CameraKeyController());
addController(new CameraMouseController());/**/
In ScatterPickingController<V, E> extends MousePickingController<V, E> I did what you recommended, except I've changed stopTheadController because it didn't exist :
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if(threadController!=null)
threadController.stop();
float factor = 1 + (e.getWheelRotation()/10.0f);
zoomZ(factor);
}
I've also added super.addController(mouseController); in my extended Chart when there's a scatter loaded and kept this code :
List<AbstractCameraController> controllerList = getControllers();
AbstractCameraController[] controllerArray = new AbstractCameraController[controllerList.size()];
controllerArray = controllerList.toArray(controllerArray);
for (int i = 0; i < controllerArray.length; i++) {
AbstractCameraController tempController = controllerArray[i];
removeController(tempController);
}
addController(new CameraMouseController());/**/
addController(new CameraKeyController());
It works when I display a new Drawable, but if I move the camera then the mousewheel event makes the chart zoom like the picture attached or shifts on the Z axis depending on some unknown factor.
Assuming mouseController is your ScatterPickingController, that should be OK. But then you should not call the constructor referencing Chart, otherwise, the controller will register itself two times (at mousecontroller initialization, and once you call addController).
List<AbstractCameraController> controllerList = getControllers();
AbstractCameraController[] controllerArray = new AbstractCameraController[controllerList.size()];
controllerArray = controllerList.toArray(controllerArray);
for (int i = 0; i < controllerArray.length; i++) {
AbstractCameraController tempController = controllerArray[i];
removeController(tempController);
}I do not understand why you try removing controllers as their should be none, see chart constructor here:
https://github.com/jzy3d/jzy3d-api/blob/master/src/api/org/jzy3d/chart/Chart.java
But clearing an empty list shouldn't cause any problem.
addController(new CameraMouseController());/**/
addController(new CameraKeyController());
It works when I display a new Drawable, but if I move the camera then the mousewheel event makes the chart zoom like the picture attached or shifts on the Z axis depending on some unknown factor.You then have two mouse listeners listening to mouse wheel change: ScatterMousePicking (hopefully registered only one time), and CameraMouseController.That should simply double the Z zoom, but it is still worth trying if the problem still occurs if not adding CameraMouseController and CameraKeyController.
If that does not change anything, can you show your pickable scatter implementation?
--
if (_currentMouseController != null) {
_currentMouseController.dispose();
removeController(_currentMouseController);
_currentMouseController = null;
}
Thank you for the response.
I tried your first suggestion, now each time a point is made a pickable drawable I add its coordinates to its bbox, and when a Pickable scatter is created I add those bbox to the bbox of the scatter, that alone didn't really change the behavior. I've also added this code before loading a new drawable :
if (_currentMouseController != null) {
_currentMouseController.dispose();
removeController(_currentMouseController);
_currentMouseController = null;
}
It seems that .dispose() being before removeController() is important. Before that I got out of range exceptions, now it fixed a lot of problems.
Now there's still one problem remaining : When I load a new drawable in scatter mode, the mouseWheel event works fine and the drawable stretches along the Z axis, but it seems that as soon the Chart got the focus, i.e. after click the chart without dragging the mouse, I got the wrong mousewheel event behavior again. But when i click on a point the drawable stretches itself back correctly the way it is supposed after x mousewheel ticks.
2013/2/28 Tommy D <fido...@gmail.com>Thank you for the response.
I tried your first suggestion, now each time a point is made a pickable drawable I add its coordinates to its bbox, and when a Pickable scatter is created I add those bbox to the bbox of the scatter, that alone didn't really change the behavior. I've also added this code before loading a new drawable :
if (_currentMouseController != null) {
_currentMouseController.dispose();
removeController(_currentMouseController);
_currentMouseController = null;
}What is the goal of that piece of code?
It seems that .dispose() being before removeController() is important. Before that I got out of range exceptions, now it fixed a lot of problems.
Now there's still one problem remaining : When I load a new drawable in scatter mode, the mouseWheel event works fine and the drawable stretches along the Z axis, but it seems that as soon the Chart got the focus, i.e. after click the chart without dragging the mouse, I got the wrong mousewheel event behavior again. But when i click on a point the drawable stretches itself back correctly the way it is supposed after x mousewheel ticks.
What is "wrong mouseWheel behaviour"? Is that possible you provide a video or a serie of screenshots?