Skip to content

Commit

Permalink
Merge pull request #110 from jburel/sprint10-insight
Browse files Browse the repository at this point in the history
Sprint10 insight. All tickets tested by @omeroscott. Merging.
  • Loading branch information
jburel committed Mar 7, 2012
2 parents 796354d + 426f196 commit 8120454
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 182 deletions.
Expand Up @@ -104,7 +104,7 @@ class BrowserControl
private boolean leftMouseButton;

/** The location of the mouse pressed.*/
private Point anchor;
private Point anchor = new Point();

/** The source of the mouse pressed.*/
private Component source;
Expand Down Expand Up @@ -625,6 +625,7 @@ public void mouseDragged(MouseEvent e)
if (e.getSource() != view.getInternalDesktop()) return;
dragging = true;
Point p = e.getPoint();
if (p == null) p = new Point();
selection.width = Math.abs(p.x-anchor.x);
selection.height = Math.abs(p.y-anchor.y);
if (anchor.x < p.x) selection.x = anchor.x;
Expand Down
Expand Up @@ -610,7 +610,7 @@ public GroupData getSelectedGroup()
if (g.getId() == ctx.getGroupID())
return g;
}
return null;
return EditorAgent.getUserDetails().getDefaultGroup();
}

/**
Expand Down
Expand Up @@ -1080,6 +1080,8 @@ public void renderXYPlane()
"This method can't be invoked in the NEW state.");
case LOADING_IMAGE:
case DISCARDED:
case LOADING_BIRD_EYE_VIEW:
case LOADING_RND:
return;
}
if (model.isBigImage()) {
Expand Down Expand Up @@ -3368,9 +3370,10 @@ public void cancelInit()
if (model.isBigImage()) {
model.cancelBirdEyeView();
view.dispose();
fireStateChange();
} else {
model.cancelRendering();
view.getLoadingWindow().setVisible(false);
discard();
fireStateChange();
}
break;
Expand Down
Expand Up @@ -877,12 +877,10 @@ public void stateChanged(ChangeEvent e)
return;
}
int state = model.getState();
LoadingWindow window;
LoadingWindow window = view.getLoadingWindow();
switch (state) {
case ImViewer.DISCARDED:
window = view.getLoadingWindow();
window.setVisible(false);
window.dispose();
window.close();
view.setVisible(false);
if (view.isLensVisible())
view.setLensVisible(false, model.getSelectedIndex());
Expand All @@ -891,18 +889,16 @@ public void stateChanged(ChangeEvent e)
break;
case ImViewer.LOADING_RND:
case ImViewer.LOADING_BIRD_EYE_VIEW:
//view.onStateChange(false);
window = view.getLoadingWindow();
if (!window.isVisible())
UIUtilities.centerAndShow(window);
break;
case ImViewer.CANCELLED:
view.getLoadingWindow().setVisible(false);
window.setVisible(false);
case ImViewer.LOADING_IMAGE:
if (historyState == ImViewer.LOADING_METADATA)
view.getLoadingWindow().setVisible(false);
window.setVisible(false);
view.onStateChange(false);
view.getLoadingWindow().setVisible(false);
window.setVisible(false);
/*
window = view.getLoadingWindow();
if (!window.isVisible())
Expand All @@ -918,7 +914,7 @@ public void stateChanged(ChangeEvent e)
break;
case ImViewer.READY:
view.setStatus(false);
view.getLoadingWindow().setVisible(false);
window.setVisible(false);
if (historyState == ImViewer.CHANNEL_MOVIE)
view.onStateChange(false);
else {
Expand All @@ -927,7 +923,7 @@ public void stateChanged(ChangeEvent e)
}
break;
case ImViewer.LOADING_TILES:
view.getLoadingWindow().setVisible(false);
window.setVisible(false);
view.onStateChange(false);
break;
case ImViewer.CHANNEL_MOVIE:
Expand Down
Expand Up @@ -135,14 +135,11 @@ class ImViewerModel
/** Index of the <code>RenderingSettings</code> loader. */
private static final int SETTINGS = 0;

/** Index of the <code>RenderingControlLoader</code> loader. */
private static final int RND = 1;

/** Index of the <code>ImageLoader</code> loader. */
private static final int IMAGE = 2;
private static final int IMAGE = 1;

/** Index of the <code>ImageLoader</code> loader. */
private static final int BIRD_EYE_BVIEW = 3;
private static final int BIRD_EYE_BVIEW = 2;

/** The image to view. */
private DataObject image;
Expand Down Expand Up @@ -701,10 +698,6 @@ void discard()
if (imageIcon != null) imageIcon.flush();
browser.discard();
if (image == null) return;
//Shut down the service
OmeroImageService svr = ImViewerAgent.getRegistry().getImageService();
long pixelsID = getImage().getDefaultPixels().getId();
svr.shutDown(ctx, pixelsID);
Iterator i = loaders.keySet().iterator();
Integer index;
while (i.hasNext()) {
Expand Down Expand Up @@ -2791,16 +2784,13 @@ void clearTileImages(Collection<Tile> toClear)
/** Cancels the rendering of the image.*/
void cancelRendering()
{
DataLoader loader = loaders.get(IMAGE);
if (loader != null) {
loader.cancel();
firstTime = true;
state = ImViewer.LOADING_IMAGE_CANCELLED;
}
if (metadataViewer == null) return;
Renderer rnd = metadataViewer.getRenderer();
if (rnd != null) rnd.discard();
state = ImViewer.CANCELLED;
}

/**
<<<<<<< HEAD
* Sets the image for the bird eye view.
*
* @param image The image to set.
Expand Down
Expand Up @@ -1103,6 +1103,7 @@ private void clearZoomMenu(ButtonGroup group, JMenu menu)
super(title);
loadingWindow = new LoadingWindow(this);
loadingWindow.setTitle("Opening Image Viewer...");
loadingWindow.setModal(false);
defaultIndex = UnitBarSizeAction.DEFAULT_UNIT_INDEX;
displayMode = NEUTRAL;
bigImageMagnification = 1.0;
Expand Down Expand Up @@ -1304,8 +1305,6 @@ void setColorModel(int key)
*/
void onStateChange(boolean b)
{
//TODO
//model.getRenderer().onStateChange(b);
model.getBrowser().onStateChange(b);
if (tabs != null) {
tabs.setEnabled(b);
Expand Down
Expand Up @@ -23,15 +23,18 @@
package org.openmicroscopy.shoola.agents.measurement;

//Java imports
import java.util.Collection;
import java.util.List;
import java.util.Map;

//Third-party libraries

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.measurement.view.MeasurementViewer;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import org.openmicroscopy.shoola.env.log.LogMessage;
import org.openmicroscopy.shoola.env.ui.UserNotifier;

import pojos.PixelsData;
Expand All @@ -54,27 +57,18 @@
public class Analyser
extends MeasurementViewerLoader
{

/** Indicates to analyze a collection of shapes. */
public static final int SHAPE = 0;

/** Indicates to analyze a collection of ROIs. */
public static final int ROI = 1;

/** The pixels set to analyze. */
private PixelsData pixels;

/** One of the constants defined by this class. */
private int index;

private PixelsData pixels;

/** Collection of active channels. */
private List channels;
private Collection channels;

/** Collection of shapes to analyze. */
private List shapes;
private List shapes;

/** Handle to the asynchronous call so that we can cancel it. */
private CallHandle handle;
private CallHandle handle;

/**
* Creates a new instance.
Expand All @@ -89,7 +83,7 @@ public class Analyser
* Mustn't be <code>null</code>.
*/
public Analyser(MeasurementViewer viewer, SecurityContext ctx,
PixelsData pixels, List channels, List shapes)
PixelsData pixels, Collection channels, List shapes)
{
super(viewer, ctx);
if (channels == null || channels.size() == 0)
Expand All @@ -99,7 +93,6 @@ public Analyser(MeasurementViewer viewer, SecurityContext ctx,
this.pixels = pixels;
this.channels = channels;
this.shapes = shapes;
index = SHAPE;
}

/**
Expand All @@ -108,16 +101,7 @@ public Analyser(MeasurementViewer viewer, SecurityContext ctx,
*/
public void load()
{
switch (index) {
case SHAPE:
handle = idView.analyseShapes(ctx, pixels, channels, shapes,
this);
break;
case ROI:
handle = idView.analyseShapes(ctx, pixels, channels, shapes,
this);
break;
}
handle = idView.analyseShapes(ctx, pixels, channels, shapes, this);
}

/**
Expand All @@ -131,6 +115,24 @@ public void handleNullResult()
"the data.");
}

/**
* Notifies the user that an error has occurred.
* @see DSCallAdapter#handleException(Throwable)
*/
public void handleException(Throwable exc)
{
int state = viewer.getState();
String s = "Data Retrieval Failure: ";
LogMessage msg = new LogMessage();
msg.print("State: "+state);
msg.print(s);
msg.print(exc);
registry.getLogger().error(this, msg);
UserNotifier un = registry.getUserNotifier();
un.notifyInfo("Analysing data", "An error occurred while analysing " +
"the data.");
}

/**
* Cancels the data loading.
* @see MeasurementViewerLoader#cancel()
Expand All @@ -143,8 +145,8 @@ public void handleNullResult()
*/
public void handleResult(Object result)
{
if (viewer.getState() == MeasurementViewer.DISCARDED) return; //Async cancel.
if (viewer.getState() == MeasurementViewer.DISCARDED) return;
viewer.setStatsShapes((Map) result);
}

}
Expand Up @@ -73,13 +73,13 @@ public static Map<StatsType, Map> convertStats(Map shapeStats)
{
if (shapeStats == null || shapeStats.size() == 0) return null;
ROIShapeStats stats;
Map<Integer, Double> channelMin = new TreeMap<Integer, Double>();
Map<Integer, Double> channelSum = new TreeMap<Integer, Double>();
Map<Integer, Double> channelMax = new TreeMap<Integer, Double>();
Map<Integer, Double> channelMean = new TreeMap<Integer, Double>();
Map<Integer, Double> channelStdDev = new TreeMap<Integer, Double>();
Map<Integer, double[]> channelData = new TreeMap<Integer, double[]>();
Map<Integer, Map<Point, Double>> channelPixel =
Map<Integer, Double> channelMin = new TreeMap<Integer, Double>();
Map<Integer, Double> channelSum = new TreeMap<Integer, Double>();
Map<Integer, Double> channelMax = new TreeMap<Integer, Double>();
Map<Integer, Double> channelMean = new TreeMap<Integer, Double>();
Map<Integer, Double> channelStdDev = new TreeMap<Integer, Double>();
Map<Integer, double[]> channelData = new TreeMap<Integer, double[]>();
Map<Integer, Map<Point, Double>> channelPixel =
new TreeMap<Integer, Map<Point, Double>>();
Iterator<Double> pixelIterator;
Map<Point, Double> pixels;
Expand Down Expand Up @@ -112,6 +112,7 @@ public static Map<StatsType, Map> convertStats(Map shapeStats)
}

channelData.put(channel, pixelData);
pixels.clear();
}
Map<StatsType, Map>
statsMap = new HashMap<StatsType, Map>(StatsType.values().length);
Expand All @@ -127,5 +128,3 @@ public static Map<StatsType, Map> convertStats(Map shapeStats)
}

}


0 comments on commit 8120454

Please sign in to comment.