• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.clients
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 4767

Show
Ignore:
Timestamp:
03/07/07 16:34:14 (21 months ago)
Author:
jburel
Message:

Clean up, Fix location of the lens when turns on and off.
Also centers the lens (if visible) when zooming the image
(cf ticket#260)

Location:
trunk/SRC/org/openmicroscopy/shoola
Files:
12 modified

  • agents/imviewer/browser/BrowserUI.java (modified) (1 diff)
  • agents/imviewer/view/ImViewerUI.java (modified) (2 diffs)
  • env/data/OMEROGateway.java (modified) (3 diffs)
  • env/data/OmeroDataServiceImpl.java (modified) (3 diffs)
  • env/data/login/LoginConfig.java (modified) (1 diff)
  • env/data/login/LoginServiceImpl.java (modified) (3 diffs)
  • env/ui/LoginOMEDSManager.java (modified) (1 diff)
  • env/ui/SplashScreenManager.java (modified) (1 diff)
  • util/ui/lens/LensComponent.java (modified) (1 diff)
  • util/ui/lens/LensModel.java (modified) (4 diffs)
  • util/ui/lens/LensUI.java (modified) (6 diffs)
  • util/ui/login/ScreenLogin.java (modified) (2 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/browser/BrowserUI.java

    r4763 r4767  
    203203        { 
    204204                Rectangle viewRect = getViewport().getViewRect(); 
     205                JScrollBar hBar = getHorizontalScrollBar(); 
     206                JScrollBar vBar = getVerticalScrollBar(); 
    205207                if (!viewRect.contains(bounds)) { 
    206                         JScrollBar hBar = getHorizontalScrollBar(); 
    207                         JScrollBar vBar = getVerticalScrollBar(); 
    208                         if (viewRect.x-bounds.x < 0 && blockIncrement) 
     208                         
     209                        int deltaX = viewRect.x-bounds.x; 
     210                        int deltaY = viewRect.y-bounds.y; 
     211                        if (deltaX < 0 && blockIncrement) 
    209212                                hBar.setValue(hBar.getValue()+hBar.getBlockIncrement()); 
    210                         else hBar.setValue(bounds.x); 
    211                         if (viewRect.y-bounds.y < 0 && blockIncrement) 
     213                        else { 
     214                                int w = viewRect.width-bounds.width; 
     215                                if (w < 0) w = -w; 
     216                                hBar.setValue(bounds.x-w/2); 
     217                        } 
     218                        if (deltaY  < 0 && blockIncrement) 
    212219                                vBar.setValue(vBar.getValue()+vBar.getBlockIncrement()); 
    213                         else vBar.setValue(bounds.y); 
     220                        else { 
     221                                int h = viewRect.height-bounds.height; 
     222                                if (h < 0) h = -h; 
     223                                vBar.setValue(bounds.y-h/2); 
     224                        } 
     225        } else { 
     226                //lens not centered 
     227                int w = viewRect.width-bounds.width; 
     228                        if (w < 0) w = -w; 
     229                        hBar.setValue(bounds.x-w/2); 
     230                        int h = viewRect.height-bounds.height; 
     231                        if (h < 0) h = -h; 
     232                        vBar.setValue(bounds.y-h/2); 
    214233        } 
    215234        } 
  • trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewerUI.java

    r4766 r4767  
    390390        colorModelGroup.add(item); 
    391391        menu.add(item); 
    392         //action = controller.getAction(ImViewerControl.HSB_MODEL); 
    393         //item = new JRadioButtonMenuItem(); 
    394         //item.setAction(action); 
    395         //item.setSelected(cm.equals(ImViewer.HSB_MODEL)); 
    396         //colorModelGroup.add(item); 
    397         //menu.add(item); 
    398392        return menu; 
    399393    } 
    … …  
    773767                model.getBrowser().addComponent(lens.getLensUI()); 
    774768                UIUtilities.setLocationRelativeTo(this, lens.getZoomWindowUI()); 
    775                 //lens.setZoomWindowLocation(getX()+getWidth(), getY()); 
    776769            } 
    777  
    778770            lens.setImageZoomFactor((float) model.getZoomFactor()); 
    779771            lens.setPlaneImage(model.getOriginalImage()); 
    780             lens.setLensPreferredColour(); 
     772            //lens.setLensPreferredColour(); 
     773            if (!firstTimeLensShown) scrollLens(); 
    781774        } 
    782775        lens.setVisible(b); 
  • trunk/SRC/org/openmicroscopy/shoola/env/data/OMEROGateway.java

    r4764 r4767  
    2626 
    2727//Java imports 
     28import java.io.File; 
     29import java.io.FileOutputStream; 
     30import java.io.IOException; 
    2831import java.io.PrintWriter; 
    2932import java.io.StringWriter; 
     33import java.util.ArrayList; 
    3034import java.util.HashMap; 
    3135import java.util.HashSet; 
    … …  
    10791083     * Retrieves the archived files if any for the specified set of pixels. 
    10801084     *  
    1081      * @param pixelsID The ID of the pixels set. 
    1082      * @return See above. 
    1083      * @throws DSOutOfServiceException If the connection is broken, or logged in 
    1084      * @throws DSAccessException If an error occured while trying to  
    1085      * retrieve data from OMEDS service.  
    1086      */ 
    1087     Map<OriginalFile, byte[]> getOriginalFiles(long pixelsID)  
     1085     * @param path              The location where to save the files. 
     1086     * @param pixelsID  The ID of the pixels set. 
     1087     * @return See above. 
     1088     * @throws DSOutOfServiceException If the connection is broken, or logged in 
     1089     * @throws DSAccessException If an error occured while trying to  
     1090     * retrieve data from OMEDS service.  
     1091     */ 
     1092    Map<Integer, List> getArchivedFiles(String path, long pixelsID)  
    10881093        throws DSOutOfServiceException, DSAccessException 
    10891094    { 
    … …  
    10941099                "where child.id = :id", 
    10951100                new Parameters().addId(new Long(pixelsID))); 
    1096         if (files == null || files.size() == 0) return null; 
     1101        Map<Integer, List> result = new HashMap<Integer, List>(); 
     1102        if (files == null || files.size() == 0) return result; 
    10971103        RawFileStore store = getRawFileService(); 
    10981104        Iterator i = files.iterator(); 
    10991105        OriginalFile of; 
    1100         Map<OriginalFile, byte[]> map =  
    1101                                         new HashMap<OriginalFile, byte[]>(files.size()); 
     1106         
     1107        int size;        
     1108        FileOutputStream stream; 
     1109        int offset = 0; 
     1110        int inc = 256000; 
     1111        File f; 
     1112        List<String> notDownloaded = new ArrayList<String>(); 
    11021113        while (i.hasNext()) { 
    11031114                        of = (OriginalFile) i.next(); 
    11041115                        store.setFileId(of.getId());  
     1116                        f = new File(path+of.getName()); 
    11051117                        try { 
    1106                                 map.put(of, store.read(0, of.getSize())); 
    1107                         } catch (Exception e) { 
    1108                                 //Original file exists but not been archived. 
     1118                                stream = new FileOutputStream(f); 
     1119                                size = of.getSize().intValue(); 
     1120                                try { 
     1121                                        try { 
     1122                                                for (offset = 0; (offset+inc) < size;) { 
     1123                                                        stream.write(store.read(offset, inc)); 
     1124                                                        offset += inc; 
     1125                                                }        
     1126                                        } finally { 
     1127                                                stream.write(store.read(offset, size-offset));  
     1128                                        } 
     1129                                } catch (Exception e) { 
     1130                                        stream.close(); 
     1131                                        f.delete(); 
     1132                                        notDownloaded.add(of.getName()); 
     1133                                } 
     1134                        } catch (IOException e) { 
     1135                                f.delete(); 
     1136                                notDownloaded.add(of.getName()); 
     1137                                throw new DSAccessException("Cannot create the file", e); 
    11091138                        } 
    11101139                } 
    1111         return map; 
     1140        result.put(files.size(), notDownloaded); 
     1141        return result; 
    11121142        } 
    11131143     
  • trunk/SRC/org/openmicroscopy/shoola/env/data/OmeroDataServiceImpl.java

    r4765 r4767  
    8080    private OMEROGateway            gateway; 
    8181     
    82     /** 
    83      * Creates a <code>File</code> from the passed array of bytes. 
    84      *  
    85      * @param name              The name of the file. 
    86      * @param values    The array of bytes. 
    87      * @return See above. 
    88      * @throws DSAccessException If we cannot create the file. 
    89      */ 
    90     private File createFile(String name, byte[] values)  
    91         throws DSAccessException 
    92     { 
    93         File f = new File(name); 
    94         try { 
    95                 FileOutputStream stream = new FileOutputStream(f); 
    96                 stream.write(values); 
    97                 stream.close(); 
    98                 return f; 
    99         } catch (Exception e) { 
    100                 f.delete(); 
    101                 throw new DSAccessException("Cannot create the file", e); 
    102         } 
    103     } 
     82 
    10483     
    10584    /** 
    … …  
    831810                throws DSOutOfServiceException, DSAccessException 
    832811        { 
     812 
     813                return gateway.getArchivedFiles(path, pixelsID); 
     814                /* 
    833815                Map<OriginalFile, byte[]> map = gateway.getOriginalFiles(pixelsID); 
    834816                Map<Integer, List> result = new HashMap<Integer, List>(); 
    835817                if (map == null || map.size() == 0) return result; 
     818                 
     819                 
     820                 
     821                 
     822                 
    836823                Iterator i = map.keySet().iterator(); 
    837824                OriginalFile of; 
    … …  
    847834                result.put(new Integer(map.size()), l); 
    848835                return result; 
     836                */ 
    849837        } 
    850838 
  • trunk/SRC/org/openmicroscopy/shoola/env/data/login/LoginConfig.java

    r4695 r4767  
    6363     */ 
    6464    public static final int     DEFAULT_RETRY_INTERVAL = 500; 
    65      
    66     /** Separator used when storing various servers. */ 
    67     public static final String  SERVER_NAME_SEPARATOR = ","; 
    68      
    69     /** Default . */     
    70     public static final String  DEFAULT_SERVER = "new server"; 
    71      
    72     /** The property name for the host to connect to <i>OMERO</i>. */ 
    73     public static final String  OMERO_SERVER = "omeroServer"; 
    7465     
    7566    /**  
  • trunk/SRC/org/openmicroscopy/shoola/env/data/login/LoginServiceImpl.java

    r4730 r4767  
    2626 
    2727//Java imports 
    28 import java.util.prefs.Preferences; 
    2928 
    3029//Third-party libraries 
    … …  
    120119            logger.info(this, msg); 
    121120             
    122             Preferences userPrefs =  
    123                     Preferences.userNodeForPackage(LoginConfig.class); 
    124             String servers = null; 
    125             servers = userPrefs.get(LoginConfig.OMERO_SERVER, servers); 
    126             String listOfServers = null; 
    127             if (servers == null) { 
    128                 listOfServers = uc.getHostName(); 
    129             } else { 
    130                 String[] l =  
    131                         servers.split(LoginConfig.SERVER_NAME_SEPARATOR, 0); 
    132                 if (l == null || l.length == 0) { 
    133                     listOfServers = uc.getHostName(); 
    134                 } else { 
    135                     int n = l.length-1; 
    136                     String name = uc.getHostName(); 
    137                     String host; 
    138                     String list = ""; 
    139                     for (int index = 0; index < l.length; index++) { 
    140                         host = l[index].trim(); 
    141                         list.trim(); 
    142                         if (!name.equals(host)) { 
    143                             list += host; 
    144                             if (index != n)  
    145                                 list += LoginConfig.SERVER_NAME_SEPARATOR; 
    146                         } 
    147                     } 
    148                     listOfServers = uc.getHostName()+ 
    149                         LoginConfig.SERVER_NAME_SEPARATOR+list; 
    150                 } 
    151             } 
    152             if (listOfServers != null) 
    153                 userPrefs.put(LoginConfig.OMERO_SERVER, listOfServers); 
    154  
    155121            return true; 
    156122        } catch (DSOutOfServiceException dsose) {  //Log failure. 
    … …  
    234200            UserNotifier un = container.getRegistry().getUserNotifier(); 
    235201            un.notifyError("Login Failure",  
    236                            "Failed to log onto OMERO. Please check your user "+ 
    237                            "name and/or password or try again later."); 
     202                           "Failed to log onto OMERO.\n" + 
     203                           "Please check your user name\n"+ 
     204                           "and/or password or try again later."); 
    238205        } 
    239206        state = IDLE; 
  • trunk/SRC/org/openmicroscopy/shoola/env/ui/LoginOMEDSManager.java

    r4717 r4767  
    9595    private void handleServerSelection() 
    9696    { 
    97         view.server.setEditable( 
    98                 (view.server.getSelectedItem().equals( 
    99                         LoginConfig.DEFAULT_SERVER))); 
     97        //view.server.setEditable( 
     98        //        (view.server.getSelectedItem().equals( 
     99         //               LoginConfig.DEFAULT_SERVER))); 
    100100    } 
    101101     
  • trunk/SRC/org/openmicroscopy/shoola/env/ui/SplashScreenManager.java

    r4762 r4767  
    7777         
    7878    /** The client's version. */ 
    79     private static final String     VERSION = "3.0_Beta2"; 
     79    private static final String     VERSION = "3.0_Beta2 OLD SERVER"; 
    8080     
    8181        /** The component's UI. */ 
  • trunk/SRC/org/openmicroscopy/shoola/util/ui/lens/LensComponent.java

    r4761 r4767  
    330330         
    331331        /** 
    332          * Set the colour of the lens border to a the colour specified.  
    333          *  
    334          * @param col new colour of the lens. 
    335          */ 
    336         public void setLensColour(Color col) 
    337         { 
    338                 lens.setLensColour(col); 
     332         * Sets the colour of the lens border to the colour specified.  
     333         *  
     334         * @param color The color to set. 
     335         */ 
     336        public void setLensColour(Color color) 
     337        { 
     338                if (color == null) return; 
     339                lens.setLensColour(color); 
    339340        } 
    340341         
  • trunk/SRC/org/openmicroscopy/shoola/util/ui/lens/LensModel.java

    r4759 r4767  
    110110        private int            zoomedDataBufferSize = DEFAULT_SIZE; 
    111111         
    112         /** 
    113          * Constructor of the lens Model. 
    114          *  
    115          * @param planeImage  
    116          * 
    117          */ 
    118         LensModel(BufferedImage planeImage) 
    119         { 
    120                 this.planeImage = planeImage; 
    121         } 
    122  
    123         /**  
    124          * Set the plane image to a new image. 
    125          *   
    126          * @param img new PlaneImage. 
    127          */ 
    128         void setPlaneImage(BufferedImage img) { planeImage = img; } 
    129          
    130         /** 
    131          * Gets the width of the plane Image. 
    132          *  
    133          * @return see above. 
    134          */ 
    135         int     getImageWidth() 
    136         { 
    137                 if (planeImage != null ) return planeImage.getWidth(); 
    138                 return 0; 
    139         } 
    140          
    141         /** 
    142          * Gets the width of the plane Image. 
    143          *  
    144          * @return see above. 
    145          */ 
    146         int     getImageScaledWidth() 
    147         { 
    148                 if (planeImage != null ) 
    149                         return (int)(planeImage.getWidth()*imageZoomFactor); 
    150                 return 0; 
    151         } 
    152  
    153         /** 
    154          * Gets the height of the plane Image. 
    155          *  
    156          * @return height see above. 
    157          */ 
    158         int     getImageScaledHeight() 
    159         { 
    160                 if (planeImage != null ) 
    161                         return (int)(planeImage.getHeight()*imageZoomFactor); 
    162                 return 0; 
    163         } 
    164         /** 
    165          * Gets the height of the plane Image. 
    166          *  
    167          * @return height see above. 
    168          */ 
    169         int     getImageHeight() 
    170         { 
    171                 if (planeImage != null ) return planeImage.getHeight(); 
    172                 return 0; 
    173         } 
    174  
    175         /** 
    176      * Returns the zoomedImage from the model.  
    177      *  
    178      * @return zoomedImage.  
    179      */ 
    180         BufferedImage getZoomedImage() 
    181         { 
    182                 if (planeImage == null) return null; 
    183                 ColorModel cm = planeImage.getColorModel(); 
    184                 Raster r = planeImage.getData().createChild(getX(),  
    185                                             getY(), getWidth(), getHeight(), 0, 0, null); 
    186                 BufferedImage img = new BufferedImage(cm, (WritableRaster) r, false, 
    187                                                                                                                                         null); 
    188                 return scaleBufferedImage(img, zoomFactor, zoomFactor);  
    189         } 
    190          
    191         /** 
    192          * Gets the height of the lens.  
    193          *  
    194          * @return the height 
    195          */ 
    196         int getHeight() { return height; } 
    197          
    198         /** 
    199          * Get the width of the lens.  
    200          *  
    201          * @return the width 
    202          */ 
    203         int getWidth() { return width; }         
    204      
    205     /** 
    206          * Gets the height of the lens.  
    207          *  
    208          * @return the height 
    209          */ 
    210          
    211         int getScaledHeight() { return (int) Math.ceil(height*imageZoomFactor); } 
    212          
    213         /** 
    214          * Gets the width of the lens.  
    215          *  
    216          * @return the width 
    217          */ 
    218         int getScaledWidth() { return (int) Math.ceil(width*imageZoomFactor); } 
    219  
    220         /** 
    221          * Gets the x coordinate of the lens. 
    222          *  
    223          * @return the x 
    224          */ 
    225         int getX() { return x; } 
    226  
    227         /** 
    228          * Gets the y coordinate of the lens. 
    229  
    230          * @return the y 
    231          */ 
    232         int getY() { return y; } 
    233      
    234         /** 
    235          * Gets the x coordinate of the lens. 
    236          *  
    237          * @return the x 
    238          */ 
    239  
    240         int getScaledX() { return (int)(x*imageZoomFactor); } 
    241  
    242         /** 
    243          * Gets the y coordinate of the lens. 
    244      *  
    245          * @return the y 
    246          */ 
    247         int getScaledY() { return (int)(y*imageZoomFactor); } 
    248  
    249         /** 
    250          * Sets the height of the lens.  
    251          *  
    252          * @param height the height to set. 
    253          */ 
    254         void setHeight(int height)  { this.height = height; } 
    255  
    256         /** 
    257          * Sets the width of the lens.  
    258          *  
    259          * @param width the width to set. 
    260          */ 
    261         void setWidth(int width) { this.width = width; } 
    262  
    263         /** 
    264          * Sets the X coordinate of the lens.  
    265          *  
    266          * @param x the x to set. 
    267          */ 
    268         void setX(int x) { this.x = x; } 
    269  
    270         /** 
    271          * Sets the y-Coordinate of the lens.  
    272          *  
    273          * @param y the y to set. 
    274          */ 
    275         void setY(int y) { this.y = y; } 
    276  
    277         /** 
    278          * Sets the location of the lens. 
    279          *  
    280          * @param x x-coordinate 
    281          * @param y y-coordinate 
    282          */ 
    283         void setLensLocation(int x, int y) 
    284         { 
    285                 setX(x); 
    286                 setY(y); 
    287         } 
    288          
    289         /** 
    290          * Gets the current Zoomfactor of the lens.  
    291          *  
    292          * @return the zoomFactor 
    293          */ 
    294         float getZoomFactor() { return zoomFactor; } 
    295  
    296         /** 
    297      * Sets the zoom factor. 
    298      *  
    299          * @param zoomFactor the zoomFactor to set 
    300          */ 
    301         void setZoomFactor(float zoomFactor) { this.zoomFactor = zoomFactor; } 
    302          
    303         /** 
    304          * Sets the image zoom factor. The image in the viewer has been zoomed by 
    305          * this number. 
    306          *  
    307          * @param imageZoomFactor the amount of zooming that has occurred on the  
    308          * image.  
    309          */ 
    310         void setImageZoomFactor(float imageZoomFactor) 
    311         { 
    312                 this.imageZoomFactor = imageZoomFactor; 
    313         } 
    314  
    315         /** 
    316          * Returns the image zoom factor. The image in the viewer has been zoomed by 
    317          * this number. 
    318          *  
    319          * @return see above. 
    320          */ 
    321         float getImageZoomFactor() { return imageZoomFactor; } 
    322          
     112 
    323113        /** 
    324114         * Returns a writable raster to the {@link #scaleBufferedImage} method. 
    … …  
    341131         
    342132        /** 
    343         * Scales the image to the new size xScale, yScale. 
    344         *  
    345     * @param image      Buffered Image to be scaled. 
    346     * @param xScale     x scale factor for image, as a percent.  
    347     * @param yScale     y scale factor for image, as a percent. 
    348     * @return thumbImage scaled image. 
    349     * @see ome.api.IScale#scaleBufferedImage(BufferedImage, float, float) 
    350     */ 
     133         * Scales the image to the new size xScale, yScale. 
     134         *  
     135        * @param image         Buffered Image to be scaled. 
     136        * @param xScale        x scale factor for image, as a percent.  
     137        * @param yScale        y scale factor for image, as a percent. 
     138        * @return thumbImage scaled image. 
     139        * @see ome.api.IScale#scaleBufferedImage(BufferedImage, float, float) 
     140        */ 
    351141    private BufferedImage scaleBufferedImage(BufferedImage image, 
    352142                                            float xScale, float yScale) 
    353143    { 
    354         int thumbHeight = (int) (image.getHeight() * yScale); 
    355         int thumbWidth  = (int) (image.getWidth() * xScale); 
     144        int thumbHeight = (int) (image.getHeight()*yScale); 
     145        int thumbWidth  = (int) (image.getWidth()*xScale); 
    356146         
    357147        // Create the required compatible (thumbnail) buffered image to   
    … …  
    367157        return thumbImage; 
    368158