Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to zoom via scroll wheel #263

Merged
merged 8 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<developer>
<name>Ryan Gardner</name>
</developer>
<developer>
<name>Matt Foulks</name>
<url>https://github.com/mfoulks3200</url>
</developer>
<developer>
<name>Martin Geldmacher</name>
<url>https://github.com/geld0r</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class AboutDialog extends ScreenCenteredDialog implements ActionListener
"Cka3o4Huk",
"Frank Dietrich",
"Bernd Eckenfels",
"Matt Foulks",
"Ryan Gardner",
"Martin Geldmacher",
"Neil Gentleman",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Point;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -27,7 +29,6 @@ public class GCViewerGui extends JFrame {

public GCViewerGui() {
super("tagtraum industries incorporated - GCViewer");

setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}

Expand Down
25 changes: 21 additions & 4 deletions src/main/java/com/tagtraum/perf/gcviewer/view/ModelChartImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import javax.swing.event.ChangeListener;
import javax.swing.event.SwingPropertyChangeSupport;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
Expand Down Expand Up @@ -185,6 +182,26 @@ private void maybePopup(MouseEvent e) {
}
});


addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (((e.getModifiersEx() & InputEvent.META_DOWN_MASK) != 0 && System.getProperty("os.name").contains("Mac OS X"))||(e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0 && !System.getProperty("os.name").contains("Mac OS X")) {
double pos = (double)(getHorizontalScrollBar().getValue()) / (double)(chart.getWidth());
if (e.getWheelRotation() > 0 && getScaleFactor() < 100) {
setScaleFactor((getScaleFactor()*1.2));
}
if (e.getWheelRotation() < 0 && getScaleFactor() > 0.01) {
setScaleFactor((getScaleFactor()/1.2));
}
if (e.getWheelRotation() != 0) {
getHorizontalScrollBar().setValue((int)(pos * (double)(chart.getWidth())));
e.consume();
}
}
}
});

}

public void addTimeOffsetChangeListener(PropertyChangeListener listener) {
Expand Down