本文整理了Java中java.awt.Rectangle.getBounds2D
方法的一些代码示例,展示了Rectangle.getBounds2D
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.getBounds2D
方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:getBounds2D
暂无
代码示例来源:origin: runelite/runelite
private void renderWidgetOverlay(Graphics2D graphics, Portal portal, String text, Color color)
{
Widget shield = client.getWidget(portal.getShield());
Widget icon = client.getWidget(portal.getIcon());
Widget hp = client.getWidget(portal.getHitpoints());
Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0);
Rectangle2D barBounds = bar.getBounds().getBounds2D();
// create one rectangle from two different widget bounds
Rectangle2D bounds = union(shield.getBounds().getBounds2D(), icon.getBounds().getBounds2D());
bounds = union(bounds, hp.getBounds().getBounds2D());
graphics.setColor(color);
graphics.draw(new Rectangle2D.Double(bounds.getX(), bounds.getY() - 2, bounds.getWidth(), bounds.getHeight() - 3));
FontMetrics fm = graphics.getFontMetrics();
Rectangle2D textBounds = fm.getStringBounds(text, graphics);
int x = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
int y = (int) (bounds.getY() + bounds.getHeight() + textBounds.getHeight() + barBounds.getHeight());
graphics.setColor(Color.BLACK);
graphics.drawString(text, x + 1, y + 5);
graphics.setColor(color);
graphics.drawString(text, x, y + 4);
}
代码示例来源:origin: runelite/runelite
private void renderProgressWidget(Graphics2D graphics)
{
Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0);
Rectangle2D bounds = bar.getBounds().getBounds2D();
Widget prgs = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_PROGRESS).getChild(0);
int perc = (int) ((prgs.getBounds().getWidth() / bounds.getWidth()) * 100);
Color color = Color.GREEN;
if (perc < 25)
{
color = Color.RED;
}
String text = String.valueOf(perc) + "%";
FontMetrics fm = graphics.getFontMetrics();
Rectangle2D textBounds = fm.getStringBounds(text, graphics);
int x = (int) (bounds.getX() - textBounds.getWidth());
int y = (int) (bounds.getY() + fm.getHeight() - 2);
graphics.setColor(Color.BLACK);
graphics.drawString(text, x + 1, y + 1);
graphics.setColor(color);
graphics.drawString(text, x, y);
}
代码示例来源:origin: runelite/runelite
Rectangle2D bounds = xpOrb.getBounds().getBounds2D();
if (bounds.getX() <= 0)
代码示例来源:origin: geotools/geotools
/**
* @see org.geotools.coverage.io.CoverageReadRequest#setDomainSubset(java.awt.Rectangle,
* org.opengis.referencing.operation.MathTransform2D,
* org.opengis.referencing.crs.CoordinateReferenceSystem)
*/
public void setDomainSubset(
final Rectangle rasterArea,
final MathTransform2D gridToWorldTrasform,
final CoordinateReferenceSystem crs)
throws MismatchedDimensionException, TransformException {
// get input elements
this.rasterArea = (Rectangle) rasterArea.clone();
this.gridToWorldTransform = gridToWorldTrasform;
// create a bbox
GeneralEnvelope env =
CRS.transform(
gridToWorldTrasform, new ReferencedEnvelope(rasterArea.getBounds2D(), crs));
this.geographicArea = new ReferencedEnvelope(new ReferencedEnvelope(env), crs);
}
代码示例来源:origin: nodebox/nodebox
private void exportToMovieFile(File file, final VideoFormat videoFormat, final int fromValue, final int toValue) {
file = videoFormat.ensureFileExtension(file);
final Rectangle2D bounds = getCanvasBounds().getBounds2D();
final int width = (int) Math.round(bounds.getWidth());
final int height = (int) Math.round(bounds.getHeight());
final Movie movie = new Movie(file.getAbsolutePath(), videoFormat, width, height, false);
exportThreadedRange(controller.getNodeLibrary(), fromValue, toValue, new ExportDelegate() {
@Override
public void frameDone(double frame, Iterable<?> results) {
movie.addFrame(ObjectsRenderer.createMovieImage(results, bounds));
}
@Override
void exportDone() {
progressDialog.setTitle("Converting frames to movie...");
progressDialog.reset();
FramesWriter w = new FramesWriter(progressDialog);
movie.save(w);
}
});
}
代码示例来源:origin: nodebox/nodebox
private void exportToFile(File file, Iterable<?> objects, ExportFormat format, Map<String, ?> options) {
file = format.ensureFileExtension(file);
ObjectsRenderer.render(objects, getCanvasBounds().getBounds2D(), file, options);
}
代码示例来源:origin: nodebox/nodebox
public void showDocumentProperties() {
DocumentPropertiesDialog dialog = new DocumentPropertiesDialog(this);
dialog.setVisible(true);
if (dialog.isCommitted()) {
addEdit("Change document properties");
controller.setProperties(dialog.getProperties());
getViewer().setCanvasBounds(getCanvasBounds().getBounds2D());
requestRender();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project
public void paint(Graphics g) {
assert resizeMode != -1;
assert rec != null;
int inset = 5;
Graphics2D g2d = (Graphics2D)g;
Stroke oStroke = g2d.getStroke();
g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{3.0f}, 0.0f));
Rectangle2D rec2d = rec.getBounds2D();
Line2D line = null;
switch(resizeMode) {
case OneSideScaleMode.N_RESIZE_MODE:
line = new Line2D.Double(rec2d.getMinX(),rec2d.getMaxY(),rec2d.getMaxX()-inset,rec2d.getMaxY());
break;
case OneSideScaleMode.E_RESIZE_MODE:
line = new Line2D.Double(rec2d.getMinX(),rec2d.getMinY(),rec2d.getMinX(),rec2d.getMaxY()-inset);
break;
case OneSideScaleMode.S_RESIZE_MODE:
line = new Line2D.Double(rec2d.getMinX(),rec2d.getMinY(),rec2d.getMaxX()-inset,rec2d.getMinY());
break;
case OneSideScaleMode.W_RESIZE_MODE:
line = new Line2D.Double(rec2d.getMaxX(),rec2d.getMinY(),rec2d.getMaxX(),rec2d.getMaxY()-inset);
break;
}
g2d.draw(line);
g2d.setStroke(oStroke);
}
代码示例来源:origin: org.geotools/gt-coverage-api
/**
* @see org.geotools.coverage.io.CoverageReadRequest#setDomainSubset(java.awt.Rectangle,
* org.opengis.referencing.operation.MathTransform2D,
* org.opengis.referencing.crs.CoordinateReferenceSystem)
*/
public void setDomainSubset(
final Rectangle rasterArea,
final MathTransform2D gridToWorldTrasform,
final CoordinateReferenceSystem crs)
throws MismatchedDimensionException, TransformException {
// get input elements
this.rasterArea = (Rectangle) rasterArea.clone();
this.gridToWorldTransform = gridToWorldTrasform;
// create a bbox
GeneralEnvelope env =
CRS.transform(
gridToWorldTrasform, new ReferencedEnvelope(rasterArea.getBounds2D(), crs));
this.geographicArea = new ReferencedEnvelope(new ReferencedEnvelope(env), crs);
}
代码示例来源:origin: raydac/netbeans-mmd-plugin
@Nonnull
@MustNotContainNull
public List<Topic> getAllSelectedElements(@Nonnull final MindMap map) {
final List<Topic> result = new ArrayList<Topic>();
final Rectangle rect = asRectangle();
addCoveredToList(result, map.getRoot(), rect.getBounds2D());
return result;
}
代码示例来源:origin: com.orsonpdf/orsonpdf
/**
* Returns {@code true} if the rectangle (in device space) intersects
* with the shape (the interior, if {@code onStroke} is false,
* otherwise the stroked outline of the shape).
*
* @param rect a rectangle (in device space).
* @param s the shape.
* @param onStroke test the stroked outline only?
*
* @return A boolean.
*/
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
Shape ts;
if (onStroke) {
ts = this.transform.createTransformedShape(
this.stroke.createStrokedShape(s));
} else {
ts = this.transform.createTransformedShape(s);
}
if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
return false;
}
Area a1 = new Area(rect);
Area a2 = new Area(ts);
a1.intersect(a2);
return !a1.isEmpty();
}
代码示例来源:origin: org.jfree/jfreesvg
/**
* Returns {@code true} if the rectangle (in device space) intersects
* with the shape (the interior, if {@code onStroke} is {@code false},
* otherwise the stroked outline of the shape).
*
* @param rect a rectangle (in device space).
* @param s the shape.
* @param onStroke test the stroked outline only?
*
* @return A boolean.
*/
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
Shape ts;
if (onStroke) {
ts = this.transform.createTransformedShape(
this.stroke.createStrokedShape(s));
} else {
ts = this.transform.createTransformedShape(s);
}
if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
return false;
}
Area a1 = new Area(rect);
Area a2 = new Area(ts);
a1.intersect(a2);
return !a1.isEmpty();
}
代码示例来源:origin: jfree/jfreesvg
/**
* Returns {@code true} if the rectangle (in device space) intersects
* with the shape (the interior, if {@code onStroke} is {@code false},
* otherwise the stroked outline of the shape).
*
* @param rect a rectangle (in device space).
* @param s the shape.
* @param onStroke test the stroked outline only?
*
* @return A boolean.
*/
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
Shape ts;
if (onStroke) {
ts = this.transform.createTransformedShape(
this.stroke.createStrokedShape(s));
} else {
ts = this.transform.createTransformedShape(s);
}
if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
return false;
}
Area a1 = new Area(rect);
Area a2 = new Area(ts);
a1.intersect(a2);
return !a1.isEmpty();
}
代码示例来源:origin: org.bidib.jbidib.eu.hansolo/SteelSeries
qualityOverlayFractions = new float[] { 0.0f, 0.2f, 0.5f, 0.75f, 0.9f, 1.0f };
qualityOverlayColors = new Color[] { Color.RED, Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.GREEN };
qualityOverlayLookup = new GradientWrapper(new Point2D.Double(INNER_BOUNDS.getBounds2D().getMinX(), 0), new Point2D.Double(INNER_BOUNDS.getMaxX(), 0), qualityOverlayFractions, qualityOverlayColors);
qualityOverlayGradient = new LinearGradientPaint(new Point2D.Double(0, 2), new Point2D.Double(0, INNER_BOUNDS.height - 2), new float[]{0.0f, 0.5f, 1.0f}, new Color[]{Color.RED, Color.RED.darker(), Color.RED});
qualityOverlay = new RoundRectangle2D.Double();
代码示例来源:origin: org.piccolo2d/piccolo2d-core
/**
* Flags processing of output as finished. Updates all stats in the process.
*
* @param g graphics context in which processing has finished
*/
public static void endProcessingOutput(final Graphics g) {
processOutputTime += System.currentTimeMillis() - startProcessingOutputTime;
framesProcessed++;
if (framesProcessed % printResultsFrameRate == 0) {
if (PDebug.debugPrintFrameRate) {
System.out.println("Process output frame rate: " + getOutputFPS() + " fps");
System.out.println("Process input frame rate: " + getInputFPS() + " fps");
System.out.println("Total frame rate: " + getTotalFPS() + " fps");
System.out.println();
resetFPSTiming();
}
if (PDebug.debugPrintUsedMemory) {
System.out.println("Approximate used memory: " + getApproximateUsedMemory() / 1024 + " k");
}
}
if (PDebug.debugRegionManagement) {
final Graphics2D g2 = (Graphics2D) g;
g2.setColor(PDebug.getDebugPaintColor());
g2.fill(g.getClipBounds().getBounds2D());
}
processingOutput = false;
}
代码示例来源:origin: HanSolo/SteelSeries-Swing
qualityOverlayFractions = new float[] { 0.0f, 0.2f, 0.5f, 0.75f, 0.9f, 1.0f };
qualityOverlayColors = new Color[] { Color.RED, Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.GREEN };
qualityOverlayLookup = new GradientWrapper(new Point2D.Double(INNER_BOUNDS.getBounds2D().getMinX(), 0), new Point2D.Double(INNER_BOUNDS.getMaxX(), 0), qualityOverlayFractions, qualityOverlayColors);
qualityOverlayGradient = new LinearGradientPaint(new Point2D.Double(0, 2), new Point2D.Double(0, INNER_BOUNDS.height - 2), new float[]{0.0f, 0.5f, 1.0f}, new Color[]{Color.RED, Color.RED.darker(), Color.RED});
qualityOverlay = new RoundRectangle2D.Double();
代码示例来源:origin: org.jfree/swtgraphics2d
/**
* Returns {@code true} if the rectangle (in device space) intersects
* with the shape (the interior, if {@code onStroke} is false,
* otherwise the stroked outline of the shape).
*
* @param rect a rectangle (in device space).
* @param s the shape.
* @param onStroke test the stroked outline only?
*
* @return A boolean.
*/
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
AffineTransform transform = getTransform();
Shape ts;
if (onStroke) {
Stroke stroke = getStroke();
ts = transform.createTransformedShape(stroke.createStrokedShape(s));
} else {
ts = transform.createTransformedShape(s);
}
if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
return false;
}
Area a1 = new Area(rect);
Area a2 = new Area(ts);
a1.intersect(a2);
return !a1.isEmpty();
}
代码示例来源:origin: RPTools/maptool
originalArea = tokenInContext.getBounds(zone);
Rectangle2D oa = originalArea.getBounds2D();
if (targetArea.contains(oa) || targetArea.intersects(oa)) {
thePoint.put("x", entry.get("x"));
内容来源于网络,如有侵权,请联系作者删除!