當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.addPaintListener方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.Canvas.addPaintListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.addPaintListener方法的具體用法?Java Canvas.addPaintListener怎麽用?Java Canvas.addPaintListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.Canvas的用法示例。


在下文中一共展示了Canvas.addPaintListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PixelPerfect

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public PixelPerfect(Composite parent) {
    super(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    mCanvas = new Canvas(this, SWT.NONE);
    setContent(mCanvas);
    setExpandHorizontal(true);
    setExpandVertical(true);
    mModel = PixelPerfectModel.getModel();
    mModel.addImageChangeListener(this);

    mCanvas.addPaintListener(mPaintListener);
    mCanvas.addMouseListener(mMouseListener);
    mCanvas.addMouseMoveListener(mMouseMoveListener);
    mCanvas.addKeyListener(mKeyListener);

    addDisposeListener(mDisposeListener);

    mCrosshairColor = new Color(Display.getDefault(), new RGB(0, 255, 255));
    mBorderColor = new Color(Display.getDefault(), new RGB(255, 0, 0));
    mMarginColor = new Color(Display.getDefault(), new RGB(0, 255, 0));
    mPaddingColor = new Color(Display.getDefault(), new RGB(0, 0, 255));

    imageLoaded();
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:24,代碼來源:PixelPerfect.java

示例2: createPartControl

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public void createPartControl(Composite parent) {
	setTitleImage(Images.TYPE_ACTSPEED);
	canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED);
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			try {
				area = canvas.getClientArea();
				drawCanvasImage(e.gc);
			} catch (Throwable t) {
				t.printStackTrace();
			}
		}
	});
	
	window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:17,代碼來源:ActiveSpeedCommonView.java

示例3: createSWTControl

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
@Override
protected Canvas createSWTControl(final Composite parent) throws Exception
{
    createColors();

    // Unfortunately, the canvas is not transparent..
    final Canvas canvas = new Canvas(parent, SWT.NO_FOCUS | SWT.NO_BACKGROUND | SWT.TRANSPARENT);
    canvas.addPaintListener(this::doPaint);

    canvas.addDisposeListener((e) ->
    {
        for (final Color color : colors)
            color.dispose();
    });
    return canvas;
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:17,代碼來源:LEDRepresentation.java

示例4: createUI_20_PageShellImage

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private Composite createUI_20_PageShellImage(final Composite parent) {

		final Canvas resizeCanvas = new Canvas(//
				parent,
//				SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE//
				SWT.NONE //
		);

		resizeCanvas.setLayout(new FillLayout());

//		resizeCanvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));

		resizeCanvas.addPaintListener(new PaintListener() {
			@Override
			public void paintControl(final PaintEvent e) {
				onPaintShellImage(e);
			}
		});

		return resizeCanvas;
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:22,代碼來源:AbstractRRShell.java

示例5: GraphicalViewer

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public GraphicalViewer(Composite parent) {
    canvas = new Canvas(parent, SWT.NONE);
    parent.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            canvas.setBounds(canvas.getParent().getClientArea());
            requestImageRedraw();
        }
    });
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            redrawImageIfRequested();
            GC gc = e.gc;
            paintCanvas(gc);
        }

    });
}
 
開發者ID:abstratt,項目名稱:eclipsegraphviz,代碼行數:18,代碼來源:GraphicalViewer.java

示例6: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Canvas cCenter = new Canvas( shell, SWT.NONE );
	AutoDataBindingViewer adbv = new AutoDataBindingViewer(  );
	cCenter.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	cCenter.addPaintListener( adbv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:26,代碼來源:AutoDataBindingViewer.java

示例7: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Canvas cCenter = new Canvas( shell, SWT.NONE );
	StyleChartViewer cv = new StyleChartViewer(  );
	cCenter.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	cCenter.addPaintListener( cv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:26,代碼來源:StyleChartViewer.java

示例8: AudioLevelMeter

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public AudioLevelMeter(Composite parent, int style) {
	super(parent, style);
	setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
	setLayout(new FillLayout(SWT.HORIZONTAL));
	canvas = new Canvas(this, SWT.NONE);
	canvas.setBackground(SWTResourceManager
			.getColor(SWT.COLOR_WIDGET_BACKGROUND));
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			Rectangle clientArea = canvas.getBounds();
			float w = clientArea.width * level;
			int y = clientArea.height;
			e.gc.fillRectangle(0, y, (int) w, (int) y);
		}
	});
}
 
開發者ID:jeukku,項目名稱:waazdoh.music.swt,代碼行數:23,代碼來源:AudioLevelMeter.java

示例9: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public static void main(String[] args) {
   final Display display = new Display();
   Shell shell = new Shell(display);
   shell.setText("Canvas Example");
   shell.setLayout(new FillLayout());

   Canvas canvas = new Canvas(shell, SWT.NONE);

   canvas.addPaintListener(new PaintListener() {
     @Override
public void paintControl(PaintEvent e) {
       
       e.gc.setFont(display.getSystemFont());
       
       e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5);
       e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5);
     }
   });

   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   display.dispose();
 }
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:28,代碼來源:FontSystemGettingSWT.java

示例10: createPreviewArea

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private void createPreviewArea(Composite cont) {
		previewGrp = new Group(cont, SWT.NONE);
		previewGrp.setText(Msgs.get("search.kws.preview"));
		previewGrp.setLayout(new FillLayout());
//		previewGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		canvas = new Canvas(previewGrp, SWT.NONE);
		canvas.setBackground(Colors.getSystemColor(SWT.COLOR_GRAY));
		
		canvas.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				if(currentImgOrig != null) {
					Rectangle client = canvas.getClientArea();
					if(currentImgScaled != null) {
						currentImgScaled.dispose();
					}
					currentImgScaled = Images.resize(currentImgOrig, client.width, client.height,
							Colors.getSystemColor(SWT.COLOR_GRAY));
					Rectangle imgBounds = currentImgScaled.getBounds();
					final int xOffset = (client.width - imgBounds.width) / 2; 
					e.gc.drawImage(currentImgScaled, xOffset, 0);
				}
			}
		});
	    
	    canvas.addListener (SWT.Resize,  e -> {
	    	if(currentImgOrig != null) {
				canvas.redraw ();
	    	}
		});
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:31,代碼來源:KwsResultViewer.java

示例11: createAnnotationInformation

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	GridLayout layout = new GridLayout(2, false);
	layout.marginHeight = 2;
	layout.marginWidth = 2;
	layout.horizontalSpacing = 0;
	composite.setLayout(layout);

	final Canvas canvas = new Canvas(composite, SWT.NO_FOCUS);
	GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
	gridData.widthHint = 17;
	gridData.heightHint = 16;
	canvas.setLayoutData(gridData);
	canvas.addPaintListener(new PaintListener() {

		@Override
		public void paintControl(PaintEvent e) {
			e.gc.setFont(null);
			fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
		}
	});

	StyledText text = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	text.setLayoutData(data);
	String annotationText = annotation.getText();
	if (annotationText != null)
		text.setText(annotationText);
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:31,代碼來源:AbstractAnnotationHover.java

示例12: createAnnotationInformation

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
	Composite composite= new Composite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	GridLayout layout= new GridLayout(2, false);
	layout.marginHeight= 2;
	layout.marginWidth= 2;
	layout.horizontalSpacing= 0;
	composite.setLayout(layout);

	final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
	GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
	gridData.widthHint= 17;
	gridData.heightHint= 16;
	canvas.setLayoutData(gridData);
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			e.gc.setFont(null);
			fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
		}
	});

	StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
	GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
	text.setLayoutData(data);
	String annotationText= annotation.getText();
	if (annotationText != null)
		text.setText(annotationText);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:29,代碼來源:AnnotationWithQuickFixesHover.java

示例13: createShell

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private static void createShell() {
    sShell = new Shell(Display.getDefault(), SWT.CLOSE | SWT.TITLE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    sShell.setLayout(gridLayout);

    sButtonBar = new Composite(sShell, SWT.NONE);
    RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
    rowLayout.pack = true;
    rowLayout.center = true;
    sButtonBar.setLayout(rowLayout);
    Composite buttons = new Composite(sButtonBar, SWT.NONE);
    buttons.setLayout(new FillLayout());

    sOnWhite = new Button(buttons, SWT.TOGGLE);
    sOnWhite.setText("On White");
    sOnBlack = new Button(buttons, SWT.TOGGLE);
    sOnBlack.setText("On Black");
    sOnBlack.setSelection(true);
    sOnWhite.addSelectionListener(sWhiteSelectionListener);
    sOnBlack.addSelectionListener(sBlackSelectionListener);

    sShowExtras = new Button(sButtonBar, SWT.CHECK);
    sShowExtras.setText("Show Extras");
    sShowExtras.addSelectionListener(sExtrasSelectionListener);

    sCanvas = new Canvas(sShell, SWT.NONE);
    sCanvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    sCanvas.addPaintListener(sPaintListener);

    sShell.addShellListener(sShellListener);

    ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
    Image image = imageLoader.loadImage("display.png", Display.getDefault()); //$NON-NLS-1$
    sShell.setImage(image);
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:38,代碼來源:CaptureDisplay.java

示例14: SpinnerThread

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public SpinnerThread(Composite parent, Object layoutData) {
	this.parent = parent;
	this.setName(ThreadUtil.getName(this));
	final Image image = new Image(parent.getDisplay(), imageDatas[0].width,imageDatas[0].height);
	canvas = new Canvas(parent, SWT.NULL);
	if (layoutData != null) {
		canvas.setLayoutData(layoutData);
	}
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			e.gc.drawImage(image, 0, 0);
		}
	});
	gc = new GC(image);
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:16,代碼來源:SpinnerThread.java

示例15: createSWTControl

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
@Override
protected Canvas createSWTControl(final Composite parent) throws Exception
{   // Unfortunately, the canvas is not transparent..
    final Canvas canvas = new Canvas(parent, SWT.NO_FOCUS | SWT.NO_BACKGROUND | SWT.TRANSPARENT);
    canvas.addPaintListener(this::doPaint);
    return canvas;
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:8,代碼來源:RectangleRepresentation.java


注:本文中的org.eclipse.swt.widgets.Canvas.addPaintListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。