Package java.awt

Examples of java.awt.Graphics2D.scale()


      // is too slow and can't be replaced by Quartz engine in applet environment
      int imageWidth = Math.round(mainGridSize * gridScale);
      BufferedImage gridImage = new BufferedImage(imageWidth, imageWidth, BufferedImage.TYPE_INT_ARGB);
      Graphics2D imageGraphics = (Graphics2D)gridImage.getGraphics();
      setRenderingHints(imageGraphics);
      imageGraphics.scale(gridScale, gridScale);
     
      paintGridLines(imageGraphics, gridScale, 0, mainGridSize, 0, mainGridSize, gridSize, mainGridSize);   
      imageGraphics.dispose();
     
      g2D.setPaint(new TexturePaint(gridImage, new Rectangle2D.Float(0, 0, mainGridSize, mainGridSize)));
View Full Code Here


      // Change component coordinates system to plan system
      Rectangle2D planBounds = getPlanBounds();   
      float paintScale = getScale();
      g2D.translate(insets.left + (MARGIN - planBounds.getMinX()) * paintScale,
          insets.top + (MARGIN - planBounds.getMinY()) * paintScale);
      g2D.scale(paintScale, paintScale);
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      // Paint component contents
      paintRuler(g2D, paintScale);
      g2D.dispose();
View Full Code Here

        @Override
        protected void paintComponent(Graphics g) {
          Graphics2D g2D = (Graphics2D) g;
          g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2D.translate(getWidth() / 2, getHeight() / 2);
          g2D.scale(getWidth() / 2, getWidth() / 2);
          g2D.rotate(Math.toRadians(controller.getNorthDirectionInDegrees()));
          // Draw a round arc
          g2D.setStroke(new BasicStroke(0.5f / getWidth()));
          g2D.draw(new Ellipse2D.Float(-0.7f, -0.7f, 1.4f, 1.4f));
          g2D.draw(new Line2D.Float(-0.85f, 0, -0.7f, 0));
View Full Code Here

       
        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();
        g2D.draw(new Line2D.Float(scaleDistancePoints [0][0], scaleDistancePoints [0][1],
View Full Code Here

        // 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]);
        g2D.scale(scale, scale);
       
        // Draw a dot at origin
        g2D.translate(this.controller.getXOrigin(), this.controller.getYOrigin());
       
        float originRadius = 4 / scale;
View Full Code Here

        {
            case 1: // 0�
                dx = (double)dim.width / (double)w;
                dy = (double)dim.height / (double)h;
                d = Math.min(dx, dy);
                g2d.scale(d, d);
                if ((int)(w*d + .5) < dim.width)
                    xOffset = (int)((dim.width - w*d)/(2.0*d) + 0.5);
                if ((int)(h*d + .5) < dim.height)
                    yOffset = (int)((dim.height - h*d)/(2.0*d) + 0.5);
                g2d.translate(xOffset, yOffset);
View Full Code Here

            case 2: // <->
                dx = (double)dim.width / (double)w;
                dy = (double)dim.height / (double)h;
                d = Math.min(dx, dy);
                g2d.translate(w*d, 0);
                g2d.scale(-d, d);
                if ((int)(w*d + .5) < dim.width)
                    xOffset = (int)((dim.width - w*d)/(2.0*d) + 0.5);
                if ((int)(h*d + .5) < dim.height)
                    yOffset = (int)((dim.height - h*d)/(2.0*d) + 0.5);
                g2d.translate(-xOffset, yOffset);
View Full Code Here

                dx = (double)dim.width / (double)w;
                dy = (double)dim.height / (double)h;
                d = Math.min(dx, dy);
                g2d.rotate(Math.PI);
                g2d.translate(-w*d, -h*d);
                g2d.scale(d, d);
                if ((int)(w*d + .5) < dim.width)
                    xOffset = (int)((dim.width - w*d)/(2.0*d) + 0.5);
                if ((int)(h*d + .5) < dim.height)
                    yOffset = (int)((dim.height - h*d)/(2.0*d) + 0.5);
                g2d.translate(-xOffset, -yOffset);
View Full Code Here

                dx = (double)dim.width / (double)w;
                dy = (double)dim.height / (double)h;
                d = Math.min(dx, dy);
                g2d.rotate(Math.PI);
                g2d.translate(0, -h*d);
                g2d.scale(-d, d);
                if ((int)(w*d + .5) < dim.width)
                    xOffset = (int)((dim.width - w*d)/(2.0*d) + 0.5);
                if ((int)(h*d + .5) < dim.height)
                    yOffset = (int)((dim.height - h*d)/(2.0*d) + 0.5);
                g2d.translate(xOffset, -yOffset);
View Full Code Here

            case 5: // -90� + <->
                dx = (double)dim.width / (double)h;
                dy = (double)dim.height / (double)w;
                d = Math.min(dx, dy);
                g2d.rotate(Math.PI/2);
                g2d.scale(d, -d);
                if ((int)(h*d + .5) < dim.width)
                    xOffset = (int)((dim.width - h*d)/(2.0*d) + 0.5);
                if ((int)(w*d + .5) < dim.height)
                    yOffset = (int)((dim.height - w*d)/(2.0*d) + 0.5);
                g2d.translate(yOffset, xOffset);
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.