Examples of AWTCanvas


Examples of ch.blackspirit.graphics.AWTCanvas

  // TODO Test AWT creation
  @Test
  public void createAWTCanvasLightweight() throws InterruptedException {
    CanvasFactory factory = new ch.blackspirit.graphics.jogl.CanvasFactory();
    AWTCanvas canvas = factory.createAWTCanvas(true);
   
    JFrame frame = new JFrame();
    frame.getContentPane().add(canvas.getComponent());
    frame.setSize(800, 600);
   
    frame.setVisible(true);
  }
View Full Code Here

Examples of ch.blackspirit.graphics.AWTCanvas

  }

  @Test
  public void createAWTCanvasHeavyweight() throws InterruptedException {
    CanvasFactory factory = new ch.blackspirit.graphics.jogl.CanvasFactory();
    AWTCanvas canvas = factory.createAWTCanvas(false);
   
    JFrame frame = new JFrame();
    frame.getContentPane().add(canvas.getComponent());
    frame.setSize(800, 600);
   
    frame.setVisible(true);
  }
View Full Code Here

Examples of ch.blackspirit.graphics.AWTCanvas

        menu.add(item);
        bar.add(menu);
    frame.setJMenuBar(bar);
       
 
        final AWTCanvas canvas = ServiceLoader.load(ch.blackspirit.graphics.CanvasFactory.class).iterator().next()
            .createAWTCanvas(true);

    canvas.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics renderer) {
        renderer.clear();
        view.setCamera(-x, -y, 0);
        renderer.clear();
        for(int x = -2; x < 2; x++) {
          for(int y = -2; y < 2; y++) {
            renderer.translate(x * 44, y * image.getHeight());
            renderer.drawImage(image, 44, image.getHeight(), 0, 0, 44, image.getHeight());
            renderer.clearTransform();
          }
        }
      }
      public void sizeChanged(GraphicsContext context, View view) {
        view.setSize(canvas.getWidth(), canvas.getHeight());
      }
      public void init(View view, Graphics renderer) {
        view.setSize(canvas.getWidth(), canvas.getHeight());
      }
       });
        // Integrate canvas into Swing frame
        frame.getContentPane().add(canvas.getComponent());
    frame.getContentPane().setPreferredSize(new Dimension(800,600));
    frame.pack();
   
    image = canvas.getImageFactory().createImage(
        SwingDemo.class.getResource("/sprites/Crono - Walk (Left) 44x68.png"), true);
   
    canvas.getComponent().addMouseMotionListener(new MouseMotionListener() {
      public void mouseDragged(MouseEvent e) {
        x += e.getX() - lastX;
        y += e.getY() - lastY;
        lastX = e.getX();
        lastY = e.getY();
       
        // Redraw the canvas
        canvas.draw();
      }
      public void mouseMoved(MouseEvent e) {}
        });
       
        canvas.getComponent().addMouseListener(new MouseListener() {
      public void mouseClicked(MouseEvent e) {}
      public void mousePressed(MouseEvent e) {
        lastX = e.getX();
        lastY = e.getY();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.