Skip to content

Commit

Permalink
fixes #145
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldrama committed Jun 20, 2013
2 parents 3fabc4d + 28af3e3 commit 60cc7ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public interface PDFController extends Plugin, Serializable
*
*/
public void openPDF(String resultID, String pageNumber);

/**
* Informs about the number of already registered pdf viewer.
*
* @return the number of registered pdf viewer.
*/
public int sizeOfRegisterdPDFViewer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ public void openPDF(String resultID, String page)
lock.readLock().unlock();
}
}

@Override
public int sizeOfRegisterdPDFViewer()
{
return registeredPDFViewer != null ? registeredPDFViewer.size() : 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import annis.gui.widgets.grid.GridEvent;
import annis.gui.widgets.grid.Row;
import annis.libgui.PDFPageHelper;
import annis.libgui.media.PDFController;
import annis.libgui.media.TimeHelper;
import annis.libgui.visualizers.VisualizerInput;
import static annis.model.AnnisConstants.ANNIS_NS;
Expand Down Expand Up @@ -71,13 +72,15 @@ public class EventExtractor {
* @param annotationNames
* @param startTokenIndex token index of the first token in the match
* @param endTokenIndex token index of the last token in the match
* @param pdfController makes status of all pdfviewer available for the
* events.
* @return
*/
public static LinkedHashMap<String, ArrayList<Row>> parseSalt(
VisualizerInput input,
List<String> annotationNames, long startTokenIndex, long endTokenIndex)
{
VisualizerInput input,
List<String> annotationNames, long startTokenIndex, long endTokenIndex,
PDFController pdfController) {

SDocumentGraph graph = input.getDocument().getSDocumentGraph();

// only look at annotations which were defined by the user
Expand All @@ -95,9 +98,9 @@ public static LinkedHashMap<String, ArrayList<Row>> parseSalt(
for (SSpan span : graph.getSSpans()) {
// calculate the left and right values of a span
// TODO: howto get these numbers with Salt?
RelannisNodeFeature feat = (RelannisNodeFeature)
span.getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
RelannisNodeFeature feat = (RelannisNodeFeature) span.
getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();

long leftLong = feat.getLeftToken();
long rightLong = feat.getRightToken();

Expand Down Expand Up @@ -167,9 +170,11 @@ public static LinkedHashMap<String, ArrayList<Row>> parseSalt(
r.addEvent(event);
rows.add(r);

String page = pageNumberHelper.getPageFromAnnotation(span);
if (page != null) {
event.setPage(page);
if (pdfController != null && pdfController.sizeOfRegisterdPDFViewer() > 0) {
String page = pageNumberHelper.getPageFromAnnotation(span);
if (page != null) {
event.setPage(page);
}
}
}
} // end for each annotation of span
Expand Down Expand Up @@ -423,11 +428,13 @@ public int compare(String o1, String o2) {
if (node2 == null) {
return +1;
}

RelannisNodeFeature feat1 =
(RelannisNodeFeature) node1.getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
RelannisNodeFeature feat2 =
(RelannisNodeFeature) node2.getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();

RelannisNodeFeature feat1 =
(RelannisNodeFeature) node1.getSFeature(ANNIS_NS,
FEAT_RELANNIS_NODE).getValue();
RelannisNodeFeature feat2 =
(RelannisNodeFeature) node2.getSFeature(ANNIS_NS,
FEAT_RELANNIS_NODE).getValue();

long tokenIndex1 = feat1.getTokenIndex();
long tokenIndex2 = feat2.getTokenIndex();
Expand All @@ -441,8 +448,9 @@ public int compare(String o1, String o2) {
for (String id : sortedCoveredToken) {

SNode node = graph.getSNode(id);
RelannisNodeFeature feat =
(RelannisNodeFeature) node.getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
RelannisNodeFeature feat =
(RelannisNodeFeature) node.getSFeature(ANNIS_NS,
FEAT_RELANNIS_NODE).getValue();
long tokenIndexRaw = feat.getTokenIndex();

tokenIndexRaw = clip(tokenIndexRaw, startTokenIndex, endTokenIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ public GridVisualizerComponent(VisualizerInput input,
SSpan.class);

EList<SToken> token = graph.getSortedSTokenByText();
RelannisNodeFeature featTokStart =

RelannisNodeFeature featTokStart =
(RelannisNodeFeature) token.get(0).getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
long startIndex = featTokStart.getTokenIndex();
RelannisNodeFeature featTokEnd =

RelannisNodeFeature featTokEnd =
(RelannisNodeFeature) token.get(token.size() - 1).getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
long endIndex = featTokEnd.getTokenIndex();

LinkedHashMap<String, ArrayList<Row>> rowsByAnnotation =
EventExtractor.parseSalt(input, annos, (int) startIndex,
(int) endIndex);
(int) endIndex, pdfController);

// we will only add tokens of one texts which is mentioned by any
// included annotation.
Expand Down Expand Up @@ -191,9 +191,9 @@ public GridVisualizerComponent(VisualizerInput input,
}

// only add token if text ID matches the valid one
if (tokenTextID != null && validTextIDs.contains(tokenTextID))
if (tokenTextID != null && validTextIDs.contains(tokenTextID))
{
RelannisNodeFeature feat =
RelannisNodeFeature feat =
(RelannisNodeFeature) t.getSFeature(ANNIS_NS, FEAT_RELANNIS_NODE).getValue();
long idx = feat.getTokenIndex() - startIndex;

Expand Down

0 comments on commit 60cc7ce

Please sign in to comment.