new createImage method for creating an image from an existing
image plus an image filter. Kicked out obsolete and unimplemented methods.
This commit is contained in:
parent
2a3cfc960c
commit
c43cc32f5e
4 changed files with 34 additions and 28 deletions
|
@ -16,6 +16,7 @@ public interface IRemoteImage extends Remote {
|
|||
public void setFont (String name, int style, int size) throws RemoteException;
|
||||
public void setColor (int color) throws RemoteException;
|
||||
public void setColor (int r, int g, int b) throws RemoteException;
|
||||
|
||||
public void reduceColors (int colors) throws RemoteException;
|
||||
|
||||
public void drawString (String str, int x, int y) throws RemoteException;
|
||||
|
@ -29,9 +30,5 @@ public interface IRemoteImage extends Remote {
|
|||
public void resize (int w, int h) throws RemoteException;
|
||||
|
||||
public void saveAs (String filename) throws RemoteException;
|
||||
public void readFrom (String filename) throws RemoteException;
|
||||
|
||||
public byte[] getBytes (String type) throws RemoteException;
|
||||
public void setBytes (byte[] bytes, String type) throws RemoteException;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package helma.image;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
|
@ -117,7 +118,32 @@ public class ImageGenerator extends Window {
|
|||
}
|
||||
return rimg;
|
||||
}
|
||||
|
||||
|
||||
public ImageWrapper createPaintableImage (ImageWrapper iw, ImageFilter filter) {
|
||||
ImageWrapper rimg = null;
|
||||
MediaTracker tracker = new MediaTracker (this);
|
||||
try {
|
||||
FilteredImageSource fis = new FilteredImageSource (iw.getSource(), filter);
|
||||
Image img1 = createImage (fis);
|
||||
tracker.addImage (img1, 0);
|
||||
tracker.waitForAll ();
|
||||
int w = img1.getWidth (null);
|
||||
int h = img1.getHeight (null);
|
||||
Image img = createImage (w, h);
|
||||
Graphics g = img.getGraphics ();
|
||||
g.drawImage (img1, 0, 0, null);
|
||||
try {
|
||||
rimg = new ActivatedImageWrapper (img, g, w, h, this);
|
||||
} catch (NoClassDefFoundError notfound) {
|
||||
rimg = new SunImageWrapper (img, g, w, h, this);
|
||||
} catch (ClassNotFoundException notfound) {
|
||||
rimg = new SunImageWrapper (img, g, w, h, this);
|
||||
}
|
||||
} catch (Exception x) {}
|
||||
return rimg;
|
||||
}
|
||||
|
||||
|
||||
public Image createImage (String filename) {
|
||||
Image img = null;
|
||||
MediaTracker tracker = new MediaTracker (this);
|
||||
|
|
|
@ -102,16 +102,11 @@ public abstract class ImageWrapper {
|
|||
|
||||
public abstract void saveAs (String filename);
|
||||
|
||||
public void readFrom (String filename) {
|
||||
throw new RuntimeException ("Image.readFrom() is currently not implemented.");
|
||||
}
|
||||
|
||||
public byte[] getBytes (String type) {
|
||||
throw new RuntimeException ("Image.getBytes() is currently not implemented.");
|
||||
}
|
||||
|
||||
public void setBytes (byte[] bytes, String type) {
|
||||
throw new RuntimeException ("Image.setBytes() is currently not implemented.");
|
||||
/**
|
||||
* Get ImageProducer of the wrapped image
|
||||
*/
|
||||
public ImageProducer getSource () {
|
||||
return img.getSource ();
|
||||
}
|
||||
|
||||
public void fillString (String str) {
|
||||
|
|
|
@ -77,18 +77,6 @@ public class RemoteImage extends UnicastRemoteObject implements IRemoteImage {
|
|||
wrapped.saveAs (filename);
|
||||
}
|
||||
|
||||
public void readFrom (String filename) {
|
||||
wrapped.readFrom (filename);
|
||||
}
|
||||
|
||||
public byte[] getBytes (String type) {
|
||||
return wrapped.getBytes (type);
|
||||
}
|
||||
|
||||
public void setBytes (byte[] bytes, String type) {
|
||||
wrapped.setBytes (bytes, type);
|
||||
}
|
||||
|
||||
public void fillString (String str) {
|
||||
wrapped.fillString (str);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue