Skip to content

Commit

Permalink
change image display to remove any existing images left over from mou…
Browse files Browse the repository at this point in the history
…se pick when starting playback or left over from playback when mouse picking
  • Loading branch information
zhanshi committed Dec 6, 2007
1 parent 83c40fb commit 357cffd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/powerreader/Pick.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package powerreader;

//for image
import com.sun.j3d.utils.image.TextureLoader;
import image.ImageFetcher;
import java.awt.event.MouseAdapter;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -123,8 +125,30 @@ else if(ConfigurationManager.getFocusLevel() == RawTextParser.LEVEL_DOCUMENT_ID)
Player.setHierarchyRoot(root);
Player.setFocusOn(pickedObject);
Player.playOne();

// Get image
if(ConfigurationManager.showImages()) {
// clear out any existing images from the player
Player.removeImages();
ImageFetcher f = ConfigurationManager.getImageFetcher();
TextureLoader imageT = new TextureLoader(f.getImage(pickedText),c3D);
Raster imageObj = new Raster(new Point3f(0, 0,1f),
Raster.RASTER_COLOR, 0, 0, imageT.getImage().getWidth(), imageT.getImage().getHeight(),
imageT.getImage(), null);
Shape3D shape = new Shape3D(imageObj);
imageObj.setCapability(Raster.ALLOW_IMAGE_WRITE);
BranchGroup node = new BranchGroup();

node.setCapability(BranchGroup.ALLOW_DETACH);

node.addChild(shape);
lastPicked = tObj.getTheTextTransformGroup();
lastPicked.addChild(node);

lastAttached =node;
}
}
// dictionary meaning and images
// dictionary meaning
if(mouseAction == ConfigurationManager.ACTION_DEFINE) {
DictionaryLookup w = ConfigurationManager.getDictionary();
String def = w.getDefinition(pickedText);
Expand Down Expand Up @@ -183,4 +207,10 @@ public void mouseReleased(MouseEvent e) {
}
}

public static void removeImages() {
if(lastPicked != null && lastAttached != null) {
lastPicked.removeChild(lastAttached);
}
}

}
9 changes: 9 additions & 0 deletions src/powerreader/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ public void run() {
currentObj.color(true);
// Get image
if(ConfigurationManager.showImages()) {
// clear out any existing images from mouse picking
Pick.removeImages();

ImageFetcher f = ConfigurationManager.getImageFetcher();
BufferedImage img = f.getImage(currentObj.getValue());
if (img != null) {
Expand Down Expand Up @@ -332,4 +335,10 @@ static public void disableRenderOfChildren(HierarchyObject parent, HierarchyObje
i++;
}
}

static public void removeImages() {
if(lastAttachedTo != null && lastAttached != null) {
lastAttachedTo.removeChild(lastAttached);
}
}
}

0 comments on commit 357cffd

Please sign in to comment.