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


Java Canvas類代碼示例

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


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

示例1: paintVerticalRuler

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
	// FIXME - not i18n safe!!
	String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
	if (disk.getBitmapLabels().length == 2) {
		label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
	}
	StringBuffer buf = new StringBuffer();
	for (int i=0; i<label.length(); i++) {
		if (i>0) buf.append("\n"); //$NON-NLS-1$
		buf.append(label.charAt(i));
	}
	label = buf.toString();
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();
	event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
	Point size = event.gc.textExtent(label);
	event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:22,代碼來源:DiskMapTab.java

示例2: paintBlockMap

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * Paint a block map.
 */	
private void paintBlockMap(PaintEvent event) {
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();

	double blocks = disk.getBitmapLength();
	double width = area.width;
	double height = area.height;
	double factor = Math.sqrt(blocks / (width * height));
	int xdim = (int) (width * factor + 0.5);
	int ydim = (int) (height * factor + 0.5);
	if (xdim * ydim < blocks) {
		xdim++;
	}
	if (xdim * ydim < blocks) {
		ydim++;
	}
	
	paintDiskMap(xdim, ydim, event);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:23,代碼來源:DiskMapTab.java

示例3: createContents

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
protected Control createContents(Composite parent) {
	GridLayout gridLayout = new GridLayout(1, false);
	gridLayout.numColumns = 1;
	parent.setLayout(gridLayout);

	String[] values = PreferenceManager.getAuthorizedFolderForGraphDefinition();
	String[] propertyNames = new String[] { PreferenceManager.AUTHORIZED_FOLDERS_FOR_GRAPH_DEFINITION };
	authorizedFolders = new CustomListWithButtons(parent, SWT.NONE, true,
			new StringCustomListModel(MessageUtil.getString("authorizedfolderforgraphmodel"), values));
	authorizedFolders.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	authorizedFolders.setPropertyNames(propertyNames);

	values = PreferenceManager.getGraphWalkerJavaLibName();
	propertyNames = new String[] { PreferenceManager.GRAPHWALKER_JAVALIBRARIES };
	gw4eLibraries = new CustomListWithButtons(parent, SWT.NONE, true,
			new StringCustomListModel(MessageUtil.getString("graphwalkerlibraries"), values));
	gw4eLibraries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	gw4eLibraries.setPropertyNames(propertyNames);

	return new Canvas(parent, 0);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:22,代碼來源:GW4EPreferencePage.java

示例4: createControl

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void createControl(final Composite parent) {
    sash = new SashForm(parent, SWT.VERTICAL);

    // コンストラクタで指定したビューワの作成
    viewer.createControl(sash);

    // EditPartFactory の設定
    final ERDiagramOutlineEditPartFactory editPartFactory = new ERDiagramOutlineEditPartFactory();
    viewer.setEditPartFactory(editPartFactory);

    // グラフィカル・エディタのルート・モデルをツリー・ビューワにも設定
    viewer.setContents(diagram);

    final Canvas canvas = new Canvas(sash, SWT.BORDER);
    // サムネイル・フィギュアを配置する為の LightweightSystem
    lws = new LightweightSystem(canvas);

    resetView(registry);

    final AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance());
    viewer.addDragSourceListener(dragSourceListener);

    diagram.refreshOutline();
}
 
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:29,代碼來源:ERDiagramOutlinePage.java

示例5: PlotWindow

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
public PlotWindow(final AbstractRenderCommand<?> cmd) {
	this.cmd = cmd;
	Platform.get().runOnMainThread(new Runnable() {
		@Override
		public void run() {
			shell = new Shell(Display.getDefault());
			shell.setText("Plot");
			shell.setLayout(new FillLayout());
			canvasUI = new Canvas(shell, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
			canvasUI.addPaintListener(PlotWindow.this);
			canvasUI.addMouseListener(PlotWindow.this);
			canvasUI.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
			shell.pack();
			shell.setSize(800, shell.getSize().y);
			shell.setVisible(true);
			shell.setActive();
			new Repeating(500, 20, canvasUI, canvasUI::redraw);
		}
	});
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:21,代碼來源:PlotWindow.java

示例6: paint

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * Does not paint hidden annotations. Annotations are hidden when they
 * only span one line.
 * 
 * @see ProjectionAnnotation#paint(org.eclipse.swt.graphics.GC,
 *      org.eclipse.swt.widgets.Canvas,
 *      org.eclipse.swt.graphics.Rectangle)
 */
@Override
public void paint(GC gc, Canvas canvas, Rectangle rectangle) {
	/* workaround for BUG85874 */
	/*
	 * only need to check annotations that are expanded because hidden
	 * annotations should never have been given the chance to collapse.
	 */
	if (!isCollapsed()) {
		// working with rectangle, so line height
		FontMetrics metrics = gc.getFontMetrics();
		if (metrics != null) {
			// do not draw annotations that only span one line and
			// mark them as not visible
			if ((rectangle.height / metrics.getHeight()) <= 1) {
				visible = false;
				return;
			}
		}
	}
	visible = true;
	super.paint(gc, canvas, rectangle);
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:31,代碼來源:IndentFoldingStrategy.java

示例7: createControl

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * Creates the Control of this outline page. By default this is a PageBook, which can toggle between a hierarchical Outline and a graphical Thumbnail.
 *
 * @param parent
 *          the parent
 * @see org.eclipse.gef.ui.parts.ContentOutlinePage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
  _pageBook = new PageBook(parent, SWT.NONE);
  _outline = getViewer().createControl(_pageBook);
  _overview = new Canvas(_pageBook, SWT.NONE);
  _pageBook.showPage(_outline);
  createOutlineViewer();

  // register listeners
  _selectionSynchronizer.addViewer(getViewer());
  if (_diagramEditor.getWorkbenchPart() != null) {
    _diagramEditor.getWorkbenchPart().addPropertyListener(this);
  }

  initContents();
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:24,代碼來源:DiagramEditorOutlinePage.java

示例8: createPartControl

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * This operation sets up the Composite that contains the VisIt canvas and
 * create the VisIt widget.
 * 
 * @param parent
 *            The parent Composite to create the Control in.
 */
@Override
public void createPartControl(Composite parent) {

	// Create a top level composite to hold the canvas or text
	vizComposite = new Composite(parent, SWT.NONE);
	vizComposite.setLayout(new GridLayout(1, true));

	// Set up the canvas where the graph is displayed
	plotCanvas = new Canvas(vizComposite, SWT.BORDER);
	plotCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	// MAGIC
	lws = new LightweightSystem(plotCanvas);

	return;
}
 
開發者ID:eclipse,項目名稱:eavp,代碼行數:24,代碼來源:CSVPlotEditor.java

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

示例10: findCanvas

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/** Find the canvas of TransGraph.  For some reason it's not exposed.
 * 
 * @param transGraph
 * @return Canvas of null if it can't be found.
 */
private Canvas findCanvas(Composite composite) {
  for (Control child : composite.getChildren()) {
    if (child instanceof Canvas) {
      return (Canvas) child;
    }
    if (child instanceof Composite) {
      Canvas look = findCanvas((Composite) child);
      if (look!=null) {
        return look;
      }
    }
  }
  
  return null;
}
 
開發者ID:mattcasters,項目名稱:pentaho-pdi-dataset,代碼行數:21,代碼來源:ShowUnitTestMenuExtensionPoint.java

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

示例12: create

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
public long create(GLCanvas canvas, GLData attribs, GLData effective) {
    Canvas dummycanvas = new Canvas(canvas.getParent(), checkStyle(canvas.getParent(), canvas.getStyle()));
    long context = 0L;
    MemoryStack stack = MemoryStack.stackGet(); int ptr = stack.getPointer();
    try {
        context = create(canvas.handle, dummycanvas.handle, attribs, effective);
    } catch (SWTException e) {
        stack.setPointer(ptr);
        SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH, e);
    }
    final long finalContext = context;
    dummycanvas.dispose();
    Listener listener = new Listener() {
        public void handleEvent(Event event) {
            switch (event.type) {
            case SWT.Dispose:
                deleteContext(finalContext);
                break;
            }
        }
    };
    canvas.addListener(SWT.Dispose, listener);
    return context;
}
 
開發者ID:httpdigest,項目名稱:lwjgl3-swt,代碼行數:25,代碼來源:PlatformWin32GLCanvas.java

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

示例14: createPartControl

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 */
@Override
public void createPartControl(Composite parent) {
    paintCanvas = new Canvas(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    paintCanvas.setLayoutData(gridData);

    // paintSurface
    paintSurface = new PaintSurface(paintCanvas, parent.getDisplay().getSystemColor(
            SWT.COLOR_WHITE));

    tooltip = new ToolTipHandler(parent.getShell());
    tooltip.activateHoverHelp(paintCanvas);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(paintCanvas,
            "de.loskutov.eclipse.jdepend.jdepend"); //$NON-NLS-1$

    if (packages != null) {
        redrawPackages(packages);
    }
}
 
開發者ID:iloveeclipse,項目名稱:jdepend4eclipse,代碼行數:25,代碼來源:MetricsView.java

示例15: createControl

import org.eclipse.swt.widgets.Canvas; //導入依賴的package包/類
@Override
public void createControl(Composite parent) {
    this.sash = new SashForm(parent, SWT.VERTICAL);
    viewer.createControl(sash);
    editPartFactory = new ERDiagramOutlineEditPartFactory();
    editPartFactory.setQuickMode(quickMode);
    viewer.setEditPartFactory(editPartFactory);
    viewer.setContents(diagram);
    if (!quickMode) {
        final Canvas canvas = new Canvas(sash, SWT.BORDER);
        lws = new LightweightSystem(canvas);
    }
    resetView(registry);
    final AbstractTransferDragSourceListener dragSourceListener =
            new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance());
    viewer.addDragSourceListener(dragSourceListener);

    expandVirturalDiagramTree();
}
 
開發者ID:dbflute-session,項目名稱:erflute,代碼行數:20,代碼來源:ERDiagramOutlinePage.java


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