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


Java Rectangle.getWidth方法代码示例

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


在下文中一共展示了Rectangle.getWidth方法的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: zoomIn

import java.awt.Rectangle; //导入方法依赖的package包/类
public void zoomIn(Point p) {
	if( image==null )return;
	Insets ins = border.getBorderInsets(this);
	Rectangle rect = getVisibleRect();
	double zoomX = getZoomX();
	double zoomY = getZoomY();
	double x = (double) (p.x - ins.left) / zoomX;
	double y = (double) (p.y - ins.top) / zoomY;
	double w = (double) rect.width - ins.left - ins.right;
	double h = (double) rect.height - ins.top - ins.bottom;
	if(xAvg==1) xRep*=2;
	else xAvg /=2;
	if(yAvg==1) yRep*=2;
	else yAvg /=2;
	zoomX = getZoomX();
	zoomY = getZoomY();
	invalidate();
	int newX = (int) (x*zoomX - rect.getWidth()*.5d);
	int newY = (int) (y*zoomY - rect.getHeight()*.5d);
	synchronized(this) {
		scroller.validate();
	}
	scroller.scrollTo(new Point(newX, newY));
	repaint();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:26,代码来源:XMImage.java

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

示例5: getWorldtoScreen

import java.awt.Rectangle; //导入方法依赖的package包/类
public static Point2D getWorldtoScreen(double x, double y){
    
    Rectangle imageBounds=null;
    ReferencedEnvelope mapBounds=null;
    try{
//        mapBounds=map.getLayerBounds();
        imageBounds = mapFrame.getBounds();
        int width = (int)imageBounds.getWidth();
        int height = (int)imageBounds.getHeight();
    }catch(Exception e){
        
    } 
    
    
    AffineTransform world2screen =
    RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
    Point2D pointScreenAbsolute = new Point2D.Double(x, y);
    Point2D pointScreen = world2screen.transform(pointScreenAbsolute, null);
    return pointScreen;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:21,代码来源:WorldScreen.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: doZoom

import java.awt.Rectangle; //导入方法依赖的package包/类
public void doZoom( Point p, double factor ) {
Rectangle rect = getVisibleRect();
double x = p.getX() / zoom;
		double y = p.getY() / zoom;
		double w = rect.getWidth();
		double h = rect.getHeight();
		zoom *= factor;
zoomX = zoomY = zoom;
		int newX = (int) (x*zoom - w*.5d);
		int newY = (int) (y*zoom - h*.5d);
		invalidate();
		scrollPane.validate();
		JScrollBar sb = scrollPane.getHorizontalScrollBar();
		sb.setValue(newX);
		sb = scrollPane.getVerticalScrollBar();
		sb.setValue(newY);
		repaint();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:SCSImage2.java

示例8: doZoom

import java.awt.Rectangle; //导入方法依赖的package包/类
public void doZoom( Point p, double factor ) {
Rectangle rect = getVisibleRect();
double x = p.getX() / zoom;
		double y = p.getY() / zoom;
		double w = rect.getWidth();
		double h = rect.getHeight();
		zoom *= factor;
		int newX = (int) (x*zoom - w*.5d);
		int newY = (int) (y*zoom - h*.5d);
		invalidate();
		scrollPane.validate();
		JScrollBar sb = scrollPane.getHorizontalScrollBar();
		sb.setValue(newX);
		sb = scrollPane.getVerticalScrollBar();
		sb.setValue(newY);
		repaint();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:18,代码来源:SCSImage.java

示例9: init

import java.awt.Rectangle; //导入方法依赖的package包/类
private void init() {
    int nds = scene.getNodes().size();
    bounds = new Rectangle(magicSizeConstant  + (magicSizeMultiplier * nds), 
                           magicSizeConstant  + (magicSizeMultiplier * nds)); //g.getMaximumBounds();
    temp = bounds.getWidth() / 10;
    forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
    
    GraphNode<I> rn = scene.getRootGraphNode();
    NodeWidget rw = getWidget(rn);
    rw.locX = bounds.getCenterX();
    rw.locY = bounds.getCenterY();
    rw.setFixed(true);
    layoutCirculary(scene.getNodes(), rn);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FruchtermanReingoldLayout.java

示例10: getTableCellRendererComponent

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent (
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column
) {
    JLabel c = (JLabel)defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    
    if (value instanceof String) {
        Rectangle cellRect = table.getCellRect(row, column, false);
        String scCell = (String) value;
        Dimension d = new Dimension((int) cellRect.getWidth(), (int) cellRect.getHeight());
        if (panel == null)
            panel = new ShortcutCellPanel(scCell);
        panel.setText(scCell);
        panel.setSize(d);

        if (isSelected) {
            panel.setBgColor(table.getSelectionBackground());
            if (UIManager.getLookAndFeel ().getID ().equals ("GTK"))
                panel.setFgCOlor(table.getForeground(), true);
            else
                panel.setFgCOlor(table.getSelectionForeground(), true);
        } else {
            panel.setBgColor(c.getBackground());
            panel.setFgCOlor(c.getForeground(), false);
        }
        if (hasFocus) {
            panel.setBorder(c.getBorder());
        } else {
            panel.setBorder(null);
        }

        return panel;
    }
    else {
        return c;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ButtonCellRenderer.java

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

示例12: getClipRect2D

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Gets the region currently displayed in Projection coordinates.
 * @return the region currently displayed in Projection coordinates.
 */
public Rectangle2D getClipRect2D() {
	Rectangle r = getVisibleRect();
	Dimension dim = getPreferredSize();
	r.width = Math.min(r.width, dim.width);
	r.height = Math.min(r.height, dim.height);
	AffineTransform at = new AffineTransform();
	if(rotation==1) {
		at.translate( 0., dim.getHeight() );
		at.rotate(-.5*Math.PI);
	} else if( rotation==2 ) {
		at.translate( dim.getWidth(), dim.getHeight() );
		at.rotate( Math.PI );
	} else if( rotation == 3) {
		at.translate( dim.getWidth(), 0. );
		at.rotate( .5*Math.PI );
	}
	if(rotation != 0) {
		Point2D p1 = at.transform(new Point(r.x,r.y), null);
		Point2D p2 = at.transform(new Point(r.x+r.width,r.y+r.width), null);
		r.x = (int) Math.min(p1.getX(), p2.getX());
		r.width = (int) Math.max(p1.getX(), p2.getX()) - r.x;
		r.y = (int) Math.min(p1.getY(), p2.getY());
		r.height = (int) Math.max(p1.getY(), p2.getY()) - r.y;
	}

	if(mapBorder != null) {
		Insets ins = mapBorder.getBorderInsets(this);
		r.width -= ins.left + ins.right;
		r.height -= ins.top + ins.bottom;
	}
	Rectangle2D.Double r2d = new Rectangle2D.Double(
			r.getX()/zoom, r.getY()/zoom,
			r.getWidth()/zoom, r.getHeight()/zoom);
	return r2d;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:40,代码来源:XMap.java

示例13: pressOK

import java.awt.Rectangle; //导入方法依赖的package包/类
private static boolean pressOK(Component comp) {

        JInternalFrame internalFrame
                = findModalInternalFrame(comp, QUESTION);

        if (internalFrame == null) {
            return false;
        }

        JButton button = (JButton) findButton(internalFrame);

        if (button == null) {
            return false;
        }

        try {
            Robot robot = new Robot();
            Point location = button.getLocationOnScreen();
            Rectangle bounds = button.getBounds();
            int centerX = (int) (location.getX() + bounds.getWidth() / 2);
            int centerY = (int) (location.getY() + bounds.getHeight() / 2);
            robot.mouseMove(centerX, centerY);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        } catch (IllegalComponentStateException ignore) {
            return false;
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
        return true;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:bug6219960.java

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

示例15: getPointToClick

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


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