- Timestamp:
- 07/31/19 15:51:04 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/core/Image.java
r1097 r1426 147 147 } 148 148 149 public static Image getNoise() { 150 return _manager.getNoise(); 151 } 152 149 153 /** Convenience access to ImageManager.getImage(URL). */ 150 154 public static Image getImage(URL url) -
trunk/src/org/expeditee/gio/ImageManager.java
r1097 r1426 5 5 import java.net.HttpURLConnection; 6 6 import java.net.URL; 7 import java.util.Random; 7 8 8 9 import org.expeditee.core.Colour; … … 75 76 public abstract Image getImage(String filename); 76 77 78 /** Gets an image that is just noise */ 79 public Image getNoise() { 80 int width = 100; 81 int height = 100; 82 int[] pixelData = new int[width * height]; 83 Random rand = new Random(); 84 85 for (int i = 0; i < pixelData.length; i++) { 86 int alpha = rand.nextInt(256) << 24; 87 int red = rand.nextInt(256) << 16; 88 int green = rand.nextInt(256) << 8; 89 int blue = rand.nextInt(256); 90 pixelData[i] = alpha | red | green | blue; 91 } 92 93 return createImage(width, height, pixelData); 94 } 95 77 96 /** Gets image data from a HTTP connection. */ 78 97 public abstract Image getImage(HttpURLConnection connection) throws IOException; … … 125 144 126 145 /** Writes the image data to disk. Format should be png, bmp, etc. */ 127 public abstract boolean writeImageToDisk(Image image, String format, File file) throws IOException; 128 146 public abstract boolean writeImageToDisk(Image image, String format, File file) throws IOException; 129 147 } -
trunk/src/org/expeditee/gui/Frame.java
r1425 r1426 26 26 import java.util.HashMap; 27 27 import java.util.HashSet; 28 import java.util.Iterator; 28 29 import java.util.LinkedHashSet; 29 30 import java.util.LinkedList; … … 2823 2824 if (i.isVisible()) { 2824 2825 _interactableItems.add(i); 2826 } else { 2827 Collection<? extends XRayable> enclosures = i.getEnclosures(); 2828 if (enclosures != null && !enclosures.isEmpty()) { 2829 Iterator<? extends XRayable> iterator = enclosures.iterator(); 2830 while (iterator.hasNext()) { 2831 _interactableItems.add(iterator.next()); 2832 } 2833 } 2825 2834 } 2826 2835 } -
trunk/src/org/expeditee/items/Item.java
r1422 r1426 4052 4052 if (copy.isAnnotation()) { 4053 4053 if (ItemUtils.startsWithTag(copy, ItemUtils.TAG_IMAGE, true)) { 4054 copy.setText(ItemUtils.GetTag(ItemUtils.TAG_IMAGE) + ": redacted.png"); 4054 String text = copy.getText(); 4055 String size = ""; 4056 4057 // remove @i tag 4058 text = text.replaceFirst("@i:", ""); 4059 text = text.replaceAll("\n", ""); 4060 text = text.trim(); 4061 4062 int dotPos = text.indexOf('.'); 4063 if (dotPos >= 0) { 4064 int endOfFileNamePos = text.indexOf(' ', dotPos); 4065 if (endOfFileNamePos >= 0) { 4066 size = text.substring(endOfFileNamePos).trim(); 4067 } 4068 } 4069 4070 String copyText = ItemUtils.GetTag(ItemUtils.TAG_IMAGE) + ": " + Picture.REDACTED_IMAGE_NAME + " " + size; 4071 copy.setText(copyText.trim()); 4055 4072 copy.setVisible(true); 4056 4073 } -
trunk/src/org/expeditee/items/ItemUtils.java
r1415 r1426 400 400 } 401 401 fileName = path; 402 403 // try images subdirectory 404 File file = null; 405 406 for (String dir : FolderSettings.ImageDirs.getAbsoluteDirs()) { 407 file = new File(dir + path); 408 if (file.exists() && !file.isDirectory()) { 409 break; 410 } 411 } 412 413 if (file == null || !file.exists() || file.isDirectory()) { 402 403 if (!fileName.equals(Picture.REDACTED_IMAGE_NAME)) { 404 // try images subdirectory 405 File file = null; 406 407 for (String dir : FolderSettings.ImageDirs.getAbsoluteDirs()) { 408 file = new File(dir + path); 409 if (file.exists() && !file.isDirectory()) { 410 break; 411 } 412 } 413 414 if (file == null || !file.exists() || file.isDirectory()) { 415 file = new File(path); 416 } 417 418 // try relative path 419 if (!file.exists() || file.isDirectory()) { 420 URL picture = new Object().getClass().getResource(path); 421 422 // decode to remove %20 in windows folder names 423 if (picture != null) { 424 try { 425 path = URLDecoder.decode(picture.getFile(), "UTF-8"); 426 } catch (UnsupportedEncodingException e) { 427 // TODO Auto-generated catch block 428 e.printStackTrace(); 429 } 430 } 431 432 } else { 433 path = file.getPath(); 434 } 435 436 // if the image isn't found by now, try remote servers 414 437 file = new File(path); 415 } 416 417 // try relative path 418 if (!file.exists() || file.isDirectory()) { 419 URL picture = new Object().getClass().getResource(path); 420 421 // decode to remove %20 in windows folder names 422 if (picture != null) { 423 try { 424 path = URLDecoder.decode(picture.getFile(), "UTF-8"); 425 } catch (UnsupportedEncodingException e) { 426 // TODO Auto-generated catch block 427 e.printStackTrace(); 428 } 429 } 430 431 } else { 432 path = file.getPath(); 433 } 434 435 // if the image isn't found by now, try remote servers 436 file = new File(path); 437 if (!file.exists() || file.isDirectory()) { 438 if(tryRemote && FrameShare.getInstance().loadImage(fileName, null)) { 439 // call CreatePicture again, but with tryRemote set to false so we won't get into an infinite loop 440 // if something goes wrong with finding the downloaded image 441 return CreatePicture(source, false); 442 } 443 return null; 444 } 445 438 if (!file.exists() || file.isDirectory()) { 439 if(tryRemote && FrameShare.getInstance().loadImage(fileName, null)) { 440 // call CreatePicture again, but with tryRemote set to false so we won't get into an infinite loop 441 // if something goes wrong with finding the downloaded image 442 return CreatePicture(source, false); 443 } 444 return null; 445 } 446 } 446 447 } catch (Exception e) { 447 448 return null; -
trunk/src/org/expeditee/items/Picture.java
r1420 r1426 62 62 public class Picture extends XRayable { 63 63 64 public static final String REDACTED_IMAGE_NAME = "redacted.png"; 65 64 66 private static final float CROPPING_COMPOSITE_ALPHA = 0.5f; 65 67 … … 146 148 parseSize(); 147 149 } 150 151 public boolean isNoise() { 152 return _fileName.equals(REDACTED_IMAGE_NAME); 153 } 154 155 148 156 149 157 protected String getImageSize() { … … 788 796 } 789 797 */ 790 _image = Image.getImage(_path); 798 799 if (isNoise()) { 800 _image = Image.getNoise(); 801 } else { 802 _image = Image.getImage(_path); 803 } 804 791 805 return true; 792 806 } -
trunk/src/org/expeditee/items/XRayable.java
r1423 r1426 41 41 42 42 @Override 43 public Item getPrimary() { 44 return _source.getPrimary(); 45 } 46 47 @Override 48 public boolean isSurrogate() { 49 return _source.isSurrogate(); 50 } 51 52 @Override 43 53 public void setEncryptionLabel(String label) { 44 54 _source.setEncryptionLabel(label);
Note:
See TracChangeset
for help on using the changeset viewer.