Pages

about my opensource eclipse java applications recently i'm studying GWT and Android

Thursday, August 11, 2005

like WaveFormGraph and zoom in and zoom out and stretch[GEF/Draw2D]


Of course my way is tricky.
But I don't know how to set different scale both width and height.
please see code anyway,it's difficult to explain how to do that.

In my program,I use ScaledPane and ToolbarLayout.
So It's easy zoom in and zoom out.
but When I wish fix height,I would do something.

In my code,I change my graph figure return 1x1 dimension everytime.
because on scaled changed,height length would be changed.

public Dimension getPreferredSize(int hintW,int hintH){
System.out.println(getParentScale());
if(horizontal){
//return new Dimension(values.length*space,maxValue-minValue);
//return new Dimension(values.length*space,(int)((maxValue-minValue)/getParentScale()));
return new Dimension(values.length*space,1);
}else{
return new Dimension(hintW,hintH);
}
}

Once you do that,it's ToolbarLayout and height would be stretched automatic.

Codes
ScaledToolbarLayoutTest.java
ScaledWavFormGraphTest.java