Example #1
0
File: Z.java Project: adamldavis/z
  private void updateSubLocations(ZNode node, boolean immediate, Point2D loc) {
    final Point center = new Point((int) Math.round(loc.getX()), (int) Math.round(loc.getY()));
    // make bigger when more nodes
    final float factor =
        selectedNode == node ? (1.3f + logSize(node.getSubmodules().size()) / 2.2f) : 1.2f;
    int size = Math.round(sizeMap.get(node) * factor);
    final float xRatio = display.getWidth() / display.getHeight();
    Map<ZNode, Point2D> map =
        new PixelZNodePositioner(
                center,
                new Dimension((int) (size * xRatio), size),
                new DirectionZNodePositioner(direction, makeNodePositioner()))
            .getNewPositions(node);

    for (ZNode sub : node.getSubmodules()) {
      pointMap.put(sub, map.get(sub));
      if (immediate) sub.setLocation((java.awt.geom.Point2D.Float) map.get(sub));

      updateSubLocations(sub, immediate, map.get(sub));
    }
    if (node == selectedNode)
      for (ZNode dep : node.getDependencies()) {
        pointMap.put(dep, map.get(dep));
        if (immediate) dep.setLocation((java.awt.geom.Point2D.Float) map.get(dep));
      }
  }
Example #2
0
File: Z.java Project: adamldavis/z
  protected void clicked(ZNode node) {
    log.info("selected: " + node);
    selectedNode = new ZCodeLoader(apiFactory).load(node);
    synchronized (zNodes) {
      zNodes.clear();
      zNodes.add(selectedNode);
      zNodes.addAll(selectedNode.getDependencies());
      zNodes.addAll(selectedNode.getSubmodules());
    }
    count.set(0);

    state = State.ANIMATING;
    aniCount.set(0);
    final Dimension dim = display.getDimension();
    sortNodes();
    float selSize = (float) Math.min(dim.getWidth(), dim.getHeight()) / 2.2f;
    sizeMap.put(selectedNode, selSize);
    float shrinkFactor = 0.2f;
    float size = (float) (selSize * shrinkFactor);

    for (ZNode dep : selectedNode.getDependencies()) {
      sizeMap.put(dep, size);
    }
    for (ZNode sub : selectedNode.getSubmodules()) {
      sub = new ZCodeLoader(apiFactory).load(sub);
      sizeMap.put(sub, size + logSize(sub.getSubmodules().size()));
      synchronized (zNodes) {
        zNodes.addAll(sub.getSubmodules());
      }
      for (ZNode sub2 : sub.getSubmodules()) {
        sizeMap.put(sub2, size * shrinkFactor + logSize(sub2.getCodeLineSize()));
      }
    }
    Point2D.Float center = new Point2D.Float(selSize * 1.25f, selSize);
    pointMap.put(node, center);
    updateSubLocations(selectedNode, false, center);
  }
Example #3
0
File: Z.java Project: adamldavis/z
 protected void dragged(ZNode z) {
   log.info("dragged: " + z);
   // create dependency on z?
   if (z.getNodeType() == ZNodeType.DEPENDENCY) selectedNode.getDependencies().add(z);
 }