Package lupos.gui.operatorgraph

Examples of lupos.gui.operatorgraph.GraphBox


            result.add(data);

            final Operator newOp = (Operator) data;
            newOp.setParents();

            final GraphBox graphBox = this.visualGraphs.get(0).graphBoxCreator.createGraphBox(
                this.visualGraphs.get(0),
                new GraphWrapperOperator(newOp));
            graphBox.setY(rowY);
            graphBox.arrange(Arrange.values()[0]);

            this.visualGraphs.get(0).addOperator(graphBox.getX(),
                rowY, newOp);

            // TODO: update x position of last box...
            if (data instanceof OperatorContainer) {
              final OperatorContainer tc = (OperatorContainer) data;

              ((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);

              if (tc.getGUIComponent().getLocation().x < 0) {
                this.visualGraphs
                .get(0)
                .getBoxes()
                .get(new GraphWrapperOperator(tc))
                .setX((int) this.visualGraphs.get(0).PADDING);
              }
            }
          } else {
            // it is an RDF term!
            final Item item = SPARQLCoreParserVisitorImplementation.getItem(child);

            rdfHash.put(
                item,
                new QueryRDFTerm(
                    ((VisualGraphOperatorWithPrefix) this.visualGraphs
                        .get(0)).prefix, item));
          }
        }

        if (result.size() == 1
            && result.get(0) instanceof OperatorContainer) {
          final OperatorContainer tc = (OperatorContainer) result
          .get(0);

          final LinkedHashSet<Operator> hop = new LinkedHashSet<Operator>();

          for (final Operator op : tc.getOperators()) {
            hop.add(op);

            op.visit(new SimpleOperatorGraphVisitor() {
              private static final long serialVersionUID = -350730291684630002L;

              public Object visit(final Operator basicOperator) {
                hop.add(basicOperator);

                return null;
              }
            });
          }

          for (final Operator op : rdfHash.values()) {
            if (!hop.contains(op)) {
              tc.addOperator(op);

              op.setParents();
            }
          }

          ((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);

          if (tc.getGUIComponent().getLocation().x < 0) {
            this.visualGraphs.get(0).getBoxes()
            .get(new GraphWrapperOperator(tc))
            .setX((int) this.visualGraphs.get(0).PADDING);
          }
        } else if (rdfHash.size() > 0) {
          // only single RDF terms are pasted...
          // => collect them in a TripleContainer!
          final LinkedHashSet<Operator> lhso = new LinkedHashSet<Operator>();
          lhso.addAll(rdfHash.values());

          final TripleContainer tc = new TripleContainer(lhso);
          tc.setParents();

          final GraphBox graphBox = this.visualGraphs.get(0).graphBoxCreator.createGraphBox(
              this.visualGraphs.get(0), new GraphWrapperOperator(
                  tc));
          graphBox.setY(rowY);
          graphBox.arrange(Arrange.values()[0]);

          this.visualGraphs.get(0).addOperator(graphBox.getX(), rowY,
              tc);

          ((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);

          if (tc.getGUIComponent().getLocation().x < 0) {
View Full Code Here


  protected void replaceOperator(final Operator newOP, final VisualGraph<Operator> parent, final GraphWrapper oldGW) {
    newOP.cloneFrom(this);
    this.replaceWith(newOP);

    final GraphWrapper gw = new GraphWrapperOperator(newOP);
    final GraphBox box = parent.getBoxes().get(oldGW);

    box.initBox(gw);
    box.arrange(Arrange.values()[0]);

    parent.getBoxes().remove(oldGW);
    parent.getBoxes().put(gw, box);

    parent.remove(this.panel);
    parent.add(box.getElement());

    for(final Operator preOp : this.precedingOperators) {
      final GraphWrapper preGW = new GraphWrapperOperator(preOp);
      final GraphBox preBox = parent.getBoxes().get(preGW);

      preBox.setLineAnnotations(preOp.drawAnnotations(parent));
    }

    parent.revalidate();
    parent.repaint();
  }
View Full Code Here

      this.handleAddOperator(newOp);

      final GraphWrapper gw = this.createGraphWrapper(newOp);

      // create the GraphBox at the right position...
      final GraphBox box = this.graphBoxCreator.createGraphBox(this, gw);
      box.setY(y);
      box.updateX(x, y, new HashSet<GraphBox>());
      box.arrange(Arrange.values()[0]);
      box.getElement().revalidate();

      this.boxes.put(gw, box);
      this.rootList.add(gw);

      this.revalidate();
View Full Code Here

    if(newClassSuperName.startsWith("RetrieveData")) {
      this.rootList.add(gw);
    }

    // create the GraphBox at the right position...
    final GraphBox box = this.graphBoxCreator.createGraphBox(this, gw);
    box.setX(x);
    box.setY(y);
    box.arrange(Arrange.values()[0]);
    box.getElement().revalidate();

    this.boxes.put(gw, box);
    this.rootList.add(gw);

    this.revalidate();
View Full Code Here

  public void mouseMoved(final MouseEvent me) {
    // get connection mode...
    final Connection<T> connectionMode = this.visualEditor.connectionMode;

    if(connectionMode != null) {
      final GraphBox dummyBox = connectionMode.getDummyBox(this); // get dummy operator

      if(dummyBox != null) { // update position of dummy box...
        dummyBox.setX(me.getX());
        dummyBox.setY(me.getY());

        this.visualEditor.repaint();
      }
    }
  }
View Full Code Here

      // add dummy operator to be able to draw the arrow to the current
      // mouse position...
      this.dummyOperator = this.queryGraph.createDummyOperator();
      this.dummyGW = this.queryGraph.createGraphWrapper(this.dummyOperator);
      final GraphBox dummyBox = this.queryGraph.graphBoxCreator.createGraphBox(this.queryGraph,this.dummyGW);

      this.queryGraph.getBoxes().put(this.dummyGW, dummyBox);

      this.firstOp.addSucceedingElement(new GraphWrapperIDTuple(this.dummyGW, 0));
View Full Code Here

    }

    this.queryGraph.removeFromRootList(this.secondOp);

    // get the GraphBox of the GraphWrapper of the first operator...
    final GraphBox firstBox = this.queryGraph.getBoxes().get(this.firstOp);

    // draw all annotations of the first Operator...
    firstBox.setLineAnnotations(this.firstOp.drawAnnotations(this.queryGraph));

    this.firstOp.getGUIComponent().repaint();

    this.queryGraph.revalidate();
    this.queryGraph.repaint();
View Full Code Here

    }
   
    // x-correction
    if (minX < 0) {
      for (GraphWrapper gw : boxes.keySet()) {
        GraphBox box = boxes.get(gw);
        box.setXWithoutUpdatingParentsSize(box.getX()+Math.abs(minX));
      }
    }
       
    // y-correction
    if (minY < 0) {
      for (GraphWrapper gw : boxes.keySet()) {
        GraphBox box = boxes.get(gw);
        box.setYWithoutUpdatingParentsSize(box.getY()+Math.abs(minY));
      }
    }
   
    minX = Integer.MAX_VALUE; minY = Integer.MAX_VALUE;
   
    // get the smallest x- and y-values
    for (GraphBox box : boxes.values()) {
      if (box.getX() < minX) minX = box.getX();
      if (box.getY() < minY) minY = box.getY();
    }
   
    // x-correction
    for (GraphWrapper gw : boxes.keySet()) {
      GraphBox box = boxes.get(gw);
      box.setXWithoutUpdatingParentsSize(box.getX()-minX);
    }
       
    // y-correction
    for (GraphWrapper gw : boxes.keySet()) {
      GraphBox box = boxes.get(gw);
      box.setYWithoutUpdatingParentsSize(box.getY()-minY);
    }
  } 
View Full Code Here

    int field_height = (int) Math.ceil(sqrt_size * (avgSizes.getSecond()+operatorgraph.SPACING_Y));
   
    Random rnd = new Random();
       
    for(GraphWrapper gw : boxes.keySet()) {
      GraphBox box = boxes.get(gw);
     
      // Get some random positions
      int x = rnd.nextInt(field_width);
      int y = rnd.nextInt(field_height);
     
      box.setXWithoutUpdatingParentsSize(x);
      box.setYWithoutUpdatingParentsSize(y);     
    }
    //time1 = System.currentTimeMillis() - time1;
    //System.out.println("Laufzeit = " + time1 + " ms");
  }
View Full Code Here

   * Method computes the repulsing force between two
   * nodes a and b. The result will be stored in force.
   */
  private static double computeRepulsionForce (GraphWrapper a, GraphWrapper b, OperatorGraph op, Force repulsion) {
    HashMap<GraphWrapper, GraphBox> boxes = op.getBoxes();
    GraphBox boxA = boxes.get(a); GraphBox boxB = boxes.get(b);
    int x = boxB.getX() - boxA.getX(); int y = boxB.getY() - boxA.getY();
   
    // compute distance between a and b
    double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

    // compute unit vector with direction from b to a
View Full Code Here

TOP

Related Classes of lupos.gui.operatorgraph.GraphBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.