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

Issue 114: Zoom Window Bug for Slider FIXED #186

Merged
merged 4 commits into from
Jul 15, 2022
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
1 change: 1 addition & 0 deletions src/main/java/edu/rpi/legup/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void mouseMoved(MouseEvent e) {
*/
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
// System.out.println(e.getWheelRotation());
if (e.isControlDown()) {
if (e.getWheelRotation() != 0){
viewer.zoom(e.getWheelRotation() * 2, e.getPoint());
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/edu/rpi/legup/ui/DynamicView.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseWheelEvent;
import java.awt.event.*;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Objects;
Expand Down Expand Up @@ -76,6 +74,14 @@ public void mouseWheelMoved(MouseWheelEvent e) {

zoomSlider.setPreferredSize(new Dimension(160, 30));

scrollView.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
zoomSlider.setValue(scrollView.getZoom() );
zoomLabel.setText(zoomSlider.getValue() + "%");
}
});

zoomSlider.addChangeListener((ChangeEvent e) -> {
scrollView.zoomTo(zoomSlider.getValue() / 100.0);
zoomLabel.setText(zoomSlider.getValue() + "%");
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/edu/rpi/legup/ui/ZoomWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ public ZoomWidget(ScrollView parent) {
/**
*
*/
private class PopupSlider extends JPopupMenu implements ChangeListener {
private static final long serialVersionUID = 8225019381200459814L;
private class PopupSlider extends JPopupMenu implements ChangeListener {
private static final long serialVersionUID = 8225019381200459814L;

private JSlider slider;
private JSlider slider;

public PopupSlider() {
slider = new JSlider(SwingConstants.VERTICAL, 25, 400, 100);
slider.setMajorTickSpacing(25);
slider.setPaintTicks(true);
public PopupSlider() {
slider = new JSlider(SwingConstants.VERTICAL, 0, 400, 200);
slider.setMajorTickSpacing(25);
slider.setPaintTicks(true);

add(slider);
slider.addChangeListener(this);
}
add(slider);
slider.addChangeListener(this);
}

public void stateChanged(ChangeEvent e) {
if (slider.getValueIsAdjusting()) {
parent.zoomTo((double) slider.getValue() / 100.0);
public void stateChanged(ChangeEvent e) {
if (slider.getValueIsAdjusting()) {
parent.zoomTo((double) slider.getValue() / 100.0);
}
}
}
}
}