Java Code Examples for java.awt.Rectangle.setRect()

The following are Jave code examples for showing how to use setRect() of the java.awt.Rectangle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alevin-svn2   File: MyGraphZoomScrollPane.java   View Source Code Vote up 6 votes
/**
 * Corrects the scrollbar sync issue with JUNG 2.0.1
 * 
 * recalculated at every scroll/translate/addvertex operation
 */
@Override
protected void setScrollBarValues(Rectangle rectangle, Point2D h0,
		Point2D h1, Point2D v0, Point2D v1) {
	// inject real graph bounds
	rectangle.setRect(vv.getGraphBoundsCache());
	// inject offset
	BidirectionalTransformer viewTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.VIEW);
	BidirectionalTransformer layoutTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
	Point2D location = layoutTransformer.inverseTransform(viewTransformer
			.inverseTransform(new Point2D.Double()));
	double xoff = h0.getX() - location.getX();
	double yoff = v0.getY() - location.getY();
	// offset
	h0.setLocation(h0.getX() - xoff, h0.getY() - yoff);
	h1.setLocation(h1.getX() - xoff, h1.getY() - yoff);
	v0.setLocation(v0.getX() - xoff, v0.getY() - yoff);
	v1.setLocation(v1.getX() - xoff, v1.getY() - yoff);
	//
	super.setScrollBarValues(rectangle, h0, h1, v0, v1);
}
 
Example 2
Project: incubator-netbeans   File: DialogBoundsPreserver.java   View Source Code Vote up 6 votes
private Rectangle getDialogBounds() {
    String size = preferences.get(key, DELIMITER);        
    if(size != null) {                                    
        String[] dim = size.split(DELIMITER);             
        if(dim.length != 4 || 
           dim[0].trim().equals("") ||                                      // NOI18N 
           dim[1].trim().equals("") ||                                      // NOI18N
           dim[2].trim().equals("") ||                                      // NOI18N    
           dim[3].trim().equals("") )                                       // NOI18N
        {
            return null;
        }
        Rectangle r = new Rectangle();
        r.setRect(Double.parseDouble(dim[0]), 
                  Double.parseDouble(dim[1]), 
                  Double.parseDouble(dim[2]), 
                  Double.parseDouble(dim[3]));
        return r;
    }
    return null;                
}
 
Example 3
Project: OpenJSharp   File: CStrike.java   View Source Code Vote up 6 votes
void getGlyphImageBounds(int glyphCode, Point2D.Float pt, Rectangle result) {
    Rectangle2D.Float floatRect = new Rectangle2D.Float();

    if (invDevTx != null) {
        invDevTx.transform(pt, pt);
    }

    getGlyphImageBounds(glyphCode, pt.x, pt.y, floatRect);

    if (floatRect.width == 0 && floatRect.height == 0) {
        result.setRect(0, 0, -1, -1);
        return;
    }

    result.setRect(floatRect.x + pt.x, floatRect.y + pt.y, floatRect.width, floatRect.height);
}
 
Example 4
Project: jdk8u-jdk   File: CStrike.java   View Source Code Vote up 6 votes
void getGlyphImageBounds(int glyphCode, Point2D.Float pt, Rectangle result) {
    Rectangle2D.Float floatRect = new Rectangle2D.Float();

    if (invDevTx != null) {
        invDevTx.transform(pt, pt);
    }

    getGlyphImageBounds(glyphCode, pt.x, pt.y, floatRect);

    if (floatRect.width == 0 && floatRect.height == 0) {
        result.setRect(0, 0, -1, -1);
        return;
    }

    result.setRect(floatRect.x + pt.x, floatRect.y + pt.y, floatRect.width, floatRect.height);
}
 
Example 5
Project: openjdk-jdk10   File: CStrike.java   View Source Code Vote up 6 votes
void getGlyphImageBounds(int glyphCode, Point2D.Float pt, Rectangle result) {
    Rectangle2D.Float floatRect = new Rectangle2D.Float();

    if (invDevTx != null) {
        invDevTx.transform(pt, pt);
    }

    getGlyphImageBounds(glyphCode, pt.x, pt.y, floatRect);

    if (floatRect.width == 0 && floatRect.height == 0) {
        result.setRect(0, 0, -1, -1);
        return;
    }

    result.setRect(floatRect.x + pt.x, floatRect.y + pt.y, floatRect.width, floatRect.height);
}
 
Example 6
Project: incubator-netbeans   File: ViewUtils.java   View Source Code Vote up 4 votes
public static Rectangle toRect(Rectangle2D r2d) {
    Rectangle r = new Rectangle();
    r.setRect(r2d);
    return r;
}