Ejemplo n.º 1
0
 /*
  * Test method for 'prefuse.Visualization.removeGroup(String)'
  */
 @Test
 public void testRemoveGroup() {
   m_vis.removeGroup("g");
   Assert.assertEquals(null, m_vis.getGroup("g"));
   Assert.assertEquals(null, m_vis.getGroup("g.nodes"));
   Assert.assertEquals(null, m_vis.getGroup("g.edges"));
   Assert.assertEquals(null, m_vis.getSourceData("g"));
   Assert.assertEquals(null, m_vis.getSourceData("g.nodes"));
   Assert.assertEquals(null, m_vis.getSourceData("g.edges"));
   Assert.assertEquals(false, m_vis.getFocusGroup("_focus_").containsTuple(m_n0));
 }
Ejemplo n.º 2
0
 public MultipleFocusControl(
     Visualization v, String activity, String filterGroup, boolean focusFixed) {
   super(1, activity);
   this.v = v;
   this.focusedTupleSet = v.getFocusGroup(group);
   this.focusFixed = focusFixed;
   if (focusFixed) {
     focusedTupleSet.addTupleSetListener(DOFIX);
   }
   setFilter(new InGroupPredicate(filterGroup));
 }
Ejemplo n.º 3
0
    public void itemReleased(VisualItem item, MouseEvent e) {
      if (!SwingUtilities.isLeftMouseButton(e)) return;
      if (dragged) {
        activeItem = null;
        item.setFixed(wasFixed);
        dragged = false;
      }
      // clear the focus
      Visualization vis = item.getVisualization();
      vis.getFocusGroup(Visualization.FOCUS_ITEMS).clear();

      vis.cancel("forces");
    }
Ejemplo n.º 4
0
    public void itemPressed(VisualItem item, MouseEvent e) {
      if (!SwingUtilities.isLeftMouseButton(e)) return;

      // set the focus to the current node
      Visualization vis = item.getVisualization();
      vis.getFocusGroup(Visualization.FOCUS_ITEMS).setTuple(item);

      item.setFixed(true);
      dragged = false;
      Display d = (Display) e.getComponent();
      down = d.getAbsoluteCoordinate(e.getPoint(), down);

      vis.run("forces");
    }
Ejemplo n.º 5
0
 @Override
 public void itemPressed(VisualItem item, MouseEvent e) {
   // on right-mouse press, start dragging the document
   if (SwingUtilities.isRightMouseButton(e)) {
     // debug
     System.out.println("debug: " + this.getClass().getName() + ": item pressed w/ right mouse");
     // drag, set the focus to the current node
     Visualization vis = item.getVisualization();
     vis.getFocusGroup(Visualization.FOCUS_ITEMS).setTuple(item);
     item.setFixed(true);
     dragged = false;
     Display d = controller.getDocumentGrid();
     down = d.getAbsoluteCoordinate(e.getPoint(), down);
   }
 }
Ejemplo n.º 6
0
  /**
   * updates the focus group to the step if a sequence is being collapsed or to the start node of
   * the sequence if the sequence is being expanded
   *
   * @param id
   */
  public void updateFocusGroup(int nodeId, Visualization vis) {
    Iterator visualItems = vis.items();
    VisualItem item = null;
    final String group = Visualization.FOCUS_ITEMS;

    while (visualItems.hasNext()) {
      item = (VisualItem) visualItems.next();
      if (item instanceof TableNodeItem && item.getInt(ID) == nodeId) {
        TupleSet ts = vis.getFocusGroup(group);
        ts.setTuple(item);
        break;
      }
    }

    vis.run("animate");
  }
Ejemplo n.º 7
0
  @Before
  public void setUp() {
    m_vis = new Visualization();
    m_t = TableTest.getTestCaseTable();
    m_g = GraphTest.getTestCaseGraph();

    m_t0 = m_t.getTuple(0);
    m_n0 = m_g.getNode(0);

    VisualTable vt = (VisualTable) m_vis.add("t", m_t);
    VisualGraph vg = (VisualGraph) m_vis.add("g", m_g);

    m_vt0 = vt.getItem(0);
    m_vn0 = (NodeItem) vg.getNode(0);

    TupleSet ts = m_vis.getFocusGroup(Visualization.FOCUS_ITEMS);
    ts.addTuple(m_vt0);
    ts.addTuple(m_vn0);
  }
Ejemplo n.º 8
0
  /*
   * Test method for 'prefuse.Visualization.reset()'
   */
  @Test
  public void testReset() {
    m_vis.reset();

    Assert.assertEquals(null, m_vis.getGroup("t"));
    Assert.assertEquals(null, m_vis.getSourceData("t"));

    Assert.assertEquals(null, m_vis.getGroup("g"));
    Assert.assertEquals(null, m_vis.getGroup("g.nodes"));
    Assert.assertEquals(null, m_vis.getGroup("g.edges"));
    Assert.assertEquals(null, m_vis.getSourceData("g"));
    Assert.assertEquals(null, m_vis.getSourceData("g.nodes"));
    Assert.assertEquals(null, m_vis.getSourceData("g.edges"));

    Assert.assertEquals(0, m_vis.size("t"));
    Assert.assertEquals(0, m_vis.size("g"));
    Assert.assertEquals(0, m_vis.size("g.nodes"));
    Assert.assertEquals(0, m_vis.size("g.edges"));
    Assert.assertEquals(0, m_vis.getFocusGroup("_focus_").getTupleCount());
    Assert.assertEquals(false, m_vis.items().hasNext());
  }
Ejemplo n.º 9
0
    @Override
    public void itemReleased(VisualItem item, MouseEvent e) {
      // when right-mouse released, release the dragged document glyph
      if (!SwingUtilities.isRightMouseButton(e)) {
        return;
      }
      // debug
      System.out.println("debug: " + this.getClass().getName() + ": item released");
      if (dragged) {
        activeItem = null;
        item.setFixed(wasFixed);
        dragged = false;
      }
      // clear the focus
      Visualization vis = item.getVisualization();
      vis.getFocusGroup(Visualization.FOCUS_ITEMS).clear();

      // determine whether item is in same region or new region;
      //  if new region, call controller to update attr vals
      double x = item.getX();
      double y = item.getY();
      double w = item.getDouble(WIDTH);
      double h = item.getDouble(HEIGHT);
      int newRegionX = -1;
      int newRegionY = -1;
      String xAttrName = docGridLayout.getXAttr();
      String yAttrName = docGridLayout.getYAttr();
      List<String> xCats = docGridLayout.getXCats();
      List<String> yCats = docGridLayout.getYCats();
      List<Integer> xCatRegionSizes = docGridLayout.getXCatRegionSizes();
      List<Integer> yCatRegionSizes = docGridLayout.getYCatRegionSizes();
      List<Integer> xCatPositions = docGridLayout.getXCatPositions();
      List<Integer> yCatPositions = docGridLayout.getYCatPositions();
      // for each region, get start and range;
      for (int i = 0; i < xCats.size(); i++) {
        int xRegionStart = xCatPositions.get(i);
        int xRegionEnd = xRegionStart + xCatRegionSizes.get(i);
        if (xRegionStart < x + (w / 2.) && x + (w / 2.) < xRegionEnd) {
          newRegionX = i;
        }
      }
      for (int i = 0; i < yCats.size(); i++) {
        int yRegionStart = yCatPositions.get(i);
        int yRegionEnd = yRegionStart + yCatRegionSizes.get(i);
        if (yRegionStart < y + (h / 2.) && y + (h / 2.) < yRegionEnd) {
          newRegionY = i;
        }
      }

      int docID = item.getInt(DocumentGridTable.NODE_ID);

      // debug
      //            System.out.println("debug: item moved:
      // docID="+docID+"xOrig="+xCats.get(origRegionX)+", xNew="+xCats.get(newRegionX)+",
      // yOrig="+yCats.get(origRegionY)+", yNew="+yCats.get(newRegionY));

      // update for x and y separately
      //            if (origRegionX != newRegionX && newRegionX != -1) {
      String newCatX = xCats.get(newRegionX);
      controller.updateDocumentAttr(docID, xAttrName, newCatX);
      controller.documentAttributesUpdated(docID);
      //            }
      //            if (origRegionY != newRegionY && newRegionY != -1) {
      String newCatY = yCats.get(newRegionY);
      controller.updateDocumentAttr(docID, yAttrName, newCatY);
      controller.documentAttributesUpdated(docID);
      //            }

    }