Ignore:
Timestamp:
11/05/19 16:16:11 (5 years ago)
Author:
bnemhaus
Message:

Added the ability to copy/paste recognised files (mostly images) into Expeditee. This functionality already existed when drag n dropping, but now also works when using copy/paste.

At this stage, recognised files get imported as a approapriate Text Item. For example, a image will create a @i Text Item and attach it to your cursor. Ideally this would be the image directly. Unfortunately, items attached to the cursor (FreeItems) are not currently parsed. This is something I will discuss with David as there are confounding issues to consider. For example: surrogates...

Attached to the bottom of this commit message are my current thoughts.

Also made it so when creating a @i through DND or Copy/Paste, that @i is as relative as possible. The users image directories setting is used to achieve this.


  • FreeItems need to be parsed...we would need to deal with primaries/surrogates in them...
  • Do we want FreeItems to be parsed? If I attach an item to my cursor and then enter surrogate mode, should it change?
  • My gut says no. Both because it would be work, and also because it kind of feels like a free win if we do not.
  • But we do want to replace @i with images etc. Therefore, we want an old style parse for FreeItems?
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/importer/pdfImporter.java

    r1242 r1436  
    2424import java.nio.ByteBuffer;
    2525import java.nio.channels.FileChannel;
     26import java.nio.file.Path;
     27import java.nio.file.Paths;
    2628
    2729import org.expeditee.core.Colour;
     
    3739import org.expeditee.gui.FrameIO;
    3840import org.expeditee.gui.MessageBay;
     41import org.expeditee.gui.management.ResourceManager;
    3942import org.expeditee.items.Item;
    4043import org.expeditee.items.Text;
     
    4548public class pdfImporter implements FileImporter {
    4649       
    47         public Item importFile(final File f, Point location) throws IOException {
     50        public Item importFile(final File f, Point location, boolean attachToFreeItems) throws IOException {
    4851                if (location == null || f == null) {
    4952                        return null;
     
    6366                }
    6467               
    65                 final Text link = DragAndDropManager.importString(name, location);
     68                final Text link = DragAndDropManager.importString(name, location, false);
    6669                link.setLink(name+"1");
    6770               
     
    135138                              g.popDrawingSurface();
    136139                              //save it as a file
    137                               File out = new File(framesetPath+i+".png");
     140                              Path p = Paths.get(framesetPath+i+".png");
     141                              p = ResourceManager.relativiseImagePath(p, DisplayController.getCurrentFrame());
     142                              File out = p.toFile();
    138143                              bimg.writeToDisk("png", out);
    139144                              //generate a frame with that image
    140145                              System.out.println(width);
    141                               System.out.println("@i: "+framesetPath+i+".png "+width);
    142                                                 currentFrame.addText(x, y, "@i: "+framesetPath+i+".png "+width, null);
     146                              System.out.println("@i: "+p.toString()+width);
     147                                                currentFrame.addText(x, y, "@i: "+p.toString()+width, null);
    143148                                                if(i>1)
    144149                                                {
Note: See TracChangeset for help on using the changeset viewer.