Package com.agifans.picedit.picture.PictureCache

Examples of com.agifans.picedit.picture.PictureCache.PictureCacheEntry


        int index = 0;

        // Tells other parts of the application that want to ask that we're drawing the picture now.
        isDrawing = true;
       
        PictureCacheEntry cacheEntry = this.pictureCache.getCacheEntry(picturePosition);
        if (cacheEntry != null) {
          // Copy the cached screen arrays into the main picture images.
          System.arraycopy(cacheEntry.getVisualScreen(), 0, visualScreen, 0, visualScreen.length);
          System.arraycopy(cacheEntry.getPriorityScreen(), 0, priorityScreen, 0, priorityScreen.length);
          if (editStatus.getPictureType().equals(PictureType.SCI0)) {
            System.arraycopy(cacheEntry.getControlScreen(), 0, controlScreen, 0, controlScreen.length);
          }
         
          // Skip straight to the cached position.
          index = cacheEntry.getPicturePosition();
         
          // Restore the settings from the EditStatus that apply to the cached position.
          editStatus.setBrushShape(cacheEntry.getBrushShape());
          editStatus.setBrushSize(cacheEntry.getBrushSize());
          editStatus.setBrushTexture(cacheEntry.getBrushTexture());
          editStatus.setControlColour(cacheEntry.getControlColour());
          editStatus.setPriorityColour(cacheEntry.getPriorityColour());
          editStatus.setTool(cacheEntry.getTool());
          editStatus.setVisualColour(cacheEntry.getVisualColour());
         
        } else {
          // Clear the picture bitmaps to the original colours.
          clearPictureScreens();
        
          // When drawing from the start, we need to clear everything except for the data.
          editStatus.clear(false);
        }

        if ((picturePosition > 0) && (index < picturePosition)) {
            do {
                boolean isCacheable = true;
               
                // Get the next picture action.
                PictureCode pictureCode = pictureCodes.get(index++);
                action = pictureCode.getCode();
               
                // Process the actions data.
                switch (action) {
                    case 0xF0:
                        editStatus.setVisualColour(pictureCodes.get(index++).getCode());
                        isCacheable = false;
                        break;
                    case 0xF1:
                        editStatus.setVisualColour(EditStatus.VISUAL_OFF);
                        isCacheable = false;
                        break;
                    case 0xF2:
                        editStatus.setPriorityColour(pictureCodes.get(index++).getCode());
                        isCacheable = false;
                        break;
                    case 0xF3:
                        editStatus.setPriorityColour(EditStatus.PRIORITY_OFF);
                        isCacheable = false;
                        break;
                    case 0xF4:
                        editStatus.setTool(ToolType.STEPLINE);
                        index = drawPictureYCorner(pictureCodes, index);
                        break;
                    case 0xF5:
                        editStatus.setTool(ToolType.STEPLINE);
                        index = drawPictureXCorner(pictureCodes, index);
                        break;
                    case 0xF6:
                        editStatus.setTool(ToolType.LINE);
                        index = drawPictureAbsoluteLine(pictureCodes, index);
                        break;
                    case 0xF7:
                        editStatus.setTool(ToolType.SHORTLINE);
                        index = drawPictureRelativeDraw(pictureCodes, index);
                        break;
                    case 0xF8:
                        editStatus.setTool(ToolType.FILL);
                        index = drawPictureFill(pictureCodes, index);
                        break;
                    case 0xF9:
                        editStatus.setBrushCode(pictureCodes.get(index++).getCode());
                        isCacheable = false;
                        break;
                    case 0xFA:
                        editStatus.setTool(ToolType.BRUSH);
                        index = drawPicturePlotBrush(pictureCodes, index);
                        break;
                    case 0xFF:
                        // End of the picture.
                        break;
                    default:
                        // An attempt to load a picture that is corrupt.
                        System.out.printf("Unknown picture code : %X, index: %d, picturePosition: %d, pictureSize: %d\n", action, index, picturePosition, pictureCodes.size());
                        System.exit(0);
                        break;
                }
               
                // Add the current picture state to the picture cache.
                if (isCacheable) {
                    // Cache only if a gap of at least 100 has been reached and the next picture code is an action code.
                    if (((cacheEntry == null) || ((index - cacheEntry.getPicturePosition()) > 100)) && pictureCodes.get(index).isActionCode()) {
                        cacheEntry = pictureCache.addCacheEntry(index, visualScreen, priorityScreen, controlScreen);
                    }
                }
            } while ((index < picturePosition) && (action != 0xFF));
        }
View Full Code Here

TOP

Related Classes of com.agifans.picedit.picture.PictureCache.PictureCacheEntry

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.