Java Code Examples for org.eclipse.swt.graphics.Region#add()

The following examples show how to use org.eclipse.swt.graphics.Region#add() . 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: TabBar.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
Region createRoundedTopRegion(int xOffset, int yOffset, int width, int height)
{
    Region reg = new Region(getDisplay());
    reg.add(xOffset, yOffset, width, height);
    reg.subtract(xOffset + 0, yOffset + 0, 5, 1);
    reg.subtract(xOffset + 0, yOffset + 1, 3, 1);
    reg.subtract(xOffset + 0, yOffset + 2, 2, 1);
    reg.subtract(xOffset + 0, yOffset + 3, 1, 1);
    reg.subtract(xOffset + 0, yOffset + 4, 1, 1);

    reg.subtract(xOffset + width - 5, yOffset + 0, 5, 1);
    reg.subtract(xOffset + width - 3, yOffset + 1, 3, 1);
    reg.subtract(xOffset + width - 2, yOffset + 2, 2, 1);
    reg.subtract(xOffset + width - 1, yOffset + 3, 1, 1);
    reg.subtract(xOffset + width - 1, yOffset + 4, 1, 1);
    
    return reg;
}
 
Example 2
Source File: SwtRendererImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setClip( ClipRenderEvent cre )
{
	final Location[] loa = cre.getVertices( );

	if ( loa == null )
	{
		_gc.setClipping( (Region) null );
	}
	else
	{
		Region rgClipping = new Region( );
		rgClipping.add( getCoordinatesAsInts( loa,
				TRUNCATE,
				dTranslateX,
				dTranslateY,
				dScale ) );
		_gc.setClipping( rgClipping );
		rgClipping.dispose( );
	}
}
 
Example 3
Source File: RegionAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * RegionAction constructor taking a polygon to define the region
 * 
 * @param oSource
 *            StructureSource
 * @param loa
 *            Polygon points
 * @param ac
 *            Action
 * @param dTranslateX
 *            X Translation to apply on polygon coordinates
 * @param dTranslateY
 *            Y Translation to apply on polygon coordinates
 * @param dScale
 *            Scale to apply on polygon coordinates
 * @param clipping
 *            Clipping area, points outside it will be clipped
 */
RegionAction( StructureSource oSource, Location[] loa, Action ac,
		double dTranslateX, double dTranslateY, double dScale,
		Region clipping )
{
	_oSource = oSource;
	final int[] i2a = SwtRendererImpl.getCoordinatesAsInts( loa,
			SwtRendererImpl.TRUNCATE,
			dTranslateX,
			dTranslateY,
			dScale );
	Region sh = new Region( );
	sh.add( i2a );
	if ( clipping != null )
	{
		sh.intersect( clipping );
	}
	_ac = ac;

	this.region = sh;
}
 
Example 4
Source File: RegionAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This constructor supports shape definition via a rectangle.
 * 
 * @param oSource
 *            StructureSource
 * @param bo
 *            Rectangle
 * @param ac
 *            Action
 * @param dTranslateX
 *            X translation to apply to rectangle
 * @param dTranslateY
 *            Y translation to apply to rectangle
 * @param dScale
 *            scale to apply to rectangle
 * @param clipping
 *            Clipping area, points outside it will be clipped
 */
RegionAction( StructureSource oSource, Bounds bo, Action ac,
		double dTranslateX, double dTranslateY, double dScale,
		Region clipping )
{
	_oSource = oSource;

	bo = goFactory.copyOf( bo );
	bo.translate( dTranslateX, dTranslateY );
	bo.scale( dScale );

	Rectangle rect = new Rectangle( (int) bo.getLeft( ),
			(int) bo.getTop( ),
			(int) bo.getWidth( ),
			(int) bo.getHeight( ) );

	Region sh = new Region( );
	sh.add( rect );
	if ( clipping != null )
	{
		sh.intersect( clipping );
	}
	_ac = ac;

	this.region = sh;
}
 
Example 5
Source File: PopOverShell.java    From swt-bling with MIT License 6 votes vote down vote up
/**
 * Shows the PopOverShell in a suitable location relative to the parent component. Classes extending PopOverShell will
 * provide the <code>Region</code> via the abstract <code>getAppropriatePopOverRegion()</code> method.
 */
public void show() {
  runBeforeShowPopOverShell();

  Point popOverShellSize = getAppropriatePopOverSize();
  popOverRegion = new Region();
  popOverRegion.add(new Rectangle(0, 0, popOverShellSize.x, popOverShellSize.y));

  Point location = getPopOverShellLocation(parentShell, poppedOverItem, popOverRegion);

  popOverShell.setRegion(popOverRegion);
  popOverShell.setSize(popOverRegion.getBounds().width, popOverRegion.getBounds().height);
  popOverShell.setLocation(location);
  popOverShell.setAlpha(FULLY_VISIBLE_ALPHA);
  popOverShell.setVisible(true);
}
 
Example 6
Source File: RegionAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This constructor supports shape definition via an elliptical arc
 * 
 * @param oSource
 * @param boEllipse
 * @param dStart
 * @param dExtent
 * @param iArcType
 * @param ac
 */
RegionAction( StructureSource oSource, Bounds boEllipse, double dStart,
		double dExtent, int iArcType, Action ac, double dTranslateX,
		double dTranslateY, double dScale, Region clipping )
{
	_oSource = oSource;

	boEllipse = goFactory.copyOf( boEllipse );
	boEllipse.translate( dTranslateX, dTranslateY );
	boEllipse.scale( dScale );

	Shape shape = new Arc2D.Double( boEllipse.getLeft( ),
			boEllipse.getTop( ),
			boEllipse.getWidth( ),
			boEllipse.getHeight( ),
			dStart,
			dExtent,
			toSwingArcType( iArcType ) );

	int[] i2a = shape2polyCoords( shape );
	Region sh = new Region( );
	sh.add( i2a );

	if ( clipping != null )
	{
		sh.intersect( clipping );
	}

	_ac = ac;
	this.region = sh;

}
 
Example 7
Source File: DynamicAddRemoveLineComposite.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param parent
 * @param style
 */
public DynamicAddRemoveLineComposite(Composite parent, int style) {
	super(parent, style);
	if(getWidgetFactory() != null) {
		this.setBackground(ColorConstants.white);
	}
	this.setLayout(new GridLayout(2, false));

	imageplus = Pics.getImage(PicsConstants.plusBlack);
	imagemoins = Pics.getImage(PicsConstants.remove);

	minusGD = GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).create();
	// circle button
	regionForAdd = new Region();
	regionForAdd.add(createCircle(13, 13, 10));

	addButton = createAddButton(this);
	addButton.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create()) ;
	addButton.addSelectionListener(new SelectionAdapter() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
		 * .swt.events.SelectionEvent)
		 */
		@Override
		public void widgetSelected(SelectionEvent e) {
			addLine(null);
		}
	});
}
 
Example 8
Source File: ResourceQueryTest.java    From swt-bling with MIT License 5 votes vote down vote up
@Test
public void getResources_Create4Regions_CountEquals4() {
  Map<String, Integer> counts = ResourceQuery.getAllocatedResourceCounts(display);
  for (int i = 10; i < 14; i++) {
    Region r = new Region(display);
    r.add(0,0, i,i);
  }
  Assert.assertEquals(4, ResourceQuery.getAllocatedResourceCounts(display).get(Region.class.getName()).intValue());
}