本文整理汇总了Java中org.piccolo2d.nodes.PImage类的典型用法代码示例。如果您正苦于以下问题:Java PImage类的具体用法?Java PImage怎么用?Java PImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PImage类属于org.piccolo2d.nodes包,在下文中一共展示了PImage类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNodeUsingExistingClasses
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void createNodeUsingExistingClasses() {
final PLayer layer = getCanvas().getLayer();
layer.addChild(PPath.createEllipse(0, 0, 100, 100));
layer.addChild(PPath.createRectangle(0, 100, 100, 100));
layer.addChild(new PText("Hello World"));
// Here we create an image node that displays a thumbnail
// image of the root node. Note that you can easily get a thumbnail
// of any node by using PNode.toImage().
final PImage image = new PImage(layer.toImage(300, 300, null));
layer.addChild(image);
}
示例2: createNodeUsingExistingClasses
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void createNodeUsingExistingClasses() {
final PLayer layer = getCanvas().getLayer();
layer.addChild(PPath.createEllipse(0, 0, 100, 100));
layer.addChild(PPath.createRectangle(0, 100, 100, 100));
layer.addChild(new PText("Hello World"));
// Here we create an image node that displays a thumbnail
// image of the root node. Note that you can easily get a thumbnail
// of any node by using PNode.toImage().
layer.addChild(new PImage(layer.toImage(300, 300, Color.YELLOW)));
}
示例3: setImage
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
/**
* Set the image that is wrapped by this PImage node. This method will also
* load the image using a MediaTracker before returning. And if the this
* PImage is accelerated that I'm will be copied into an accelerated image
* if needed. Note that this may cause undesired results with images that
* have transparent regions, for those cases you may want to set the PImage
* to be not accelerated.
*
* @param newImage the image that should replace the current one
*/
public void setImage(final Image newImage) {
final Image old = image;
image = newImage;
if (image != null) {
final Rectangle bounds = getImage().getBounds();
setBounds(0, 0, bounds.width, bounds.height);
invalidatePaint();
}
firePropertyChange(PImage.PROPERTY_CODE_IMAGE, PImage.PROPERTY_IMAGE, old, image);
}
示例4: testClone
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testClone() {
final PImage srcNode = new PImage(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB));
final PImage clonedNode = (PImage) srcNode.clone();
assertNotNull(clonedNode.getImage());
assertEquals(srcNode.getImage().getWidth(null), clonedNode.getImage().getWidth(null));
assertEquals(srcNode.getImage().getHeight(null), clonedNode.getImage().getHeight(null));
assertEquals(srcNode.getBounds(), clonedNode.getBounds());
}
示例5: testCanBeCreatedFromFile
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testCanBeCreatedFromFile() throws IOException {
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final File imgFile = File.createTempFile("test", ".jpeg");
ImageIO.write(img, "JPEG", imgFile);
imgFile.deleteOnExit();
final PImage imageNode = new PImage(imgFile.getAbsolutePath());
assertNotNull(imageNode.getImage());
assertEquals(100, imageNode.getImage().getWidth(null));
assertEquals(100, imageNode.getImage().getHeight(null));
}
示例6: testCanBeCreatedFromUrl
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testCanBeCreatedFromUrl() throws IOException {
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final File imgFile = File.createTempFile("test", ".jpeg");
imgFile.deleteOnExit();
ImageIO.write(img, "JPEG", imgFile);
final PImage imageNode = new PImage(imgFile.toURI().toURL());
assertEquals(100, imageNode.getImage().getWidth(null));
assertEquals(100, imageNode.getImage().getHeight(null));
}
示例7: testImageCanBeSetFromFile
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testImageCanBeSetFromFile() throws IOException {
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final File imgFile = File.createTempFile("test", ".jpeg");
imgFile.deleteOnExit();
ImageIO.write(img, "JPEG", imgFile);
final PImage imageNode = new PImage();
imageNode.setImage(imgFile.getAbsolutePath());
assertEquals(100, imageNode.getImage().getWidth(null));
assertEquals(100, imageNode.getImage().getHeight(null));
}
示例8: testPaintAnEmptyImageNodeDoesNothing
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testPaintAnEmptyImageNodeDoesNothing() {
final PImage imageNode = new PImage();
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final PPaintContext paintContext = new PPaintContext(img.createGraphics());
imageNode.paint(paintContext);
}
示例9: SwingPiccoloTest
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public SwingPiccoloTest() {
super("Zoomable Swing GUI Demo - Swing Wrapper");
// JPanel panel = new TileLayer();
// panel.setLayout(new GridLayout(200, 200, 0, 0));
// panel.enableInputMethods(false);
// PSwing swingWrapper = new PSwing(panel);
//JButton button = new JButton();
//PSwing wrapper = new PSwing(button);
PSwingCanvas canvas = new PSwingCanvas();
canvas.removeInputEventListener(canvas.getZoomEventHandler());
PMouseWheelZoomEventHandler eh = new PMouseWheelZoomEventHandler();
eh.zoomAboutMouse();
canvas.addInputEventListener(eh);
canvas.setBackground(Color.blue);
nodes = new PImage[20][20];
for(int i = 0; i < nodes.length; i++)
{
for(int j = 0; j < nodes[i].length; j++)
{
nodes[i][j] = new PImage();
nodes[i][j].setPaint(Color.BLUE);
canvas.getLayer().addChild(nodes[i][j]);
nodes[i][j].setBounds(i*16, j*16, 16, 16);
nodes[i][j].addInputEventListener(new ClickListener(i, j));
}
}
//canvas.getLayer().addChild(wrapper);
//canvas.getLayer().addChild(swingWrapper);
add(canvas, BorderLayout.CENTER);
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}
示例10: initialize
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
BufferedImage src = buildRedRectangleImage();
addHeaderAt("Shadow nodes drawn from an image, with increasing blur radius:", 0, 0);
double x = 25.0d;
double y = 25.0d;
for (int blurRadius = 4; blurRadius < 28; blurRadius += 4) {
PImage node = new PImage(src);
PShadow shadowNode = new PShadow(src, SHADOW_PAINT, blurRadius);
node.setOffset(x, y);
// offset the shadow to account for blur radius offset and light direction
shadowNode.setOffset(x - (2 * blurRadius) + 5.0d, y - (2 * blurRadius) + 5.0d);
// add shadow node before node, or set Z explicitly (e.g. sendToBack())
getCanvas().getLayer().addChild(shadowNode);
getCanvas().getLayer().addChild(node);
x += 125.0d;
if (x > 300.0d) {
y += 125.0d;
x = 25.0d;
}
}
addHeaderAt("Shadow nodes drawn from node.toImage():", 0, 300);
PPath rectNode = buildRedRectangleNode();
PShadow rectShadow = new PShadow(rectNode.toImage(), SHADOW_PAINT, 8);
rectShadow.setOffset(25.0d - (2 * 8) + 5.0d, 325.0d - (2 * 8) + 5.0d);
getCanvas().getLayer().addChild(rectShadow);
getCanvas().getLayer().addChild(rectNode);
PText textNode = new PText("Shadow Text");
textNode.setTextPaint(Color.RED);
textNode.setFont(textNode.getFont().deriveFont(36.0f));
textNode.setOffset(125.0d, 325.0d);
PShadow textShadow = new PShadow(textNode.toImage(), SHADOW_PAINT, 8);
textShadow.setOffset(125.0d - (2 * 8) + 2.5d, 325.0d - (2 * 8) + 2.5d);
getCanvas().getLayer().addChild(textShadow);
getCanvas().getLayer().addChild(textNode);
}
示例11: testToString
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testToString() {
final PImage aNode = new PImage(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB));
assertNotNull(aNode.toString());
}
示例12: testToBufferedImageReturnsCopyIfToldTo
import org.piccolo2d.nodes.PImage; //导入依赖的package包/类
public void testToBufferedImageReturnsCopyIfToldTo() {
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final BufferedImage copy = PImage.toBufferedImage(img, true);
assertNotSame(img, copy);
}