Java 类org.eclipse.draw2d.geometry.Transposer 实例源码

项目:birt    文件:EditorRulerFigure.java   
private boolean canDrawNumber(String num, Point startPoint ,Graphics g)
{
    Transposer transposer = new Transposer();
    transposer.setEnabled( !isHorizontal() );
    Rectangle rect =  transposer.t( g.getClip( Rectangle.SINGLETON ));
    Dimension strSize = FigureUtilities.getStringExtents(num, getFont());
    startPoint = transposer.t(startPoint);

    if (strSize.width + startPoint.x > rect.x  +  rect.width)
    {
        return false;
    }
    rect = transposer.t( getEndRect( g
            .getClip( Rectangle.SINGLETON ) ));

    if (rect.width == 0)
    {
        return true;
    }
    if (strSize.width + startPoint.x > rect.x)
    {
        return false;
    }
    return true;
}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
protected int getFeedbackIndexFor( Request request )
{
    Transposer transposer = new Transposer( );
    transposer.setEnabled( !isHorizontal( ) );

    List list = getHost( ).getChildren( );
    int size = list.size( ) - 1;
    int index = getFeedbackPosition( request );
    if ( size < 0 || index < 0 || index > size )
    {
        return index;
    }

    Rectangle rect = getAbsoluteBounds( (GraphicalEditPart) list.get( size ) );
    Point p = transposer.t( getLocationFromRequest( request ) );
    if ( p.y > rect.bottom( ) )
    {
        index = -1;
    }

    return index;
}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
protected void setTargetFeedbackPoints( Point p1, Point p2 )
{
    Transposer transposer = new Transposer( );
    transposer.setEnabled( !isHorizontal( ) );

    Rectangle parentBox = transposer.t( getAbsoluteClientBounds( (GraphicalEditPart) getHost( ) ) );
    Polyline fb = getLineFeedback( );
    if ( p2.y >= parentBox.bottom( ) && parentBox.bottom( ) - p1.y < 10 )
    {
        p2.y = p1.y;

        List list = ( (GraphicalEditPart) getHost( ) ).getChildren( );
        int size = list.size( );
        if ( size == 0 )
        {
            p2.x = p1.x + Math.min( 30, parentBox.width );
        }
        else
        {
            GraphicalEditPart last = (GraphicalEditPart) list.get( size - 1 );
            Rectangle rect = getAbsoluteBounds( last );
            p2.x = p1.x + Math.min( rect.width - 8, parentBox.width );
        }
    }
    else if ( p2.y >= parentBox.bottom( ) )
    {
        p2.y = parentBox.bottom( );
    }
    fb.translateToRelative( p1 );

    fb.translateToRelative( p2 );

    fb.setPoint( p1, 0 );
    fb.setPoint( p2, 1 );
}
项目:gef-gwt    文件:FlowLayoutEditPolicy.java   
/**
 * @param request
 *            the Request
 * @return the index for the insertion reference
 */
protected int getFeedbackIndexFor(Request request) {
    List children = getHost().getChildren();
    if (children.isEmpty())
        return -1;

    Transposer transposer = new Transposer();
    transposer.setEnabled(!isLayoutHorizontal());

    Point p = transposer.t(getLocationFromRequest(request));

    // Current row bottom, initialize to above the top.
    int rowBottom = Integer.MIN_VALUE;
    int candidate = -1;
    for (int i = 0; i < children.size(); i++) {
        EditPart child = (EditPart) children.get(i);
        Rectangle rect = transposer
                .t(getAbsoluteBounds(((GraphicalEditPart) child)));
        if (rect.y > rowBottom) {
            /*
             * We are in a new row, so if we don't have a candidate but yet
             * are within the previous row, then the current entry becomes
             * the candidate. This is because we know we must be to the
             * right of center of the last Figure in the previous row, so
             * this Figure (which is at the start of a new row) is the
             * candidate.
             */
            if (p.y <= rowBottom) {
                if (candidate == -1)
                    candidate = i;
                break;
            } else
                candidate = -1; // Mouse's Y is outside the row, so reset
                                // the candidate
        }
        rowBottom = Math.max(rowBottom, rect.bottom());
        if (candidate == -1) {
            /*
             * See if we have a possible candidate. It is a candidate if the
             * cursor is left of the center of this candidate.
             */
            if (p.x <= rect.x + (rect.width / 2))
                candidate = i;
        }
        if (candidate != -1) {
            // We have a candidate, see if the rowBottom has grown to
            // include the mouse Y.
            if (p.y <= rowBottom) {
                /*
                 * Now we have determined that the cursor.Y is above the
                 * bottom of the current row of figures. Stop now, to
                 * prevent the next row from being searched
                 */
                break;
            }
        }
    }
    return candidate;
}
项目:birt    文件:CrosstabCellFlowLayoutEditPolicy.java   
protected void showLayoutTargetFeedback( Request request )
{

    boolean isCrossTabElement = false;

    if ( request instanceof ChangeBoundsRequest )
    {
        List editParts = ( (ChangeBoundsRequest) request ).getEditParts( );
        if ( editParts.size( ) > 0 )
        {
            isCrossTabElement = editParts.get( 0 ) instanceof CrosstabCellEditPart;
        }
    }

    if ( !isCrossTabElement )
    {
        Object template = TemplateTransfer.getInstance( ).getTemplate( );
        if ( template instanceof Object[]
                && ( (Object[]) template ).length > 0 )
        {
            Object dragObject = ( (Object[]) template )[0];
            if ( dragObject instanceof DimensionHandle
                    || dragObject instanceof MeasureHandle
                    || dragObject instanceof LevelHandle )
            {
                isCrossTabElement = true;
            }
        }
    }

    if ( isCrossTabElement )
    {
        Transposer transposer = new Transposer( );
        transposer.setEnabled( !isHorizontal( ) );
        Rectangle r = transposer.t( getAbsoluteClientBounds( (GraphicalEditPart) getHost( ) ) );
        Point p = transposer.t( getLocationFromRequest( request ) );
        boolean before = p.x <= r.x + ( r.width / 2 );

        Point p1 = new Point( before ? r.x : r.x + r.width, r.y - 2 );
        p1 = transposer.t( p1 );

        Point p2 = new Point( before ? r.x : r.x + r.width, r.y
                + r.height
                + 7 );
        p2 = transposer.t( p2 );

        setTargetFeedbackPoints( p1, p2 );

    }
    else
    {
        super.showLayoutTargetFeedback( request );
    }
}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
/**
 * @param request
 *            the Request
 * @return the index for the insertion reference
 */
protected int getFeedbackPosition( Request request )
{
    List children = getHost( ).getChildren( );
    if ( children.isEmpty( ) )
        return -1;

    Transposer transposer = new Transposer( );
    transposer.setEnabled( !isHorizontal( ) );

    Point p = transposer.t( getLocationFromRequest( request ) );

    // Current row bottom, initialize to above the top.
    int rowBottom = Integer.MIN_VALUE;
    int candidate = -1;
    for ( int i = 0; i < children.size( ); i++ )
    {
        EditPart child = (EditPart) children.get( i );
        Rectangle rect = transposer.t( getAbsoluteBounds( ( (GraphicalEditPart) child ) ) );
        if ( rect.y > rowBottom )
        {
            /*
             * We are in a new row, so if we don't have a candidate but yet
             * are within the previous row, then the current entry becomes
             * the candidate. This is because we know we must be to the
             * right of center of the last Figure in the previous row, so
             * this Figure (which is at the start of a new row) is the
             * candidate.
             */
            if ( p.y <= rowBottom )
            {
                if ( candidate == -1 )
                    candidate = i;
                break;
            }
            else
                candidate = -1; // Mouse's Y is outside the row, so reset
            // the candidate
        }
        rowBottom = Math.max( rowBottom, rect.bottom( ) );
        if ( candidate == -1 )
        {
            /*
             * See if we have a possible candidate. It is a candidate if the
             * cursor is left of the center of this candidate.
             */
            if ( p.x <= rect.x + ( rect.width / 2 ) || p.y < rect.y )
                candidate = i;
        }
        if ( candidate != -1 )
        {
            // We have a candidate, see if the rowBottom has grown to
            // include the mouse Y.
            if ( p.y <= rowBottom )
            {
                /*
                 * Now we have determined that the cursor.Y is above the
                 * bottom of the current row of figures. Stop now, to
                 * prevent the next row from being searched
                 */
                break;
            }
        }
    }
    return candidate;
}
项目:wt-studio    文件:PageLayoutEditPolicy.java   
/**
 * @return <code>true</code> if the host's LayoutManager is in a horizontal orientation
 * @deprecated Use {@link #isLayoutHorizontal()} instead.
 */

protected int getFeedbackIndexFor(Request request)
{
    List children = getHost().getChildren();
    if (children.isEmpty())
        return -1;

    Transposer transposer = new Transposer();
    transposer.setEnabled(true);

    Point p = transposer.t(getLocationFromRequest(request));

    // Current row bottom, initialize to above the top.
    int rowBottom = Integer.MIN_VALUE;
    int candidate = -1;
    for (int i = 0; i < children.size(); i++) {
        EditPart child = (EditPart) children.get(i);
        if (child instanceof QueryBlockModelPart || child instanceof TableModelPart
                || child instanceof ChartBlockModelPart || child instanceof FrameModelPart) {
            Rectangle rect = transposer.t(getAbsoluteBounds(((GraphicalEditPart) child)));
            if (rect.y > rowBottom) {
                /*
                 * We are in a new row, so if we don't have a candidate but yet
                 * are within the previous row, then the current entry becomes
                 * the candidate. This is because we know we must be to the
                 * right of center of the last Figure in the previous row, so
                 * this Figure (which is at the start of a new row) is the
                 * candidate.
                 */
                if (p.y <= rowBottom) {
                    if (candidate == -1)
                        candidate = i;
                    break;
                } else
                    candidate = -1; // Mouse's Y is outside the row, so reset
                                    // the candidate
            }
            rowBottom = Math.max(rowBottom, rect.bottom());
            if (candidate == -1) {
                /*
                 * See if we have a possible candidate. It is a candidate if the
                 * cursor is left of the center of this candidate.
                 */
                if (p.x <= rect.x + (rect.width / 2))
                    candidate = i;
            }
            if (candidate != -1) {
                // We have a candidate, see if the rowBottom has grown to
                // include the mouse Y.
                if (p.y <= rowBottom) {
                    /*
                     * Now we have determined that the cursor.Y is above the
                     * bottom of the current row of figures. Stop now, to
                     * prevent the next row from being searched
                     */
                    break;
                }
            }
        }
    }
    return candidate;
}
项目:gef-gwt    文件:ScrollBarLayout.java   
/**
 * Constructs a ScrollBarLayout. If the given Transposer is enabled, the
 * Scrollbar will be horizontally oriented. Otherwise, the ScrollBar will be
 * vertically oriented.
 * 
 * @param t
 *            the Transposer
 * @since 2.0
 */
public ScrollBarLayout(Transposer t) {
    transposer = t;
}