import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import javax.xml.bind.DatatypeConverter;
import javax.xml.parsers.*;
{
OntologyTerm term = new OntologyTerm();
term.setAccessionId(array.getJSONObject(i).getString("accession_id"));
- term.setName(array.getJSONObject(i).getString("match"));
+ term.setName(formatizeToUnescapeHTML(array.getJSONObject(i).getString("match")));
terms.add(term);
}
in.close();
return terms;
}
+ public static String formatizeToUnescapeHTML(String term)
+ {
+ Pattern pattern = Pattern.compile("&#[0-9]+");
+ Matcher matcher = pattern.matcher(term);
+ StringBuffer formattedTerm = new StringBuffer();
+ while (matcher.find()) {
+ String matchedText = matcher.group();
+ matcher.appendReplacement(formattedTerm, matchedText + ";");
+ }
+ matcher.appendTail(formattedTerm);
+ return formattedTerm.toString();
+ }
+
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.*;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.operation.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
if(view.getContext().isEnabled())
{
OntologyTerm term = new OntologyTerm();
- term.setName((String)comboLabel.getData(comboLabel.getText()));
+ term.setName((String)comboLabel.getData(formatizeToUnescapeHTML(comboLabel.getText())));
term.setAccessionId(parseAccessionIdFromComboLabel(comboLabel));
view.getContext().getEnabledMask().ontologyTerm = term;
}
});
}
+ public static String formatizeToUnescapeHTML(String term)
+ {
+ Pattern pattern = Pattern.compile("&#[0-9]+");
+ Matcher matcher = pattern.matcher(term);
+ StringBuffer formattedTerm = new StringBuffer();
+ while (matcher.find()) {
+ String matchedText = matcher.group();
+ matcher.appendReplacement(formattedTerm, matchedText + ";");
+ }
+ matcher.appendTail(formattedTerm);
+ return formattedTerm.toString();
+ }
+
/**
* For dropping down the labels on pressing the down arrow key just like "Google suggests" functionality.
* @param e
for (int j=0; j<synArray.length(); j++) {
TableItem item = new TableItem (termSynonymTable, SWT.NONE);
- item.setText(0,synArray.getString(j));
+ item.setText(0,formatizeToUnescapeHTML(synArray.getString(j)));
}
termSynonymTable.getColumn(0).pack();
termSynonymTable.pack();
termDetailTable.pack();
}
- public void clearTermDetailTable() {
+ public static void clearTermDetailTable() {
TableItem[] items = termDetailTable.getItems();
for(int i=0; i<items.length; i++)
{
}
}
- public void clearTermSynonymTable() {
+ public static void clearTermSynonymTable() {
TableItem[] items = termSynonymTable.getItems();
for(TableItem item : items)
{
{
view.getTool().detach();
}
+
+ String segmentName = view.getContext().getEnabledMask().ontologyTerm.getName();
+ if (segmentName.equals("")) {
+ clearCurrentSegmentAnnotation();
+ }
}
else
{
updateToolStates();
}
+ /**
+ * Clears annotation details of currently highlighted segment
+ */
+
+ public static void clearCurrentSegmentAnnotation() {
+ SegmentationView.comboLabel.removeAll();
+ SegmentationView.clearTermDetailTable();
+ SegmentationView.clearTermSynonymTable();
+ }
+
/**
* Forms a segmentation object based on the current view skipping previous segmentation objects.
*/
view.getContext().formSegmentationObject();
updateToolStates();
}
-
- /**
- * Predicts the segments in the image using active learning.
- */
- /*public void predictSegments() {
- SIFTDescriptor sift = new SIFTDescriptor();
- sift.calculateDescriptors(view.getContext().getImage());
- updateToolStates();
- }*/
-
+
public boolean isAutoApply() {
return this.auto;
}
public void mouseUp(MouseEvent event) {
Point mouseClickedPoint = new Point(event.x,event.y);
- // For the right click
- if(event.button == 3)
- { /* // JP - don't want this functionality right now
- PopUpLabelDialog dialog = new PopUpLabelDialog(getShell());
- PopUpLabelDialog.Result result = dialog.open();
- if (result != null)
- {
- String lab = null;
- if(result.comboText.indexOf('{') != -1)
- {
- lab = result.comboText.substring(0,result.comboText.indexOf('{')-1);
- }
- else
- {
- lab = result.comboText;
- }
- System.out.println("selected"+lab);
- //comboLabel.setText(result.comboText);
- //execute(Tool.AssignButton, null);
- }*/
- }
- else if(event.button == 1)
+ if(event.button == 1)
{
if(view.imageContains(mouseClickedPoint))
{
// For setting the comboLabel value and tooltip on clicking a segment
String segmentName = ctx.getEnabledMask().ontologyTerm.getName();
getCanvas().setToolTipText(segmentName);
- SegmentationView.comboLabel.setText(segmentName);
- SegmentationView.termDetailLookup(ctx.getEnabledMask().ontologyTerm.getAccessionId());
+ if (segmentName.equals("")) {
+ SegmentationView.clearCurrentSegmentAnnotation();
+ }
+ else {
+ SegmentationView.comboLabel.setText(segmentName);
+ SegmentationView.termDetailLookup(ctx.getEnabledMask().ontologyTerm.getAccessionId());
+ }
}
repaint();
}