• 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 5673

Show
Ignore:
Timestamp:
10/10/08 11:46:07 (6 weeks ago)
Author:
jburel
Message:

Improved code so that we don't have the OOM exception

Location:
branches/Beta3.1/SRC/org/openmicroscopy/shoola
Files:
14 modified

  • agents/measurement/view/MeasurementViewer.java (modified) (1 diff)
  • agents/measurement/view/MeasurementViewerComponent.java (modified) (2 diffs)
  • agents/measurement/view/MeasurementViewerControl.java (modified) (8 diffs)
  • agents/measurement/view/MeasurementViewerModel.java (modified) (1 diff)
  • env/rnd/roi/PointIterator.java (modified) (3 diffs)
  • env/rnd/roi/ROIAnalyser.java (modified) (3 diffs)
  • util/roi/figures/MeasureBezierFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasureEllipseFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasureLineConnectionFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasureLineFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasurePointFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasureRectangleFigure.java (modified) (2 diffs)
  • util/roi/figures/MeasureTextFigure.java (modified) (3 diffs)
  • util/roi/figures/ROIFigure.java (modified) (2 diffs)

Legend:

Unmodified
Added
Removed
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/agents/measurement/view/MeasurementViewer.java

    r5616 r5673  
    241241         * @param shape The list of ROIShapes to analyse. Mustn't be <code>null</code>. 
    242242         */ 
    243         public void analyseShapeList(ArrayList<ROIShape> shape); 
     243        public void analyseShapeList(List<ROIShape> shape); 
    244244 
    245245         
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/agents/measurement/view/MeasurementViewerComponent.java

    r5616 r5673  
    650650         * @see MeasurementViewer#analyseShapeList(ArrayList) 
    651651         */ 
    652         public void analyseShapeList(ArrayList<ROIShape> shapeList) 
     652        public void analyseShapeList(List<ROIShape> shapeList) 
    653653        { 
    654654                if (shapeList == null) 
    … …  
    664664                                 
    665665                        case ANALYSE_SHAPE: 
    666                                 model.cancel(); 
    667                                 break; 
     666                                //model.cancel(); 
     667                                //break; 
     668                                return; 
    668669                } 
    669670                if (model.getActiveChannels().size() == 0) return; 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/agents/measurement/view/MeasurementViewerControl.java

    r5541 r5673  
    2828import java.awt.event.KeyEvent; 
    2929import java.awt.event.KeyListener; 
     30import java.awt.event.MouseAdapter; 
     31import java.awt.event.MouseEvent; 
    3032import java.awt.event.WindowAdapter; 
    3133import java.awt.event.WindowEvent; 
    … …  
    3739import java.util.HashMap; 
    3840import java.util.Iterator; 
     41import java.util.List; 
    3942import java.util.Map; 
    4043import java.util.TreeMap; 
    … …  
    6265import org.openmicroscopy.shoola.agents.measurement.actions.ShowROIAssistant; 
    6366import org.openmicroscopy.shoola.agents.measurement.actions.UnitsAction; 
     67import org.openmicroscopy.shoola.util.roi.figures.MeasureLineFigure; 
     68import org.openmicroscopy.shoola.util.roi.figures.MeasurePointFigure; 
    6469import org.openmicroscopy.shoola.util.roi.figures.MeasureTextFigure; 
    6570import org.openmicroscopy.shoola.util.roi.figures.ROIFigure; 
    … …  
    161166 
    162167    /** 
     168     * Sets the status of the currently selected Region of Interest. 
     169     *  
     170     * @param status The value to set. 
     171     */ 
     172    private void setROIFigureStatus(int status) 
     173    { 
     174        Collection<Figure> selectedFigures =  
     175                                view.getDrawingView().getSelectedFigures();  
     176        if (selectedFigures.size() != 1) return; 
     177        Iterator<Figure> i = selectedFigures.iterator(); 
     178        Figure fig; 
     179        ROIFigure roiFigure; 
     180        while (i.hasNext()) { 
     181                fig =  i.next(); 
     182                if (fig instanceof ROIFigure) { 
     183                        roiFigure = (ROIFigure) fig; 
     184                        roiFigure.setStatus(status); 
     185                        handleFigureChange(roiFigure); 
     186                } 
     187        } 
     188    } 
     189     
     190    /** 
     191     * Handles the selection of new Region of Interest. 
     192     *  
     193     * @param figure The value to handle. 
     194     */ 
     195    private void handleFigureChange(ROIFigure figure) 
     196        { 
     197        //TODO clean that code 
     198        if ((figure instanceof MeasureLineFigure) ||  
     199                                (figure instanceof MeasurePointFigure)) { 
     200                figure.calculateMeasurements(); 
     201                view.refreshResultsTable(); 
     202                model.setDataChanged(); 
     203                if (!view.inDataView()) return; 
     204                ROIShape shape = figure.getROIShape(); 
     205                List<ROIShape> shapeList = new ArrayList<ROIShape>(); 
     206                ROI roi = shape.getROI(); 
     207                TreeMap<Coord3D, ROIShape> shapeMap = roi.getShapes(); 
     208                Iterator<Coord3D> shapeIterator = shapeMap.keySet().iterator(); 
     209                while (shapeIterator.hasNext()) 
     210                        shapeList.add(shapeMap.get(shapeIterator.next())); 
     211                 
     212                if (shapeList.size() != 0) 
     213                        model.analyseShapeList(shapeList); 
     214                return; 
     215                } 
     216         
     217                if (figure.getStatus() != ROIFigure.IDLE) return; 
     218                figure.calculateMeasurements(); 
     219                view.refreshResultsTable(); 
     220                model.setDataChanged(); 
     221                if (!view.inDataView()) return; 
     222                ROIShape shape = figure.getROIShape(); 
     223                List<ROIShape> shapeList = new ArrayList<ROIShape>(); 
     224                ROI roi = shape.getROI(); 
     225                TreeMap<Coord3D, ROIShape> shapeMap = roi.getShapes(); 
     226                Iterator<Coord3D> shapeIterator = shapeMap.keySet().iterator(); 
     227                while (shapeIterator.hasNext()) 
     228                        shapeList.add(shapeMap.get(shapeIterator.next())); 
     229                 
     230                if (shapeList.size() != 0) 
     231                        model.analyseShapeList(shapeList); 
     232        } 
     233     
     234    /** 
    163235     * Creates a new instance. 
    164236     * The {@link #initialize(MeasurementViewer, MeasurementViewerUI) initialize}  
    … …  
    205277                 view.addWindowFocusListener(this); } 
    206278         }); 
     279         view.getDrawingView().addMouseListener(new MouseAdapter() { 
     280                         
     281                        public void mouseReleased(MouseEvent e) 
     282                        { 
     283                                setROIFigureStatus(ROIFigure.IDLE); 
     284                        } 
     285                 
     286                        public void mousePressed(MouseEvent e) 
     287                        { 
     288                                setROIFigureStatus(ROIFigure.MOVING); 
     289                        } 
     290                 
     291                }); 
     292          
    207293    } 
    208294     
    … …  
    319405                Figure f = e.getFigure(); 
    320406                if (!(f instanceof ROIFigure)) return; 
     407 
    321408                ROIFigure roiFigure = (ROIFigure) f; 
     409                roiFigure.setStatus(ROIFigure.MOVING); 
    322410                view.addROI(roiFigure); 
    323411                roiFigure.addFigureListener(this); 
    … …  
    325413                if (!view.inDataView()) return; 
    326414                ROIShape shape = roiFigure.getROIShape(); 
    327                 if (view.inDataView()) 
    328                 { 
    329                         ArrayList<ROIShape> shapeList = new ArrayList<ROIShape>(); 
    330                         ROI roi = shape.getROI(); 
    331                         TreeMap<Coord3D, ROIShape> shapeMap = roi.getShapes(); 
    332                         Iterator<Coord3D> shapeIterator = shapeMap.keySet().iterator(); 
    333                         while (shapeIterator.hasNext()) 
    334                                 shapeList.add(shapeMap.get(shapeIterator.next())); 
    335                         if (shapeList.size() != 0) model.analyseShapeList(shapeList); 
     415                List<ROIShape> shapeList = new ArrayList<ROIShape>(); 
     416                ROI roi = shape.getROI(); 
     417                TreeMap<Coord3D, ROIShape> shapeMap = roi.getShapes(); 
     418                Iterator<Coord3D> shapeIterator = shapeMap.keySet().iterator(); 
     419                while (shapeIterator.hasNext()) 
     420                        shapeList.add(shapeMap.get(shapeIterator.next())); 
     421                if (shapeList.size() == 0) return; 
     422                if ((f instanceof MeasureLineFigure) ||  
     423                                (f instanceof MeasurePointFigure)) { 
     424                        roiFigure.setStatus(ROIFigure.IDLE); 
     425                        model.analyseShapeList(shapeList); 
    336426                } 
    337427        } 
    … …  
    401491                if (f instanceof ROIFigure) { 
    402492                        ROIFigure roiFigure = (ROIFigure) f; 
    403                         roiFigure.calculateMeasurements(); 
    404                         view.refreshResultsTable(); 
    405                         model.setDataChanged(); 
    406                         if (view.inDataView()) { 
    407                                  
    408                                 ROIShape shape = roiFigure.getROIShape(); 
    409                                 ArrayList<ROIShape> shapeList = new ArrayList<ROIShape>(); 
    410                                 ROI roi = shape.getROI(); 
    411                                 TreeMap<Coord3D, ROIShape> shapeMap = roi.getShapes(); 
    412                                 Iterator<Coord3D> shapeIterator = shapeMap.keySet().iterator(); 
    413                                 while (shapeIterator.hasNext()) 
    414                                         shapeList.add(shapeMap.get(shapeIterator.next())); 
    415                                  
    416                                 if (shapeList.size() != 0) 
    417                                         model.analyseShapeList(shapeList); 
    418                         } 
     493                        handleFigureChange(roiFigure); 
    419494                } 
    420495        } 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/agents/measurement/view/MeasurementViewerModel.java

    r5508 r5673  
    810810         * @param shapeList The shapelist to analyse. Mustn't be <code>null</code>. 
    811811         */ 
    812         void fireAnalyzeShape(ArrayList<ROIShape> shapeList) 
    813         { 
    814                 if(getState() == MeasurementViewer.ANALYSE_SHAPE) 
    815                         return; 
     812        void fireAnalyzeShape(List<ROIShape> shapeList) 
     813        { 
    816814                state = MeasurementViewer.ANALYSE_SHAPE; 
    817815                List channels = new ArrayList(activeChannels.size()); 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/env/rnd/roi/PointIterator.java

    r5004 r5673  
    270270     *  
    271271     * @param shape     The shape to analyse. Mustn't be <code>null</code>. 
     272     * @param points    The points contained within the Region of Interest. 
    272273     * @param w                 The selected channel.  
    273274     * @throws DataSourceException  If an error occurs while retrieving plane 
    274275     *                              data from the pixels source. 
    275276     */ 
    276     public void iterate(ROIShape shape, int w)  
     277    public void iterate(ROIShape shape,  PlanePoint2D[] points, int w)  
    277278        throws DataSourceException 
    278279    { 
    … …  
    280281        if (w < 0 || w >= sizeC)  
    281282                throw new NullPointerException("Channel not valid."); 
    282         ROIFigure selection2D; 
    283         PlanePoint2D[] points; 
    284283        notifyIterationStart(); 
    285284        try {  //Iterate in ZWT order and notify observers. 
    … …  
    287286                int t = shape.getT(); 
    288287                if (z >= 0 && z < sizeZ && t >= 0 && t < sizeT) { 
    289                         selection2D = shape.getFigure(); 
    290                         points = selection2D.getPoints(); 
    291288                        notifyPlaneStart(z, w, t, points.length); 
    292289                        Plane2D data = source.getPlane(z, t, w); 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/env/rnd/roi/ROIAnalyser.java

    r5004 r5673  
    3535import org.openmicroscopy.shoola.env.rnd.data.DataSink; 
    3636import org.openmicroscopy.shoola.env.rnd.data.DataSourceException; 
     37import org.openmicroscopy.shoola.util.math.geom2D.PlanePoint2D; 
    3738import org.openmicroscopy.shoola.util.roi.model.ROIShape; 
    3839 
    … …  
    152153                stats = new HashMap<Integer, ROIShapeStats>(n); 
    153154                j = channels.iterator(); 
     155                PlanePoint2D[] points = shape.getFigure().getPoints(); 
    154156                while (j.hasNext()) { 
    155157                                w = (Integer) j.next(); 
    … …  
    157159                                computer =  new ROIShapeStats(); 
    158160                                runner.register(computer); 
    159                                 runner.iterate(shape, w.intValue()); 
     161                                runner.iterate(shape, points, w.intValue()); 
    160162                                runner.remove(computer); 
    161163                                stats.put(w, computer); 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureBezierFigure.java

    r5545 r5673  
    9696        private MeasurementUnits                units; 
    9797                 
     98        private int                                     status; 
     99         
    98100        /** Create an instance of the bezier figure. */ 
    99101        public MeasureBezierFigure() 
    … …  
    534536        } 
    535537         
     538        public void setStatus(int status) { this.status = status; } 
     539         
     540        public int getStatus() { return status; } 
     541         
    536542} 
    537543 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureEllipseFigure.java

    r5502 r5673  
    7878        private MeasurementUnits        units; 
    7979         
     80        private int                             status; 
     81         
    8082        /** Creates a new instance. */ 
    8183        public MeasureEllipseFigure() 
    … …  
    507509        } 
    508510         
     511        public void setStatus(int status) { this.status = status; } 
     512         
     513        public int getStatus() { return status; } 
     514         
     515         
    509516} 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureLineConnectionFigure.java

    r5194 r5673  
    8787        /** The Measurement units, and values of the image. */ 
    8888        private MeasurementUnits                units; 
     89         
     90        private int                                     status; 
    8991         
    9092        /** 
    … …  
    489491        } 
    490492         
     493        public void setStatus(int status) { this.status = status; } 
     494         
     495        public int getStatus() { return status; } 
     496         
    491497} 
    492498 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureLineFigure.java

    r5194 r5673  
    9292        /** The Measurement units, and values of the image. */ 
    9393        private MeasurementUnits                units; 
     94         
     95        private int                                     status; 
    9496         
    9597        /** 
    … …  
    504506        } 
    505507         
     508        public void setStatus(int status) { this.status = status; } 
     509         
     510        public int getStatus() { return status; } 
     511         
    506512} 
    507513 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasurePointFigure.java

    r5009 r5673  
    7575        /** The Measurement units, and values of the image. */ 
    7676        private MeasurementUnits                units; 
     77         
     78        private int                                     status; 
    7779         
    7880          /**  
    … …  
    341343        } 
    342344         
     345        public void setStatus(int status) { this.status = status; } 
     346         
     347        public int getStatus() { return status; } 
     348         
    343349} 
    344350 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureRectangleFigure.java

    r5009 r5673  
    7979        private MeasurementUnits                units; 
    8080            
     81        private int                                     status; 
     82         
    8183    /** Creates a new instance. */ 
    8284    public MeasureRectangleFigure()  
    … …  
    375377        } 
    376378         
     379        public void setStatus(int status) { this.status = status; } 
     380         
     381        public int getStatus() { return status; } 
     382         
     383         
    377384} 
    378385 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/MeasureTextFigure.java

    r5194 r5673  
    6565        private MeasurementUnits        units; 
    6666         
     67        private int                             status; 
     68         
    6769    /** Creates a new instance. Default value <code>(0, 0) </code>.*/ 
    6870    public MeasureTextFigure()  
    … …  
    8587        shape = null; 
    8688                roi = null; 
     89                status = IDLE; 
    8790    } 
    8891 
    … …  
    140143        public PlanePoint2D[] getPoints() {  return null; } 
    141144         
     145        public void setStatus(int status) { this.status = status; } 
     146         
     147        public int getStatus() { return status; } 
     148         
    142149} 
    143150 
  • branches/Beta3.1/SRC/org/openmicroscopy/shoola/util/roi/figures/ROIFigure.java

    r5009 r5673  
    5252{ 
    5353                 
     54        /** Identified the <code>IDLE</code> status. */ 
     55        public static final int IDLE = 0; 
     56         
     57        /** Identified the <code>MOVING</code> status. */ 
     58        public static final int MOVING = 1; 
     59         
    5460        /**  
    5561         * Sets the measurement units of the ROIFigure.  
    … …  
    109115    public PlanePoint2D[] getPoints(); 
    110116     
     117        /** 
     118         * Sets the status of the figure. 
     119         *  
     120         * @param status The value to set. 
     121         */ 
     122        public void setStatus(int status); 
     123         
     124        /** 
     125         * Returns the status of the figure. 
     126         *  
     127         * @return See above. 
     128         */ 
     129        public int getStatus(); 
     130         
    111131} 
    112132 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/