Skip to content

Commit

Permalink
More mouse wheel support (for element window)
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerHeintzmann committed Jun 27, 2021
1 parent 2b5ec46 commit 4eb4318
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Binary file modified View5D.jar
Binary file not shown.
Binary file modified src/View5D_.jar
Binary file not shown.
Binary file modified src/view5d/PixelDisplay.class
Binary file not shown.
43 changes: 42 additions & 1 deletion src/view5d/PixelDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.*;
import java.text.*;

public class PixelDisplay extends Panel implements MouseListener,ImageObserver,KeyListener { // A panel displaying the multi-element contens of a single pixel
public class PixelDisplay extends Panel implements MouseListener,MouseWheelListener,ImageObserver,KeyListener { // A panel displaying the multi-element contens of a single pixel
static final long serialVersionUID = 1;
ImageCanvas c1,c2,c3;
My3DData data3d;
Expand Down Expand Up @@ -74,6 +74,7 @@ void AddColorMenu(String Name,int i)
PlotMode = 1; // Spectrum Plot

addMouseListener(this); // register this class for handling the events in it
addMouseWheelListener(this); // register this class for handling the events in it
addKeyListener(this); // register this class for handling the events in it

MyPopupMenu =new PopupMenu("Element Menu"); // tear off menu
Expand Down Expand Up @@ -118,6 +119,33 @@ void AddColorMenu(String Name,int i)

}

@Override
public void mouseWheelMoved(MouseWheelEvent e)
{
if (e.isShiftDown()) {
for (int el = 0; el < data3d.Elements; el++) {
double gamma = c1.my3ddata.GetGamma(el);
if (e.getWheelRotation() < 0) {
gamma = gamma * 1.125;
} else {
gamma = gamma / 1.125;
}
c1.my3ddata.SetGamma(el, gamma);
}
}
else {
int ae = c1.my3ddata.GetActiveElement();
double gamma = c1.my3ddata.GetGamma(ae);
if (e.getWheelRotation() < 0) {
gamma = gamma * 1.125;
} else {
gamma = gamma / 1.125;
}
c1.my3ddata.SetGamma(ae, gamma);
}
c1.UpdateAll();
}

Color GetBWColor(int e) {
int px = (int) (c2.PositionValue);
int py = (int) (c3.PositionValue);
Expand Down Expand Up @@ -572,6 +600,19 @@ public void mouseExited(MouseEvent e) {
public void mousePressed(MouseEvent e) {
//if (c1.applet instanceof View5D_) // ImageJ
// ((View5D_) c1.applet).setMenuBar(c1.myPanel.MyMenu);
if (e.getButton() == java.awt.event.MouseEvent.BUTTON2) { // This means middle mouse button!
if (e.isShiftDown()) {
for (int el=0;el<data3d.Elements;el++) {
c1.my3ddata.SetGamma(el, 1.0);
c1.UpdateAll();
}
return;
} else {
c1.my3ddata.SetGamma(c1.my3ddata.GetActiveElement(), 1.0);
c1.UpdateAll();
}
return;
}

if (e.isPopupTrigger())
{
Expand Down

0 comments on commit 4eb4318

Please sign in to comment.