当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getX方法代码示例

本文整理汇总了Java中java.awt.Rectangle.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getX方法的具体用法?Java Rectangle.getX怎么用?Java Rectangle.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintTrack

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
	int x = (int) trackBounds.getX();
	int y = (int) trackBounds.getY();
	int w = (int) trackBounds.getWidth();
	int h = (int) trackBounds.getHeight();

	g.setColor(Colors.SCROLLBAR_TRACK_BACKGROUND);
	g.fillRect(x - 1, y - 1, w + 2, h + 2);

	g.setColor(Colors.SCROLLBAR_TRACK_BORDER);
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		g.drawLine(x, y, x + w, y);
	} else {
		g.drawLine(x, y, x, y + h);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:ScrollBarUI.java

示例2: paintThumb

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
	int x = (int) thumbBounds.getX();
	int y = (int) thumbBounds.getY();
	int w = (int) thumbBounds.getWidth();
	int h = (int) thumbBounds.getHeight();

	if (c.isEnabled() && w > 0 && h > 0) {
		if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
			h -= 1;
			y++;
			drawHorizThumb(g, x, y, w, h);
		} else {
			w -= 1;
			x++;
			drawVertThumb(g, x, y, w, h);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:ScrollBarUI.java

示例3: updateEditorHeight

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Makes sure the current editor height matches its content if the annotation was never resized.
 * If the annotation has been manually resized before, does nothing.
 *
 * @param anno
 *            the annotation currently in the editor
 */
private void updateEditorHeight(final WorkflowAnnotation anno) {
	if (anno.wasResized()) {
		return;
	}

	Rectangle bounds = editPane.getBounds();
	// height is either the pref height or the current height, depending on what is bigger
	int prefHeight;
	if (anno instanceof ProcessAnnotation) {
		prefHeight = (int) Math.max(getContentHeightOfEditor((int) bounds.getWidth()), bounds.getHeight());
	} else {
		prefHeight = Math.max(getContentHeightOfEditor((int) bounds.getWidth()), OperatorAnnotation.MIN_HEIGHT);
	}
	Rectangle newBounds = new Rectangle((int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), prefHeight);
	if (!bounds.equals(newBounds)) {
		editPane.setBounds(newBounds);
		updateEditPanelPosition(newBounds, true);
		view.getModel().fireAnnotationMiscChanged(anno);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:AnnotationsDecorator.java

示例4: contains

import java.awt.Rectangle; //导入方法依赖的package包/类
public boolean contains(Rectangle rectangle, int row, int column) {
    if (rectangle == null)
        return true;

    double px = column * (pageWidth + W_SPACE / zoom) * getZoom();
    double py = row * (pageHeight + W_SPACE / zoom) * getZoom();
    double r = (width + W_SPACE / zoom) * getZoom() + px;
    double b = (height + W_SPACE / zoom) * getZoom() + py;
    double rx = rectangle.getX();
    double ry = rectangle.getY();

    double rr = rectangle.getMaxX();
    double rb = rectangle.getMaxY();
    if (((px <= rr) && (px >= rx)) || ((r <= rr) && (r >= rx))
            || ((rr <= r) && (rr >= px)) || ((rx <= r) && (rx >= px))) {
        return (((py <= rb) && (py >= ry)) || ((b <= rb) && (b >= ry))
                || ((rb <= b) && (rb >= py)) || ((ry <= b) && (ry >= py)));
    }
    return false;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:21,代码来源:PrintPreviewComponent.java

示例5: getWESN

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Not Implemented.
 */
public double[] getWESN() {
	double[] wesn = new double[4];
	Rectangle r = getVisibleRect();
	if(mapBorder != null) {
		r = mapBorder.getInteriorRectangle(this, r.x, r.y, r.width, r.height);
	}
	Point2D.Double pt = new Point2D.Double( r.getX(), r.getY() );
	pt = (Point2D.Double)proj.getRefXY( getScaledPoint(pt));
	wesn[0] = pt.x;
	wesn[3] = pt.y;
	pt = new Point2D.Double( r.getX()+r.getWidth(),
				 r.getY()+r.getHeight() );
	pt = (Point2D.Double)proj.getRefXY( getScaledPoint(pt));
	wesn[1] = pt.x;
	wesn[2] = pt.y;
	return wesn;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:21,代码来源:XMap.java

示例6: getProjection

import java.awt.Rectangle; //导入方法依赖的package包/类
private static int[] getProjection(GrayImage edgeMap,
	Rectangle region, boolean horizontal) {

	int aMin = (int) (horizontal ? region.getY() : region.getX()),
		bMin = (int) (horizontal ? region.getX() : region.getY()),
		aLen = (int) (horizontal ? region.getHeight() : region.getWidth()),
		bLen = (int) (horizontal ? region.getWidth() : region.getHeight()),
		ind = 0;

	int[] res = new int[aLen];

	for (int a = aMin; a < aMin + aLen; ++a) {
		int total = 0;
		for (int b = bMin; b < bMin + bLen; ++b) {
			// TODO other possible strategy: counting edge pixels instead of
			//      taking their value into account
			total +=
				edgeMap.getValue(horizontal ? b : a, horizontal ? a : b);
		}
		res[ind] = total;
		++ind;
	}

	return res;
}
 
开发者ID:MX-Futhark,项目名称:text-position-detector,代码行数:26,代码来源:UniresolutionTextPositionDetector.java

示例7: checkBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
private boolean checkBounds(Rectangle r) {
    Rectangle[] screens = getScreenBounds();
    for (Rectangle screen : screens) {
        if (r.getX() >= screen.getX() && r.getY() >= screen.getY()
                && r.getX() + r.getWidth() < screen.getX() + screen.getWidth()
                && r.getY() + r.getHeight() < screen.getY() + screen.getHeight()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DialogBoundsPreserver.java

示例8: paintFocus

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
protected void paintFocus(Graphics g, Rectangle textRect, Dimension d) {
	int x = 0, y = 0, w = 0, h = 0;
	x = (int) textRect.getX() - 2;
	y = (int) textRect.getY();
	w = (int) textRect.getWidth() + 4;
	h = (int) textRect.getHeight();

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	g2.setColor(Colors.RADIOBUTTON_BORDER_FOCUS);
	g2.setStroke(DASHED_STROKE);
	g2.drawRect(x, y, w, h);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:RadioButtonUI.java

示例9: paintComponent

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:OverviewPanel.java

示例10: ScreenModel

import java.awt.Rectangle; //导入方法依赖的package包/类
public ScreenModel(GraphicsDevice device, String name, int number) {
	this.name = number + " " + name;
	this.idString = device.getIDstring();
	this.width = device.getDisplayMode().getWidth();
	this.height = device.getDisplayMode().getHeight();

	GraphicsConfiguration[] gc = device.getConfigurations();
	for (GraphicsConfiguration curGc : gc) {
		Rectangle bounds = curGc.getBounds();
		this.topLeftCorner = new Point((int) bounds.getX(), (int) bounds.getY());
	}

}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:14,代码来源:ScreenModel.java

示例11: getPointToClick

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Retuns points which can be used to click on path.
 *
 * @param path a tree path to click on.
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(TreePath path) {
    if (path != null) {
        Rectangle rect = getPathBounds(path);
        if (rect != null) {
            return (new Point((int) (rect.getX() + rect.getWidth() / 2),
                    (int) (rect.getY() + rect.getHeight() / 2)));
        } else {
            throw (new NoSuchPathException(path));
        }
    } else {
        throw (new NoSuchPathException());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:JTreeOperator.java

示例12: setGrid

import java.awt.Rectangle; //导入方法依赖的package包/类
public void setGrid( Grid2D grid, Grid2D.Boolean landMask, boolean hasLand, boolean hasOcean, boolean reset ) {
	this.landMask = landMask;
	land = hasLand;
	ocean = hasOcean;
	if( this.grid==null && grid==null)return;
	this.grid = grid;
	if( grid==null ) return;
	if( !reset ) return;
	Rectangle r = grid.getBounds();
	p0 = new Point2D.Double(r.getX(), r.getY());
	p0 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p0));
	Point2D p1 = new Point2D.Double(r.getX()+1., r.getY());
	p1 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p1));
	if( p1.getX()<p0.getX() ) {
		gridScale = p1.getX()+map.getWrap()-p0.getX();
	} else {
		gridScale = p1.getX() - p0.getX();
	}
	contour.setGrid(grid);
	if( lut==null ) {
		try {
			initRenderer();
		} catch(Exception e) {
			return;
		}
	}
	lut.setNewGrid();
	//if (toString().equals(GridDialog.DEM))
//	lut.showDialog();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:Grid2DOverlay.java

示例13: propertyChange

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();
	if (prop.equals(ZoomModel.ZOOM)) {
		// mouse point
		Point point = getMousePosition(true);
		double oldZoom = ((Double) e.getOldValue()).doubleValue();
		Rectangle r = getViewport().getViewRect();
		double cx = (r.getX() + r.getWidth() / 2) / oldZoom;
		double cy = (r.getY() + r.getHeight() / 2) / oldZoom;

		double newZoom = ((Double) e.getNewValue()).doubleValue();
		r = getViewport().getViewRect();
		if (point != null) {// mouse is pointing something
			int newX = (int) Math
					.round(r.getX() / oldZoom * newZoom + point.getX() / oldZoom * newZoom - point.getX());
			int newY = (int) Math
					.round(r.getY() / oldZoom * newZoom + point.getY() / oldZoom * newZoom - point.getY());
			getHorizontalScrollBar().setValue(newX);
			getVerticalScrollBar().setValue(newY);
		} else {// mouse is outside from canvas panel
			int hv = (int) (cx * newZoom - r.getWidth() / 2);
			int vv = (int) (cy * newZoom - r.getHeight() / 2);
			getHorizontalScrollBar().setValue(hv);
			getVerticalScrollBar().setValue(vv);
		}
		contents.recomputeSize();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:30,代码来源:CanvasPane.java

示例14: draw

import java.awt.Rectangle; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
	Rectangle area = g.getClipBounds();
	currentPoint = null;
	if( !intersects(area) ) return;
	Color color = g.getColor();
	g.setColor( offColor);
	GeneralPath path = new GeneralPath();
	float offset = (float)this.offset;
	for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
		path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
		for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
			path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
		}
	}
	g.draw(path);
	double wrap = map.getWrap();
	if(wrap>0) {
		AffineTransform xform = g.getTransform();
		offset += (float)wrap;
		while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
			g.translate( (double)wrap, 0.d );
			g.draw(path);
			offset += (float)wrap;
		}
		g.setTransform( xform );
	}
	g.setColor( onColor );
	drawCurrentSeg(g, true);
	g.setColor( color );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:ShipData.java

示例15: doRender

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Run the render method of the given component.
 * 
 * @param comp
 */
private void doRender(Component comp) {
	if (rendered.contains(System.identityHashCode(comp))) {
		return;
	}
	rendered.add(System.identityHashCode(comp));
	if (comp instanceof Container) {
		Container cont = (Container) comp;
		for (Component comp2 : cont.getComponents()) {
			doRender(comp2);
		}
	}

	float[] scale = getScalef();

	Component originalComponent = null;
	try {
		originalComponent = deserializeObject(JComponent.class, originalComps.get(System.identityHashCode(comp)));
	} catch (ClassNotFoundException | IOException e) {
		e.printStackTrace();
	}

	if (originalComponent != null) {
		// Bounds
		if (isWindowOptionEnabled(WindowOptions.SCALE_COMPONENTS)) {
			Rectangle original = originalComponent.getBounds();
			int newX = (int) (original.getX() * scale[0]);
			int newY = (int) (original.getY() * scale[1]);
			int newW = (int) (original.getWidth() * scale[0]);
			int newH = (int) (original.getHeight() * scale[1]);
			comp.setBounds(newX, newY, newW, newH);
		}

		// Fonts
		if (isWindowOptionEnabled(WindowOptions.SCALE_FONTS)) {
			if (comp.getFont() != null && originalComponent.getFont() != null) {
				Font font = comp.getFont();
				Font newFont = font.deriveFont(font.getStyle(),
						getSuggestedFontSize(originalComponent.getFont().getSize()));
				comp.setFont(newFont);
			}
		}

		// Images
		if (isWindowOptionEnabled(WindowOptions.SCALE_IMAGES)) {
			if (comp instanceof JLabel) {
				JLabel label = (JLabel) comp;
				JLabel orig = (JLabel) originalComponent;
				label.setIcon(getScaledImageIcon(orig));
			}
		}
	}
}
 
开发者ID:Cyphereion,项目名称:Java-Swing-Helper,代码行数:58,代码来源:SwingWindow.java


注:本文中的java.awt.Rectangle.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。