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


Java PaintListener類代碼示例

本文整理匯總了Java中org.eclipse.swt.events.PaintListener的典型用法代碼示例。如果您正苦於以下問題:Java PaintListener類的具體用法?Java PaintListener怎麽用?Java PaintListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: SWTStrokeCanvas

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:SWTStrokeCanvas.java

示例2: main

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public static void main(String[] args) {
	Display display = Display.getDefault();
	Shell shell = new Shell(display, SWT.DIALOG_TRIM);
	shell.setLayout(new FillLayout());

	Composite c = new Composite(shell, SWT.BORDER);
	c.setLayout(new FillLayout());
	c.addPaintListener(new PaintListener() {
		@Override
		public void paintControl(PaintEvent e) {
			e.gc.drawLine(0, 0, 100, 50);
		}
	});

	Label lbl = new Label(c, SWT.NONE);
	lbl.setText("text");

	shell.open();

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

示例3: SWTBenchTest

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
 * Create a new Piccolo2D SWT benchmarking test suite with the specified parent and style.
 *
 * @param parent parent
 * @param style style
 */
private SWTBenchTest(final Composite parent, final int style) {
    super(parent, style);

    testImageOpaque = loadImage(getDisplay(), "opaque.jpg");
    testImageBitmask = loadImage(getDisplay(), "bitmask.gif");
    testImageTranslucent = loadImage(getDisplay(), "translucent.png");
    testImageARGB = new Image(getDisplay(), 128, 128);

    final GC tmpGC = new GC(testImageARGB);
    tmpGC.drawImage(testImageTranslucent, 0, 0);
    tmpGC.dispose();

    addPaintListener(new PaintListener() {
        public void paintControl(final PaintEvent pe) {
            runAll(new SWTGraphics2D(pe.gc, getDisplay()));
        }
    });
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:25,代碼來源:SWTBenchTest.java

示例4: CustomSeparator

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public CustomSeparator( Composite parent, int style) {
   super(parent, style = checkStyle(style));

   this.style = style;

   if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0)
      lineSize = 2;
   else
      lineSize = 1;

   addPaintListener(new PaintListener() {
      public void paintControl( PaintEvent event){
         onPaint(event);
      }
   });
}
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:17,代碼來源:CustomSeparator.java

示例5: init

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public void init() {
	if(TuxGuitar.getInstance().getConfig().getBooleanValue(TGConfigKeys.SHOW_SPLASH)){
		final Image image = TuxGuitar.getInstance().getIconManager().getAppSplash();
		
		this.shell = new Shell(TuxGuitar.getInstance().getDisplay(), SWT.NO_TRIM | SWT.NO_BACKGROUND);
		this.shell.setLayout(new FillLayout());
		this.shell.setBounds(getBounds(image));
		this.shell.setImage(TuxGuitar.getInstance().getIconManager().getAppIcon());
		this.shell.setText(TuxGuitar.APPLICATION_NAME);
		this.shell.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				TGPainter painter = new TGPainterImpl(e.gc);
				painter.drawImage(new TGImageImpl(image), 0, 0);
			}
		});
		this.shell.open();
		this.shell.redraw();
		this.shell.update();
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:21,代碼來源:TGSplash.java

示例6: init

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public void init() {
	this.setLayout(new GridLayout(1,true));
	this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	((GridData)this.getLayoutData()).widthHint = 600;
	
	
	this.composite = new Composite(this,SWT.BORDER | SWT.DOUBLE_BUFFERED);
	this.composite.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	this.composite.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			TGPainterImpl painter = new TGPainterImpl(e.gc);
			TGTunerRoughWidget.this.paintWidget(painter);
		}

	});
	GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
	data.minimumHeight = MIN_HEIGHT;
	data.grabExcessHorizontalSpace = true;
	this.composite.setLayoutData(data);

}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:22,代碼來源:TGTunerRoughWidget.java

示例7: createContents

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
 * Create contents of the shell.
 */
protected void createContents() {
	setText("SWT Application");
	setSize(673, 173);
	windowLocation.showWindowOnScreenCenter(this);
	addPaintListener(new PaintListener() {
		
		@Override
		public void paintControl(PaintEvent e) {
			// TODO Auto-generated method stub
			e.gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
			e.gc.drawString(infotext, 20, getSize().y-20,true);
			
		}
	});

}
 
開發者ID:piiiiq,項目名稱:Black,代碼行數:20,代碼來源:startInfo.java

示例8: RotatedLabel

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public RotatedLabel(Composite parent, int style) {
	super(parent, style);

	this.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			paint(e);
		}
	});
	this.addListener(SWT.MouseDown, new Listener() {

		@Override
		public void handleEvent(Event event) {
			if (switchListener != null && !isDefinitionSectionExpanded)
				switchListener.handleSelection();
		}
	});
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:18,代碼來源:StatechartDiagramEditor.java

示例9: createPartControl

import org.eclipse.swt.events.PaintListener; //導入依賴的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

示例10: createUI_20_PageShellImage

import org.eclipse.swt.events.PaintListener; //導入依賴的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

示例11: CanvasImpl

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public CanvasImpl(
    final IGenericWidgetFactory factory,
    final Object parentUiReference,
    final ICanvasSetupSpi setup,
    final SwtImageRegistry imageRegistry) {
    super(factory, new Canvas((Composite) parentUiReference, getStyle(setup)), imageRegistry);
    getUiReference().setBackgroundMode(SWT.INHERIT_DEFAULT);
    this.paintObservable = new PaintObservable();

    getUiReference().addPaintListener(new PaintListener() {
        @Override
        public void paintControl(final PaintEvent e) {
            final Dimension size = getSize();
            final Rectangle bounds = new Rectangle(0, 0, size.getWidth(), size.getHeight());
            final Rectangle clipBounds = new Rectangle(e.x, e.y, e.width, e.height);
            final GraphicContextSpiImpl graphicContext = new GraphicContextSpiImpl(e.gc, bounds, imageRegistry);
            paintObservable.firePaint(new PaintEventSpiImpl(graphicContext, clipBounds));
        }
    });
}
 
開發者ID:jo-source,項目名稱:jo-widgets,代碼行數:21,代碼來源:CanvasImpl.java

示例12: SpinnerProgress

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
    * Constructor
    * 
    * @param parent Parent
    * @param style Style flags
    */
public SpinnerProgress(Composite parent, int style) {
	super(parent, style);
	
	// Add paint listener
	addPaintListener(new PaintListener() {
		@Override
		public void paintControl(PaintEvent e) {
			onPaint(e);
		}
	});
	// Set font
	setFont(parent.getFont());
	// Create spoke colors
	createColors(getDisplay());
	// Compute spoke angles
	computeSpokeAngles();
}
 
開發者ID:MentorEmbedded,項目名稱:p2-installer,代碼行數:24,代碼來源:SpinnerProgress.java

示例13: AnimateControl

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
 * Constructor
 * 
 * @param parent Parent
 * @param image Image to display
 */
public AnimateControl(Composite parent, int style, Image[] images) {
	super(parent, style);
	
	// Image attributes
	this.images = images;
	imageWidth = images[0].getImageData().width;
	imageHeight = images[0].getImageData().height;
	
	// Add paint listener
	addPaintListener(new PaintListener() {
		@Override
		public void paintControl(PaintEvent e) {
			onPaint(e);
		}
	});
}
 
開發者ID:MentorEmbedded,項目名稱:p2-installer,代碼行數:23,代碼來源:AnimateControl.java

示例14: highlight

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
protected void highlight(final Composite parent, final Label labelControl, final Combo comboBox, final int color) {
	Object data= labelControl.getData();
	if (data == null) {
		if (color != HIGHLIGHT_NONE) {
			PaintListener painter= new HighlightPainter(parent, labelControl, comboBox, color);
			parent.addPaintListener(painter);
			labelControl.setData(painter);
		} else {
			return;
		}
	} else {
		if (color == HIGHLIGHT_NONE) {
			parent.removePaintListener((PaintListener) data);
			labelControl.setData(null);
		} else if (color != ((HighlightPainter) data).fColor){
			((HighlightPainter) data).fColor= color;
		} else {
			return;
		}
	}
	
	parent.redraw();
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:24,代碼來源:OptionsConfigurationBlock.java

示例15: main

import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public static void main(String[] args) {
	Display display = Display.getDefault();
	Shell shell = new Shell(display, SWT.DIALOG_TRIM);
	shell.setLayout(new FillLayout());

	Composite c = new Composite(shell, SWT.BORDER);
	c.setLayout(new FillLayout());
	c.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			e.gc.drawLine(0, 0, 100, 50);
		}
	});

	Label lbl = new Label(c, SWT.NONE);
	lbl.setText("text");

	shell.open();

	while (!shell.isDisposed()) {
		if (display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
開發者ID:AcademicTorrents,項目名稱:AcademicTorrents-Downloader,代碼行數:25,代碼來源:SWTBGImagePainter.java


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