Package com.sun.dtv.lwuit.geom

Examples of com.sun.dtv.lwuit.geom.Dimension


    /**
     * @inheritDoc
     */
    Dimension calcPreferredSize() {
        Dimension d = layout.getPreferredSize(this);
        return d;
    }
View Full Code Here


            maxH = tabsList.getPreferredSize().getHeight() + maxContentH;
        } else {
            maxW = tabsList.getPreferredSize().getWidth() + maxContentW;
            maxH = maxContentH;
        }
        return new Dimension(maxW, maxH);
    }
View Full Code Here

        /**
         * Prevents scaling down of the menu when there is no text on the menu bar
         */
        protected Dimension calcPreferredSize() {
            Dimension d = super.calcPreferredSize();
            if ((soft[0].getText() == null || soft[0].getText().equals("")) &&
                    (soft[1].getText() == null || soft[1].getText().equals(""))) {
                d.setHeight(0);
            }
            return d;
        }
View Full Code Here

    protected void sizeChanged(int w, int h) {
        Form frm = getPreviousForm();
        while (frm instanceof Dialog) {
            frm = frm.getPreviousForm();
        }
        frm.setSize(new Dimension(w, h));
        frm.setShouldCalcPreferredSize(true);
        frm.doLayout();

        super.sizeChanged(w, h);
    }
View Full Code Here

        int total = Screen.getNumberOfScreens();
        Screen[] xx = new Screen[total];
        for (int i=0;i<total;i++){
            xx[i] = new Screen();
            xx[i].id = i;
            xx[i].dimension = new Dimension(Screen.getWidthOfScreen(i), Screen.getHeightOfScreen(i));
            Display.init(Device.backend);
        }
        screens = xx;
    }
View Full Code Here

     * occur if the selection is outside of view
     */
    public void setSelectedIndex(int index, boolean scrollToSelection) {
        model.setSelectedIndex(index);
        if(scrollToSelection) {
            Dimension size = getElementSize(false);
            Rectangle rect;
            if (getOrientation() == VERTICAL) {
                rect = new Rectangle(getX(), (size.getHeight() + itemGap) * Math.max(0, index - 2), size);
            } else {
                rect = new Rectangle((size.getWidth() + itemGap) * Math.max(0, index - 2), getY(), size);
            }
            scrollRectToVisible(rect);
        }
    }
View Full Code Here

        }
        repaint();
    }
   
    private void selectElement(int selectedIndex) {
        Dimension size = getElementSize(false);
        Rectangle rect;
        if (getOrientation() == VERTICAL) {
            rect = new Rectangle(getX(), (size.getHeight() + itemGap) * selectedIndex, getElementSize(true));
        } else {
            rect = new Rectangle((size.getWidth() + itemGap) * selectedIndex, getY(), getElementSize(true));
        }
        scrollRectToVisible(rect);
    }
View Full Code Here

    private void calculateComponentPosition(int index, int defaultWidth, Rectangle rect, Dimension rendererSize, Dimension selectedSize, boolean beforeSelected) {
        Style style = getStyle();
        int initialY = style.getPadding(TOP);
        int initialX = style.getPadding(LEFT);
        int selection = getSelectedIndex();
        Dimension d = rect.getSize();
        int selectedDiff;
       
        // the algorithm illustrated here is very simple despite the "mess" of code...
        // The idea is that if we have a "fixed" element we just add up the amount of pixels
        // to get it into its place in the screen (nothing for top obviously).
        // In order to cause the list to be cyclic we just subtract the list size
        // which will cause the bottom elements to "return" from the top.
        if (orientation == VERTICAL) {
            int height = rendererSize.getHeight();
            selectedDiff = selectedSize.getHeight() - height;
            rect.setX(initialX);
            d.setHeight(height);
            d.setWidth(defaultWidth);
            int y = 0;
            int listHeight = getHeight() - style.getPadding(TOP) - style.getPadding(BOTTOM);
            int totalHeight = (height + itemGap) * getModel().getSize() + selectedDiff;
            switch (fixedSelection) {
                case FIXED_CENTER:
                    y = listHeight / 2 - (height + itemGap+ selectedDiff) / 2 +
                            (index - selection) * (height + itemGap);
                    if(!beforeSelected){
                        y += selectedDiff;
                    }
                    y = recalcOffset(y, totalHeight, listHeight, height + itemGap);
                    break;
                case FIXED_TRAIL:
                    y = listHeight - (height + itemGap + selectedDiff);
                case FIXED_LEAD:
                    y += (index - selection) * (height + itemGap);
                    if(index - selection > 0){
                        y += selectedDiff;
                    }
                    y = recalcOffset(y, totalHeight, listHeight, height + itemGap);
                    break;
                default:
                    y = index * (height + itemGap);
                    if(!beforeSelected){
                        y += selectedDiff;
                    }
                    break;
            }
            rect.setY(y + initialY);
            if(index == selection){
                d.setHeight(d.getHeight() + selectedDiff);
            }
           
        } else {
            int width = rendererSize.getWidth();
            selectedDiff = selectedSize.getWidth() - width;
            rect.setY(initialY);
            d.setHeight(getHeight() - style.getPadding(TOP) - style.getPadding(BOTTOM));
            d.setWidth(width);
            int x = 0;
            int listWidth = getWidth() - style.getPadding(RIGHT) - style.getPadding(LEFT);
            int totalWidth = (width + itemGap) * getModel().getSize() + selectedDiff;
            switch (fixedSelection) {
                case FIXED_CENTER:
                    x = listWidth / 2 - (width + itemGap +selectedDiff) / 2 +
                            (index - selection) * (width + itemGap);
                    if(!beforeSelected){
                        x += selectedDiff;
                    }
                    x = recalcOffset(x, totalWidth, listWidth, width + itemGap);
                    break;
                case FIXED_TRAIL:
                    x = listWidth - (width + itemGap + selectedDiff);
                case FIXED_LEAD:
                    x += (index - selection) * (width + itemGap);
                    if(index - selection > 0){
                        x += selectedDiff;
                    }
                    x = recalcOffset(x, totalWidth, listWidth, width + itemGap);
                    break;
                default:
                    x = index * (width + itemGap);
                    if(!beforeSelected){
                        x += selectedDiff;
                    }
                    break;
            }
            rect.setX(initialX + x);
            if(index == selection){
                d.setWidth(d.getWidth() + selectedDiff);
            }
        }
    }
View Full Code Here

        }
        int xTranslate = getX();
        int yTranslate = getY();
        g.translate(xTranslate, yTranslate);
        Rectangle pos = new Rectangle();
        Dimension rendererSize = getElementSize(false);

        int selection = model.getSelectedIndex();

        if (animationPosition != 0 && fixedSelection > FIXED_NONE_BOUNDRY) {
            // selection should never move during animation of fixed elements
            selection = -1;

            if (orientation == VERTICAL) {
                yTranslate += animationPosition;
                g.translate(0, animationPosition);
            } else {
                xTranslate += animationPosition;
                g.translate(animationPosition, 0);
            }
        }

        int clipX = g.getClipX();
        int clipY = g.getClipY();
        int clipWidth = g.getClipWidth();
        int clipHeight = g.getClipHeight();
       
        if(paintFocusBehindList){
            paintFocus(g, width, pos, rendererSize);
        }

        // this flag is for preformance improvements
        // if we figured out that the list items are not visible anymore
        // we should break from the List loop
        boolean shouldBreak = false;

        // improve performance for browsing the end of a very large list
        int startingPoint = 0;
        if(fixedSelection < FIXED_NONE_BOUNDRY) {
            startingPoint = Math.max(0, pointerSelect(clipX + getAbsoluteX(), clipY + getAbsoluteY()) - 1);
        }
       
        for(int i = startingPoint; i < numOfcomponents; i++) {
            // skip on the selected
            if(i == getSelectedIndex() && animationPosition == 0){
                continue;           
            }
            calculateComponentPosition(i, width, pos, rendererSize, getElementSize(true), i <= getSelectedIndex());
           
            // if the renderer is in the clipping region
            if(pos.intersects(clipX, clipY, clipWidth, clipHeight)) {
                Object value = model.getItemAt(i);
                Component cmp = renderer.getListCellRendererComponent(this, value, i, false);
                cmp.setCellRenderer(true);
                Dimension size = pos.getSize();
                renderComponent(g, cmp, pos.getX(), pos.getY(), size.getWidth(), size.getHeight());
                shouldBreak = true;
            } else {
                //this is relevant only if the List is not fixed.
                if(shouldBreak && (fixedSelection < FIXED_NONE_BOUNDRY)) {
                    break;
                }
            }
        }
        if(!paintFocusBehindList){
            paintFocus(g, width, pos, rendererSize);
        }else{
            calculateComponentPosition(getSelectedIndex(), width, pos, rendererSize, getElementSize(true), true);
        }
        Dimension size = pos.getSize();
        //if the animation has finished draw the selected element
        if (animationPosition == 0 && model.getSize() > 0) {
            Component selected = renderer.getListCellRendererComponent(this, model.getItemAt(selection), selection, true);
            renderComponent(g, selected, pos.getX(), pos.getY(), size.getWidth(), size.getHeight());
        }

        g.translate(-xTranslate, -yTranslate);
    }
View Full Code Here

        g.translate(-xTranslate, -yTranslate);
    }

    private void paintFocus(Graphics g, int width, Rectangle pos, Dimension rendererSize){
        calculateComponentPosition(getSelectedIndex(), width, pos, rendererSize, getElementSize(true), true);
        Dimension size = pos.getSize();

        Component cmp = renderer.getListFocusComponent(this);
        if (cmp != null) {
            cmp.setCellRenderer(true);
            int x = pos.getX();
            int y = pos.getY();

            // prevent focus animation from working during a drag operation
            if (orientation == VERTICAL) {
                y -= animationPosition;
            } else {
                x -= animationPosition;
            }
            renderComponent(g, cmp, x, y, size.getWidth(), size.getHeight());
        }
   
    }
View Full Code Here

TOP

Related Classes of com.sun.dtv.lwuit.geom.Dimension

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.