コード例 #1
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
 public override void transform(java.awt.geom.AffineTransform tx)
 {
     using (Matrix transform = g.Transform,
            matrix = J2C.ConvertTransform(tx))
     {
         transform.Multiply(matrix);
         g.Transform = transform;
     }
 }
コード例 #2
0
 internal static Matrix ConvertTransform(java.awt.geom.AffineTransform tx)
 {
     return(new Matrix(
                (float)tx.getScaleX(),
                (float)tx.getShearY(),
                (float)tx.getShearX(),
                (float)tx.getScaleY(),
                (float)tx.getTranslateX(),
                (float)tx.getTranslateY()));
 }
コード例 #3
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
 public override java.awt.geom.AffineTransform getTransform()
 {
     if (tx != null)
     {
         return(tx);
     }
     using (Matrix matrix = g.Transform)
     {
         return(tx = C2J.ConvertMatrix(matrix));
     }
 }
コード例 #4
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
        public override bool drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, ImageObserver observer)
        {
            if (img == null)
            {
                return(true);
            }

            if (xform == null || xform.isIdentity())
            {
                return(drawImage(img, 0, 0, null, observer));
            }

            throw new NotImplementedException("drawImage(Image,AffineTransform,ImageObserver) not implemented for non-null or non-identity AffineTransform!");
        }
コード例 #5
0
        protected java.awt.geom.AffineTransform computeGeographicToRasterTransform(int width, int height, Sector sector)
        {
            // Compute the the transform from geographic to raster coordinates. In this computation a pixel is assumed
            // to have no dimension. We measure the distance between pixels rather than some pixel dimension.

            double ty = -sector.getMaxLatitude().degrees;
            double tx = -sector.getMinLongitude().degrees;

            double sy = -((height - 1) / sector.getDeltaLatDegrees());
            double sx = ((width - 1) / sector.getDeltaLonDegrees());

            java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();
            transform.scale(sx, sy);
            transform.translate(tx, ty);
            return(transform);
        }
コード例 #6
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
        public override void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
        {
            if (img == null)
            {
                return;
            }

            // BufferedImage case: use a simple drawImage call
            if (img is BufferedImage)
            {
                BufferedImage bufImg = (BufferedImage)img;
                drawImage(bufImg, xform, null);
                return;
            }
            throw new NotImplementedException("drawRenderedImage not implemented for images which are not BufferedImages.");
        }
コード例 #7
0
        protected java.awt.geom.AffineTransform computeSourceToDestTransform(
            int sourceWidth, int sourceHeight, Sector sourceSector,
            int destWidth, int destHeight, Sector destSector)
        {
            // Compute the the transform from source to destination coordinates. In this computation a pixel is assumed
            // to have no dimension. We measure the distance between pixels rather than some pixel dimension.

            double ty = (destHeight - 1) * -(sourceSector.getMaxLatitude().degrees - destSector.getMaxLatitude().degrees)
                        / destSector.getDeltaLatDegrees();
            double tx = (destWidth - 1) * (sourceSector.getMinLongitude().degrees - destSector.getMinLongitude().degrees)
                        / destSector.getDeltaLonDegrees();

            double sy = ((double)(destHeight - 1) / (double)(sourceHeight - 1))
                        * (sourceSector.getDeltaLatDegrees() / destSector.getDeltaLatDegrees());
            double sx = ((double)(destWidth - 1) / (double)(sourceWidth - 1))
                        * (sourceSector.getDeltaLonDegrees() / destSector.getDeltaLonDegrees());

            java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();
            transform.translate(tx, ty);
            transform.scale(sx, sy);
            return(transform);
        }
コード例 #8
0
ファイル: graphics.cs プロジェクト: ikvm/IKVM.NET-cvs-clone
 public override java.awt.geom.AffineTransform getTransform()
 {
     if (tx != null)
     {
         return tx;
     }
     using (Matrix matrix = g.Transform)
     {
         return tx = C2J.ConvertMatrix(matrix);
     }
 }
コード例 #9
0
ファイル: graphics.cs プロジェクト: ikvm/IKVM.NET-cvs-clone
 public override void setTransform(java.awt.geom.AffineTransform tx)
 {
     g.Transform = J2C.ConvertTransform(tx);
     this.tx = tx;
 }
コード例 #10
0
        protected void doDrawOnTo(BufferWrapperRaster canvas)
        {
            if (!this.getSector().intersects(canvas.getSector()))
            {
                return;
            }

            int    thisWidth            = this.getWidth();
            int    thisHeight           = this.getHeight();
            int    canvasWidth          = canvas.getWidth();
            int    canvasHeight         = canvas.getHeight();
            double thisTransparentValue = this.getTransparentValue();

            // Compute the transform from the canvas' coordinate system to this raster's coordinate system.
            java.awt.geom.AffineTransform canvasToThis = this.computeSourceToDestTransform(
                canvasWidth, canvasHeight, canvas.getSector(),
                thisWidth, thisHeight, this.getSector());

            /// Compute the region of the destination raster to be be clipped by the specified clipping sector. If no
            // clipping sector is specified, then perform no clipping. We compute the clip region for the destination
            // raster because this region is used to limit which pixels are rasterized to the destination.
            java.awt.Rectangle clipRect = new java.awt.Rectangle(0, 0, canvasWidth - 1, canvasHeight - 1);
//        if (clipSector != null)
//        {
//            java.awt.Rectangle rect = this.computeClipRect(clipSector, canvas);
//            clipRect = clipRect.intersection(rect);
//        }

            // Precompute the interpolation values for each transformed x- and y-coordinate.
            InterpolantLookupTable lut = this.createLookupTable(
                canvasWidth, canvasHeight,           // lookup table dimensions
                0, thisWidth - 1, 0, thisHeight - 1, // lookup table xMin, xMax, yMin, yMax
                canvasToThis);                       // lookup transform

            // If the lookup table is null, then no values in the canvas fall within this raster's bounds. This means
            // either the two rasters do not intersect or that this raster fits entirely between two x-coordinates or two
            // y-coordinates (or both) in the canvas. In either case, we do not rasterize any contribution from this raster
            // into the canvas, and simply exit.
            if (lut == null)
            {
                return;
            }

            // Allocate space to hold the lookup table parameters.
            double[] xParams = new double[3];
            double[] yParams = new double[3];

            // Compute the range of x-values in this raster that are needed during rendering.
            lut.computeRangeX(xParams);
            int xParamMin   = (int)Math.Floor(xParams[0]);
            int xParamMax   = (int)Math.Ceiling(xParams[1]);
            int xParamWidth = xParamMax - xParamMin + 1;

            // Allocate a buffer for two rows of samples from this raster, and allocate a buffer for one row of samples
            // from the canvas.
            double[] thisSamples = new double[2 * xParamWidth];
            double[] canvasSamples = new double[canvasWidth];
            int      x1, x2, y1, y2;
            double   xf, yf;

            // Iterate over each canvas row, filling canvas pixels with samples from this raster.
            for (int j = clipRect.y; j <= (clipRect.y + clipRect.height); j++)
            {
                // If the interpolant lookup table has an entry for "j", then process this row.
                if (lut.getInterpolantY(j, yParams))
                {
                    y1 = (int)yParams[0];
                    y2 = (int)yParams[1];
                    yf = yParams[2];
                    // Read the two rows of image samples that straddle yf.
                    this.get(xParamMin, y1, xParamWidth, thisSamples, 0);
                    this.get(xParamMin, y2, xParamWidth, thisSamples, xParamWidth);
                    // Read the canvas row samples.
                    canvas.get(0, j, canvasWidth, canvasSamples, 0);

                    // Iterate over each canvas column, sampling canvas pixels.
                    for (int i = clipRect.x; i <= (clipRect.x + clipRect.width); i++)
                    {
                        // If the interpolant lookup table has an entry for "i", then process this column.
                        if (lut.getInterpolantX(i, xParams))
                        {
                            x1 = (int)xParams[0] - xParamMin;
                            x2 = (int)xParams[1] - xParamMin;
                            xf = xParams[2];
                            // Sample this raster with the interpolated coordinates. This produces a bi-linear mix
                            // of the four values surrounding the canvas pixel. Place the output in the canvas sample array.
                            sample(thisSamples, x1, x2, xf, 0, 1, yf, xParamWidth, thisTransparentValue, canvasSamples, i);
                        }
                    }

                    // Write the canvas row samples.
                    canvas.put(0, j, canvasSamples, 0, canvasWidth);
                }
            }
        }
コード例 #11
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
 public override void drawRenderableImage(java.awt.image.renderable.RenderableImage image, java.awt.geom.AffineTransform xform)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
ファイル: graphics.cs プロジェクト: maikebing/IKVM.NetCore
 public override void setTransform(java.awt.geom.AffineTransform tx)
 {
     g.Transform = J2C.ConvertTransform(tx);
     this.tx     = tx;
 }