On Nov 22, 5:09 am, Martin Pernollet <
martin.pernol...@gmail.com>
wrote:
> 2010/11/19 mhd.bakri <
mhdbakr...@gmail.com>
>
>
>
>
>
>
>
>
>
> > Update:
> > I got normal zoom to work. I just modify setScale function in View
> > class.
>
> > public void setScale(org.jzy3d.maths.Scale scale, boolean notify){
> > BoundingBox3d bounds = getBounds();
> > bounds.setZmin((float)scale.getMin());
> > bounds.setZmax((float)scale.getMax());
> > bounds.setXmin((float)scale.getMin());
> > bounds.setXmax((float)scale.getMax());
> > bounds.setYmin((float)scale.getMin());
> > bounds.setYmax((float)scale.getMax());
> > //setBoundManual(bounds);
> > if(notify)
> > shoot();
> > }
>
> As I told you: "*You will need to call View.setBoundManual(...) and then
> View.shoot(). I just noticed getBound() is missing, but you can call
> View.getAxe().getBoxBounds() if you want to know the current bounds of the
> view.*"
>
>
I moved the zoom function into mouseWheelMoved in
ChartMouseController. The zoom function worked.
But, if I call setBoundManual(..), the zoom will break. Only objects
in the graph will zoom, the axes size remain the same.
/** Compute zoom */
public void mouseWheelMoved(MouseWheelEvent e) {
if(threadController!=null)
threadController.stop();
float factor = 1 + (e.getWheelRotation()/10.0f);
//zoom(factor);
Scale currScale = View.current().getScale();
double range = currScale.getMax() - currScale.getMin();
if(range<=0)
return;
double center = (currScale.getMax() + currScale.getMin())/2;
double min = center + (currScale.getMin()-center) * (factor);
double max = center + (currScale.getMax()-center) * (factor);
Scale scale = null;
if(min<max) {
scale = new org.jzy3d.maths.Scale(min, max);
}
else{
if(factor<1) // forbid to have min = max if we zoom in
scale = new org.jzy3d.maths.Scale(center, center);
}
BoundingBox3d bounds = View.current().getBounds();
bounds.setZmin((float)scale.getMin());
bounds.setZmax((float)scale.getMax());
bounds.setYmin((float)scale.getMin());
bounds.setYmax((float)scale.getMax());
bounds.setXmin((float)scale.getMin());
bounds.setXmax((float)scale.getMax());
//View.current().setBoundManual(bounds); can't use this
//View.current().updateBounds();
View.current().shoot();
}
>
> > Right now, I'm trying to move camera position when user press arrow
> > key by using:
>
> > chart.getCanvas().addKeyListener(new KeyListener() { ... });
>
> > taken from one of the demo. Still no luck.
>
> Which demo?
Interactive scatterplot demo, to react when user press a key. The
keylistener is working.
How do I move the camera position(left, right, up and down), is it the
'Coord3d target' in camera object?
Thank you.