I wrote a simple ZoomOutMouseMode that seems to work for me:
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import com.bbn.openmap.MapBean;
import com.bbn.openmap.event.CoordMouseMode;
public class ZoomOutMouseMode extends CoordMouseMode {
public final static transient String modeID = "ZoomOut";
protected float multiplyScaleBy;
//Default constructor to zoom out 1.5x
public ZoomOutMouseMode() {
this(true, 1.5f);
}
//A simple mouse mode to zoom out on a mouse press
public ZoomOutMouseMode(boolean shouldConsumeEvents, float multiplyScaleBy)
{
super(modeID, shouldConsumeEvents);
this.multiplyScaleBy = multiplyScaleBy;
setModeCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
//Do a quick zoom out when the mouse is pressed
public void mousePressed(MouseEvent e) {
e.getComponent().requestFocus();
if (!mouseSupport.fireMapMousePressed(e) && e.getSource() instanceof
MapBean) {
MapBean mapBean = (MapBean)e.getSource();
mapBean.setScale(mapBean.getScale() * multiplyScaleBy);
}
}
}
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Aug 31 2004 - 11:37:32 EDT