source: trunk/src/org/apollo/io/SampledAudioFileImporter.java@ 1436

Last change on this file since 1436 was 1436, checked in by bnemhaus, 5 years ago

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 size: 1.0 KB
Line 
1package org.apollo.io;
2
3import java.io.File;
4import java.io.IOException;
5
6import org.apollo.widgets.SampledTrack;
7import org.expeditee.core.Point;
8import org.expeditee.gui.DisplayController;
9import org.expeditee.importer.FileImporter;
10import org.expeditee.items.Item;
11
12/**
13 * Imports sampled audio files as track widgets into the current frame.
14 *
15 * @author Brook Novak
16 *
17 */
18public class SampledAudioFileImporter implements FileImporter {
19
20 public Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException
21 {
22 if (location == null || !AudioIO.canImportFile(f) || DisplayController.getCurrentFrame() == null) return null;
23
24 SampledTrack trackWidget = SampledTrack.createFromFile(
25 f,
26 DisplayController.getCurrentFrame(),
27 location.getX(),
28 location.getY());
29
30 // Add the sampled track widget to the current frame
31 DisplayController.getCurrentFrame().addAllItems(trackWidget.getItems());
32
33 return trackWidget.getSource(); // Don't allow for other importers to deal with this file
34
35 }
36
37}
Note: See TracBrowser for help on using the repository browser.