예제 #1
0
 /* (non-Javadoc)
  * @see de.enough.polish.ui.ContainerView#focus(de.enough.polish.ui.Style, int)
  */
 public void focus(Style focusstyle, int direction) {
   super.focus(focusstyle, direction);
   AnimationThread.removeAnimationItem(this.parentItem);
   // #if polish.css.fisheyeview-text-style
   // # if (this.focusedLabelFocusedStyle != null) {
   // # this.focusedLabel.setStyle( this.focusedLabelFocusedStyle );
   // # }
   // #endif
 }
예제 #2
0
 /* (non-Javadoc)
  * @see de.enough.polish.ui.ContainerView#defocus(de.enough.polish.ui.Style)
  */
 protected void defocus(Style originalStyle) {
   super.defocus(originalStyle);
   AnimationThread.addAnimationItem(this.parentItem);
   // #if polish.css.fisheyeview-text-style
   // # if (this.focusedLabelFocusedStyle != null && this.focusedLabelStyle != null) {
   // # this.focusedLabel.setStyle( this.focusedLabelStyle );
   // # }
   // #endif
 }
예제 #3
0
  /* (non-Javadoc)
   * @see de.enough.polish.ui.ContainerView#initContent(de.enough.polish.ui.Container, int, int)
   */
  protected void initContent(
      Item parentContainerItem, int firstLineWidth, int availWidth, int availHeight) {

    // #if polish.hasPointerEvents
    if (!isPointerDraggedEnabled) {
      isPointerDraggedEnabled = Display.getInstance().hasPointerMotionEvents();
    }
    // #endif
    this.isVertical = false;
    this.isHorizontal = true;
    Container parent = (Container) parentContainerItem;
    // #debug
    // # System.out.println("FishEye: intialising content for " + this + " with vertical-padding " +
    // this.paddingVertical + ", availWidth=" + availWidth );

    this.parentContainer = parent;
    Item[] myItems = parent.getItems();
    int length = myItems.length;
    if (this.focusedIndex == -1 && length != 0) {
      // this.parentContainer.focus(0);
      if (parent.focusedIndex != -1) {
        this.focusedIndex = parent.focusedIndex;
      } else {
        this.focusedIndex = 0;
      }
      // System.out.println("AUTO-FOCUSSING ITEM " + this.focusedIndex );
      this.focusedItem = myItems[this.focusedIndex];
      this.focusedStyle = this.focusedItem.getFocusedStyle();
    }
    if (this.referenceXCenterPositions != null && this.referenceXCenterPositions.length == length) {
      // only another item has been focused, so nothing needs to be adjusted.
      return;
    }

    // #if polish.css.show-text-in-title
    // # if (this.isRemoveText && this.focusedLabel == null && !this.isShowTextInTitle) {
    // # this.focusedLabel = new StringItem(null, null);
    // #if polish.css.fisheyeview-text-style
    // # if (this.focusedLabelStyle != null) {
    // # this.focusedLabel.setStyle(this.focusedLabelStyle);
    // # }
    // #endif
    // # }
    // #else
    if (this.isRemoveText && this.focusedLabel == null) {
      this.focusedLabel = new StringItem(null, null);
      // #if polish.css.fisheyeview-text-style
      // # if (this.focusedLabelStyle != null) {
      // # this.focusedLabel.setStyle(this.focusedLabelStyle);
      // # }
      // #endif
    }
    // #endif

    if (this.isRemoveText && (this.labels == null || this.labels.length != length)) {
      this.labels = new String[length];
    }

    int maxWidth = 0;
    int maxHeight = 0;
    boolean hasFocusableItem = false;
    // #if polish.midp2
    this.originalRgbData = new int[length][];
    this.originalRgbDataWidths = new int[length];
    this.shownRgbData = new int[length][];
    this.shownRgbDataWidths = new int[length];
    this.shownRgbDataHeights = new int[length];
    // #endif
    for (int i = 0; i < length; i++) {
      Item item = myItems[i];
      if (this.isRemoveText) {
        String text = item.getLabel();
        if (text != null) {
          this.labels[i] = text;
          item.setLabel(null);
        } else if (item instanceof IconItem) {
          IconItem iconItem = (IconItem) item;
          text = iconItem.getText();
          if (text != null) {
            this.labels[i] = text;
            iconItem.setTextVisible(false);
            // iconItem.setText(null);
          }
        }
      }
      int width = item.getItemWidth(firstLineWidth, availWidth, availHeight);
      int height = item.getItemHeight(firstLineWidth, availWidth, availHeight);
      // #if polish.midp2
      int[] data = item.getRgbData(true, 255);
      this.originalRgbData[i] = data;
      this.originalRgbDataWidths[i] = width;
      if (this.scaleFactor == 100) {
        this.shownRgbData[i] = data;
        this.shownRgbDataWidths[i] = width;
        this.shownRgbDataHeights[i] = height;
      } else {
        int newWidth = (width * this.scaleFactor) / 100;
        int newHeight = (height * this.scaleFactor) / 100;
        // this.shownRgbData[i] = ImageUtil.scale(data, newWidth, newHeight, width, height );
        int alpha =
            this
                .endTranslucency; // calculateAlpha( getDistance( i, this.focusedIndex, length ),
                                  // length );
        this.shownRgbData[i] = new int[data.length];
        // #if polish.FishEye.scaleHq
        // # ImageUtil.scaleDownHq(this.shownRgbData[i], data,width, newWidth, 0, alpha, false);
        // #else
        ImageUtil.scale(alpha, data, newWidth, newHeight, width, height, this.shownRgbData[i]);
        // #endif

        this.shownRgbDataWidths[i] = newWidth;
        this.shownRgbDataHeights[i] = newHeight;
      }
      // #endif
      if (item.appearanceMode != Item.PLAIN) {
        hasFocusableItem = true;
      }
      if (width > maxWidth) {
        maxWidth = width;
      }
      if (height > maxHeight) {
        maxHeight = height;
      }
    }
    this.maxItemHeight = maxHeight;
    if (hasFocusableItem) {
      this.appearanceMode = Item.INTERACTIVE;
    } else {
      this.appearanceMode = Item.PLAIN;
    }

    initItemArrangement(availWidth, availHeight, myItems, length, maxWidth, maxHeight);

    // use reference positions to set the position for the items:
    for (int i = 0; i < length; i++) {
      Item item = myItems[i];
      int distance = getDistance(i, this.focusedIndex, length);
      if (distance != 0) {
        distance--;
      }
      int halfItemWidth = (item.getItemWidth(availWidth, availWidth, availHeight) >> 1);
      int halfItemHeight = (item.getItemHeight(availWidth, availWidth, availHeight) >> 1);
      // #if polish.midp2
      if (i != this.focusedIndex) {
        int factor = getScaleFactor(distance, length);
        halfItemWidth = (halfItemWidth * factor) / 100;
        halfItemHeight = (halfItemHeight * factor) / 100;
      }
      // #endif
      // System.out.println(i + ": initContent:  with distance " + distance + ", halfItemWidth=" +
      // halfItemWidth + ", focusedIndex=" + this.focusedIndex);
      item.relativeX = this.referenceXCenterPositions[i] - halfItemWidth;
      if (this.referenceYCenterPositions != null) {
        item.relativeY = this.referenceYCenterPositions[i] - halfItemHeight;
      }
      // System.out.println( i + ": relativeX=" + item.relativeX);

      //			System.out.println("item.relativeX for " + i + "=" + item.relativeX);
    }
    if (this.focusedStyle != null) {
      focusItem(this.focusedIndex, this.focusedItem, this.focusedDirection, this.focusedStyle);
      this.focusedItem.relativeX =
          this.referenceXCenterPositions[this.focusedIndex]
              - (this.focusedItem.getItemWidth(availWidth, availWidth, availHeight) >> 1);
      if (this.referenceYCenterPositions != null) {
        this.focusedItem.relativeY =
            this.referenceYCenterPositions[this.focusedIndex]
                - (this.focusedItem.getItemHeight(availWidth, availWidth, availHeight) >> 1);
      }
      //			System.out.println("focused.relativeX=" + this.focusedItem.relativeX);
      this.focusedStyle = null;
    }

    this.contentWidth = availWidth; // TODO: this can change when no expanded layout is used
    this.contentHeight =
        this.focusedLabel == null
            ? maxHeight
            : maxHeight
                + this.focusedLabel.getItemHeight(
                    availWidth,
                    availWidth,
                    availHeight); // maxItemHeight + this.paddingVertical +
                                  // this.focusedLabel.getItemHeight(lineWidth, lineWidth);

    if (!this.isFocused) {
      AnimationThread.addAnimationItem(parent);
    }
  }
예제 #4
0
 /* (non-Javadoc)
  * @see de.enough.polish.ui.ContainerView#focus(de.enough.polish.ui.Style, int)
  */
 public void focus(Style focusstyle, int direction) {
   super.focus(focusstyle, direction);
   AnimationThread.removeAnimationItem(this.parentItem);
 }
예제 #5
0
 /* (non-Javadoc)
  * @see de.enough.polish.ui.ContainerView#defocus(de.enough.polish.ui.Style)
  */
 protected void defocus(Style originalStyle) {
   super.defocus(originalStyle);
   AnimationThread.addAnimationItem(this.parentItem);
 }
예제 #6
0
  /* (non-Javadoc)
   * @see de.enough.polish.ui.ContainerView#initContent(de.enough.polish.ui.Container, int, int)
   */
  protected void initContent(
      Item parentContainerItem, int firstLineWidth, int availWidth, int availHeight) {
    synchronized (this.lock) {
      this.isVertical = false;
      this.isHorizontal = true;
      Container parent = (Container) parentContainerItem;
      // #debug
      System.out.println(
          "CoverFlow: intialising content for "
              + this
              + " with vertical-padding "
              + this.paddingVertical);

      this.parentContainer = parent;
      Item[] myItems = parent.getItems();
      int length = myItems.length;
      if (this.focusedIndex == -1 && length != 0) {
        // this.parentContainer.focus(0);
        if (parent.focusedIndex != -1) {
          this.focusedIndex = parent.focusedIndex;
        } else {
          this.focusedIndex = 0;
        }
        // System.out.println("AUTO-FOCUSSING ITEM " + this.focusedIndex );
        this.focusedItem = myItems[this.focusedIndex];
        this.focusedStyle = this.focusedItem.getFocusedStyle();
      }
      if (this.referenceXCenterPositions != null
          && this.referenceXCenterPositions.length == length) {
        return;
      }

      // #if polish.css.show-text-in-title
      if (this.isRemoveText && this.focusedLabel == null && !this.isShowTextInTitle) {
        this.focusedLabel = new StringItem(null, null);
      }
      // #else
      if (this.isRemoveText && this.focusedLabel == null) {
        this.focusedLabel = new StringItem(null, null);
      }
      // #endif

      if (this.isRemoveText && (this.labels == null || this.labels.length != length)) {
        this.labels = new String[length];
      }

      int maxWidth = 0;
      int maxHeight = 0;
      boolean hasFocusableItem = false;
      // #if polish.midp2
      this.originalRgbData = new int[length][];
      this.originalRgbDataWidths = new int[length];
      this.shownRgbData = new int[length][];
      this.shownRgbDataWidths = new int[length];
      this.shownRgbDataHeights = new int[length];
      // #endif
      for (int i = 0; i < length; i++) {
        Item item = myItems[i];
        if (this.isRemoveText) {
          String text = item.getLabel();
          if (text != null) {
            this.labels[i] = text;
            item.setLabel(null);
          } else if (item instanceof IconItem) {
            IconItem iconItem = (IconItem) item;
            text = iconItem.getText();
            if (text != null) {
              this.labels[i] = text;
              iconItem.setTextVisible(false);
              // iconItem.setText(null);
            }
          }
        }
        int width = item.getItemWidth(firstLineWidth, availWidth, availHeight);
        int height = item.getItemHeight(firstLineWidth, availWidth, availHeight);
        // #if polish.midp2
        int[] data = UiAccess.getRgbData(item);
        this.originalRgbData[i] = data;
        this.originalRgbDataWidths[i] = width;
        if (this.scaleFactorWidth == 100) {
          this.shownRgbData[i] = data;
          this.shownRgbDataWidths[i] = width;
          this.shownRgbDataHeights[i] = height;
        } else {
          int newWidth = (width * this.scaleFactorWidth) / 100;
          int newHeightInner = (height * this.scaleFactorInnerHeight) / 100;
          int newHeightOuter = (height * this.scaleFactorOuterHeight) / 100;
          this.shownRgbData[i] = new int[data.length];
          if (isLeftOfFocus(i, this.focusedIndex, length)) {
            ImageUtil.perspectiveShear(
                data,
                this.shownRgbData[i],
                width,
                newWidth,
                newHeightOuter,
                newHeightInner,
                255,
                ImageUtil.EDGEDETECTION_MAP_FAST_AND_SIMPLE);
          } else {
            ImageUtil.perspectiveShear(
                data,
                this.shownRgbData[i],
                width,
                newWidth,
                newHeightInner,
                newHeightOuter,
                255,
                ImageUtil.EDGEDETECTION_MAP_FAST_AND_SIMPLE);
          }
          //					System.out.println("newWidth=" + newWidth);
          this.shownRgbDataWidths[i] = width;
          this.shownRgbDataHeights[i] = height;
        }
        // #endif
        if (item.appearanceMode != Item.PLAIN) {
          hasFocusableItem = true;
        }
        if (width > maxWidth) {
          maxWidth = width;
        }
        if (height > maxHeight) {
          maxHeight = height;
        }
      }
      this.maxItemHeight = maxHeight;
      if (hasFocusableItem) {
        this.appearanceMode = Item.INTERACTIVE;
      } else {
        this.appearanceMode = Item.PLAIN;
      }

      initItemArrangement(availWidth, myItems, length, maxWidth, maxHeight);

      // use reference positions to set the position for the items:
      for (int i = 0; i < length; i++) {
        Item item = myItems[i];
        int distance = getDistance(i, this.focusedIndex, length);
        if (distance != 0) {
          distance--;
        }
        int halfItemWidth = (item.getItemWidth(availWidth, availWidth, availHeight) >> 1);
        int halfItemHeight = (item.getItemHeight(availWidth, availWidth, availHeight) >> 1);
        // #if polish.midp2
        if (i != this.focusedIndex) {
          int factor = getScaleFactor(distance, length);
          halfItemWidth = (halfItemWidth * factor) / 100;
          halfItemHeight = (halfItemHeight * factor) / 100;
        }
        // #endif
        // System.out.println(i + ": initContent:  with distance " + distance + ", halfItemWidth=" +
        // halfItemWidth + ", focusedIndex=" + this.focusedIndex);
        item.relativeX = this.referenceXCenterPositions[i] - halfItemWidth;
        if (this.referenceYCenterPositions != null) {
          item.relativeY = this.referenceYCenterPositions[i] - halfItemHeight;
        }
        // System.out.println( i + ": relativeX=" + item.relativeX);

        //			System.out.println("item.relativeX for " + i + "=" + item.relativeX);
      }
      if (this.focusedStyle != null) {
        focusItem(this.focusedIndex, this.focusedItem, this.focusedDirection, this.focusedStyle);
        this.focusedItem.relativeX =
            this.referenceXCenterPositions[this.focusedIndex]
                - (this.focusedItem.getItemWidth(availWidth, availWidth, availHeight) >> 1);
        if (this.referenceYCenterPositions != null) {
          this.focusedItem.relativeY =
              this.referenceYCenterPositions[this.focusedIndex]
                  - (this.focusedItem.getItemHeight(availWidth, availWidth, availHeight) >> 1);
        }
        //			System.out.println("focused.relativeX=" + this.focusedItem.relativeX);
        this.focusedStyle = null;
      }

      this.contentWidth = availWidth; // TODO: this can change when no expanded layout is used
      this.contentHeight =
          this.focusedLabel == null
              ? maxHeight
              : maxHeight
                  + this.focusedLabel.getItemHeight(
                      availWidth,
                      availWidth,
                      availHeight); // maxItemHeight + this.paddingVertical +
      // this.focusedLabel.getItemHeight(lineWidth, lineWidth);

      if (!this.isFocused) {
        AnimationThread.addAnimationItem(parent);
      }
      animate(System.currentTimeMillis(), null);
    }
  }