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


Java Canvas.setBackground方法代碼示例

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


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

示例1: createPreviewArea

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private void createPreviewArea( Composite parent )
{
	Composite cmpPreview = ChartUIUtil.createCompositeWrapper( parent );
	{
		GridData gridData = new GridData( GridData.FILL_BOTH );
		gridData.widthHint = CENTER_WIDTH_HINT;
		gridData.heightHint = 200;
		cmpPreview.setLayoutData( gridData );
	}

	Label label = new Label( cmpPreview, SWT.NONE );
	{
		label.setFont( JFaceResources.getBannerFont( ) );
		label.setText( Messages.getString( "TaskSelectData.Label.ChartPreview" ) ); //$NON-NLS-1$
	}

	previewCanvas = new Canvas( cmpPreview, SWT.BORDER );
	{
		GridData gd = new GridData( GridData.FILL_BOTH );
		previewCanvas.setLayoutData( gd );
		previewCanvas.setBackground( Display.getDefault( )
				.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
	}
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:25,代碼來源:TaskSelectData.java

示例2: createTopPreviewArea

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected void createTopPreviewArea( Composite parent )
{
	Composite cmpPreview = new Composite( parent, SWT.NONE );
	cmpPreview.setLayout( new GridLayout( ) );

	GridData gridData = new GridData( GridData.FILL_BOTH );
	gridData.horizontalSpan = 2;
	gridData.heightHint = 270;
	cmpPreview.setLayoutData( gridData );

	Label label = new Label( cmpPreview, SWT.NONE );
	{
		label.setText( getChartPreviewTitle( ) );
	}

	previewCanvas = new Canvas( cmpPreview, SWT.BORDER );
	previewCanvas.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	previewCanvas.setBackground( Display.getDefault( )
			.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );

	previewPainter = createPreviewPainter( );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:23,代碼來源:TaskSelectType.java

示例3: 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

示例4: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public static void main(String[] args) {
	Shell shell = new Shell(new Display());
	shell.setSize(1200, 500);
	shell.setLayout(new GridLayout());
	shell.setLocation(100, 150);

	Figure root = new Figure();
	root.setFont(shell.getFont());
	//		XYLayout layout = new XYLayout();
	//		root.setLayoutManager(layout);

	org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
	layout.horizontalSpacing = 100;
	root.setLayoutManager(layout);

	Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.white);
	canvas.setLayoutData(new GridData(GridData.FILL_BOTH));

	createDiagram(root);

	LightweightSystem lws = new LightweightSystem(canvas);
	lws.setContents(root);

	Display display = shell.getDisplay();
	shell.open();
	while (!shell.isDisposed()) {
		while (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:33,代碼來源:TestFigure.java

示例5: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public static void main(String[] args) {
	Shell shell = new Shell(new Display());
	shell.setSize(1200, 500);
	shell.setLayout(new GridLayout());
	shell.setLocation(100, 150);
	
	Figure root = new Figure();
	root.setFont(shell.getFont());
	//		XYLayout layout = new XYLayout();
	//		root.setLayoutManager(layout);
	
	org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
	layout.horizontalSpacing = 100;
	root.setLayoutManager(layout);
	
	Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.white);
	canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
	
	MatrixWidget widget = new MatrixWidget();
	MockArray array = new MockArray("int[]", new int[]{1,2,3}, new int[]{4,5,6}, new int[]{7,8,9}, new int[]{10,11,12});
	root.add(widget.createFigure(array));
	
	LightweightSystem lws = new LightweightSystem(canvas);
	lws.setContents(root);
	
	Display display = shell.getDisplay();
	shell.open();
	while (!shell.isDisposed()) {
		while (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:35,代碼來源:TestMatrixWidget.java

示例6: main

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
public static void main(String[] args) {
	Shell shell = new Shell(new Display());
	shell.setSize(365, 280);
	shell.setLayout(new GridLayout());

	Figure root = new Figure();
	root.setFont(shell.getFont());
	XYLayout layout = new XYLayout();
	root.setLayoutManager(layout);

	Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.white);
	canvas.setLayoutData(new GridData(GridData.FILL_BOTH));

	VarParser parser = new VarParser("src/pt/iscte/pandionj/tests/Test.java");
	parser.run();
	System.out.println(parser.toText());
	
	createDiagram(root, parser);
	
	LightweightSystem lws = new LightweightSystem(canvas);
	lws.setContents(root);
	

	Display display = shell.getDisplay();
	shell.open();
	while (!shell.isDisposed()) {
		while (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:33,代碼來源:TestFigureParser.java

示例7: 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

示例8: paintPad

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * create the samples adapting their size from a maximum of 22x22 to a minimum of 1x1 pixels.
 */
private void paintPad(){
	//Clear old elements
	for(Control child : colorComposite.getChildren()){
		child.dispose();
	}
	Rectangle rect = colorComposite.getClientArea();
	int sampleSize = 22;
	int spaceBetween = 1;
	int samplesRow = 18;
	int samplesColumn = 216/samplesRow;
	boolean enoughSize = false;
	while(!enoughSize && sampleSize != 0){
		boolean enoughWidth = ((sampleSize*samplesRow) + (spaceBetween*(samplesRow-1)))<rect.width;
		boolean enoughHeight = ((sampleSize*samplesColumn) + (spaceBetween*(samplesColumn-1)))<rect.height;
		enoughSize = enoughHeight & enoughWidth;
		if (!enoughSize) sampleSize--;
	}
	GridLayout colorLayout = new GridLayout(samplesRow, true);
	colorLayout.horizontalSpacing = spaceBetween;
	colorLayout.verticalSpacing = spaceBetween;
	colorComposite.setLayout(colorLayout);
	Iterator<RGB> colorIt = webColors.iterator();
	for(int i=0; i<samplesColumn; i++){
		for(int j=0; j<samplesRow; j++){
			Canvas canv = new Canvas(colorComposite, SWT.NONE);
			GridData canvData = new GridData();
			canvData.widthHint = sampleSize;
			canvData.heightHint = sampleSize;
			canv.setLayoutData(canvData);
			RGB actualColor = colorIt.next();
			canv.setBackground(imagesCache.getColor(actualColor));
			canv.setData(actualColor);
			canv.addMouseListener(colorSelectedAdapter);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:40,代碼來源:WebColorsWidget.java

示例9: paintPad

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * create the samples adapting their size from a maximum of 22x22 to a minimum of 1x1 pixels.
 */
private void paintPad(){
	//Clear old elements
	for(Control child : colorComposite.getChildren()){
		child.dispose();
	}
	Rectangle rect = colorComposite.getClientArea();
	int sampleSize = 22;
	int spaceBetween = 1;
	int samplesRow = 18;
	int samplesColumn = 216/samplesRow;
	boolean enoughSize = false;
	while(!enoughSize && sampleSize != 0){
		boolean enoughWidth = ((sampleSize*samplesRow) + (spaceBetween*(samplesRow-1)))<rect.width;
		boolean enoughHeight = ((sampleSize*samplesColumn) + (spaceBetween*(samplesColumn-1)))<rect.height;
		enoughSize = enoughHeight & enoughWidth;
		if (!enoughSize) sampleSize--;
	}
	GridLayout colorLayout = new GridLayout(samplesRow, true);
	colorLayout.horizontalSpacing = spaceBetween;
	colorLayout.verticalSpacing = spaceBetween;
	colorComposite.setLayout(colorLayout);
	Iterator<AlfaRGB> colorIt = usedColors.iterator();
	for(int i=0; i<samplesColumn && colorIt.hasNext(); i++){
		for(int j=0; j<samplesRow && colorIt.hasNext(); j++){
			Canvas canv = new Canvas(colorComposite, SWT.NONE);
			GridData canvData = new GridData();
			canvData.widthHint = sampleSize;
			canvData.heightHint = sampleSize;
			canv.setLayoutData(canvData);
			AlfaRGB actualColor = colorIt.next();
			canv.setBackground(imagesCache.getColor(actualColor.getRgb()));
			canv.setData(actualColor);
			canv.addMouseListener(colorSelectedAdapter);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:40,代碼來源:LastUsedColorsWidget.java

示例10: createPopupControl

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected void createPopupControl() {
	// overall panel
	final Shell top = getPopup();
	final GridLayout layout = new GridLayout(3, true);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 5;
	layout.marginHeight = 5;
	top.setLayout(layout);
	top.setBackground(IGamaColors.BLACK.color());
	if (createExtraInfo) {
		// left overlay info
		left = label(top, SWT.LEFT);
		// center overlay info
		center = label(top, SWT.CENTER);
		// right overlay info
		right = label(top, SWT.RIGHT);
	}
	// coordinates overlay info
	coord = label(top, SWT.LEFT);
	// zoom overlay info
	zoom = label(top, SWT.CENTER);
	// scalebar overlay info
	scalebar = new Canvas(top, SWT.None);
	scalebar.setVisible(getView().getOutput().getData().isDisplayScale());
	final GridData scaleData = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
	scaleData.minimumWidth = 140;
	scaleData.widthHint = 140;
	scaleData.minimumHeight = 24;
	scaleData.heightHint = 24;
	scalebar.setLayoutData(scaleData);
	scalebar.setBackground(IGamaColors.BLACK.color());
	scalebar.addPaintListener(e -> paintScale(e.gc));
	top.addMouseListener(toggleListener);
	scalebar.addMouseListener(toggleListener);
	top.layout();
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:38,代碼來源:DisplayOverlay.java

示例11: addCategoryIcon

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected final void addCategoryIcon(final Image image) {
	if (image != null) {
		ImageData imageData = image.getImageData();
		Canvas canvas = new Canvas(iconRow, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);
		canvas.setLayoutData(new RowData(imageData.width, imageData.height));
		canvas.setBackground(iconRow.getBackground());
	    canvas.addPaintListener(new PaintListener() {
	        @Override
			public void paintControl(PaintEvent e) {
	        	e.gc.drawImage(image,0,0);
	        }
	    });
	}
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:15,代碼來源:PlanOverview.java

示例12: adjustItemNumber

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected void adjustItemNumber() {
	if (fComposite == null)
		return;

	Control[] children= fComposite.getChildren();
	int oldSize= children.length;
	int newSize= fInput == null ? 0 : fInput.fAnnotations.length;

	Display display= fShell.getDisplay();

	// add missing items
	for (int i= oldSize; i < newSize; i++) {
		Canvas canvas= new Canvas(fComposite, SWT.NONE);
		Object gridData= fLayouter.getLayoutData();
		canvas.setLayoutData(gridData);
		canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

		canvas.addPaintListener(fPaintListener);

		canvas.addMouseTrackListener(fMouseTrackListener);

		canvas.addMouseListener(fMouseListener);

		canvas.addListener(SWT.MenuDetect, fMenuDetectListener);

		canvas.addDisposeListener(fDisposeListener);
	}

	// dispose of exceeding resources
	for (int i= oldSize; i > newSize; i--) {
		Item item= (Item) children[i - 1].getData();
		item.deselect();
		children[i - 1].dispose();
	}

}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:37,代碼來源:AnnotationExpansionControl.java

示例13: createTitleIcon

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private Canvas createTitleIcon(final Composite parent, final Image icon) {
  LOGGER.trace("Creating the title icon.");
  final Canvas canvas = new Canvas(parent, SWT.NONE);
  canvas.setBackground(parent.getBackground());
  canvas.setBounds(icon.getBounds());
  canvas.addListener(SWT.Paint, new Listener() {
    @Override
    public void handleEvent(Event event) {
      event.gc.drawImage(icon, 0, 0);
    }
  });
  return canvas;
}
 
開發者ID:Haixing-Hu,項目名稱:swt-widgets,代碼行數:14,代碼來源:BalloonWindow.java

示例14: createTitleArea

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected Composite createTitleArea( Composite parent )
{
	Composite cmpTitle = super.createTitleArea( parent );
	// ( (GridData) cmpTitle.getLayoutData( ) ).heightHint = 250;

	previewCanvas = new Canvas( cmpTitle, SWT.BORDER );
	{
		GridData gd = new GridData( GridData.FILL_BOTH );
		gd.horizontalSpan = 2;
		previewCanvas.setLayoutData( gd );
		previewCanvas.setBackground( Display.getDefault( )
				.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
	}
	return cmpTitle;
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:16,代碼來源:TaskFormatChart.java

示例15: RuntimeViewer

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
RuntimeViewer(Composite parent) {
	super(parent, SWT.BORDER);
	instance = this;

	setLayout(new FillLayout());
	setBackground(PandionJConstants.Colors.VIEW_BACKGROUND);
	scroll = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
	scroll.setBackground(PandionJConstants.Colors.VIEW_BACKGROUND);
	canvas = new Canvas(scroll, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.white);
	canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
	scroll.setContent(canvas);
	addMenu();

	//				rootFig = new ScalableLayeredPane();
	//				((ScalableLayeredPane) rootFig).setScale(2);
	rootFig = new Figure();
	rootFig.setOpaque(true);
	rootGrid = new GridLayout(2, false);
	rootGrid.horizontalSpacing = PandionJConstants.STACK_TO_OBJECTS_GAP;
	rootGrid.marginWidth = PandionJConstants.MARGIN;
	rootGrid.marginHeight = PandionJConstants.MARGIN;
	rootFig.setLayoutManager(rootGrid);

	stackFig = new StackContainer();
	rootFig.add(stackFig);
	org.eclipse.draw2d.GridData d = new org.eclipse.draw2d.GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
	d.widthHint = Math.max(PandionJConstants.STACKCOLUMN_MIN_WIDTH, stackFig.getPreferredSize().width);
	rootGrid.setConstraint(stackFig, d);

	objectContainers = new ArrayList<>();
	objectContainer = ObjectContainer.create(true);
	rootFig.add(objectContainer);
	rootGrid.setConstraint(objectContainer, new org.eclipse.draw2d.GridData(SWT.FILL, SWT.FILL, true, true));

	lws = new LightweightSystem(canvas);
	lws.setContents(rootFig);
	pointersMap = new HashMap<>();
	pointersMapOwners = ArrayListMultimap.create();

}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:42,代碼來源:RuntimeViewer.java


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