本文整理汇总了Java中edu.umd.cs.piccolo.util.PBounds.expandNearestIntegerDimensions方法的典型用法代码示例。如果您正苦于以下问题:Java PBounds.expandNearestIntegerDimensions方法的具体用法?Java PBounds.expandNearestIntegerDimensions怎么用?Java PBounds.expandNearestIntegerDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.util.PBounds
的用法示例。
在下文中一共展示了PBounds.expandNearestIntegerDimensions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: repaint
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Flags the bounds provided as needing to be redrawn.
*
* @param bounds the bounds that should be repainted
*/
public void repaint(final PBounds bounds) {
bounds.expandNearestIntegerDimensions();
bounds.inset(-1, -1);
redraw((int) bounds.x, (int) bounds.y, (int) bounds.width, (int) bounds.height, true);
}
示例2: print
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Prints the node into the given Graphics context using the specified
* format. The zero based index of the requested page is specified by
* pageIndex. If the requested page does not exist then this method returns
* NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. If the printable object
* aborts the print job then it throws a PrinterException.
*
* @param graphics the context into which the node is drawn
* @param pageFormat the size and orientation of the page
* @param pageIndex the zero based index of the page to be drawn
*
* @return Either NO_SUCH_PAGE or PAGE_EXISTS
*/
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) {
if (pageIndex != 0) {
return NO_SUCH_PAGE;
}
if (!(graphics instanceof Graphics2D)) {
throw new IllegalArgumentException("Provided graphics context is not a Graphics2D object");
}
final Graphics2D g2 = (Graphics2D) graphics;
final PBounds imageBounds = getFullBounds();
imageBounds.expandNearestIntegerDimensions();
g2.setClip(0, 0, (int) pageFormat.getWidth(), (int) pageFormat.getHeight());
g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
// scale the graphics so node's full bounds fit in the imageable bounds.
double scale = pageFormat.getImageableWidth() / imageBounds.getWidth();
if (pageFormat.getImageableHeight() / imageBounds.getHeight() < scale) {
scale = pageFormat.getImageableHeight() / imageBounds.getHeight();
}
g2.scale(scale, scale);
g2.translate(-imageBounds.x, -imageBounds.y);
final PPaintContext pc = new PPaintContext(g2);
pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
fullPaint(pc);
return PAGE_EXISTS;
}
示例3: repaint
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void repaint(final PBounds bounds) {
PDebug.processRepaint();
bounds.expandNearestIntegerDimensions();
bounds.inset(-1, -1);
repaint((int) bounds.x, (int) bounds.y, (int) bounds.width, (int) bounds.height);
}
示例4: printAll
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Prints the entire scene regardless of what the viewable area is.
*
* @param graphics Graphics context onto which to paint the scene for printing
*/
public void printAll(final Graphics graphics) {
if (!(graphics instanceof Graphics2D)) {
throw new IllegalArgumentException("Provided graphics context is not a Graphics2D object");
}
final Graphics2D g2 = (Graphics2D) graphics;
final PBounds clippingRect = new PBounds(graphics.getClipBounds());
clippingRect.expandNearestIntegerDimensions();
final PBounds originalCameraBounds = getCamera().getBounds();
final PBounds layerBounds = getCamera().getUnionOfLayerFullBounds();
getCamera().setBounds(layerBounds);
final double clipRatio = clippingRect.getWidth() / clippingRect.getHeight();
final double nodeRatio = ((double) getWidth()) / ((double) getHeight());
final double scale;
if (nodeRatio <= clipRatio) {
scale = clippingRect.getHeight() / getCamera().getHeight();
}
else {
scale = clippingRect.getWidth() / getCamera().getWidth();
}
g2.scale(scale, scale);
g2.translate(-clippingRect.x, -clippingRect.y);
final PPaintContext pc = new PPaintContext(g2);
pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
getCamera().fullPaint(pc);
getCamera().setBounds(originalCameraBounds);
}
示例5: toImage
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Paint a representation of this node into the specified buffered image. If
* background, paint is null, then the image will not be filled with a color
* prior to rendering
*
* @since 1.3
* @param image Image onto which this node will be painted
* @param backGroundPaint will fill background of image with this. May be
* null.
* @param fillStrategy strategy to use regarding how node will cover the
* image
* @return a rendering of this image and its descendants onto the specified
* image
*/
public Image toImage(final BufferedImage image, final Paint backGroundPaint, final int fillStrategy) {
final int imageWidth = image.getWidth();
final int imageHeight = image.getHeight();
final Graphics2D g2 = image.createGraphics();
if (backGroundPaint != null) {
g2.setPaint(backGroundPaint);
g2.fillRect(0, 0, imageWidth, imageHeight);
}
g2.setClip(0, 0, imageWidth, imageHeight);
final PBounds nodeBounds = getFullBounds();
nodeBounds.expandNearestIntegerDimensions();
final double nodeWidth = nodeBounds.getWidth();
final double nodeHeight = nodeBounds.getHeight();
double imageRatio = imageWidth / (imageHeight * 1.0);
double nodeRatio = nodeWidth / nodeHeight;
double scale;
switch (fillStrategy) {
case FILL_STRATEGY_ASPECT_FIT:
// scale the graphics so node's full bounds fit in the imageable
// bounds but aspect ration is retained
if (nodeRatio <= imageRatio) {
scale = image.getHeight() / nodeHeight;
}
else {
scale = image.getWidth() / nodeWidth;
}
g2.scale(scale, scale);
g2.translate(-nodeBounds.x, -nodeBounds.y);
break;
case FILL_STRATEGY_ASPECT_COVER:
// scale the graphics so node completely covers the imageable
// area, but retains its aspect ratio.
if (nodeRatio <= imageRatio) {
scale = image.getWidth() / nodeWidth;
}
else {
scale = image.getHeight() / nodeHeight;
}
g2.scale(scale, scale);
break;
case FILL_STRATEGY_EXACT_FIT:
// scale the node so that it covers then entire image,
// distorting it if necessary.
g2.scale(image.getWidth() / nodeWidth, image.getHeight() / nodeHeight);
g2.translate(-nodeBounds.x, -nodeBounds.y);
break;
default:
throw new IllegalArgumentException("Fill strategy provided is invalid");
}
final PPaintContext pc = new PPaintContext(g2);
pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
fullPaint(pc);
return image;
}