Search in sources :

Example 1 with GripDragComponent

use of annis.gui.widgets.GripDragComponent in project ANNIS by korpling.

the class TigerQueryBuilderCanvas method clearAll.

public void clearAll() {
    for (EdgeWindow w : edges) {
        area.removeComponent(w);
    }
    edges.clear();
    for (GripDragComponent w : nodes.values()) {
        area.removeComponent(w);
    }
    nodes.clear();
    number = 0;
    updateLinesAndEdgePositions();
    updateQuery();
}
Also used : GripDragComponent(annis.gui.widgets.GripDragComponent)

Example 2 with GripDragComponent

use of annis.gui.widgets.GripDragComponent in project ANNIS by korpling.

the class TigerQueryBuilderCanvas method updateLinesAndEdgePositions.

public void updateLinesAndEdgePositions() {
    canvas.getLines().clear();
    for (EdgeWindow e : edges) {
        GripDragComponent w1 = nodes.get(e.getSource());
        GripDragComponent w2 = nodes.get(e.getTarget());
        ComponentPosition p1 = area.getPosition(w1);
        ComponentPosition p2 = area.getPosition(w2);
        float x1 = p1.getLeftValue() + (w1.getWidth() / 2);
        float y1 = p1.getTopValue() + (w1.getHeight() / 2);
        float x2 = p2.getLeftValue() + (w2.getWidth() / 2);
        float y2 = p2.getTopValue() + (w2.getHeight() / 2);
        float v_x = x2 - x1;
        float v_y = y2 - y1;
        // add line
        canvas.getLines().add(new Line2D.Float(x1, y1, x2, y2));
        // set position on half of the line for the edge window
        ComponentPosition posEdge = area.getPosition(e);
        float vectorLength = (float) Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        float xM = x1 + (vectorLength / 2.0f) * ((x2 - x1) / vectorLength);
        float yM = y1 + (vectorLength / 2.0f) * ((y2 - y1) / vectorLength);
        double normV_x = v_x / vectorLength;
        double normV_y = v_y / vectorLength;
        double pos1_x = (2.1 * vectorLength / 3) * normV_x + x1;
        double pos1_y = (2.1 * vectorLength / 3) * normV_y + y1;
        double origDir = Math.atan2(normV_y, normV_x);
        double pos2_x = ((1 * vectorLength) / 3) * normV_x + x1;
        double pos2_y = ((1 * vectorLength) / 3) * normV_y + y1;
        canvas.getLines().addAll(createArrow(pos1_x, pos1_y, origDir, 20.0));
        canvas.getLines().addAll(createArrow(pos2_x, pos2_y, origDir, 20.0));
        posEdge.setLeftValue(xM - e.getWidth() / 2.0f);
        posEdge.setTopValue(yM - e.getHeight() / 2.0f);
    }
    canvas.markAsDirty();
}
Also used : GripDragComponent(annis.gui.widgets.GripDragComponent) ComponentPosition(com.vaadin.ui.AbsoluteLayout.ComponentPosition) Line2D(java.awt.geom.Line2D)

Example 3 with GripDragComponent

use of annis.gui.widgets.GripDragComponent in project ANNIS by korpling.

the class TigerQueryBuilderCanvas method addNode.

public void addNode() {
    final NodeWindow n = new NodeWindow(number++, this);
    GripDragComponent panel = new GripDragComponent(n);
    panel.setWidth(NodeWindow.WIDTH, Layout.Unit.PIXELS);
    panel.setHeight(NodeWindow.HEIGHT, Layout.Unit.PIXELS);
    nodes.put(n, panel);
    area.addComponent(panel, "top:" + (10 + ((NodeWindow.HEIGHT + 20) * (number - 1))) + "px;left:10px");
    // area.addComponent(wrapper, "top:" + (10 + (120 * (number-1))) + "px;left:10px");
    updateQuery();
}
Also used : GripDragComponent(annis.gui.widgets.GripDragComponent)

Aggregations

GripDragComponent (annis.gui.widgets.GripDragComponent)3 ComponentPosition (com.vaadin.ui.AbsoluteLayout.ComponentPosition)1 Line2D (java.awt.geom.Line2D)1