Exemplo n.º 1
0
 public Point getActivePosition(TextAppearance appearance) {
   synchronized (content) {
     if (activeLine != null) {
       Point result = activeLine.getActivePosition(appearance);
       if (result != null) result.setY(result.getY() + activeLineY);
       return result;
     } else {
       return null;
     }
   }
 }
  private void moveWidget(int timeDelta) {
    final Point currentPosition = new Point(widget.getPosition());

    if (currentPosition.equals(endPosition)) {
      // end reached remove actor.
      unHook(widget);
    } else {
      // move widget
      // todo: make framerate independent
      // use time as base to calc movement speed. So someone will tell
      // that it
      // should take 1sec from A to B. More space between A and B means
      // faster movement.

      translate(currentPosition, endPosition, movementSpeed);
      widget.setPosition(currentPosition);
    }
  }
Exemplo n.º 3
0
  public void moveDown(TextAppearance appearance) {
    synchronized (content) {
      if (activeLine == null) return;

      Point currentPos = activeLine.getActivePosition(appearance);

      if (activeLine.getSelectedLine() != null) {
        currentPos.setY(
            activeLineY + currentPos.getY() + (activeLine.getSelectedLine().getSize().getHeight()));
        if (currentPos.getY() > getSize().getHeight()) {
          currentPos.setY(getSize().getHeight());
        }
        activeAtom = findAtomOnPosition(currentPos.getX(), currentPos.getY(), appearance);
        setActiveAtom(this.activeAtom);
      }
    }
  }
Exemplo n.º 4
0
  /**
   * This will create a copy of the widget. This copy will be deep. The only restriction is that it
   * will not copy any content Items or child Widgets of this widget.
   */
  public Widget clone() {
    Widget result;
    try {
      result = (Widget) super.clone();
    } catch (CloneNotSupportedException e) {
      // can not happen but write out anyway
      Log.error("Couldn't clone Widget", e);
      return null;
    }

    result.position = position.clone();
    result.size = size.clone();
    result.minSize = minSize.clone();

    result.data = null;
    result.parent = null;
    result.layoutData = null;

    result.initHooks();

    return result;
  }
Exemplo n.º 5
0
 /* (non-Javadoc)
  * @see org.fenggui.IWidget#getX()
  */
 public int getX() {
   return position.getX();
 }
  private void translate(Point current, Point destination, Point speed) {
    if (current.getX() > destination.getX()) {
      current.setX(current.getX() - speed.getX());
      if (current.getX() < destination.getX()) {
        current.setX(destination.getX());
      }
    } else {
      current.setX(current.getX() + speed.getX());
      if (current.getX() > destination.getX()) {
        current.setX(destination.getX());
      }
    }

    if (current.getY() > destination.getY()) {
      current.setX(current.getY() - speed.getY());
      if (current.getY() < destination.getY()) {
        current.setX(destination.getY());
      }
    } else {
      current.setX(current.getY() + speed.getY());
      if (current.getY() > destination.getY()) {
        current.setY(destination.getY());
      }
    }
  }