- Timestamp:
- 11/30/06 12:10:23 (2 years ago)
- Location:
- trunk/SRC/org/openmicroscopy/shoola
- Files:
-
- 10 modified
-
agents/hiviewer/util/RollOverCanvas.java (modified) (3 diffs)
-
agents/hiviewer/util/RollOverWin.java (modified) (6 diffs)
-
env/ui/tdialog/BorderListener.java (modified) (2 diffs)
-
env/ui/tdialog/DialogControl.java (modified) (4 diffs)
-
env/ui/tdialog/ScreenControl.java (modified) (1 diff)
-
env/ui/tdialog/ThumbnailCanvas.java (modified) (3 diffs)
-
env/ui/tdialog/TinyDialog.java (modified) (5 diffs)
-
env/ui/tdialog/TinyDialogUI.java (modified) (2 diffs)
-
util/image/geom/Factory.java (modified) (2 diffs)
-
util/ui/lens/LensController.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/org/openmicroscopy/shoola/agents/hiviewer/util/RollOverCanvas.java
r4600 r4628 41 41 import java.awt.event.MouseAdapter; 42 42 import java.awt.event.MouseEvent; 43 import java.awt.event.MouseWheelEvent; 44 import java.awt.event.MouseWheelListener; 43 45 import javax.swing.BorderFactory; 44 46 import javax.swing.ImageIcon; … … 100 102 private Rectangle classifiedRectangle; 101 103 104 102 105 /** 103 106 * Creates a new instance. … … 129 132 } 130 133 }); 134 addMouseWheelListener(new MouseWheelListener() { 135 public void mouseWheelMoved(MouseWheelEvent e) { 136 model.magnifyImage(e.getWheelRotation()); 137 } 138 }); 131 139 } 132 140 -
trunk/SRC/org/openmicroscopy/shoola/agents/hiviewer/util/RollOverWin.java
r4585 r4628 53 53 import org.openmicroscopy.shoola.agents.hiviewer.browser.Thumbnail; 54 54 import org.openmicroscopy.shoola.agents.hiviewer.cmd.ViewCmd; 55 import org.openmicroscopy.shoola.util.image.geom.Factory; 55 56 56 57 import pojos.DataObject; … … 76 77 { 77 78 79 /** The minimum magnification value. */ 80 final static int MINIMUM_ZOOM = 1; 81 82 /** The maximum magnification value. */ 83 final static int MAXIMUM_ZOOM = 2; 84 78 85 /** ImageNode displayed. */ 79 p ublicImageNode node;86 private ImageNode node; 80 87 81 88 /** The image to display. */ 82 89 private BufferedImage image; 83 90 91 /** The image to display. */ 92 private BufferedImage originalImage; 93 84 94 /** The canvas hosting the image. */ 85 95 private RollOverCanvas canvas; … … 88 98 private Browser browser; 89 99 100 /** The magnification factor. */ 101 private float zoomFactor; 102 90 103 /** Sets the property of the dialog window. */ 91 104 private void setProperties() … … 94 107 setResizable(false); 95 108 setUndecorated(true); 109 zoomFactor = MINIMUM_ZOOM; 96 110 } 97 111 … … 137 151 } 138 152 153 /** 154 * Magnifies the displayed image. 155 * 156 * @param tick The number of "clicks" the mouse wheel was rotated. 157 */ 158 void magnifyImage(int tick) 159 { 160 zoomFactor -= 0.1f*tick; 161 zoomFactor = Math.round(zoomFactor*10)/10.0f; 162 if (zoomFactor < RollOverWin.MINIMUM_ZOOM) 163 zoomFactor = RollOverWin.MINIMUM_ZOOM; 164 if (zoomFactor > RollOverWin.MAXIMUM_ZOOM) 165 zoomFactor = RollOverWin.MAXIMUM_ZOOM; 166 image = Factory.magnifyImage(zoomFactor, originalImage); 167 makeComponentsSize(image.getWidth(), image.getHeight()); 168 pack(); 169 } 170 171 139 172 /** Pins the thumbnail. */ 140 173 void pinThumbnail() { browser.setThumbSelected(true, node); } … … 184 217 if (full != null) { 185 218 image = full; 219 originalImage = full; 186 220 makeComponentsSize(image.getWidth(), image.getHeight()); 187 221 canvas.repaint(); -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/BorderListener.java
r3096 r4628 70 70 /** Reference to the model. */ 71 71 private TinyDialog model; 72 73 72 74 73 /** … … 94 93 this.model = model; 95 94 } 96 97 95 98 96 /** -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/DialogControl.java
r3096 r4628 37 37 import java.awt.event.MouseListener; 38 38 import java.awt.event.MouseMotionListener; 39 import java.awt.event.MouseWheelEvent; 40 import java.awt.event.MouseWheelListener; 41 import java.awt.image.BufferedImage; 39 42 import java.beans.PropertyChangeEvent; 40 43 import java.beans.PropertyChangeListener; 41 44 45 42 46 //Third-party libraries 43 47 44 48 //Application-internal dependencies 49 import org.openmicroscopy.shoola.util.image.geom.Factory; 45 50 46 51 /** … … 64 69 class DialogControl 65 70 implements 66 PropertyChangeListener, ActionListener, MouseListener, MouseMotionListener 71 PropertyChangeListener, ActionListener, MouseListener, MouseMotionListener, 72 MouseWheelListener 67 73 { 68 74 69 /** Action command ID. */ 70 static final int SIZE = 0, CLOSE = 1; 75 /** Action command ID to modify the size of the component. */ 76 static final int SIZE = 0; 77 78 /** Action command ID to modify the close of the component. */ 79 static final int CLOSE = 1; 71 80 72 81 /** The window this controller is for. */ … … 78 87 /** The mouse events controller. */ 79 88 private ScreenControl sControl; 80 89 81 90 /** 82 91 * Creates a new instance to control a given {@link TinyDialog} and 83 92 * notify its View. 84 93 * 85 * @param model The window. Mustn't be <code>null</code>.86 * @param view The window's UI. Mustn't be <code>null</code>.94 * @param model The window. Mustn't be <code>null</code>. 95 * @param view The window's UI. Mustn't be <code>null</code>. 87 96 */ 88 97 DialogControl(TinyDialog model, TinyDialogUI view) … … 147 156 148 157 /** 158 * Modifies the magnification factor depending on the number of "clicks" 159 * the mouse wheel was rotated. 160 * 161 * @see MouseWheelListener#mouseWheelMoved(MouseWheelEvent) 162 */ 163 public void mouseWheelMoved(MouseWheelEvent e) 164 { 165 float zoomFactor = model.getZoomFactor(); 166 zoomFactor -= 0.1f*e.getWheelRotation(); 167 zoomFactor = Math.round(zoomFactor*10)/10.0f; 168 if (zoomFactor < TinyDialog.MINIMUM_ZOOM) 169 zoomFactor = TinyDialog.MINIMUM_ZOOM; 170 if (zoomFactor > TinyDialog.MAXIMUM_ZOOM) 171 zoomFactor = TinyDialog.MAXIMUM_ZOOM; 172 model.setZoomFactor(zoomFactor); 173 BufferedImage img = Factory.magnifyImage(zoomFactor, 174 model.getOriginalImage()); 175 view.setImage(img); 176 } 177 178 /** 149 179 * Forward event to the <code>Screen control</code>. 150 180 * @see MouseListener#mousePressed(MouseEvent) -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/ScreenControl.java
r3096 r4628 64 64 { 65 65 66 /** MousePressed location in absolute coordinate system .*/ 67 private int xAbs, yAbs; 66 /** 67 * The x-coordinate of mouse in absolute coordinate system 68 * when the mouse is pressed. 69 */ 70 private int xAbs; 68 71 69 /** MousePressed location in source view's coordinate system .*/ 70 private int xView, yView; 71 72 /** 73 * The y-coordinate of mouse in absolute coordinate system 74 * when the mouse is pressed. 75 */ 76 private int yAbs; 77 78 /** 79 * The y-coordinate of mouse in source view's coordinate system 80 * when the mouse is pressed. 81 */ 82 private int xView; 83 84 /** 85 * The y-coordinate of mouse in source view's coordinate system 86 * when the mouse is pressed. 87 */ 88 private int yView; 89 72 90 /** Dragging control. */ 73 91 private boolean dragging; -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/ThumbnailCanvas.java
r3929 r4628 63 63 64 64 /** The {@link BufferedImage} to paint. */ 65 private BufferedImage image;65 private BufferedImage image; 66 66 67 67 /** … … 76 76 } 77 77 78 /** 79 * Sets the image to paint. 80 * 81 * @param image The {@link BufferedImage} to paint. 82 */ 83 void setImage(BufferedImage image) { this.image = image; } 84 78 85 /** 79 * Overrid en to paint the thumbnail.86 * Overridden to paint the thumbnail. 80 87 * @see JComponent#paintComponent(Graphics) 81 88 */ … … 89 96 } 90 97 } 98 91 99 92 100 } -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/TinyDialog.java
r3929 r4628 74 74 public final static String TITLE_PROPERTY = "title"; 75 75 76 /** The minimum magnification value. */ 77 final static int MINIMUM_ZOOM = 1; 78 79 /** The maximum magnification value. */ 80 final static int MAXIMUM_ZOOM = 2; 81 76 82 /** The size of the frame before the last collapse request. */ 77 83 private Dimension restoreSize; … … 91 97 /** Tells if the close button is displayed. */ 92 98 private boolean closedButton; 99 100 /** The image to display. */ 101 private BufferedImage originalImage; 102 103 /** The magnification factor. */ 104 private float zoomFactor; 93 105 94 106 /** The title displayed in this window's title bar. */ … … 102 114 setUndecorated(true); 103 115 setRestoreSize(new Dimension(getWidth(), getHeight())); 104 } 116 zoomFactor = MINIMUM_ZOOM; 117 } 118 119 /** 120 * Returns the original image to display. 121 * 122 * @return Se above 123 */ 124 BufferedImage getOriginalImage() { return originalImage; } 125 126 /** 127 * Returns the magnification factor. 128 * 129 * @return See above. 130 */ 131 float getZoomFactor() { return zoomFactor; } 132 133 /** 134 * Sets the magnification factor. 135 * 136 * @param v The value to set. 137 */ 138 void setZoomFactor(float v) { zoomFactor = v; } 105 139 106 140 /** … … 153 187 if (image == null) throw new NullPointerException("No image."); 154 188 this.title = title; 189 originalImage = image; 190 zoomFactor = MINIMUM_ZOOM; 155 191 closedButton = true; 156 192 //Create the View and the Controller. 157 193 uiDelegate = new TinyDialogUI(this, image); 158 194 controller = new DialogControl(this, uiDelegate); 195 uiDelegate.attachMouseWheelListener(controller); 159 196 } 160 197 … … 330 367 } 331 368 332 333 334 369 } -
trunk/SRC/org/openmicroscopy/shoola/env/ui/tdialog/TinyDialogUI.java
r3929 r4628 42 42 import java.awt.event.MouseListener; 43 43 import java.awt.event.MouseMotionListener; 44 import java.awt.event.MouseWheelListener; 44 45 import java.awt.image.BufferedImage; 45 46 import javax.swing.BorderFactory; … … 251 252 makeBorders(); 252 253 buildUI(); 254 } 255 256 /** 257 * Sets the image to paint if the canvas is an instance of 258 * <code>ThumbnailCanvas</code>. 259 * 260 * @param image The image to paint. 261 */ 262 void setImage(BufferedImage image) 263 { 264 if (canvas instanceof ThumbnailCanvas) { 265 makeComponentsSize(image.getWidth(), image.getHeight()); 266 ((ThumbnailCanvas) canvas).setImage(image); 267 //window.getContentPane().removeAll(); 268 //buildUI(); 269 window.pack(); 270 } 271 } 272 273 /** 274 * Adds a {@link MouseWheelListener} to the canvas if the canvas is 275 * an instance of <code>ThumbnailCanvas</code>. 276 * 277 * @param controller The listener to add. 278 */ 279 void attachMouseWheelListener(MouseWheelListener controller) 280 { 281 if (canvas instanceof ThumbnailCanvas) 282 canvas.addMouseWheelListener(controller); 253 283 } 254 284 -
trunk/SRC/org/openmicroscopy/shoola/util/image/geom/Factory.java
r3780 r4628 89 89 private static final int BORDER = 2; 90 90 91 /** The default message for the default thumbnail. */ 91 92 private static final String DEFAULT_TEXT = "No thumbnail"; 92 93 … … 102 103 0.1f, 0.2f, 0.1f, 103 104 0.1f, 0.1f, 0.1f}; 105 106 /** 107 * Magnifies the specified image. 108 * 109 * @param f the magnification factor. 110 * @param img The image to magnify. 111 * 112 * @return The magnified image. 113 */ 114 public static BufferedImage magnifyImage(double f, BufferedImage img) 115 { 116 if (img == null) return null; 117 int width = img.getWidth(), height = img.getHeight(); 118 AffineTransform at = new AffineTransform(); 119 at.scale(f, f); 120 BufferedImageOp biop = new AffineTransformOp(at, 121 AffineTransformOp.TYPE_BILINEAR); 122 BufferedImage rescaleBuff = new BufferedImage((int) (width*f), 123 (int) (height*f), img.getType()); 124 biop.filter(img, rescaleBuff); 125 return rescaleBuff; 126 } 104 127 105 128 /** -
trunk/SRC/org/openmicroscopy/shoola/util/ui/lens/LensController.java
r4627 r4628 250 250 251 251 /** 252 * M ouseWheelMoved event253 * 254 * @param tick 252 * Magnifies the image. 253 * 254 * @param tick The number of "clicks" the mouse wheel was rotated. 255 255 */ 256 256 void lensMouseWheelMoved(int tick)
