/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#setStyle(de.enough.polish.ui.Style) */ protected void setStyle(Style style) { super.setStyle(style); // #if polish.css.fisheyeview-remove-text Boolean removeTextBool = style.getBooleanProperty("fisheyeview-remove-text"); if (removeTextBool != null) { this.isRemoveText = removeTextBool.booleanValue(); } // #endif // #if polish.css.fisheyeview-scale && polish.midp2 Integer scaleInt = style.getIntProperty("fisheyeview-scale"); if (scaleInt != null) { this.scaleFactorWidth = scaleInt.intValue(); } // #endif // #if polish.css.show-text-in-title Boolean showTextInTitleBool = style.getBooleanProperty("show-text-in-title"); if (showTextInTitleBool != null) { this.isShowTextInTitle = showTextInTitleBool.booleanValue(); if (this.isShowTextInTitle) { this.isRemoveText = true; } } // #endif // #if polish.css.fisheyeview-max-visible Integer maxVisibleItemsInt = style.getIntProperty("fisheyeview-max-visible"); if (maxVisibleItemsInt != null) { this.maxVisibleItems = maxVisibleItemsInt.intValue(); } // #endif }
/* (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 }
/* (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 }
/* (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) { super.initContent(parentContainerItem, firstLineWidth, availWidth, availHeight); // #debug // # System.out.println("initContent of " + this + ": restartAnimation=" + this.restartAnimation // + ", focusedItem=" + this.focusedItem + ", items.length=" + // this.parentContainer.getItems().length); // new RuntimeException().printStackTrace(); if (this.restartAnimation && this.focusedItem != null) { setTargets( this.focusedItem.relativeX, this.focusedItem.relativeY, this.parentContainer.getItems()); } }
/* * (non-Javadoc) * @see de.enough.polish.ui.ContainerView#releaseResources() */ public void releaseResources() { super.releaseResources(); synchronized (this.lock) { // #if polish.midp2 this.originalRgbData = null; this.originalRgbDataWidths = null; this.shownRgbData = null; this.shownRgbDataWidths = null; this.shownRgbDataHeights = null; this.referenceXCenterPositions = null; this.referenceYCenterPositions = null; // #endif } }
/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#paintItem(de.enough.polish.ui.Item, int, int, int, int, int, int, int, int, int, javax.microedition.lcdui.Graphics) */ protected void paintItem( Item item, int index, int x, int y, int leftBorder, int rightBorder, int clipX, int clipY, int clipWidth, int clipHeight, Graphics g) { // #if polish.midp2 int width = this.shownRgbDataWidths[index]; if (index == this.focusedIndex && (width == this.originalRgbDataWidths[index])) { super.paintItem( item, index, x, y, leftBorder, rightBorder, clipX, clipY, clipWidth, clipHeight, g); return; } int height = this.shownRgbDataHeights[index]; int[] data = this.shownRgbData[index]; int itemLayout = item.getLayout(); if ((itemLayout & Item.LAYOUT_VCENTER) == Item.LAYOUT_VCENTER) { y += (this.maxItemHeight - height) >> 1; } else if ((itemLayout & Item.LAYOUT_BOTTOM) == Item.LAYOUT_BOTTOM) { y += (this.maxItemHeight - height); } DrawUtil.drawRgb(data, x, y, width, height, true, g); // g.setColor( 0xffff00); // g.drawRect( x, y, item.itemWidth, item.itemHeight ); // g.drawLine( x, y, x + item.itemWidth, y + item.itemHeight ); // #else super.paintItem( item, index, x, y, leftBorder, rightBorder, clipX, clipY, clipWidth, clipHeight, g); // #endif }
/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#paintItem(de.enough.polish.ui.Item, int, int, int, int, int, int, int, int, int, javax.microedition.lcdui.Graphics) */ protected void paintItem( Item item, int index, int x, int y, int leftBorder, int rightBorder, int clipX, int clipY, int clipWidth, int clipHeight, Graphics g) { if (this.targetYPositions != null) { y = this.targetYPositions[index] + y - item.relativeY; } super.paintItem( item, index, x, y, leftBorder, rightBorder, clipX, clipY, clipWidth, clipHeight, g); }
/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#paintContent(de.enough.polish.ui.Container, de.enough.polish.ui.Item[], int, int, int, int, int, int, int, int, javax.microedition.lcdui.Graphics) */ protected void paintContent( Container container, Item[] myItems, int x, int y, int leftBorder, int rightBorder, int clipX, int clipY, int clipWidth, int clipHeight, Graphics g) { if (this.restartAnimation && this.focusedItem != null) { setTargets( this.focusedItem.relativeX, this.focusedItem.relativeY, this.parentContainer.getItems()); } super.paintContent( container, myItems, x, y, leftBorder, rightBorder, clipX, clipY, clipWidth, clipHeight, g); }
protected void setStyle(Style style) { super.setStyle(style); // #ifdef polish.css.horizontalview-roundtrip Boolean allowRoundTripBool = style.getBooleanProperty("horizontalview-roundtrip"); if (allowRoundTripBool != null) { this.allowRoundTrip = allowRoundTripBool.booleanValue(); } // #endif // #if polish.css.horizontalview-align-heights Boolean alignHeightsBools = style.getBooleanProperty("horizontalview-align-heights"); if (alignHeightsBools != null) { this.isAlignHeights = alignHeightsBools.booleanValue(); } // #endif // #if polish.css.show-text-in-title Boolean showTextInTitleBool = style.getBooleanProperty("show-text-in-title"); if (showTextInTitleBool != null) { this.isShowTextInTitle = showTextInTitleBool.booleanValue(); } // #endif // #if polish.css.horizontalview-distribution Integer distribution = style.getIntProperty("horizontalview-distribution"); if (distribution != null) { this.isDistributeEquals = (distribution.intValue() == DISTRIBUTE_EQUALS); } // #endif // #if polish.css.horizontalview-arrow-left String urlLeft = style.getProperty("horizontalview-arrow-left"); if (urlLeft != null) { setArrowLeft(urlLeft); } // #endif // #if polish.css.horizontalview-arrow-right String urlRight = style.getProperty("horizontalview-arrow-right"); if (urlRight != null) { setArrowRight(urlRight); } // #endif }
/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#paintContent(de.enough.polish.ui.Container, de.enough.polish.ui.Item[], int, int, int, int, int, int, int, int, javax.microedition.lcdui.Graphics) */ protected void paintContent( Container container, Item[] myItems, int x, int y, int leftBorder, int rightBorder, int clipX, int clipY, int clipWidth, int clipHeight, Graphics g) { // #debug System.out.println( "paint " + this + " at " + x + ", " + y + ", with xOffset " + getScrollXOffset() + ", clipping req=" + this.isClippingRequired + ", expandRightLayout=" + this.isExpandRightLayout); if (this.isExpandRightLayout) { x = rightBorder - this.contentWidth; } Image right = this.arrowRight; Image left = this.arrowLeft; boolean paintArrows = (right != null) && (left != null); if (paintArrows) { x += left.getWidth() + this.paddingHorizontal; rightBorder -= right.getWidth() + this.paddingHorizontal; } if (this.isClippingRequired) { g.clipRect(x, y, rightBorder - x, this.contentHeight + 1); } if (paintArrows) { x -= left.getWidth() + this.paddingHorizontal; } super.paintContent( container, myItems, x, y, leftBorder, rightBorder, clipX, clipY, clipWidth, clipHeight, g); if (this.isClippingRequired) { g.setClip(clipX, clipY, clipWidth, clipHeight); } if (paintArrows) { if (container.isLayoutExpand()) { rightBorder += this.paddingHorizontal; g.drawImage(left, leftBorder, y + this.arrowLeftYAdjust, Graphics.TOP | Graphics.LEFT); g.drawImage(right, rightBorder, y + this.arrowRightYAdjust, Graphics.TOP | Graphics.LEFT); } else { g.drawImage(left, x, y + this.arrowLeftYAdjust, Graphics.TOP | Graphics.LEFT); g.drawImage( right, x + this.contentWidth, y + this.arrowRightYAdjust, Graphics.TOP | Graphics.RIGHT); } } }
/* (non-Javadoc) * @see de.enough.polish.ui.ItemView#animate(long, de.enough.polish.ui.ClippingRegion) */ public void animate(long currentTime, ClippingRegion repaintRegion) { super.animate(currentTime, repaintRegion); synchronized (this.lock) { // #if polish.midp2 if (this.shownRgbDataWidths == null) { // #debug warn de.enough.polish.util.Debug.debug( "warn", "de.enough.polish.ui.containerviews.FishEyeContainerView", 158, "FishEyeContainerView is animated before initContent has been called"); return; } // #endif boolean animated = false; if (this.targetXCenterPositions != null) { Item[] myItems = this.parentContainer.getItems(); int length = myItems.length; // #if polish.css.fisheyeview-max-visible // # int maxDistance = length; // # if (this.maxVisibleItems != 0) { // # maxDistance = this.maxVisibleItems >> 1; // # } // #endif for (int i = 0; i < length; i++) { int target = this.targetXCenterPositions[i]; Item item = myItems[i]; int halfItemWidth = (item.itemWidth >> 1); int distance = getDistance(i, this.focusedIndex, length); if (distance != 0) { distance--; } // #if polish.midp2 int factor = this.scaleFactor; // #endif // #if tmp.scaleAll // # factor = factor + ((this.scaleFactorEnd - factor ) * distance) / (length >> 1); // #endif // #if polish.midp2 if (i != this.focusedIndex) { halfItemWidth = (halfItemWidth * factor) / 100; } // #endif int current = item.relativeX + halfItemWidth; // System.out.println("animate: itemWidth of " + i + " with distance " + distance + " =" + // halfItemWidth); // System.out.println(i + ": current=" + current + ", target=" + target); if (current != target) { animated = true; // System.out.println(i + ": animate: with distance " + distance + ", halfItemWidth=" + // halfItemWidth + ", current=" + current + ", target=" + target + ", focusedIndex=" + // this.focusedIndex); item.relativeX = calculateCurrent(current, target) - halfItemWidth; // System.out.println( i + ": relativeX=" + item.relativeX); } if (this.targetYCenterPositions != null) { int halfItemHeight = (item.itemHeight >> 1); // #if polish.midp2 if (i != this.focusedIndex) { halfItemHeight = (halfItemHeight * factor) / 100; } // #endif current = item.relativeY + halfItemHeight; target = this.targetYCenterPositions[i]; if (current != target) { animated = true; item.relativeY = calculateCurrent(current, target) - halfItemHeight; } } // #if polish.css.fisheyeview-max-visible // # if (distance >= maxDistance ) { // # continue; // # } // #endif // #if polish.midp2 int currentAlpha = this.currentTranslucencies[i]; int targetAlpha = this.targetTranslucencies[i]; boolean adjustAlpha = (currentAlpha != targetAlpha); if (adjustAlpha) { currentAlpha = calculateCurrent(currentAlpha, targetAlpha); this.currentTranslucencies[i] = currentAlpha; } boolean isScaled = false; if (factor != 100) { current = this.shownRgbDataWidths[i]; if (i == this.focusedIndex) { target = this.originalRgbDataWidths[i]; } else { target = (this.originalRgbDataWidths[i] * factor) / 100; } if (current != target && (distance < (length >> 2) || i == this.focusedIndex || (Math.abs(current - target) * 100 / target > 5))) { animated = true; isScaled = true; int[] data = this.originalRgbData[i]; int originalWidth = this.originalRgbDataWidths[i]; int originalHeight = data.length / originalWidth; int newWidth = calculateCurrent(current, target); int newHeight = (newWidth * originalHeight) / originalWidth; // int alpha = calculateAlpha( getDistance( i, this.focusedIndex, length ), length ); // this.shownRgbData[i] = ImageUtil.scale(alpha, data, newWidth, newHeight, // originalWidth, originalHeight ); // #if polish.FishEye.scaleHq // # ImageUtil.scaleDownHq(this.shownRgbData[i],data, originalWidth, newWidth, 0, // currentAlpha, false); // #else ImageUtil.scale( currentAlpha, data, newWidth, newHeight, originalWidth, originalHeight, this.shownRgbData[i]); // #endif this.shownRgbDataWidths[i] = newWidth; this.shownRgbDataHeights[i] = newHeight; // item.itemWidth = newWidth; // item.itemHeight = newHeight; // item.relativeX += (originalWidth - newWidth) >> 1; // System.out.println("animate: new item width of " + i + " = " + newWidth + ", // difference=" + (originalWidth - newWidth)); } } if (adjustAlpha && !isScaled) { // adjust only the translucency: animated = true; int[] rgbData = this.shownRgbData[i]; if (rgbData != null) { ImageUtil.setTransparencyOnlyForOpaque(currentAlpha, rgbData, true); } } // #endif } } if (this.isRemoveText && this.focusedLabel != null) { animated |= this.focusedLabel.animate(); } if (this.focusedBackground != null) { animated |= this.focusedBackground.animate(); } if (animated) { repaintRegion.addRegion( this.parentContainer.getAbsoluteX() - 10, this.parentContainer.getAbsoluteY() - 10, this.parentContainer.itemWidth + 20, this.parentContainer.itemHeight + 20); } } }
/* (non-Javadoc) * @see de.enough.polish.ui.ContainerView#setStyle(de.enough.polish.ui.Style) */ protected void setStyle(Style style) { super.setStyle(style); // #if polish.css.fisheyeview-remove-text // # Boolean removeTextBool = style.getBooleanProperty(242); // # if (removeTextBool != null) { // # this.isRemoveText = removeTextBool.booleanValue(); // # } // #if polish.css.fisheyeview-text-style // # Style textStyle = (Style) style.getObjectProperty(449); // # if (textStyle != null) { // # this.focusedLabelStyle = textStyle; // # if (this.focusedLabel != null) { // # this.focusedLabel.setStyle(textStyle); // # this.focusedLabelFocusedStyle = (Style) textStyle.getObjectProperty(1); // # } // # } // #endif // #endif // #if polish.css.fisheyeview-place-label-at-top // # Boolean placeLabelAtTopBool = style.getBooleanProperty(420); // # if (placeLabelAtTopBool != null) { // # this.isPlaceLabelAtTop = placeLabelAtTopBool.booleanValue(); // # } // #endif // #if polish.css.fisheyeview-scale && polish.midp2 // # Integer scaleInt = style.getIntProperty( 241 ); // # if (scaleInt != null) { // # this.scaleFactor = scaleInt.intValue(); // # } // #endif // #if polish.css.fisheyeview-scale-start && polish.midp2 // # Integer scaleStartInt = style.getIntProperty(293); // # if (scaleStartInt != null) { // # this.scaleFactor = scaleStartInt.intValue(); // # } // #endif // #if polish.css.fisheyeview-scale-end && polish.midp2 // # Integer scaleEndInt = style.getIntProperty(259); // # if (scaleEndInt != null) { // # this.scaleFactorEnd = scaleEndInt.intValue(); // # } else if (this.scaleFactorEnd == 0) { // # this.scaleFactorEnd = this.scaleFactor; // # } // #endif // #if polish.css.show-text-in-title // # Boolean showTextInTitleBool = style.getBooleanProperty(37); // # if (showTextInTitleBool != null) { // # this.isShowTextInTitle = showTextInTitleBool.booleanValue(); // # if (this.isShowTextInTitle) { // # this.isRemoveText = true; // # } // # } // #endif // #if polish.css.fisheyeview-transparency && polish.midp2 // # Boolean transparencyBool = style.getBooleanProperty(296); // # if (transparencyBool != null && !transparencyBool.booleanValue()) { // # this.startTranslucency = 255; // # this.endTranslucency = 255; // # } // #endif // #if polish.css.fisheyeview-max-visible // # Integer maxVisibleItemsInt = style.getIntProperty(302); // # if (maxVisibleItemsInt != null) { // # this.maxVisibleItems = maxVisibleItemsInt.intValue(); // # } // #endif }
/* (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); }
/* (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); }
/* (non-Javadoc) * @see de.enough.polish.ui.ItemView#animate(long, de.enough.polish.ui.ClippingRegion) */ public void animate(long currentTime, ClippingRegion repaintRegion) { super.animate(currentTime, repaintRegion); synchronized (this.lock) { // #if polish.midp2 if (this.shownRgbDataWidths == null) { // #debug warn System.out.println("CoverFlowContainerView is animated before initContent has been called"); return; } // #endif boolean animated = false; if (this.targetXCenterPositions != null) { Item[] myItems = this.parentContainer.getItems(); int length = myItems.length; // #if polish.css.fisheyeview-max-visible int maxDistance = length; if (this.maxVisibleItems != 0) { maxDistance = this.maxVisibleItems >> 1; } // #endif for (int i = 0; i < length; i++) { int target = this.targetXCenterPositions[i]; Item item = myItems[i]; int halfItemWidth = (item.itemWidth >> 1); int distance = getDistance(i, this.focusedIndex, length); if (distance != 0) { distance--; } // #if polish.midp2 int factor = this.scaleFactorWidth; // #endif // #if polish.midp2 if (i != this.focusedIndex) { halfItemWidth = (halfItemWidth * factor) / 100; } // #endif int current = item.relativeX + halfItemWidth; boolean scaleInAnyCase = false; // System.out.println("animate: itemWidth of " + i + " with distance " + distance + " =" + // halfItemWidth); // System.out.println(i + ": current=" + current + ", target=" + target); if (current != target) { if (Math.abs(current - target) > item.itemWidth) { scaleInAnyCase = true; } animated = true; // System.out.println(i + ": animate: with distance " + distance + ", halfItemWidth=" + // halfItemWidth + ", current=" + current + ", target=" + target + ", focusedIndex=" + // this.focusedIndex); item.relativeX = calculateCurrent(current, target) - halfItemWidth; // System.out.println( i + ": relativeX=" + item.relativeX); } if (this.targetYCenterPositions != null) { int halfItemHeight = (item.itemHeight >> 1); // #if polish.midp2 if (i != this.focusedIndex) { halfItemHeight = (halfItemHeight * factor) / 100; } // #endif current = item.relativeY + halfItemHeight; target = this.targetYCenterPositions[i]; if (current != target) { animated = true; item.relativeY = calculateCurrent(current, target) - halfItemHeight; } } // #if polish.css.fisheyeview-max-visible if (distance >= maxDistance) { continue; } // #endif // #if polish.midp2 boolean isLeft = current < target; current = this.shownRgbDataWidths[i]; if (i == this.focusedIndex) { target = this.originalRgbDataWidths[i]; } else { target = (this.originalRgbDataWidths[i] * factor) / 100; } if (current != target || scaleInAnyCase) { animated = true; int[] data = this.originalRgbData[i]; int originalWidth = this.originalRgbDataWidths[i]; int newWidth = calculateCurrent(current, target); int height = item.itemHeight; int newHeightInner; int newHeightOuter; if (i == this.focusedIndex) { newHeightInner = (height * (this.scaleFactorInnerHeight + ((current * (100 - this.scaleFactorInnerHeight)) / target))) / (100); newHeightOuter = (height * (this.scaleFactorOuterHeight + ((current * (100 - this.scaleFactorOuterHeight)) / target))) / (100); } else { newHeightInner = (height * (100 - ((current * (100 - this.scaleFactorInnerHeight)) / target))) / (100); newHeightOuter = (height * (100 - ((current * (100 - this.scaleFactorOuterHeight)) / target))) / (100); } if (newHeightInner > height) { newHeightInner = height; } if (newHeightOuter > height) { newHeightOuter = height; } // this.shownRgbDataWidths[i] = newWidth; if ((i == this.focusedIndex && isLeft) || isLeftOfFocus(i, this.focusedIndex, length)) { ImageUtil.perspectiveShear( data, this.shownRgbData[i], originalWidth, newWidth, newHeightOuter, newHeightInner, 255, ImageUtil.EDGEDETECTION_MAP_FAST_AND_SIMPLE); } else { ImageUtil.perspectiveShear( data, this.shownRgbData[i], originalWidth, newWidth, newHeightInner, newHeightOuter, 255, ImageUtil.EDGEDETECTION_MAP_FAST_AND_SIMPLE); } // System.out.println("newWidth=" + newWidth + ", originalWidth=" + originalWidth); } // #endif } } if (this.isRemoveText && this.focusedLabel != null) { animated |= this.focusedLabel.animate(); } if (this.focusedBackground != null) { animated |= this.focusedBackground.animate(); } if (animated && repaintRegion != null) { repaintRegion.addRegion( this.parentContainer.getAbsoluteX() - 10, this.parentContainer.getAbsoluteY() - 10, this.parentContainer.itemWidth + 20, this.parentContainer.itemHeight + 20); } } }