当前位置: 首页>>代码示例>>Java>>正文


Java Region.dispose方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.Region.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Region.dispose方法的具体用法?Java Region.dispose怎么用?Java Region.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.Region的用法示例。


在下文中一共展示了Region.dispose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clipPath

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
/**
 * Simple implementation of clipping a Path within the context of current
 * clipping rectangle for now (not region) <li>Note that this method wipes
 * out the clipping rectangle area, hence if clients need to reset it call
 * {@link #restoreState()}
 * 
 * @see org.eclipse.draw2d.Graphics#clipPath(org.eclipse.swt.graphics.Path)
 */
public void clipPath(Path path) {
	initTransform(false);
	if (((appliedState.graphicHints ^ currentState.graphicHints) & FILL_RULE_MASK) != 0) {
		// If there is a pending change to the fill rule, apply it first.
		gc.setFillRule(((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT)
				- FILL_RULE_WHOLE_NUMBER);
		// As long as the FILL_RULE is stored in a single bit, just toggling
		// it works.
		appliedState.graphicHints ^= FILL_RULE_MASK;
	}
	Rectangle clipping = currentState.relativeClip != null ? getClip(new Rectangle())
			: new Rectangle();
	if (!clipping.isEmpty()) {
		Path flatPath = new Path(path.getDevice(), path, 0.01f);
		PathData pathData = flatPath.getPathData();
		flatPath.dispose();
		Region region = new Region(path.getDevice());
		loadPath(region, pathData.points, pathData.types);
		region.intersect(new org.eclipse.swt.graphics.Rectangle(clipping.x,
				clipping.y, clipping.width, clipping.height));
		gc.setClipping(region);
		appliedState.relativeClip = currentState.relativeClip = null;
		region.dispose();
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:34,代码来源:SWTGraphics.java

示例2: setClip

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
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( );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:21,代码来源:SwtRendererImpl.java

示例3: paintContainer

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
void paintContainer(PaintEvent event) {
	GC gc = event.gc;
	gc.setAdvanced(true);
	if (gc.getAdvanced())
		gc.setAntialias(SWT.ON);

	Point size = composite.getSize();
	int h = size.y;
	int[] simpleCurve = new int[] { 0, h - 1, 1, h - 1, 2, h - 2, 2, 1, 3,
			0 };

	gc.setForeground(getContainerCurveColor(event));
	gc.drawPolyline(simpleCurve);

	Rectangle bounds = ((Control) event.widget).getBounds();
	bounds.x = bounds.y = 0;
	Region r = new Region();
	r.add(bounds);

	int[] simpleCurveClose = new int[simpleCurve.length + 4];
	System.arraycopy(simpleCurve, 0, simpleCurveClose, 0,
			simpleCurve.length);
	int index = simpleCurve.length;
	simpleCurveClose[index++] = bounds.width;
	simpleCurveClose[index++] = 0;
	simpleCurveClose[index++] = bounds.width;
	simpleCurveClose[index++] = bounds.height;

	r.subtract(simpleCurveClose);

	Region clipping = new Region();
	gc.getClipping(clipping);
	r.intersect(clipping);
	gc.setClipping(r);

	clipping.dispose();
	r.dispose();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:39,代码来源:PerspectiveSwitcherSwtTrim.java

示例4: drawOverlay_Label

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
private void drawOverlay_Label(	final ChartLabel chartLabel,
								final GC gc,
								final Color colorDefault,
								final Color colorDevice,
								final Color colorHidden,
								final boolean isSelected) {

	if (chartLabel == null) {
		return;
	}

	if (isSelected) {
		gc.setAlpha(0x60);
	} else {
		gc.setAlpha(0x30);
	}

	if (isSelected) {

		final Color selectedColorBg = gc.getDevice().getSystemColor(SWT.COLOR_DARK_GRAY);
		gc.setBackground(selectedColorBg);

	} else if (chartLabel.isDeviceMarker()) {
		gc.setBackground(colorDevice);
	} else if (chartLabel.isVisible) {
		gc.setBackground(colorDefault);
	} else {
		gc.setBackground(colorHidden);
	}

	/*
	 * Rectangles can be merged into a union with regions, took me some time to find this
	 * solution :-)
	 */
	final Region region = new Region(gc.getDevice());

	final Rectangle paintedLabel = chartLabel.paintedLabel;
	if (paintedLabel != null) {

		final int devLabelX = paintedLabel.x - MARKER_HOVER_SIZE;
		final int devLabelY = paintedLabel.y - MARKER_HOVER_SIZE;
		final int devLabelWidth = paintedLabel.width + 2 * MARKER_HOVER_SIZE;
		final int devLabelHeight = paintedLabel.height + 2 * MARKER_HOVER_SIZE;

		region.add(devLabelX, devLabelY, devLabelWidth, devLabelHeight);
	}

	final int devMarkerX = chartLabel.devXMarker - MARKER_HOVER_SIZE;
	final int devMarkerY = chartLabel.devYMarker - MARKER_HOVER_SIZE;
	final int devMarkerSize = MARKER_POINT_SIZE + 2 * MARKER_HOVER_SIZE;

	region.add(devMarkerX, devMarkerY, devMarkerSize, devMarkerSize);

	// get whole chart rect
	final Rectangle clientRect = gc.getClipping();

	gc.setClipping(region);
	{
		gc.fillRectangle(clientRect);
	}
	region.dispose();
	gc.setClipping((Region) null);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:64,代码来源:ChartLayerMarker.java

示例5: showException

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
/**
 * Show the exception message that prevented to draw the chart
 * 
 * @param g2d
 * @param ex
 *            The exception that occured
 */
private final void showException( GC g2d, Exception ex )
{
	Point pTLC = new Point( 0, 0 );

	// String sWrappedException = ex.getClass( ).getName( );
	Throwable th = ex;

	String sMessage = null;
	if ( th instanceof BirtException )
	{
		sMessage = ( (BirtException) th ).getLocalizedMessage( );
	}
	else
	{
		sMessage = ex.getMessage( );
	}

	if ( sMessage == null )
	{
		sMessage = "<null>"; //$NON-NLS-1$
	}
	// StackTraceElement[] stea = ex.getStackTrace( );
	Dimension d = getSize( );

	Device dv = Display.getCurrent( );
	Font fo = new Font( dv, "Courier", SWT.BOLD, 12 ); //$NON-NLS-1$
	g2d.setFont( fo );
	FontMetrics fm = g2d.getFontMetrics( );
	g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) );
	g2d.fillRectangle( pTLC.x + 20,
			pTLC.y + 20,
			d.width - 40,
			d.height - 40 );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
	g2d.drawRectangle( pTLC.x + 20,
			pTLC.y + 20,
			d.width - 40,
			d.height - 40 );
	Region rgPrev = new Region( );
	g2d.getClipping( rgPrev );
	g2d.setClipping( pTLC.x + 20, pTLC.y + 20, d.width - 40, d.height - 40 );
	int x = pTLC.x + 25, y = pTLC.y + 20 + fm.getHeight( );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
	g2d.drawString( ERROR_MSG, x, y );
	y += fm.getHeight( );
	g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) );
	g2d.drawText( sMessage, x, y );

	g2d.setClipping( rgPrev );
	rgPrev.dispose( );
	fo.dispose( );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:60,代码来源:DesignerRepresentation.java

示例6: setProperty

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
public final void setProperty( final String sProperty, final Object oValue )
{
	if ( sProperty.equals( IDeviceRenderer.UPDATE_NOTIFIER ) )
	{
		_iun = (IUpdateNotifier) oValue;
		iv.reset( );
		iv.setUpdateNotifier( _iun );

		cleanUpTriggers( );
		Object obj = _iun.peerInstance( );

		if ( obj instanceof Composite )
		{
			Composite jc = (Composite) obj;

			if ( _eh != null )
			{
				// We can't promise to remove all the old swtEventHandler
				// due to SWT limitation here, so be sure to just attach the
				// update_notifier only to one renderer.

				jc.removeMouseListener( _eh );
				jc.removeMouseMoveListener( _eh );
				jc.removeMouseTrackListener( _eh );
				jc.removeKeyListener( _eh );
				jc.removeFocusListener( _eh );

				_eh.dispose( );
			}

			_eh = new SwtEventHandler( iv, _lhmAllTriggers, _iun, getULocale( ) );
			
			jc.addMouseListener( _eh );
			jc.addMouseMoveListener( _eh );
			jc.addMouseTrackListener( _eh );
			jc.addKeyListener( _eh );
			jc.addFocusListener( _eh );
		}
	}
	else if ( sProperty.equals( IDeviceRenderer.GRAPHICS_CONTEXT ) )
	{
		_gc = (GC) oValue;

		if ( R31Enhance.isR31Available( ) )
		{
			Region rg = new Region( );
			_gc.getClipping( rg );

			R31Enhance.setAdvanced( _gc, true, rg );
			R31Enhance.setAntialias( _gc, SWT.ON );
			R31Enhance.setTextAntialias( _gc, SWT.ON );

			rg.dispose( );
		}
		_ids.setGraphicsContext(_gc );

		logger.log( ILogger.INFORMATION,
				Messages.getString( "SwtRendererImpl.info.graphics.context",//$NON-NLS-1$
						new Object[]{
								_gc.getClass( ).getName( ), _gc
						},
						getULocale( ) ) );
	}
	else if ( sProperty.equals( IDeviceRenderer.DPI_RESOLUTION ) )
	{
		getDisplayServer( ).setDpiResolution( ( (Integer) oValue ).intValue( ) );
	}
	else if ( sProperty.equals( IDeviceRenderer.EXPECTED_BOUNDS ) )
	{
		Bounds bo = (Bounds)oValue;
		int x = (int)Math.round( bo.getLeft( ) );
		int y = (int)Math.round( bo.getTop( ) );
		int width = (int)Math.round( bo.getWidth( ) );
		int height = (int)Math.round( bo.getHeight( ) );
		this._gc.setClipping( x, y, width, height );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:78,代码来源:SwtRendererImpl.java

示例7: redrawGadget

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
public void redrawGadget() {
	// create the region defining the gadget
	Region region = new Region();

	// set the circle data to the region
	int polygon = profiler.getPolygon();

	region.add(GadgetProfiler.generateCircle(polygon, polygon, polygon));

	// define the shape of the shell
	gadget.getShell().setRegion(region);

	Rectangle size = region.getBounds();
	gadget.getShell().setSize(size.width, size.height);

	// dispose of the region object
	region.dispose();

}
 
开发者ID:coddo,项目名称:TeamSubb,代码行数:20,代码来源:GadgetController.java

示例8: drawPie

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
public static void
drawPie(
	GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
	Rectangle image_size = image.getBounds();

	int	width_pad 	= ( width - image_size.width  )/2;
	int	height_pad 	= ( height - image_size.height  )/2;

    int angle = (percent * 360) / 100;
    if(angle<4){
    	angle = 0; // workaround fillArc rendering bug
    }

	Region old_clipping = new Region();

	gc.getClipping(old_clipping);

	Path path_done = new Path(gc.getDevice());

	path_done.addArc(x,y,width,height,90,-angle);
	path_done.lineTo( x+width/2, y+height/2);
	path_done.close();

	gc.setClipping( path_done );

	gc.drawImage(image, x+width_pad, y+height_pad+1);

	Path path_undone = new Path(gc.getDevice());

	path_undone.addArc(x,y,width,height,90-angle,angle-360);
	path_undone.lineTo( x+width/2, y+height/2);
	path_undone.close();

	gc.setClipping( path_undone );

	gc.setAlpha( 75 );
	gc.drawImage(image, x+width_pad, y+height_pad+1);
	gc.setAlpha( 255 );

	gc.setClipping( old_clipping );

	if ( draw_border ){

		gc.setForeground(Colors.blue);

		if ( percent == 100 ){

			gc.drawOval(x , y , width-1, height-1);

		}else{

			if ( angle > 0 ){

				gc.drawPath( path_done );
			}
		}
	}

	path_done.dispose();
	path_undone.dispose();
	old_clipping.dispose();

}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:65,代码来源:PieUtils.java

示例9: drawPie

import org.eclipse.swt.graphics.Region; //导入方法依赖的package包/类
public static void 
drawPie(
	GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border ) 
{
	Rectangle image_size = image.getBounds();
	
	int	width_pad 	= ( width - image_size.width  )/2;
	int	height_pad 	= ( height - image_size.height  )/2;
	
    int angle = (percent * 360) / 100;
    if(angle<4){
    	angle = 0; // workaround fillArc rendering bug
    }
    
	Region old_clipping = new Region();

	gc.getClipping(old_clipping);
	
	Path path_done = new Path(gc.getDevice());
	
	path_done.addArc(x,y,width,height,90,-angle);
	path_done.lineTo( x+width/2, y+height/2);
	path_done.close();
	
	gc.setClipping( path_done );
	
	gc.drawImage(image, x+width_pad, y+height_pad+1);
			
	Path path_undone = new Path(gc.getDevice());
	
	path_undone.addArc(x,y,width,height,90-angle,angle-360);
	path_undone.lineTo( x+width/2, y+height/2);
	path_undone.close();
	
	gc.setClipping( path_undone );
	
	gc.setAlpha( 75 );
	gc.drawImage(image, x+width_pad, y+height_pad+1);
	gc.setAlpha( 255 );

	gc.setClipping( old_clipping );
	
	if ( draw_border ){
		
		gc.setForeground(Colors.blue);
		
		if ( percent == 100 ){
			
			gc.drawOval(x , y , width-1, height-1);
			
		}else{
			
			if ( angle > 0 ){
				
				gc.drawPath( path_done );
			}
		}
	}
	
	path_done.dispose();
	path_undone.dispose();
	old_clipping.dispose();

}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:65,代码来源:PieUtils.java


注:本文中的org.eclipse.swt.graphics.Region.dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。