Commit 1e2ec39f authored by lafabregue's avatar lafabregue
Browse files

small fix 2

parent 8777df20
...@@ -10,6 +10,7 @@ import java.awt.Graphics; ...@@ -10,6 +10,7 @@ import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
...@@ -135,6 +136,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic ...@@ -135,6 +136,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic
private JCheckBox clusterDiameterCheckBox; private JCheckBox clusterDiameterCheckBox;
private JTextField diameterTextField; private JTextField diameterTextField;
private Point offSet = new Point(0,0);
/** Record steps of constraint construction */ /** Record steps of constraint construction */
private int currentStep = 0; private int currentStep = 0;
...@@ -374,10 +377,33 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic ...@@ -374,10 +377,33 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic
zoomBoxChkBox.doClick(); zoomBoxChkBox.doClick();
} }
int step = 10;
// hide constraints // hide constraints
if(e.getKeyCode() == KeyEvent.VK_H) { if(e.getKeyCode() == KeyEvent.VK_H) {
check.doClick(); check.doClick();
} }
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
offSet.x += (int) (step*mZoomRate);
displayPanel.repaint();
}
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
offSet.x -= (int) (step*mZoomRate);
displayPanel.repaint();
}
else if (e.getKeyCode() == KeyEvent.VK_UP) {
offSet.y += (int) (step*mZoomRate);
displayPanel.repaint();
}
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
offSet.y -= (int) (step*mZoomRate);
displayPanel.repaint();
}
// if (offSet.x < 0) {
// offSet.x = 0;
// }
// if(offSet.y < 0) {
// offSet.y = 0;
// }
} }
...@@ -467,6 +493,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic ...@@ -467,6 +493,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic
@Override @Override
public BufferedImage getDisplayedImage() { public BufferedImage getDisplayedImage() {
// return mNew.getSubimage(offSet.x, offSet.y,
// mNew.getWidth() - offSet.x, mNew.getHeight() - offSet.y);
return mNew; return mNew;
} }
...@@ -1384,5 +1412,10 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic ...@@ -1384,5 +1412,10 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic
} }
} }
@Override
public Point getOffset() {
return offSet;
}
} }
...@@ -1207,4 +1207,9 @@ public class ImagePanel extends JPanel implements Zoomable { ...@@ -1207,4 +1207,9 @@ public class ImagePanel extends JPanel implements Zoomable {
return rawImage; return rawImage;
} }
@Override
public Point getOffset() {
return new Point(0,0);
}
} }
...@@ -174,8 +174,8 @@ public class ZoomBoxPanel extends JPanel{ ...@@ -174,8 +174,8 @@ public class ZoomBoxPanel extends JPanel{
return new Point(0, 0); return new Point(0, 0);
} }
int x = (getWidth() - dialog.getDisplayedImage().getWidth()) / 2; int x = (getWidth() - dialog.getDisplayedImage().getWidth()) / 2 + dialog.getOffset().x;
int y = (getHeight() - dialog.getDisplayedImage().getHeight()) / 2; int y = (getHeight() - dialog.getDisplayedImage().getHeight()) / 2 + dialog.getOffset().y;
return new Point(x, y); return new Point(x, y);
} }
......
package mustic.utils.image; package mustic.utils.image;
import java.awt.Image; import java.awt.Image;
import java.awt.Point;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/** /**
...@@ -36,4 +37,6 @@ public interface Zoomable { ...@@ -36,4 +37,6 @@ public interface Zoomable {
* @return the BufferedImage from the origin image * @return the BufferedImage from the origin image
*/ */
public Image getMatchingImage(int x, int y, int width, int height, float zoom); public Image getMatchingImage(int x, int y, int width, int height, float zoom);
public Point getOffset();
} }
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