Пример #1
1
  private void setVertexColor(Object vertex, Color color) {

    DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();

    GraphConstants.setBackground(attr, color);

    AttributeMap cellAttr = new AttributeMap();

    cellAttr.put(cell, attr);

    m_jgAdapter.edit(cellAttr, null, null, null);
  }
Пример #2
1
  private void positionVertexAt(Object vertex, int x, int y) {

    DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();
    Rectangle2D b = GraphConstants.getBounds(attr);

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, 5, 5);
    GraphConstants.setBounds(attr, newBounds);

    AttributeMap cellAttr = new AttributeMap();

    cellAttr.put(cell, attr);

    m_jgAdapter.edit(cellAttr, null, null, null);
  }
Пример #3
0
  @SuppressWarnings("unchecked")
  private AttributeMap createVertexAttributeMap(GraphCell vertexCell) {
    AttributeMap attrs = new AttributeMap();

    // FIXME hb 28-nov-05: waiting for graph to go generic
    attrs.put(vertexCell, getDefaultVertexAttributes().clone());

    return attrs;
  }
Пример #4
0
  @SuppressWarnings("unchecked")
  private void positionVertexAt(Object vertex, int x, int y) {
    DefaultGraphCell cell = m_jgAdapter_.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();
    Rectangle2D bounds = GraphConstants.getBounds(attr);

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight());

    GraphConstants.setBounds(attr, newBounds);

    // TODO: Clean up generics once JGraph goes generic
    AttributeMap cellAttr = new AttributeMap();
    cellAttr.put(cell, attr);
    m_jgAdapter_.edit(cellAttr, null, null, null);
  }
Пример #5
0
 /**
  * Adjust the given treenode's display coordinates. If given tree node is null or the root, will
  * simply ignore.
  *
  * @param treeNode the tree node
  * @param oldAttributeMap the existing attribute on the graph associated with the given tree node
  * @return the oldAttributeMap after applying the newly calculated attribute.
  */
 private AttributeMap adjustToNewPosition(
     DefaultMutableTreeNode treeNode, AttributeMap oldAttributeMap) {
   if (treeNode != null
       && !treeNode
           .isRoot()) { // change the render value if and only if neither it is null nor a root.
     boolean isFromSourceTree = UIHelper.isDataFromSourceTree(treeNode);
     int sourceYpos = -1;
     AttributeMap newTreeNodeAttribute = null;
     if (isFromSourceTree) {
       // Find the Y position for the source for this mappingNode.
       // find the # of pixels hidden. For example : 30
       sourceYpos =
           getGraphController()
               .calculateScrolledDistanceOnY(mappingPanel.getSourceScrollPane(), treeNode, true);
       // To hide the vertex body from the graph
       newTreeNodeAttribute =
           UIHelper.getDefaultInvisibleVertexBounds(new Point(0, sourceYpos), true);
     } else {
       sourceYpos =
           getGraphController()
               .calculateScrolledDistanceOnY(mappingPanel.getTargetScrollPane(), treeNode, true);
       newTreeNodeAttribute =
           UIHelper.getDefaultInvisibleVertexBounds(
               new Point((int) graphScrollPane.getVisibleRect().getWidth() - 5, sourceYpos),
               false);
     }
     if (oldAttributeMap == null) { // never return null.
       oldAttributeMap = new AttributeMap();
     }
     oldAttributeMap.applyMap(newTreeNodeAttribute);
   }
   return oldAttributeMap;
 }