Package gistoolkit.features.featureutils

Examples of gistoolkit.features.featureutils.EnvelopeBuffer


           
            // check for the selected records.
            if (getGISDisplay().getDrawModel() instanceof SelectDrawModel){
                Record[] tempRecords = ((gistoolkit.display.drawmodel.SelectDrawModel) getGISDisplay().getDrawModel()).getSelectedRecords();
                if ((tempRecords != null) && (tempRecords.length > 0)){
                    EnvelopeBuffer tempEnvelopeBuffer = new EnvelopeBuffer();
                    for (int i=0; i<tempRecords.length; i++){
                        if (tempRecords[i] != null){
                            gistoolkit.features.Shape tempShape = tempRecords[i].getShape();
                            if (tempShape != null){
                                tempEnvelopeBuffer.expandToInclude(tempShape.getEnvelope());
                            }
                        }
                    }
                    tempEnvelope = tempEnvelopeBuffer.getEnvelope();
                }
            }
           
            // check the layer
            if (tempEnvelope == null){
View Full Code Here


        int tempImageStartY = 0;
        int tempImageEndX = 0;
        int tempImageEndY = 0;

        // save the world coordinates to go with the image coordinates.
        EnvelopeBuffer tempWorldBuffer = new EnvelopeBuffer();
       
        // loop through the image retrieving the tiles as necissary.
        boolean tempFoundTile = false;
        for (int i=0; i<tempPoints.length; i++){
           
            // retrieve the file
            File tempFile = new File(myIndex.getFileName(tempResolution, tempPoints[i].x, tempPoints[i].y));
            if (tempFile.exists()){
                // read the image
                System.out.println("Reading Image "+tempFile.getName());
                ImageInformation tempImageInformation = ImageReader.readImage(tempFile.getAbsolutePath());
                if (tempImageInformation != null){
               
                    // draw the tile on the image.
                    Envelope tempTileEnvelope = myIndex.getWorldCoordinates(tempResolution, tempPoints[i].x, tempPoints[i].y);
                    tempWorldBuffer.expandToInclude(tempTileEnvelope);
                    int tempTileStartX = (int) (((tempTileEnvelope.getMinX() - inEnvelope.getMinX())/inEnvelope.getWidth()) * tempWidth);
                    int tempTileStartY = tempHeight - (int) (((tempTileEnvelope.getMinY() - inEnvelope.getMinY())/inEnvelope.getHeight()) * tempHeight);
                    int tempTileEndX = (int) (((tempTileEnvelope.getMaxX() - inEnvelope.getMinX())/inEnvelope.getWidth()) * tempWidth);
                    int tempTileEndY = tempHeight - (int) (((tempTileEnvelope.getMaxY() - inEnvelope.getMinY())/inEnvelope.getHeight()) * tempHeight);
                    if (i==0) {
                        tempImageStartX = tempTileStartX;
                        tempImageStartY = tempTileEndY;
                        tempImageEndX = tempTileEndX;
                        tempImageEndY = tempTileStartY;
                    }
                    else{
                        if (tempTileStartX < tempImageStartX) tempImageStartX = tempTileStartX;
                        if (tempTileEndY < tempImageStartY) tempImageStartY = tempTileEndY;
                        if (tempTileEndX > tempImageEndX) tempImageEndX = tempTileEndX;
                        if (tempTileStartY > tempImageEndY) tempImageEndY = tempTileStartY;
                    }
                    g2d.drawImage(tempImageInformation.getImage(), tempTileStartX, tempTileEndY, tempTileEndX, tempTileStartY, 0, 0, tempImageInformation.getImageWidth(), tempImageInformation.getImageHeight(), null);
                    tempFoundTile = true;
                }
            }
        }
        if (!tempFoundTile) return new GISDataset();
       
        // create the dataset
        String[] tempAttributeNames = {"Name"};
        AttributeType[] tempAttributeTypes = {new AttributeType(AttributeType.STRING)};
        GISDataset tempGISDataset = new GISDataset(tempAttributeNames, tempAttributeTypes);

        // create a new image if necissary.
        if (tempImageStartX < 0) tempImageStartX = 0;
        if (tempImageStartY < 0) tempImageStartY = 0;
        if (tempImageEndX > tempWidth) tempImageEndX = tempWidth;
        if (tempImageEndY > tempHeight) tempImageEndY = tempHeight;
        if ((tempImageStartX > 0) || (tempImageStartY > 0) || (tempImageEndX < tempWidth) || (tempImageEndY < tempHeight)){
            int tempNWidth = tempImageEndX - tempImageStartX;
            int tempNHeight = tempImageEndY - tempImageStartY;
            BufferedImage tempNewImage = new BufferedImage(tempNWidth, tempNHeight, BufferedImage.TYPE_INT_ARGB);
           
            // fill the background with a transparent color.
            Graphics gn = tempNewImage.getGraphics();
            gn.setColor(new Color(255,255,255,1));
            gn.fillRect(0,0,tempNWidth, tempNHeight);       
            Graphics2D gn2d = (Graphics2D) gn;
           
            // draw the old image onto the new image.
            gn2d.drawImage(tempImage, 0, 0, tempNWidth, tempNHeight,
            tempImageStartX, tempImageStartY, tempImageEndX, tempImageEndY,
            null);
           
            // create the envelope for this image.
            Envelope tempNewEnvelope = tempWorldBuffer.getEnvelope();
            double tempWorldMinX = inEnvelope.getMinX()+(((double)tempImageStartX)/(double)tempWidth)*inEnvelope.getWidth();
            double tempWorldMinY = inEnvelope.getMaxY()-(((double)tempImageStartY)/(double)tempHeight)*inEnvelope.getHeight();
            double tempWorldMaxX = inEnvelope.getMinX()+(((double)tempImageEndX)/(double)tempWidth)*inEnvelope.getWidth();
            double tempWorldMaxY = inEnvelope.getMaxY()-(((double)tempImageEndY)/(double)tempHeight)*inEnvelope.getHeight();
           
View Full Code Here

       
        if (tempEnvelope == null){
            mySourceList.clear();
           
            // Find the envelope of all the files.
            EnvelopeBuffer tempEnvelopeBuffer = new EnvelopeBuffer();
            notify("Reading World Files", -1, 0,0);
           
            // get the directory listing.
            File[] tempFiles = mySourceImageDirectory.listFiles();
            for (int i=0; i<tempFiles.length; i++){
                if (myStopProcessing) return;
                String tempName = tempFiles[i].getName();
                String tempUCName = tempName.toUpperCase();
                if ((tempUCName.endsWith(".TFW")) || (tempUCName.endsWith(".JGW")) || (tempUCName.endsWith(".TIFW"))){
                    int tempExtensionLength = 0;
                    if (tempUCName.endsWith(".TFW")) tempExtensionLength = 4;
                    if (tempUCName.endsWith(".JGW")) tempExtensionLength = 4;
                    if (tempUCName.endsWith(".TIFW")) tempExtensionLength = 5;
                   
                    // look for the corrisponding Image File
                    String tempImageName = tempName.substring(0, tempName.length()-tempExtensionLength);
                    File tempImageFile = null;
                    for (int j=0; j<myExtensions.length; j++){
                        String tempFileName = mySourceImageDirectory.getAbsolutePath()+File.separatorChar+tempImageName+myExtensions[j];
                        File tempFile = new File(tempFileName);
                        if (tempFile.exists()){
                            tempImageFile = tempFile;
                            break;
                        }
                    }
                   
                    // if the image file was found then calculate the Envelope for this image.
                    notify("Reading World File "+tempImageFile.getAbsolutePath(), -1, 0,0);
                    if (tempImageFile != null){
                        // read the image file
                        ImageInformation tempInformation = ImageUtilities.readImageInformation(tempImageFile);
                        if (tempInformation != null){
                           
                            // calculate the envelope for this file.
                            Envelope tempImgEnvelope = ImageUtilities.calculateEnvelope(tempFiles[i], tempInformation);
                            tempEnvelopeBuffer.expandToInclude(tempImgEnvelope);
                           
                            // save in the source list
                            ImageTile tempImageTile = new ImageTile(tempImageFile.getAbsolutePath(), tempImgEnvelope, tempInformation.getImageWidth(), tempInformation.getImageHeight());
                            mySourceList.add(tempImageTile);
                        }
                    }
                }
            }
           
            // loop through the envelope.
            tempEnvelope = tempEnvelopeBuffer.getEnvelope();
            // write the XML file for these nodes.
            writeIndex(tempEnvelope);
        }
        if (tempEnvelope != null){
           
View Full Code Here

TOP

Related Classes of gistoolkit.features.featureutils.EnvelopeBuffer

Copyright © 2018 www.massapicom. 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.