Java Code Examples for org.eclipse.draw2d.geometry.Rectangle#setLocation()

The following examples show how to use org.eclipse.draw2d.geometry.Rectangle#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompartmentLayout.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void layout(IFigure container) {
	if (container instanceof CompartmentSegment) {
		CompartmentSegment compartment = (CompartmentSegment) container;
		Rectangle innerBounds = new Rectangle();
		innerBounds.setLocation(ILayoutConstants.COMPARTMENT_PADDING, ILayoutConstants.COMPARTMENT_PADDING);
		innerBounds.setSize(compartment.getInnerSegment().getPreferredSize());
		compartment.getInnerSegment().setBounds(innerBounds);
		
		Rectangle bounds = Rectangle.SINGLETON;
		bounds.setLocation(0, innerBounds.getCenter().y);
		bounds.setSize(0, 0);
		compartment.getEntry().setBounds(bounds);
		bounds.setLocation(innerBounds.getRight().x + ILayoutConstants.COMPARTMENT_PADDING, innerBounds.getCenter().y);
		compartment.getExit().setBounds(bounds);
	}
}
 
Example 2
Source File: PrintERDiagramOperation.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void printPages() {
    final Graphics graphics = getFreshPrinterGraphics();
    final IFigure figure = getPrintSource();
    setupPrinterGraphicsFor(graphics, figure);
    final Rectangle bounds = figure.getBounds();
    int x = bounds.x, y = bounds.y;
    final Rectangle clipRect = new Rectangle();
    while (y < bounds.y + bounds.height) {
        while (x < bounds.x + bounds.width) {
            graphics.pushState();
            getPrinter().startPage();
            graphics.translate(-x, -y);
            graphics.getClip(clipRect);
            clipRect.setLocation(x, y);
            graphics.clipRect(clipRect);
            figure.paint(graphics);
            getPrinter().endPage();
            graphics.popState();
            x += clipRect.width;
        }
        x = bounds.x;
        y += clipRect.height;
    }
}
 
Example 3
Source File: PrintERDiagramOperation.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected void printPages() {
    final Graphics graphics = getFreshPrinterGraphics();
    final IFigure figure = getPrintSource();
    setupPrinterGraphicsFor(graphics, figure);
    final Rectangle bounds = figure.getBounds();
    int x = bounds.x, y = bounds.y;
    final Rectangle clipRect = new Rectangle();
    while (y < bounds.y + bounds.height) {
        while (x < bounds.x + bounds.width) {
            graphics.pushState();
            getPrinter().startPage();
            graphics.translate(-x, -y);
            graphics.getClip(clipRect);
            clipRect.setLocation(x, y);
            graphics.clipRect(clipRect);
            figure.paint(graphics);
            getPrinter().endPage();
            graphics.popState();
            x += clipRect.width;
        }
        x = bounds.x;
        y += clipRect.height;
    }
}
 
Example 4
Source File: PrintERDiagramOperation.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void printPages() {
	Graphics graphics = getFreshPrinterGraphics();
	IFigure figure = getPrintSource();
	setupPrinterGraphicsFor(graphics, figure);
	Rectangle bounds = figure.getBounds();
	int x = bounds.x, y = bounds.y;
	Rectangle clipRect = new Rectangle();
	while (y < bounds.y + bounds.height) {
		while (x < bounds.x + bounds.width) {
			graphics.pushState();
			getPrinter().startPage();
			graphics.translate(-x, -y);
			graphics.getClip(clipRect);
			clipRect.setLocation(x, y);
			graphics.clipRect(clipRect);
			figure.paint(graphics);
			getPrinter().endPage();
			graphics.popState();
			x += clipRect.width;
		}
		x = bounds.x;
		y += clipRect.height;
	}
}
 
Example 5
Source File: ReportPrintGraphicalViewerOperation.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Prints the pages based on the current print mode.
 * 
 * @see org.eclipse.draw2d.PrintOperation#printPages()
 */
protected void printPages( )
{
	Graphics graphics = getFreshGraphics( );
	IFigure figure = getPrintSource( );
	setupPrinterGraphicsFor( graphics, figure );
	Rectangle bounds = figure.getBounds( );
	int x = bounds.x, y = bounds.y;
	Rectangle clipRect = new Rectangle( );
	while ( y < bounds.y + bounds.height )
	{
		while ( x < bounds.x + bounds.width )
		{
			graphics.pushState( );
			graphics.translate( -x, -y );
			graphics.getClip( clipRect );
			clipRect.setLocation( x, y );
			graphics.clipRect( clipRect );
			figure.paint( graphics );
			graphics.popState( );
			x += clipRect.width;
			if ( x == 0 )
			{
				return;
			}
		}
		x = bounds.x;
		y += clipRect.height;
	}
}
 
Example 6
Source File: TreeLayoutEditPolicy.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void showLayoutTargetFeedback(Request request) {
	if (request instanceof ChangeBoundsRequest) {
		final ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
		if (!changeBoundsRequest.getEditParts().isEmpty()
				&& !(changeBoundsRequest.getEditParts().get(0) instanceof LabelEditPart)) {

			final IGraphicalEditPart editPart = (IGraphicalEditPart) changeBoundsRequest
					.getEditParts().get(0);

			final List<IGraphicalEditPart> siblingList = TreeLayoutUtil
					.getSiblings(editPart);

			if (!siblingList.isEmpty()) {
				final int newTreePosition = TreeLayoutUtil
						.getNewTreeNodePosition(
								changeBoundsRequest.getLocation(),
								TreeLayoutUtil.getSiblings(editPart));
				Point point;
				if (newTreePosition == 0) {
					// top end
					point = getFeedBackFigurePoint(editPart.getFigure(),
							siblingList, 0, 0);
				} else if (newTreePosition == siblingList.size()) {
					// Bottom end
					point = getFeedBackFigurePoint(editPart.getFigure(),
							siblingList, siblingList.size(),
							siblingList.size());
				} else {
					// Between siblings
					point = getFeedBackFigurePoint(editPart.getFigure(),
							siblingList, newTreePosition - 1,
							newTreePosition);
				}

				final Rectangle bounds = getFeedbackFigureBounds();
				siblingList.get(0).getFigure().translateToAbsolute(bounds);
				bounds.setLocation(point);
				getFeedbackFigure().setBounds(bounds);
				getFeedbackFigure().translateToRelative(
						getFeedbackFigure().getBounds());
				getFeedbackLayer().add(getFeedbackFigure());
				getFeedbackLayer().repaint();
			}
		}
	}
}