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


Java Rectangle類代碼示例

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


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

示例1: getInitialLocation

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * Returns the initial location to use for the shell based upon the current selection in the viewer. Bottom is
 * preferred to top, and right is preferred to left, therefore if possible the popup will be located below and to
 * the right of the selection.
 *
 * @param initialSize
 *            the initial size of the shell, as returned by {@code getInitialSize}.
 * @return the initial location of the shell
 */
@Override
protected Point getInitialLocation(final Point initialSize) {
	if (null == anchor) {
		return super.getInitialLocation(initialSize);
	}

	final Point point = anchor;
	final Rectangle monitor = getShell().getMonitor().getClientArea();
	if (monitor.width < point.x + initialSize.x) {
		point.x = max(0, point.x - initialSize.x);
	}
	if (monitor.height < point.y + initialSize.y) {
		point.y = max(0, point.y - initialSize.y);
	}

	return point;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:27,代碼來源:TypeInformationPopup.java

示例2: getConstrainedShellBounds

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * Given the desired position of the shell, this method returns an adjusted position such that the window is no
 * larger than its monitor, and does not extend beyond the edge of the monitor. This is used for computing the
 * initial window position via the parent shell, clients can use this as a utility method if they want to limit the
 * region in which the window may be moved.
 *
 * @param shell
 *            the shell which shell bounds is being calculated.
 * @param preferredSize
 *            the preferred position of the window.
 * @return a rectangle as close as possible to preferredSize that does not extend outside the monitor.
 */
public static Rectangle getConstrainedShellBounds(final Shell shell, final Point preferredSize) {

	final Point location = getInitialLocation(shell, preferredSize);
	final Rectangle result = new Rectangle(location.x, location.y, preferredSize.x, preferredSize.y);

	final Monitor monitor = getClosestMonitor(shell.getDisplay(), Geometry.centerPoint(result));

	final Rectangle bounds = monitor.getClientArea();

	if (result.height > bounds.height) {
		result.height = bounds.height;
	}

	if (result.width > bounds.width) {
		result.width = bounds.width;
	}

	result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
			+ bounds.width - result.width));
	result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
			+ bounds.height - result.height));

	return result;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:37,代碼來源:UIUtils.java

示例3: getClosestMonitor

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * Returns the monitor whose client area contains the given point. If no monitor contains the point, returns the
 * monitor that is closest to the point.
 *
 * @param toSearch
 *            point to find (display coordinates).
 * @param toFind
 *            point to find (display coordinates).
 * @return the monitor closest to the given point.
 */
private static Monitor getClosestMonitor(final Display toSearch, final Point toFind) {
	int closest = Integer.MAX_VALUE;

	final Monitor[] monitors = toSearch.getMonitors();
	Monitor result = monitors[0];

	for (int index = 0; index < monitors.length; index++) {
		final Monitor current = monitors[index];

		final Rectangle clientArea = current.getClientArea();

		if (clientArea.contains(toFind)) {
			return current;
		}

		final int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
		if (distance < closest) {
			closest = distance;
			result = current;
		}
	}

	return result;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:35,代碼來源:UIUtils.java

示例4: getScreenDataArea

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * Returns the data area (the area inside the axes) for the plot or subplot,
 * with the current scaling applied.
 *
 * @param x  the x-coordinate (for subplot selection).
 * @param y  the y-coordinate (for subplot selection).
 * 
 * @return The scaled data area.
 */
public Rectangle getScreenDataArea(int x, int y) {
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle result;
    if (plotInfo.getSubplotCount() == 0)
        result = getScreenDataArea();
    else {
        // get the origin of the zoom selection in the Java2D space used for
        // drawing the chart (that is, before any scaling to fit the panel)
        Point2D selectOrigin = translateScreenToJava2D(new Point(x, y));
        int subplotIndex = plotInfo.getSubplotIndex(selectOrigin);
        if (subplotIndex == -1) {
            return null;
        }
        result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea());
    }
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:ChartComposite.java

示例5: setViewRequiresOneDownload

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
public static void setViewRequiresOneDownload(Composite genComposite) {
	if (genComposite == null || genComposite.isDisposed()) {
		return;
	}
	Utils.disposeComposite(genComposite, false);

	Label lab = new Label(genComposite, SWT.NULL);
	GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true);
	gridData.verticalIndent = 10;
	lab.setLayoutData(gridData);
	Messages.setLanguageText(lab, "view.one.download.only");

	genComposite.layout(true);

	Composite parent = genComposite.getParent();
	if (parent instanceof ScrolledComposite) {
		ScrolledComposite scrolled_comp = (ScrolledComposite) parent;

		Rectangle r = scrolled_comp.getClientArea();
		scrolled_comp.setMinSize(genComposite.computeSize(r.width, SWT.DEFAULT ));
	}

}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:24,代碼來源:ViewUtils.java

示例6: cellMouseTrigger

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
	if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE
			|| event.eventType == TableRowMouseEvent.EVENT_MOUSEDOWN) {
		TableRow row = event.cell.getTableRow();
		if (row == null) {
			return;
		}
		Object data = row.getData(ID_EXPANDOHITAREA);
		if (data instanceof Rectangle) {
			Rectangle hitArea = (Rectangle) data;
			boolean inExpando = hitArea.contains(event.x, event.y);

			if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE) {
				((TableCellCore) event.cell).setCursorID(inExpando ? SWT.CURSOR_HAND
						: SWT.CURSOR_ARROW);
			} else if (inExpando) { // mousedown
				if (row instanceof TableRowCore) {
					TableRowCore rowCore = (TableRowCore) row;
					rowCore.setExpanded(!rowCore.isExpanded());
				}
			}
		}
	}
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:26,代碼來源:ColumnThumbAndName.java

示例7: handleEvent

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
public static void handleEvent(Event event) {

		Table table = (Table) event.widget;
		int columnCount = table.getColumnCount();
		if (columnCount == 0)
			return;
		Rectangle area = table.getClientArea();
		int totalAreaWdith = area.width;
		int lineWidth = table.getGridLineWidth();
		int totalGridLineWidth = (columnCount - 1) * lineWidth;
		int totalColumnWidth = 0;
		for (TableColumn column : table.getColumns()) {
			totalColumnWidth = totalColumnWidth + column.getWidth();
		}
		int diff = totalAreaWdith - (totalColumnWidth + totalGridLineWidth);

		TableColumn lastCol = table.getColumns()[columnCount - 1];

		lastCol.setWidth(diff + lastCol.getWidth());

	}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:22,代碼來源:TableHelper.java

示例8: translateToPoint

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
protected static boolean translateToPoint ( final Rectangle clientRect, final XAxis x, final YAxis y, final DataPoint point, final DataEntry entry )
{
    // we always need X
    point.x = clientRect.x + x.translateToClient ( clientRect.width, entry.getTimestamp () );

    final Double value = entry.getValue ();
    if ( value == null || Double.isNaN ( value ) || Double.isInfinite ( value ) )
    {
        return false;
    }

    // we only provide Y if we really have a value

    point.y = clientRect.y + y.translateToClient ( clientRect.height, value );

    return true;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:18,代碼來源:AbstractDataSeriesRenderer.java

示例9: MainAvoCADoShell

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * create the main avoCADo shell and display it
 * @param display
 */
public MainAvoCADoShell(Display display){
	shell = new Shell(display);
	
	setupShell(); 				// place components in the main avoCADo shell
	
	shell.setText("avoCADo");
	shell.setSize(800, 600);	//TODO: set intial size to last known size
	shell.setMinimumSize(640, 480);
	Rectangle b = display.getBounds();
	int xPos = Math.max(0, (b.width-800)/2);
	int yPos = Math.max(0, (b.height-600)/2);
	shell.setLocation(xPos, yPos);
	shell.setImage(ImageUtils.getIcon("./avoCADo.png", 32, 32));
	shell.open();
	
	AvoGlobal.intializeNewAvoCADoProject(); // initialize app to starting model/view.
	
	StartupSplashShell.closeSplash();
			
	// handle events while the shell is not disposed
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:30,代碼來源:MainAvoCADoShell.java

示例10: SWTStrokeCanvas

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

示例11: render

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return;
    }

    g.setClipping ( this.rect );

    g.setFont ( createFont ( g.getResourceManager () ) );

    final Point size = g.textExtent ( this.title );

    final int x = this.rect.width / 2 - size.x / 2;
    final int y = this.padding;
    g.drawText ( this.title, this.rect.x + x, this.rect.y + y, null );

    g.setClipping ( clientRectangle );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:TitleRenderer.java

示例12: resize

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return null;
    }

    final GC gc = new GC ( resourceManager.getDevice () );
    gc.setFont ( createFont ( resourceManager ) );

    try
    {
        final Point size = gc.textExtent ( this.title );
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, size.y + this.padding * 2 );
        return new Rectangle ( clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width, clientRectangle.height - this.rect.height );
    }
    finally
    {
        gc.dispose ();
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:23,代碼來源:TitleRenderer.java

示例13: cellPaint

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
	Rectangle bounds = cell.getBounds();

	ImageLoader imageLoader = ImageLoader.getInstance();
	Image viewImage = imageLoader.getImage("ic_view");
	if(imageWidth == -1 || imageHeight == -1) {
		imageWidth = viewImage.getBounds().width;
		imageHeight = viewImage.getBounds().height;
	}

	bounds.width -= (imageWidth + 5);

	GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds,true,false,SWT.LEFT);

	Subscription sub = (Subscription) cell.getDataSource();

	if ( sub != null && !sub.isSearchTemplate()){

		gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
	}

	imageLoader.releaseImage("ic_view");

		//gc.drawText(cell.getText(), bounds.x,bounds.y);
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:27,代碼來源:ColumnSubscriptionName.java

示例14: setupPagingInformation

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
/**
 * Setup some sensible paging information.
 */
public static void setupPagingInformation(ScrolledComposite composite) {
	GC gc = new GC(composite);
	FontMetrics fontMetrics = gc.getFontMetrics();
	gc.dispose();
	int fontHeight = fontMetrics.getHeight();
	int fontWidth = fontMetrics.getAverageCharWidth();
	Rectangle clientArea = composite.getClientArea();
	int lines = clientArea.height / fontHeight;
	int pageHeight = lines * fontHeight;
	int pageWidth = clientArea.width - fontWidth; 
	composite.getVerticalBar().setIncrement(fontHeight);
	composite.getVerticalBar().setPageIncrement(pageHeight);
	composite.getHorizontalBar().setIncrement(fontWidth);
	composite.getHorizontalBar().setPageIncrement(pageWidth);
}
 
開發者ID:marvinmalkowskijr,項目名稱:applecommander,代碼行數:19,代碼來源:SwtUtil.java

示例15: paint

import org.eclipse.swt.graphics.Rectangle; //導入依賴的package包/類
void paint(GC gc) {
	if (fImage != null) {
		Rectangle bounds = fImage.getBounds();
		Rectangle clientArea = getClientArea();
		int x;
		if (bounds.width < clientArea.width)
			x = (clientArea.width - bounds.width) / 2;
		else
			x = -getHorizontalBar().getSelection();
		int y;
		if (bounds.height < clientArea.height)
			y = (clientArea.height - bounds.height) / 2;
		else
			y = -getVerticalBar().getSelection();
		gc.drawImage(fImage, x, y);
	}
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:18,代碼來源:ImageCanvas.java


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