本文整理汇总了Java中java.awt.geom.Rectangle2D.Float方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.Float方法的具体用法?Java Rectangle2D.Float怎么用?Java Rectangle2D.Float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.Float方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItalicBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D getItalicBounds() {
float left = Float.MAX_VALUE, right = -Float.MAX_VALUE;
float top = Float.MAX_VALUE, bottom = -Float.MAX_VALUE;
for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
Rectangle2D tlcBounds = tlc.getItalicBounds();
float x = locs[n];
float y = locs[n+1];
left = Math.min(left, x + (float)tlcBounds.getX());
right = Math.max(right, x + (float)tlcBounds.getMaxX());
top = Math.min(top, y + (float)tlcBounds.getY());
bottom = Math.max(bottom, y + (float)tlcBounds.getMaxY());
}
return new Rectangle2D.Float(left, top, right-left, bottom-top);
}
示例2: getBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Returns the bounds of this {@code TextLayout}.
* The bounds are in standard coordinates.
* <p>Due to rasterization effects, this bounds might not enclose all of the
* pixels rendered by the TextLayout.</p>
* It might not coincide exactly with the ascent, descent,
* origin or advance of the {@code TextLayout}.
* @return a {@link Rectangle2D} that is the bounds of this
* {@code TextLayout}.
*/
public Rectangle2D getBounds() {
ensureCache();
if (boundsRect == null) {
Rectangle2D vb = textLine.getVisualBounds();
if (dx != 0 || dy != 0) {
vb.setRect(vb.getX() - dx,
vb.getY() - dy,
vb.getWidth(),
vb.getHeight());
}
boundsRect = vb;
}
Rectangle2D bounds = new Rectangle2D.Float();
bounds.setRect(boundsRect);
return bounds;
}
示例3: createItalicBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D createItalicBounds() {
float ia = cm.italicAngle;
Rectangle2D lb = getLogicalBounds();
float l = (float)lb.getMinX();
float t = -cm.ascent;
float r = (float)lb.getMaxX();
float b = cm.descent;
if (ia != 0) {
if (ia > 0) {
l -= ia * (b - cm.ssOffset);
r -= ia * (t - cm.ssOffset);
} else {
l -= ia * (t - cm.ssOffset);
r -= ia * (b - cm.ssOffset);
}
}
return new Rectangle2D.Float(l, t, r - l, b - t);
}
示例4: makeTexturePaint
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private TexturePaint makeTexturePaint(int size, boolean alpha) {
int s2 = size / 2;
int type =
alpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
BufferedImage img = new BufferedImage(size, size, type);
Color[] colors = makeGradientColors(4, alpha);
Graphics2D g2d = img.createGraphics();
g2d.setComposite(AlphaComposite.Src);
g2d.setColor(colors[0]);
g2d.fillRect(0, 0, s2, s2);
g2d.setColor(colors[1]);
g2d.fillRect(s2, 0, s2, s2);
g2d.setColor(colors[3]);
g2d.fillRect(0, s2, s2, s2);
g2d.setColor(colors[2]);
g2d.fillRect(s2, s2, s2, s2);
g2d.dispose();
Rectangle2D bounds = new Rectangle2D.Float(0, 0, size, size);
return new TexturePaint(img, bounds);
}
示例5: getAlignBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public final Rectangle2D getAlignBounds(float x, float y) {
if (ab == null) {
ab = createAlignBounds();
}
return new Rectangle2D.Float((float)(ab.getX() + x),
(float)(ab.getY() + y),
(float)ab.getWidth(),
(float)ab.getHeight());
}
示例6: getMaxCharBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Returns the bounds for the character with the maximum
* bounds as defined in the specified <code>FontRenderContext</code>.
* <p>Note: The returned bounds is in baseline-relative coordinates
* (see {@link java.awt.Font class notes}).
* @param frc the specified <code>FontRenderContext</code>
* @return a <code>Rectangle2D</code> that is the bounding box
* for the character with the maximum bounds.
*/
public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
float [] metrics = new float[4];
getFont2D().getFontMetrics(this, frc, metrics);
return new Rectangle2D.Float(0, -metrics[0],
metrics[3],
metrics[0] + metrics[1] + metrics[2]);
}
示例7: modelToView
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Provides a mapping from the document model coordinate space
* to the coordinate space of the view mapped to it.
*
* @param pos the position to convert
* @param a the allocated region to render into
* @return the bounding box of the given position is returned
* @exception BadLocationException if the given position does not represent a
* valid location in the associated document
* @see View#modelToView
*/
public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException {
Rectangle alloc = a.getBounds();
alloc.height = metrics.getHeight();
alloc.width = 1;
int p0 = getStartOffset();
if (pos < p0 || pos > getEndOffset()) {
throw new BadLocationException("Position out of range", pos);
}
int testP = (b == Position.Bias.Forward) ? pos :
Math.max(p0, pos - 1);
int line = 0;
int[] lineEnds = getLineEnds();
if (lineEnds != null) {
line = findLine(testP - p0);
if (line > 0) {
p0 += lineEnds[line - 1];
}
alloc.y += alloc.height * line;
}
if (pos > p0) {
Segment segment = SegmentCache.getSharedSegment();
loadText(segment, p0, pos);
float x = alloc.x;
x += Utilities.getTabbedTextWidth(segment, metrics, x,
WrappedPlainView.this, p0);
SegmentCache.releaseSharedSegment(segment);
return new Rectangle2D.Float(x, alloc.y, alloc.width, alloc.height);
}
return alloc;
}
示例8: GlyphMetrics
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Constructs a {@code GlyphMetrics} object.
* @param advance the advance width of the glyph
* @param bounds the black box bounds of the glyph
* @param glyphType the type of the glyph
*/
public GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType) {
this.horizontal = true;
this.advanceX = advance;
this.advanceY = 0;
this.bounds = new Rectangle2D.Float();
this.bounds.setRect(bounds);
this.glyphType = glyphType;
}
示例9: intersectRectShape
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Shape intersectRectShape(Rectangle2D r, Shape s,
boolean keep1, boolean keep2) {
if (s instanceof Rectangle2D) {
Rectangle2D r2 = (Rectangle2D) s;
Rectangle2D outrect;
if (!keep1) {
outrect = r;
} else if (!keep2) {
outrect = r2;
} else {
outrect = new Rectangle2D.Float();
}
double x1 = Math.max(r.getX(), r2.getX());
double x2 = Math.min(r.getX() + r.getWidth(),
r2.getX() + r2.getWidth());
double y1 = Math.max(r.getY(), r2.getY());
double y2 = Math.min(r.getY() + r.getHeight(),
r2.getY() + r2.getHeight());
if (((x2 - x1) < 0) || ((y2 - y1) < 0))
// Width or height is negative. No intersection.
outrect.setFrameFromDiagonal(0, 0, 0, 0);
else
outrect.setFrameFromDiagonal(x1, y1, x2, y2);
return outrect;
}
if (r.contains(s.getBounds2D())) {
if (keep2) {
s = cloneShape(s);
}
return s;
}
return intersectByArea(r, s, keep1, keep2);
}
示例10: getGlyphOutlineBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
synchronized Rectangle2D.Float getGlyphOutlineBounds(
long pScalerContext, int glyphCode)
throws FontScalerException {
if (nativeScaler != 0L) {
return getGlyphOutlineBoundsNative(font.get(),
pScalerContext,
nativeScaler,
glyphCode);
}
return FontScaler.getNullScaler().
getGlyphOutlineBounds(0L,glyphCode);
}
示例11: getItalicBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D getItalicBounds(float x, float y) {
if (ib == null) {
ib = createItalicBounds();
}
return new Rectangle2D.Float((float)(ib.getX() + x),
(float)(ib.getY() + y),
(float)ib.getWidth(),
(float)ib.getHeight());
}
示例12: getVisualBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Return the union of the visual bounds of all the components.
* This incorporates the path. It does not include logical
* bounds (used by carets).
*/
public Rectangle2D getVisualBounds() {
Rectangle2D result = null;
for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
Rectangle2D r = tlc.getVisualBounds();
Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
if (lp == null) {
r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
r.getWidth(), r.getHeight());
} else {
lp.pathToPoint(pt, false, pt);
AffineTransform at = tlc.getBaselineTransform();
if (at != null) {
AffineTransform tx = AffineTransform.getTranslateInstance
(pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
tx.concatenate(at);
r = tx.createTransformedShape(r).getBounds2D();
} else {
r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
r.getWidth(), r.getHeight());
}
}
if (result == null) {
result = r;
} else {
result.add(r);
}
}
if (result == null) {
result = new Rectangle2D.Float(Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
}
return result;
}
示例13: getGlyphOutlineBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
return nativeFont.getGlyphOutlineBounds(pScalerContext, glyphCode);
}
示例14: getGlyphOutlineBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
return null;
}
示例15: draw
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
float zoom = 1f / (float) map.getZoom();
Rectangle2D.Float rect = new Rectangle2D.Float(-3f*zoom, -3f*zoom, 6f*zoom, 6f*zoom);
Rectangle2D.Float rect1 = new Rectangle2D.Float(-2f*zoom, -2f*zoom, 4f*zoom, 4f*zoom);
Rectangle2D bounds = g.getClipBounds();
AffineTransform at = g.getTransform();
g.setColor( Color.black);
double lastX = 0;
double lastY = 0;
double x, y;
int n = 0;
g.setStroke( new BasicStroke(zoom) );
model.setArea( map.getClipRect2D(), map.getZoom() );
// First Column Corner Text
table.setCornerText( model.current.length +" Stations");
aTable.setCornerText( aModel.analyses.size() +" Analyses");
sTable.setCornerText( sModel.samples.size() +" Samples");
double x1 = bounds.getX();
double x2 = x1+bounds.getWidth();
// double wrap = map.getWrap();
for( int i=0 ; i<model.toPlot.length ; i++) {
x = PDBStation.stations[model.toPlot[i]].getX();
if(wrap>0.)while(x<x1) x+=wrap;
y = PDBStation.stations[model.toPlot[i]].getY();
Color a = computeStationColor(model.toPlot[i]);
if (a == null) continue;
g.setColor(a);
g.translate( x - lastX, y-lastY );
g.draw(rect1);
g.setColor(Color.black);
g.draw(rect);
if( wrap>0 && x+wrap < bounds.getX()+bounds.getWidth() ) {
x += wrap;
g.setColor(a);
g.translate( wrap, 0.);
g.draw(rect1);
g.setColor( Color.black );
g.draw(rect);
}
lastX = x;
lastY = y;
}
current = -1;
g.setTransform( at);
}