There are 4 code examples for java.awt.event.MouseWheelEvent.
The API names are highlighted below.
You can use
button
to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.
Project Name: jFreeChart Package: org.jfree.chart
Source Code: MouseWheelHandler.java (Click to view .java file)
Method Code:
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(Zoomable zoomable,MouseWheelEvent e){
ChartRenderingInfo info=this.chartPanel.getChartRenderingInfo();
PlotRenderingInfo pinfo=info.getPlotInfo();
Point2D p=this.chartPanel.translateScreenToJava2D(e.getPoint());
if (!pinfo.getDataArea().contains(p)) {
return;
}
Plot plot=(Plot)zoomable;
boolean notifyState=plot.isNotify();
plot.setNotify(false);
int clicks=e.getWheelRotation();
double zf=1.0 + this.zoomFactor;
if (clicks < 0) {
zf=1.0 / zf;
}
if (chartPanel.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf,pinfo,p,true);
}
if (chartPanel.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf,pinfo,p,true);
}
plot.setNotify(notifyState);
}
Project Name: megamek Package: megamek.client.ui.AWT
Source Code: BoardView1.java (Click to view .java file)
Method Code:
/**
* Construct a new board view for the specified game
*/
public BoardView1(IGame game) throws IOException {
this.game=game;
tileManager=new TilesetManager(this);
game.addGameListener(gameListener);
game.getBoard().addBoardListener(this);
scheduleRedrawTimer();
addKeyListener(this);
addMouseListener(this);
addMouseMotionListener(this);
addMouseWheelListener(new MouseWheelListener(){
public void mouseWheelMoved( MouseWheelEvent we){
if (GUIPreferences.getInstance().getMouseWheelZoom()) {
if (we.getWheelRotation() > 0) {
zoomIn();
}
else {
zoomOut();
}
}
}
}
);
zoomIndex=GUIPreferences.getInstance().getMapZoomIndex();
checkZoomIndex();
scale=ZOOM_FACTORS[zoomIndex];
updateFontSizes();
updateBoardSize();
tipWindow=new Window(new Frame());
hex_size=new Dimension((int)(HEX_W * scale),(int)(HEX_H * scale));
initPolys();
cursorSprite=new CursorSprite(Color.cyan);
highlightSprite=new CursorSprite(Color.white);
selectedSprite=new CursorSprite(Color.blue);
firstLOSSprite=new CursorSprite(Color.red);
secondLOSSprite=new CursorSprite(Color.red);
PreferenceManager.getClientPreferences().addPreferenceChangeListener(this);
SpecialHexDisplay.Type.ARTILLERY_HIT.init(getToolkit());
SpecialHexDisplay.Type.ARTILLERY_INCOMING.init(getToolkit());
SpecialHexDisplay.Type.ARTILLERY_TARGET.init(getToolkit());
SpecialHexDisplay.Type.ARTILLERY_ADJUSTED.init(getToolkit());
SpecialHexDisplay.Type.ARTILLERY_AUTOHIT.init(getToolkit());
}
Project Name: megamek Package: megamek.client.ui.AWT
Source Code: BoardView1.java (Click to view .java file)
Method Code:
public void mouseWheelMoved(MouseWheelEvent we){
if (GUIPreferences.getInstance().getMouseWheelZoom()) {
if (we.getWheelRotation() > 0) {
zoomIn();
}
else {
zoomOut();
}
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: BoardView1.java (Click to view .java file)
Method Code:
public void mouseWheelMoved(MouseWheelEvent we){
Point mousePoint=we.getPoint();
for (int i=0; i < displayables.size(); i++) {
IDisplayable disp=displayables.get(i);
if (!(disp instanceof ChatterBox2)) {
break;
}
double width=Math.min(boardSize.getWidth(),scrollpane.getViewport().getSize().getWidth());
double height=Math.min(boardSize.getHeight(),scrollpane.getViewport().getSize().getHeight());
Dimension drawDimension=new Dimension();
drawDimension.setSize(width,height);
if (disp.isMouseOver(mousePoint,drawDimension)) {
ChatterBox2 cb2=(ChatterBox2)disp;
if (we.getWheelRotation() > 0) {
cb2.scrollDown();
}
else {
cb2.scrollUp();
}
refreshDisplayables();
return;
}
}
if (GUIPreferences.getInstance().getMouseWheelZoom()) {
if (we.getWheelRotation() > 0) {
zoomIn();
}
else {
zoomOut();
}
}
else {
int notches=we.getWheelRotation();
if (notches < 0) {
vbar.setValue((int)(vbar.getValue() - (HEX_H * scale * (-1 * notches))));
}
else {
vbar.setValue((int)(vbar.getValue() + (HEX_H * scale * (notches))));
}
}
}