Package palmed.edit.util

Examples of palmed.edit.util.Coordinate


    {
        final int lines = lines_; // can be changed by the functor
        if( from.y_ - start.y_ <= lines )
        {
            final int length = lastLineLength_; // can be changed by the functor
            final Coordinate translatedFrom = translate( from, start );
            final Coordinate translatedTo = translate( to, start );
            if( !translatedTo.equals( translatedFrom ) )
                functor.select( getText(), translatedFrom, translatedTo );
            if( from.y_ - start.y_ == 0 )
                return new Coordinate( start.x_ + length, start.y_ + lines );
            return new Coordinate( length, start.y_ + lines );
        }
        return new Coordinate( start.x_, start.y_ + lines );
    }
View Full Code Here


    }

    private Coordinate translate( final Coordinate coordinate, final Coordinate start )
    {
        if( coordinate.y_ < start.y_ )
            return new Coordinate( 0, 0 );
        if( coordinate.y_ > start.y_ + lines_ )
            return new Coordinate( lastLineLength_, lines_ );
        final int y = coordinate.y_ - start.y_;
        if( coordinate.x_ <= start.x_ )
            return new Coordinate( 0, y );
        final int x = getText().getLine( y ).length();
        if( coordinate.x_ >= start.x_ + x )
            return new Coordinate( x, y );
        return new Coordinate( coordinate.x_ - start.x_, y );
    }
View Full Code Here

    }

    private void apply( final ITextExtractor functor, final Coordinate from, final Coordinate to )
    {
        final Enumeration chunks = cache_.elements();
        Coordinate start = new Coordinate();
        while( chunks.hasMoreElements() && to.y_ >= start.y_ )
            start = ((IChunk)chunks.nextElement()).handle( functor, start, from, to );
    }
View Full Code Here

        update();
    }

    private void update()
    {
        final Coordinate size = new Coordinate( 0, 1 );
        int length = 0;
        boolean hasBeenModified = false;
        final Enumeration chunks = cache_.elements();
        while( chunks.hasMoreElements() )
        {
View Full Code Here

    {
        if( viewport == null )
            throw new IllegalArgumentException( "parameter 'viewport' is null" );
        viewport_ = viewport;
        font_ = new MonospacedFont( "ProFontWindows_12" );
        cursorPosition_ = new Coordinate();
    }
View Full Code Here

    public Viewport( final IContent content )
    {
        if( content == null )
            throw new IllegalArgumentException( "parameter 'content' is null" );
        content_ = content;
        scroll_ = new Coordinate();
        view_ = new NullView();
        cursorPosition_ = new Coordinate();
        views_ = new Vector();
        content_.register( this );
    }
View Full Code Here

     */
    public void update( final Coordinate position )
    {
        cursorPosition_.x_ = position.x_;
        cursorPosition_.y_ = position.y_;
        view_.update( new Coordinate( cursorPosition_.x_ - scroll_.x_, cursorPosition_.y_ - scroll_.y_ ) );
    }
View Full Code Here

    private void center()
    {
        scroll_.x_ = Math.max( 0, Math.min( scroll_.x_, maxColumns_ - visibleColumns_ ) );
        scroll_.y_ = Math.max( 0, Math.min( scroll_.y_, maxLines_ - visibleLines_ ) );
        view_.update( new Coordinate( cursorPosition_.x_ - scroll_.x_, cursorPosition_.y_ - scroll_.y_ ) );
        view_.update( maxColumns_, maxLines_ );
        final Enumeration e = views_.elements();
        while( e.hasMoreElements() )
            ((IScrollView)e.nextElement()).scrolled( scroll_ );
    }
View Full Code Here

    public Selection( final IText text )
    {
        if( text == null )
            throw new IllegalArgumentException( "parameter 'text' is null" );
        text_ = text;
        from_ = new Coordinate();
        to_ = new Coordinate();
        start_ = from_;
        end_ = to_;
        views_ = new Vector();
    }
View Full Code Here

        text.read( createInputStreamStub( string ) );
        reset();
        mockView.update( string.length() + 1, 1 );
        mockView.modified( true );
        replay();
        text.insert( new Coordinate( 7, 0 ), '*' );
        assertEquals( "this is* my string", text.getLine( 0 ) );
    }
View Full Code Here

TOP

Related Classes of palmed.edit.util.Coordinate

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.