Skip to content

Commit

Permalink
fix #456 (share match: some visualizers don't show the matched nodes)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Nov 3, 2015
1 parent 4420e70 commit e1aa8a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 30 deletions.
3 changes: 3 additions & 0 deletions annis-gui/src/main/java/annis/gui/EmbeddedVisUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,13 @@ private void generateVisFromRemoteURL(String visName, String rawUri, Map<String,
}

Map<String, String> markedColorMap = new HashMap<>();
Map<String, String> exactMarkedMap =
Helper.calculateColorsForMarkedExact(doc);
Map<String, Long> markedAndCovered = Helper.calculateMarkedAndCoveredIDs(doc, segNodes, baseText);
Helper.calulcateColorsForMarkedAndCovered(doc, markedAndCovered, markedColorMap);
visInput.setMarkedAndCovered(markedAndCovered);
visInput.setMarkableMap(markedColorMap);
visInput.setMarkableExactMap(exactMarkedMap);
visInput.setContextPath(Helper.getContext());
String template = Helper.getContext()
+ "/Resource/" + visName + "/%s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,36 +387,9 @@ public void setVisibleTokenAnnosVisible(SortedSet<String> annos)

private void calculateHelperVariables()
{
markedExactMap = new HashMap<>();
markedCoveredMap = new HashMap<>();

if (result != null)
{
SDocumentGraph g = result.getSDocumentGraph();
if (g != null)
{
for (SNode n : result.getSDocumentGraph().getSNodes())
{

SFeature featMatched = n.getSFeature(ANNIS_NS, FEAT_MATCHEDNODE);
Long matchNum = featMatched == null ? null : featMatched.
getSValueSNUMERIC();

if (matchNum != null)
{
int color = Math.max(0, Math.min((int) matchNum.longValue() - 1,
MatchedNodeColors.values().length - 1));
RelannisNodeFeature feat = RelannisNodeFeature.extract(n);
if (feat != null)
{
markedExactMap.put("" + feat.getInternalID(),
MatchedNodeColors.values()[color].name());
}
}

}
} // end if g not null
} // end if result not null

markedExactMap = Helper.calculateColorsForMarkedExact(result);
}

@Override
Expand Down
34 changes: 33 additions & 1 deletion annis-libgui/src/main/java/annis/libgui/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.common.base.Joiner;
import com.google.common.escape.Escaper;
import com.google.common.escape.Escapers;
import com.google.common.html.HtmlEscapers;
import com.google.common.net.UrlEscapers;
import com.sun.jersey.api.client.AsyncWebResource;
import com.sun.jersey.api.client.Client;
Expand Down Expand Up @@ -940,6 +939,39 @@ public static <T> JsonValue encodeGeneric(Object v)
return JsonCodec.encode(v, null, v.getClass().getGenericSuperclass(), null).
getEncodedValue();
}

public static Map<String, String> calculateColorsForMarkedExact(SDocument result)
{
Map<String, String> markedExactMap = new HashMap<>();
if (result != null)
{
SDocumentGraph g = result.getSDocumentGraph();
if (g != null)
{
for (SNode n : result.getSDocumentGraph().getSNodes())
{

SFeature featMatched = n.getSFeature(ANNIS_NS, FEAT_MATCHEDNODE);
Long matchNum = featMatched == null ? null : featMatched.
getSValueSNUMERIC();

if (matchNum != null)
{
int color = Math.max(0, Math.min((int) matchNum.longValue() - 1,
MatchedNodeColors.values().length - 1));
RelannisNodeFeature feat = RelannisNodeFeature.extract(n);
if (feat != null)
{
markedExactMap.put("" + feat.getInternalID(),
MatchedNodeColors.values()[color].name());
}
}

}
} // end if g not null
} // end if result not null
return markedExactMap;
}

public static void calulcateColorsForMarkedAndCovered(SDocument result,
Map<String, Long> markedAndCovered, Map<String, String> markedCoveredMap)
Expand Down

0 comments on commit e1aa8a1

Please sign in to comment.