- Timestamp:
- 08/07/19 14:14:42 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/core/Image.java
r1426 r1427 8 8 9 9 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 10 import org.expeditee.encryption.core.EncryptedImage; 10 11 import org.expeditee.gio.ImageManager; 11 12 … … 26 27 27 28 /** The ImageManager used to perform platform-specific image interactions. */ 28 pr ivatestatic ImageManager _manager = null;29 protected static ImageManager _manager = null; 29 30 30 31 /** Sets the platform-specific ImageManager for all images. Can only be set once. */ … … 72 73 73 74 /** Private constructor as instantiation handled through Image.get(boolean). */ 74 private Image(boolean fromDisk) 75 { 75 protected Image(boolean fromDisk) { 76 76 // Assign the next available handle ID number 77 77 _handle = nextHandle; … … 147 147 } 148 148 149 public static Image getNoise() {150 return _manager.getNoise();151 }152 153 149 /** Convenience access to ImageManager.getImage(URL). */ 154 150 public static Image getImage(URL url) … … 158 154 159 155 /** Convenience access to ImageManager.getImage(String). */ 160 public static Image getImage(String filename) 161 { 162 return _manager.getImage(filename); 156 public static Image getImage(String filename) { 157 if (filename.endsWith(EncryptedImage.EXPEDITEE_ENCRYPTED_IMAGE_EXTENSION)) { 158 return EncryptedImage.getImage(filename); 159 } else { 160 return _manager.getImage(filename); 161 } 163 162 } 164 163 … … 168 167 return _manager.getImage(connection); 169 168 } 170 169 171 170 /** Convenience access to ImageManager.releaseImage(Image). */ 172 171 public void releaseImage() -
trunk/src/org/expeditee/gio/ImageManager.java
r1426 r1427 40 40 return createImage(size.width, size.height, hintUseAcceleratedMemory); 41 41 } 42 43 /**44 * Creates an image of the given width and height in either main or video RAM.45 *46 * @param hintUseAcceleratedMemory47 * True to use video RAM, false for main memory.48 */49 public abstract Image createImage(int width, int height, boolean hintUseAcceleratedMemory);50 42 51 43 /** Creates an image in main memory with the given size. */ … … 56 48 57 49 /** Creates an image in main memory with the given width and height. */ 58 public Image createImage(int width, int height) 59 { 50 public Image createImage(int width, int height) { 60 51 return createImage(width, height, false); 61 52 } 53 54 /** 55 * Creates an image of the given width and height in either main or video RAM. 56 * 57 * @param hintUseAcceleratedMemory 58 * True to use video RAM, false for main memory. 59 */ 60 public abstract Image createImage(int width, int height, boolean hintUseAcceleratedMemory); 62 61 63 62 /** Creates an image from packed 32-bit ARGB data in an array. */ … … 66 65 /** Creates an image of a PDF page. */ 67 66 public abstract Image createImage(int width, int height, PDFPage page); 67 68 /** Creates an image from the raw byte data read from a file. Must be in a format recognised by the implementing Ecosystem. **/ 69 public abstract Image createImage(byte[] rawImageData); 68 70 69 71 /** Creates a new image which is a cropped section of another image. */ … … 75 77 /** Gets image data from a file. */ 76 78 public abstract Image getImage(String filename); 79 80 //public abstract Image getItem(byte[] imageData); 77 81 78 82 /** Gets an image that is just noise */ -
trunk/src/org/expeditee/gio/javafx/JavaFXImageManager.java
r1097 r1427 20 20 import javafx.scene.image.PixelFormat; 21 21 import javafx.scene.image.WritableImage; 22 import sun.reflect.generics.reflectiveObjects.NotImplementedException; 22 23 23 24 public class JavaFXImageManager extends ImageManager { … … 96 97 // Register the image 97 98 return register(writableImage, false); 99 } 100 101 102 @Override 103 public Image createImage(byte[] rawImageData) { 104 throw new NotImplementedException(); 98 105 } 99 106 -
trunk/src/org/expeditee/gio/swing/SwingImageManager.java
r1097 r1427 117 117 } 118 118 119 @Override 120 public org.expeditee.core.Image createImage(byte[] rawImageData) { 121 // Get the image from the given file 122 java.awt.Image swingImage = Toolkit.getDefaultToolkit().createImage(rawImageData); 123 if (swingImage == null) return null; 124 125 // Register and return the handle 126 return register(swingImage, true); 127 } 128 119 129 /** 120 130 * Registers the given swing image with the Expeditee image system. Not available from the abstract interface. -
trunk/src/org/expeditee/items/Item.java
r1426 r1427 47 47 import org.expeditee.core.bounds.EllipticalBounds; 48 48 import org.expeditee.core.bounds.PolygonBounds; 49 import org.expeditee.encryption.core.EncryptedImage; 49 50 import org.expeditee.encryption.items.surrogates.EncryptionDetail; 50 51 import org.expeditee.encryption.items.surrogates.EncryptionDetail.Type; … … 4049 4050 } 4050 4051 4052 //Setup surrogate items. 4051 4053 Item copy = this.copy(); 4052 4054 if (copy.isAnnotation()) { … … 4075 4077 copy.setText("Encrypted"); 4076 4078 } 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 4077 4092 this.addToSurrogates(copy); 4078 4093 } -
trunk/src/org/expeditee/items/Picture.java
r1426 r1427 37 37 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 38 38 import org.expeditee.core.bounds.PolygonBounds; 39 import org.expeditee.encryption.core.EncryptedImage; 40 import org.expeditee.encryption.items.surrogates.Label; 41 import org.expeditee.encryption.items.surrogates.Label.LabelResult; 39 42 import org.expeditee.gio.EcosystemManager; 40 43 import org.expeditee.gio.GraphicsManager; … … 42 45 import org.expeditee.gui.FrameIO; 43 46 import org.expeditee.gui.FrameUtils; 47 import org.expeditee.gui.MessageBay; 44 48 45 49 /** … … 62 66 public class Picture extends XRayable { 63 67 64 public static final String REDACTED_IMAGE_NAME = " redacted.png";68 public static final String REDACTED_IMAGE_NAME = "expeditee_noise.encrypted"; 65 69 66 70 private static final float CROPPING_COMPOSITE_ALPHA = 0.5f; … … 775 779 @Override 776 780 public boolean refresh() { 777 // ImageIcon is faster, but cannot handle some formats778 // (notably.bmp) hence, we try this first, then if it fails we try779 // ImageIO780 /*781 try {782 _image = new ImageIcon(_path).getImage();783 } catch (Exception e) {784 }785 786 // if ImageIcon failed to read the image787 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 799 781 if (isNoise()) { 800 _image = Image.getNoise();782 _image = EncryptedImage.getNoise(); 801 783 } 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 } 803 796 } 804 797 -
trunk/src/org/expeditee/items/XRayable.java
r1426 r1427 25 25 import org.expeditee.core.Colour; 26 26 import org.expeditee.core.Point; 27 import org.expeditee.encryption.core.EncryptedImage; 27 28 import org.expeditee.encryption.items.surrogates.Label; 28 29 import org.expeditee.gui.DisplayController; 29 30 30 31 public abstract class XRayable extends Item { 31 32 32 33 33 protected Text _source = null;
Note:
See TracChangeset
for help on using the changeset viewer.