Package com.sun.dtv.lwuit.geom

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


       
        int height = getHorizontalScrollHeight();
                 
        Painter p = s.getBgPainter();
        if(p != null) {
            p.paint(g, new Rectangle(x, y, width, height));
        } else {
            g.fillRect(x, y, width, height, s.getBgTransparency());
        }
       
        g.setColor(s.getBgColor());
View Full Code Here


    }

    public void moveCaret(int action) {

        //scroll the TextArea
        Rectangle rect = new Rectangle(getScrollX(), getScrollY(), getWidth(), getHeight());
        Font textFont = getStyle().getFont();

        // TODO Remove
        //System.out.println("cursorRow =" + cursorRow + " cursorColumn=" + cursorColumn + "rows=" + rows + " column=" + columns);

        if (action == Display.GAME_DOWN) {
            cursorRow++;
            if ((getScrollY() + getHeight()) < (rowsGap + getStyle().getFont().getHeight()) * getLines()) {
                rect.setY(rect.getY() + textFont.getHeight() + rowsGap);
                scrollRectToVisible(rect, this);
            } else {
                setHandlesInput(false);
            }
        } else if (action == Display.GAME_UP) {
            cursorRow--;
            if (getScrollY() > 0) {
                rect.setY(Math.max(0, rect.getY() - textFont.getHeight() - rowsGap));
                scrollRectToVisible(rect, this);
            } else {
                setHandlesInput(false);
            }
        } else if (action == Display.GAME_LEFT) {
View Full Code Here

                endIndex = indexOfComponent;
            }

            for (int i = startIndex; i < endIndex; i++) {
                Component cmp2 = (Component) components.elementAt(i);
                Rectangle rect = new Rectangle(cmp2.getBounds());
                rect.setX(cmp2.getAbsoluteX());
                rect.setY(cmp2.getAbsoluteY());

                if (rect.intersects(bounds)) {
                    cmp2.paintInternal(g, false);
                }
            }
        }
    }
View Full Code Here

                if (c.getParent() != null) {
                    // special case for the first component to allow the user to scroll all the
                    // way to the top
                    Form f = getComponentForm();
                    if (f != null && f.getFocusPosition(c) == 0) {
                        scrollRectToVisible(new Rectangle(0, 0, c.getX() + c.getWidth(), c.getY() + c.getHeight()), c);
                        return;
                    }
                }
                scrollRectToVisible(c.getBounds(), c);
            }
View Full Code Here

     */
    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

     */
    public void scrollRectToVisible(Rectangle rect) {
        if (fixedSelection < FIXED_NONE_BOUNDRY) {
            //Dimension elemSize = getElementSize();
            if (orientation == VERTICAL) {
                super.scrollRectToVisible(new Rectangle(getScrollX(), rect.getY() , rect.getSize().getWidth(), rect.getSize().getHeight() + itemGap), this);
            } else {
                super.scrollRectToVisible(new Rectangle(rect.getX(), getScrollY(), rect.getSize().getWidth() + itemGap, rect.getSize().getHeight()), this);
            }
        }
    }
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

            return;
        }
        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

            } else {
                selectedIndex = x / (elemSize.getWidth() + itemGap);
            }
        } else {
            int numOfcomponents = getModel().getSize();
            Rectangle pos = new Rectangle();
            Style style = getStyle();
            int width = getWidth() - style.getPadding(RIGHT) - style.getPadding(LEFT) - getSideGap();
            if (isScrollableX()) {
                width = Math.max(width, getPreferredSize().getWidth() - style.getPadding(RIGHT) - style.getPadding(LEFT) - getSideGap());
            }
            Dimension rendererSize = getElementSize(false);
            Dimension selectedSize = getElementSize(true);
            for (int i = 0; i < numOfcomponents; i++) {
                calculateComponentPosition(i, width, pos, rendererSize, selectedSize, true);
                if (pos.contains(x, y)) {
                    selectedIndex = i;
                    break;
                }
            }
        }
View Full Code Here

            // the animation thus invalidating the size
            for (int iter = 0; iter < animatableComponents.size(); iter++) {
                Animation c = (Animation) animatableComponents.elementAt(iter);
                if (c.animate()) {
                    if (c instanceof Component) {
                        Rectangle rect = ((Component) c).getDirtyRegion();
                        if (rect != null) {
                            ((Component) c).repaint(rect.getX(), rect.getY(), rect.getSize().getWidth(), rect.getSize().getHeight());
                        } else {
                            ((Component) c).repaint();
                        }
                    } else {
                        Display.getInstance().repaint(c);
View Full Code Here

TOP

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

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.