
Signature
Bill Tschumy
Otherwise -- Austin, TX
http://www.otherwise.com
> What have you tried doing to debug it? I don't see anything overtly wrong
> with the code presented.
[quoted text clipped - 3 lines]
> called. If it is being called then then you need to look at paint() method
> to see why the new zoom is not being used.
Dear Bill,
I've tried to put a println in setZoom(), and I'm sure it's called!
public void setZoom(double z){
System.out.println("setZoom entered");
this.zoom = z;
System.out.println("New zoom:"+ getZoom());
repaint();
}
It tells me that
1)the method has been used
2)zoom has been changed... apparently!
The "new" zoom will be used by the method paintComponent(), called by
repaint(), in JPanel_Zoom, which redraws the component according to the
new magnifing ratio:
public void paintComponent(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D)g;
g2d.clearRect(0, 0, w, h);
g2d.setColor(Color.blue);
g2d.draw(selectionRectangle);
g2d.setColor(Color.black);
if (lines.size()!=0){
int j = 0;
double z = getZoom();
// debug: zoom is still the same!!!
System.out.println("Zoom: "+ z);
for (Iterator i = lines.iterator(); i.hasNext(); ) {
LineInt line = (LineInt)i.next();
if (selected.contains(new Integer(j)))
g2d.setColor(Color.red);
int x1 = (int)Math.round(line.px1*z);
int y1 = (int)Math.round(line.py1*z);
int x2 = (int)Math.round(line.px2*z);
int y2 = (int)Math.round(line.py2*z);
g2d.drawLine(x1, y1, x2, y2);
g2d.setColor(Color.black);
j++;
}
}
}
I usually put a debug instruction in my code and, as you can see from
the comment... zoom is still the same!
Anyway, thanks for your help!
Fred L. Kleinschmidt - 13 Jun 2005 23:01 GMT
> > What have you tried doing to debug it? I don't see anything overtly wrong
> > with the code presented.
[quoted text clipped - 58 lines]
>
> Anyway, thanks for your help!
Maybe the problem is in getZoom().
And why are you using getZoom() in the first place? Why not just use
"zoom"?

Signature
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225