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


Java Canvas.addMouseListener方法代碼示例

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


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

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

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

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

示例6: activateCell

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

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

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:35,代碼來源:CheckBoxCellEditor.java


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