/**
* Creates a new {@link MapCanvas}.
*
* @param repProc replay processor
* @param zoomComboBox combo box which tells how to zoom the map image
*/
public MapCanvas( final RepProcessor repProc, final XComboBox< Zoom > zoomComboBox ) {
this.repProc = repProc;
this.zoomComboBox = zoomComboBox;
ricon = MapImageCache.getMapImage( repProc );
GuiUtils.makeComponentDragScrollable( this );
// Zoom in and out with CTRL+wheel scroll:
addMouseWheelListener( new MouseWheelListener() {
@Override
public void mouseWheelMoved( final MouseWheelEvent event ) {
if ( event.isControlDown() ) {
final int newZoomIdx = zoomComboBox.getSelectedIndex() - event.getWheelRotation();
zoomComboBox.setSelectedIndex( Math.max( 0, Math.min( zoomComboBox.getItemCount() - 1, newZoomIdx ) ) );
// An event will be fired which will cause reconfigureZoom() to be called...
}
}
} );
}
MapCanvas.java 文件源码
java
阅读 142
收藏 0
点赞 0
评论 0
项目:scelight
作者:
评论列表
文章目录