Ignore:
Timestamp:
08/07/19 14:14:42 (5 years ago)
Author:
bln4
Message:

New piping and functionality implementation to support the encrypting of images.

Location:
trunk/src/org/expeditee/items
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Item.java

    r1426 r1427  
    4747import org.expeditee.core.bounds.EllipticalBounds;
    4848import org.expeditee.core.bounds.PolygonBounds;
     49import org.expeditee.encryption.core.EncryptedImage;
    4950import org.expeditee.encryption.items.surrogates.EncryptionDetail;
    5051import org.expeditee.encryption.items.surrogates.EncryptionDetail.Type;
     
    40494050                }
    40504051               
     4052                //Setup surrogate items.
    40514053                Item copy = this.copy();
    40524054                if (copy.isAnnotation()) {
     
    40754077                        copy.setText("Encrypted");
    40764078                }
     4079               
     4080                // Encrypt XRayables representative files and update pointer.
     4081                Collection<? extends XRayable> xrayables = this.getEnclosures();
     4082                for (XRayable xray: xrayables) {
     4083                        if (xray instanceof Picture) {
     4084                                EncryptedImage.encryptImage((Picture) xray, labelResult.key);
     4085                                Text source = xray._source;
     4086                                String oldName = xray.getName();
     4087                                String newName = oldName.substring(0, oldName.lastIndexOf('.')) + EncryptedImage.EXPEDITEE_ENCRYPTED_IMAGE_EXTENSION;
     4088                                source.setText(source.getText().replace(oldName, newName));
     4089                        }
     4090                }
     4091               
    40774092                this.addToSurrogates(copy);
    40784093        }
  • trunk/src/org/expeditee/items/Picture.java

    r1426 r1427  
    3737import org.expeditee.core.bounds.AxisAlignedBoxBounds;
    3838import org.expeditee.core.bounds.PolygonBounds;
     39import org.expeditee.encryption.core.EncryptedImage;
     40import org.expeditee.encryption.items.surrogates.Label;
     41import org.expeditee.encryption.items.surrogates.Label.LabelResult;
    3942import org.expeditee.gio.EcosystemManager;
    4043import org.expeditee.gio.GraphicsManager;
     
    4245import org.expeditee.gui.FrameIO;
    4346import org.expeditee.gui.FrameUtils;
     47import org.expeditee.gui.MessageBay;
    4448
    4549/**
     
    6266public class Picture extends XRayable {
    6367       
    64         public static final String REDACTED_IMAGE_NAME = "redacted.png";
     68        public static final String REDACTED_IMAGE_NAME = "expeditee_noise.encrypted";
    6569       
    6670        private static final float CROPPING_COMPOSITE_ALPHA = 0.5f;
     
    775779        @Override
    776780        public boolean refresh() {
    777                 // ImageIcon is faster, but cannot handle some formats
    778                 // (notably.bmp) hence, we try this first, then if it fails we try
    779                 // ImageIO
    780                 /*
    781                 try {
    782                         _image = new ImageIcon(_path).getImage();
    783                 } catch (Exception e) {
    784                 }
    785 
    786                 // if ImageIcon failed to read the image
    787                 if (_image == null || _image.getWidth() <= 0) {
    788                         try {
    789                                 _image = ImageIO.read(new File(_path));
    790                         } catch (IOException e) {
    791                                 // e.printStackTrace();
    792                                 Logger.Log(e);
    793                                 _image = null;
    794                                 return false;
    795                         }
    796                 }
    797 */
    798                
    799781                if (isNoise()) {
    800                         _image = Image.getNoise();
     782                        _image = EncryptedImage.getNoise();
    801783                } else {
    802                         _image = Image.getImage(_path);
     784                        String encryptionLabel = _source.getEncryptionLabel();
     785                        if (encryptionLabel == null || encryptionLabel.isEmpty()) {
     786                                _image = Image.getImage(_path);
     787                        } else {
     788                                LabelResult result = Label.getLabel(encryptionLabel);
     789                                if (result == LabelResult.SuccessResolveLabelToKey) {
     790                                        _image = EncryptedImage.getImage(_path, result.key);
     791                                } else {
     792                                        MessageBay.displayMessage(result.toString());
     793                                        _image = EncryptedImage.getNoise();
     794                                }
     795                        }
    803796                }
    804797               
  • trunk/src/org/expeditee/items/XRayable.java

    r1426 r1427  
    2525import org.expeditee.core.Colour;
    2626import org.expeditee.core.Point;
     27import org.expeditee.encryption.core.EncryptedImage;
    2728import org.expeditee.encryption.items.surrogates.Label;
    2829import org.expeditee.gui.DisplayController;
    2930
    3031public abstract class XRayable extends Item {
    31        
    3232       
    3333        protected Text _source = null;
Note: See TracChangeset for help on using the changeset viewer.