Exemplo n.º 1
0
Arquivo: Z.java Projeto: adamldavis/z
 @Override
 public void mouseMoved(MouseEvent e) {
   final ZNode node = findZNodeAt(e.getPoint());
   if (node == selectedNode) {
     return;
   }
   if (hoveredNode != node && hoveredNode != null) {
     hoveredNode.setSize(hoveredNode.getSize() * 1f / 1.1f);
   }
   if (node != null && hoveredNode != node) {
     node.setSize(node.getSize() * 1.1f);
   }
   hoveredNode = node;
   hoverText = node == null ? null : node.getName();
   mouseLocation = e.getPoint();
 }
Exemplo n.º 2
0
Arquivo: Z.java Projeto: adamldavis/z
  @Override
  public void run() {
    if ((state == State.ANIMATING && aniCount.incrementAndGet() >= 100)
        || (state == State.TIME_TRAVEL && aniCount.addAndGet(1) >= 999)
        || (state == State.SELECTING && aniCount.addAndGet(2) >= 100)) {
      if (state == State.ANIMATING || state == State.TIME_TRAVEL) {
        state = State.NORMAL;
        links.clear();
      } else if (state == State.SELECTING) {
        if (edit.getEditors().isEmpty()) {
          state = State.NORMAL;
        } else {
          state = State.EDITING;
          updateEditorSize(edit.getEditors().get(0));
          edit.updatePaneSize();
        }
      }
    }
    count.incrementAndGet();
    if (count.get() >= 20) {
      count.set(0);
    }
    final float time = aniCount.get() / 100f;

    if (getState() == State.SELECTING) {
      Editor ed = edit.getEditors().get(0);
      ZNode editorNode = edit.getNode(ed);
      Editor previousEd = edit.getEditors().size() == 1 ? null : edit.getEditors().get(1);
      int y = 8;
      if (previousEd != null) {
        JPanel previousPanel = previousEd.getEditorPanel();
        y += previousPanel.getY() + previousPanel.getHeight();
      }
      ed.setScale(0.25f + 0.75f * time);
      final Point2D point =
          animator.animate(
              editorNode.getLocation(), new Point2D.Float(8, y), time, AnimationType.COSINE);
      ed.getEditorPanel().setLocation((int) point.getX(), (int) point.getY());
    } else if (getState() == State.ANIMATING)
      synchronized (zNodes) {
        for (ZNode node : zNodes) {
          if (pointMap.containsKey(node)) {
            node.getLocation()
                .setLocation(
                    animator.animate(
                        node.getLocation(), pointMap.get(node), time, AnimationType.COSINE));
          }
          if (sizeMap.containsKey(node)) {
            final Float size = sizeMap.get(node);
            final Float currentSize = node.getSize();
            node.setSize(
                (float)
                    animator
                        .animate(
                            new Point2D.Float(currentSize, 0),
                            new Point2D.Float(size, 0),
                            time,
                            AnimationType.COSINE)
                        .getX());
          }
        }
      }
    else if (getState() == State.TIME_TRAVEL
        && aniCount.get() * diffsMap.getLogSize() / 1000
            > (aniCount.get() - 1) * diffsMap.getLogSize() / 1000)
      synchronized (zNodes) {
        final Collection<ZNodeLink> nodeLinks =
            diffsMap.getNodeLinks(aniCount.get() * diffsMap.getLogSize() / 1000, zNodes);
        if (!nodeLinks.isEmpty()) {
          links.clear();
          links.addAll(nodeLinks);
        }
      }
    else if (getState() == State.TIME_TRAVEL) {
      if (diffsMap.author != null) {
        ZNode node = diffsMap.author;
        float t = aniCount.get() % 100 / 100f;

        node.getLocation()
            .setLocation(
                animator.animate(
                    node.getLocation(), diffsMap.authorLocation, t, AnimationType.COSINE));
      }
    }
  }