Commit 7484167d authored by kirandjiska's avatar kirandjiska

Added the possibility of zooming in the zoom box panel and resizing the zoom box panel

parent 75fd0e0f
......@@ -16,6 +16,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
......@@ -104,7 +105,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
/** Image displayed */
private BufferedImage mNew = null;
/** Panl that containsthe displayed image */
/** Panel that contains the displayed image */
private JPanel displayPanel = null;
public JPanel mainPanel;
......@@ -221,37 +222,35 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
// display the image
this.displayPanel = (JPanel) new ZoomBoxPanel(this);
// key listener for the key "h" which hides/displays the current constraints on the image
this.displayPanel.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_H) {
// active JCheckBox check
check.doClick();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
this.displayPanel.setFocusable(true);
this.displayPanel.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getUnitsToScroll() > 0) {
zoomOut();
} else {
zoomIn();
// zoom in zoom box
if((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
if (e.getUnitsToScroll() > 0) {
((ZoomBoxPanel) displayPanel).zoomInBox();
} else {
((ZoomBoxPanel) displayPanel).zoomOutBox();
}
}
// resize zoom box area
else if((e.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) {
if (e.getUnitsToScroll() > 0) {
((ZoomBoxPanel) displayPanel).increaseZoomBoxArea();
} else {
((ZoomBoxPanel) displayPanel).decreaseZoomBoxArea();
}
}
// zoom in image
else {
if (e.getUnitsToScroll() > 0) {
zoomOut();
} else {
zoomIn();
}
}
}
});
......@@ -374,8 +373,35 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
otherComponentList.add(constraintsColorChooser);
JCheckBox zoomBoxChkBox = new JCheckBox("Zoom Box");
zoomBoxChkBox.setMnemonic(KeyEvent.VK_Z);
// zoomBoxChkBox.setSelected(zoomBoxActivated);
this.displayPanel.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
// enable zoom box
if(e.getKeyCode() == KeyEvent.VK_Z) {
zoomBoxChkBox.doClick();
}
// hide constraints
if(e.getKeyCode() == KeyEvent.VK_H) {
check.doClick();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
this.displayPanel.setFocusable(true);
zoomBoxChkBox.addItemListener(new ItemListener() {
@Override
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment