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

The following examples show how to use org.eclipse.draw2d.geometry.Rectangle#intersect() . 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: PrintERDiagramOperation.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Rectangle getPrintRegion() {
    final ERDiagram diagram = getDiagram();
    final PageSetting pageSetting = diagram.getPageSetting();

    final org.eclipse.swt.graphics.Rectangle trim = getPrinter().computeTrim(0, 0, 0, 0);
    final org.eclipse.swt.graphics.Point printerDPI = getPrinter().getDPI();

    final Insets notAvailable = new Insets(-trim.y, -trim.x, trim.height + trim.y, trim.width + trim.x);

    final Insets userPreferred = new Insets((pageSetting.getTopMargin() * printerDPI.x) / 72, (pageSetting.getLeftMargin() * printerDPI.x) / 72, (pageSetting.getBottomMargin() * printerDPI.x) / 72, (pageSetting.getRightMargin() * printerDPI.x) / 72);

    final Rectangle paperBounds = new Rectangle(getPrinter().getBounds());
    final Rectangle printRegion = shrink(paperBounds, notAvailable);
    printRegion.intersect(shrink(paperBounds, userPreferred));
    printRegion.translate(trim.x, trim.y);

    return printRegion;
}
 
Example 2
Source File: PrintERDiagramOperation.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public Rectangle getPrintRegion() {
    final ERDiagram diagram = getDiagram();
    final PageSettings pageSetting = diagram.getPageSetting();

    final org.eclipse.swt.graphics.Rectangle trim = getPrinter().computeTrim(0, 0, 0, 0);
    final org.eclipse.swt.graphics.Point printerDPI = getPrinter().getDPI();

    final Insets notAvailable = new Insets(-trim.y, -trim.x, trim.height + trim.y, trim.width + trim.x);

    final Insets userPreferred =
            new Insets((pageSetting.getTopMargin() * printerDPI.x) / 72, (pageSetting.getLeftMargin() * printerDPI.x) / 72,
                    (pageSetting.getBottomMargin() * printerDPI.x) / 72, (pageSetting.getRightMargin() * printerDPI.x) / 72);

    final Rectangle paperBounds = new Rectangle(getPrinter().getBounds());
    final Rectangle printRegion = shrink(paperBounds, notAvailable);
    printRegion.intersect(shrink(paperBounds, userPreferred));
    printRegion.translate(trim.x, trim.y);

    return printRegion;
}
 
Example 3
Source File: PrintERDiagramOperation.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Rectangle getPrintRegion() {
	ERDiagram diagram = this.getDiagram();
	PageSetting pageSetting = diagram.getPageSetting();

	org.eclipse.swt.graphics.Rectangle trim = this.getPrinter()
			.computeTrim(0, 0, 0, 0);
	org.eclipse.swt.graphics.Point printerDPI = this.getPrinter().getDPI();

	Insets notAvailable = new Insets(-trim.y, -trim.x,
			trim.height + trim.y, trim.width + trim.x);

	Insets userPreferred = new Insets(
			(pageSetting.getTopMargin() * printerDPI.x) / 72,
			(pageSetting.getLeftMargin() * printerDPI.x) / 72,
			(pageSetting.getBottomMargin() * printerDPI.x) / 72,
			(pageSetting.getRightMargin() * printerDPI.x) / 72);

	Rectangle paperBounds = new Rectangle(this.getPrinter().getBounds());
	Rectangle printRegion = shrink(paperBounds, notAvailable);
	printRegion.intersect(shrink(paperBounds, userPreferred));
	printRegion.translate(trim.x, trim.y);
	
	return printRegion;
}
 
Example 4
Source File: CrossflowTextSelectionEditPolicy.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected Rectangle getFeedbackBounds() {
	Rectangle bounds;
	if (getHostFigure() instanceof Label) {
		bounds = ((Label) getHostFigure()).getTextBounds();
		bounds.intersect(getHostFigure().getBounds());
	} else {
		bounds = getHostFigure().getBounds().getCopy();
	}
	getHostFigure().getParent().translateToAbsolute(bounds);
	getFeedbackLayer().translateToRelative(bounds);
	return bounds;
}
 
Example 5
Source File: CrossflowTextNonResizableEditPolicy.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected Rectangle getFeedbackBounds() {
	Rectangle bounds;
	if (getHostFigure() instanceof Label) {
		bounds = ((Label) getHostFigure()).getTextBounds();
		bounds.intersect(getHostFigure().getBounds());
	} else {
		bounds = getHostFigure().getBounds().getCopy();
	}
	getHostFigure().getParent().translateToAbsolute(bounds);
	getFeedbackLayer().translateToRelative(bounds);
	return bounds;
}
 
Example 6
Source File: TableUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks if the given figure is visible.
 * 
 * @param fig
 * @return
 */
private static boolean isFigureVisible( IFigure fig )
{
	Rectangle figBounds = fig.getBounds( ).getCopy( );
	IFigure walker = fig.getParent( );
	while ( !figBounds.isEmpty( ) && walker != null )
	{
		walker.translateToParent( figBounds );
		figBounds.intersect( walker.getBounds( ) );
		walker = walker.getParent( );
	}
	return !figBounds.isEmpty( );
}
 
Example 7
Source File: RootDragTracker.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isFigureVisible( IFigure fig )
{
	Rectangle figBounds = fig.getBounds( ).getCopy( );
	IFigure walker = fig.getParent( );
	while ( !figBounds.isEmpty( ) && walker != null )
	{
		walker.translateToParent( figBounds );
		figBounds.intersect( walker.getBounds( ) );
		walker = walker.getParent( );
	}
	return !figBounds.isEmpty( );
}
 
Example 8
Source File: ProcessTextNonResizableEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Rectangle getFeedbackBounds() {
	Rectangle bounds;
	if (getHostFigure() instanceof Label) {
		bounds = ((Label) getHostFigure()).getTextBounds();
		bounds.intersect(getHostFigure().getBounds());
	} else {
		bounds = getHostFigure().getBounds().getCopy();
	}
	getHostFigure().getParent().translateToAbsolute(bounds);
	getFeedbackLayer().translateToRelative(bounds);
	return bounds;
}
 
Example 9
Source File: ProcessTextSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Rectangle getFeedbackBounds() {
	Rectangle bounds;
	if (getHostFigure() instanceof Label) {
		bounds = ((Label) getHostFigure()).getTextBounds();
		bounds.intersect(getHostFigure().getBounds());
	} else {
		bounds = getHostFigure().getBounds().getCopy();
	}
	getHostFigure().getParent().translateToAbsolute(bounds);
	getFeedbackLayer().translateToRelative(bounds);
	return bounds;
}