Package java.awt

Examples of java.awt.Graphics2D.translate()


        g2D.setPaint(scaleDistanceLineColor);
       
        AffineTransform oldTransform = g2D.getTransform();
        Stroke oldStroke = g2D.getStroke();
        // Use same origin and scale as image drawing in super class
        g2D.translate(translation.x, translation.y);
        g2D.scale(scale, scale);      
        // Draw a scale distance line       
        g2D.setStroke(new BasicStroke(5 / scale,
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
        float [][] scaleDistancePoints = this.controller.getScaleDistancePoints();
View Full Code Here


        g2D.setStroke(new BasicStroke(1 / scale,
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
        double angle = Math.atan2(scaleDistancePoints [1][1] - scaleDistancePoints [0][1],
                    scaleDistancePoints [1][0] - scaleDistancePoints [0][0]);
        AffineTransform oldTransform2 = g2D.getTransform();
        g2D.translate(scaleDistancePoints [0][0], scaleDistancePoints [0][1]);
        g2D.rotate(angle);
        Shape endLine = new Line2D.Double(0, 5 / scale, 0, -5 / scale);
        g2D.draw(endLine);
        g2D.setTransform(oldTransform2);
       
View Full Code Here

        Shape endLine = new Line2D.Double(0, 5 / scale, 0, -5 / scale);
        g2D.draw(endLine);
        g2D.setTransform(oldTransform2);
       
        // Draw end point line
        g2D.translate(scaleDistancePoints [1][0], scaleDistancePoints [1][1]);
        g2D.rotate(angle);
        g2D.draw(endLine);
        g2D.setTransform(oldTransform);
        g2D.setStroke(oldStroke);
      }
View Full Code Here

            : UIManager.getColor("textHighlight");;
        g2D.setPaint(scaleDistanceLineColor);
       
        AffineTransform oldTransform = g2D.getTransform();
        Stroke oldStroke = g2D.getStroke();
        g2D.translate(translation.x, translation.y);
        // Rescale according to scale distance
        float [][] scaleDistancePoints = this.controller.getScaleDistancePoints();
        float scale = getImageScale() / BackgroundImage.getScale(this.controller.getScaleDistance(),
            scaleDistancePoints [0][0], scaleDistancePoints [0][1],
            scaleDistancePoints [1][0], scaleDistancePoints [1][1]);
View Full Code Here

            scaleDistancePoints [0][0], scaleDistancePoints [0][1],
            scaleDistancePoints [1][0], scaleDistancePoints [1][1]);
        g2D.scale(scale, scale);
       
        // Draw a dot at origin
        g2D.translate(this.controller.getXOrigin(), this.controller.getYOrigin());
       
        float originRadius = 4 / scale;
        g2D.fill(new Ellipse2D.Float(-originRadius, -originRadius,
            originRadius * 2, originRadius * 2));
       
View Full Code Here

              2 * cameraCircleRadius, 2 * cameraCircleRadius);
          List<Camera> cameraPath = controller.getCameraPath();
          for (int i = 0; i < cameraPath.size(); i++) {
            Camera camera = cameraPath.get(i);
            AffineTransform previousTransform = g2D.getTransform();
            g2D.translate(camera.getX(), camera.getY());
            g2D.rotate(camera.getYaw());
            // Paint camera location
            g2D.fill(ellipse);
            // Paint field of sight angle
            double sin = (float)Math.sin(camera.getFieldOfView() / 2);
View Full Code Here

    Image image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(IMAGE_WIDTH, IMAGE_HEIGHT, Transparency.BITMASK);
    Graphics2D g2d = (Graphics2D) image.getGraphics();
   
    // Adjust the coordinates so that the actual player image gets
    // drawn to the image area
    g2d.translate(0, IMAGE_HEIGHT % 32);
    view.draw(g2d);
    g2d.dispose();
   
    return image;
  }
View Full Code Here

 
  @Override
  public void paintComponent(Graphics g) {
    if ((point != null) && (dragged != null)) {
      Graphics2D g2d = (Graphics2D) g;
      g2d.translate(point.x, point.y);
      dragged.draw(g2d);
    }
  }

  /**
 
View Full Code Here

      final int x = (getWidth() - IGameScreen.SIZE_UNIT_PIXELS) / 2;
      final int y = (getHeight() - IGameScreen.SIZE_UNIT_PIXELS) / 2;

      final Graphics2D vg = (Graphics2D) g.create(0, 0, getWidth(),
          getHeight());
      vg.translate(x, y);
      view.draw(vg);
      vg.dispose();
    } else if (placeholder != null){
      placeholder.draw(g, (getWidth() - placeholder.getWidth()) / 2,
          (getHeight() - placeholder.getHeight()) / 2);
View Full Code Here

          Math.min(getHeight(), screenSize.height));
    }

    int xAdjust = -getScreenViewX();
    int yAdjust = -getScreenViewY();
    graphics.translate(xAdjust, yAdjust);
    // End of the world (map falls short of the view)?
    if (xAdjust > 0) {
      g2d.setColor(Color.BLACK);
      g2d.fillRect(0, 0, xAdjust, sh);
    }
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.