use of annis.model.Edge in project ANNIS by korpling.
the class ConstituentLayouter method createLayout.
public T createLayout(LayoutOptions options) {
TreeLayoutData treeLayout = new TreeLayoutData(options.getOrientation(), computeTokenPositions(options, 5));
treeLayout.setParentItem(backend.group());
if (options.getOrientation() == VerticalOrientation.TOP_ROOT) {
treeLayout.setNtStart(computeTreeHeight());
treeLayout.setBaseline(treeLayout.getNtStart() + styler.getFont(TOKEN_NODE, input).getLineHeight());
} else {
treeLayout.setBaseline(styler.getFont(TOKEN_NODE, input).getLineHeight());
treeLayout.setNtStart(styler.getFont(TOKEN_NODE, input).getLineHeight());
}
calculateNodePosition(root, treeLayout, options);
Edge e = getOutgoingEdges(root).get(0);
GraphicsItem edges = backend.makeLines(treeLayout.getLines(), styler.getEdgeColor(e, input), styler.getStroke(e, input));
edges.setZValue(-4);
edges.setParentItem(treeLayout.getParentItem());
addSecEdges(treeLayout, options);
return treeLayout.getParentItem();
}
use of annis.model.Edge in project ANNIS by korpling.
the class AomAnnotateSqlGeneratorTest method shouldMapEdgeWithRoot.
@Test
public void shouldMapEdgeWithRoot() throws SQLException {
// given
stubEdgeResultSet();
given(resultSet.wasNull()).willReturn(true);
// when
Edge actual = generator.mapEdge(resultSet, tableAccessStrategy);
// then
Edge expected = createDefaultEdge();
expected.setSource(null);
assertThat(actual, is(expected));
}
use of annis.model.Edge in project ANNIS by korpling.
the class AomAnnotateSqlGeneratorTest method createDefaultEdge.
private Edge createDefaultEdge() {
Edge expected = new Edge();
expected.setPre(PRE);
expected.setEdgeType(EDGETYPE);
expected.setNamespace(EDGE_NAMESPACE);
expected.setName(EDGE_NAME);
expected.setSource(new AnnisNode(PARENT));
expected.setDestination(new AnnisNode(NODE_REF));
return expected;
}
use of annis.model.Edge in project ANNIS by korpling.
the class AomAnnotateExtractor method mapEdge.
public Edge mapEdge(ResultSet resultSet, TableAccessStrategy tableAccessStrategy) throws SQLException {
Edge edge = new Edge();
edge.setPre(longValue(resultSet, RANK_TABLE, "pre", tableAccessStrategy));
edge.setComponentID(longValue(resultSet, RANK_TABLE, "component_id", tableAccessStrategy));
edge.setEdgeType(EdgeType.parseEdgeType(stringValue(resultSet, RANK_TABLE, "edge_type", tableAccessStrategy)));
edge.setNamespace(stringValue(resultSet, COMPONENT_TABLE, "namespace", tableAccessStrategy));
edge.setName(stringValue(resultSet, COMPONENT_TABLE, "name", tableAccessStrategy));
edge.setDestination(new AnnisNode(longValue(resultSet, RANK_TABLE, "node_ref", tableAccessStrategy)));
edge.setComponentID(longValue(resultSet, COMPONENT_TABLE, "id", tableAccessStrategy));
edge.setId(longValue(resultSet, RANK_TABLE, "id", tableAccessStrategy));
// create nodes for src with rank value (parent) as id.
// this must later be fixed by AnnotationGraphDaoHelper.fixSourceNodeIds().
// this is simpler than chaining the edgeByPre map in AnnisResultSetBuilder
// and making the EdgeRowMapper thread-safe.
// FIXME: use custum mapRow(resultSet, edgeByPre) function, throw Exception here
// also, no need to implement Spring RowMapper
long parent = longValue(resultSet, RANK_TABLE, "parent", tableAccessStrategy);
if (!resultSet.wasNull())
edge.setSource(new AnnisNode(parent));
return edge;
}
use of annis.model.Edge in project ANNIS by korpling.
the class AomAnnotateExtractor method createMissingSpanningRelations.
private void createMissingSpanningRelations(AnnotationGraph graph, Map<Long, ComponentEntry> allSpans, Map<Long, AnnisNode> nodeById) {
for (Map.Entry<Long, ComponentEntry> spanEntry : allSpans.entrySet()) {
AnnisNode span = nodeById.get(spanEntry.getKey());
// Check all covered token if there is already a coverage edge between the span
// and the token. If at least one edge already exists, it must have been
// a discontinuos span and we don't need to add any missing edges.
boolean anyTokenConnected = false;
for (long i = span.getLeftToken(); i <= span.getRightToken() && !anyTokenConnected; i++) {
AnnisNode token = graph.getToken(i);
// the span border might be behind the result set, so ignore this entries
if (token != null) {
for (Edge e : token.getIncomingEdges()) {
if (e.getSource() == span && e.getEdgeType() == EdgeType.COVERAGE) {
anyTokenConnected = true;
break;
}
}
}
}
if (!anyTokenConnected) {
long pre = 1;
for (long i = span.getLeftToken(); i <= span.getRightToken(); i++) {
AnnisNode tok = graph.getToken(i);
if (tok != null) {
Edge edge = new Edge();
ComponentEntry component = spanEntry.getValue();
edge.setPre(pre++);
edge.setComponentID(component.getId());
edge.setEdgeType(EdgeType.COVERAGE);
edge.setNamespace(component.getNamespace());
edge.setName(null);
edge.setDestination(tok);
edge.setSource(span);
graph.addEdge(edge);
span.addOutgoingEdge(edge);
tok.addIncomingEdge(edge);
}
}
}
}
// end for each node
}
Aggregations