diff options
Diffstat (limited to 'java')
307 files changed, 0 insertions, 27511 deletions
diff --git a/java/ImageProcessing/filters/Assert.java b/java/ImageProcessing/filters/Assert.java deleted file mode 100644 index c83f9ca94c0..00000000000 --- a/java/ImageProcessing/filters/Assert.java +++ /dev/null @@ -1,33 +0,0 @@ -package imaging.filters; - -/** - * A simple assertion mechanism for asserting validity of - * arguments.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - */ -class Assert { - static public void notFalse(boolean b) - throws IllegalArgumentException { - if(b == false) - throw new IllegalArgumentException( - "boolean expression false"); - } - static public void notNull(Object obj) - throws IllegalArgumentException { - if(obj == null) - throw new IllegalArgumentException("null argument"); - } - - static public void notFalse(boolean b, String s) - throws IllegalArgumentException { - if(b == false) - throw new IllegalArgumentException(s); - } - static public void notNull(Object obj, String s) - throws IllegalArgumentException { - if(obj == null) - throw new IllegalArgumentException(s); - } -} diff --git a/java/ImageProcessing/filters/BleachFilter.java b/java/ImageProcessing/filters/BleachFilter.java deleted file mode 100644 index ea269788aea..00000000000 --- a/java/ImageProcessing/filters/BleachFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -/** - * A derivation of RGBImageFilter that bleaches an image.<p> - * - * Extent of the bleaching effect is controlled by the only - * constructor argument: an integer representing the percentage - * of bleaching. The percentage of bleaching may also be - * controlled after instantiation by invoking the - * void percent(int) method.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see RGBImageFilter - */ -public class BleachFilter extends RGBImageFilter implements MedFilter -{ - private int percent; - - public BleachFilter(int percent) - { - Assert.notFalse(percent >= 0 && percent <= 100); - this.percent = percent; - canFilterIndexColorModel = true; - } - - public String info () - { - return "Bleaches/Lightens an image"; - } - - public int percent() { return percent; } - public void percent(int percent) { percent = percent; } - - public int filterRGB(int x, int y, int rgb) { - DirectColorModel cm = - (DirectColorModel)ColorModel.getRGBdefault(); - - int alpha = cm.getAlpha(rgb); - int red = cm.getRed (rgb); - int green = cm.getGreen(rgb); - int blue = cm.getBlue (rgb); - double percentMultiplier = (double)percent/100; - - red = Math.min((int) - (red + (red * percentMultiplier)), 255); - green = Math.min((int) - (green + (green * percentMultiplier)), 255); - blue = Math.min((int) - (blue + (blue * percentMultiplier)), 255); - - alpha = alpha << 24; - red = red << 16; - green = green << 8; - - return alpha | red | green | blue; - } -} diff --git a/java/ImageProcessing/filters/DarkenFilter.java b/java/ImageProcessing/filters/DarkenFilter.java deleted file mode 100644 index ea20d15a46b..00000000000 --- a/java/ImageProcessing/filters/DarkenFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class DarkenFilter extends RGBImageFilter implements MedFilter -{ - private int percent_; - - public DarkenFilter () - { - percent_ = 50; - canFilterIndexColorModel = true; - } - - public DarkenFilter(int percent) - { - Assert.notFalse(percent >= 0 && percent <= 100); - percent_ = percent; - canFilterIndexColorModel = true; - } - - public String info () - { - return "Darkens an image."; - } - - public int filterRGB(int x, int y, int rgb) - { - DirectColorModel cm = - (DirectColorModel)ColorModel.getRGBdefault(); - - int alpha = cm.getAlpha(rgb); - int red = cm.getRed (rgb); - int green = cm.getGreen(rgb); - int blue = cm.getBlue (rgb); - double percentMultiplier = (double)((double)1.0 - (double)percent_/100); - - red *= percentMultiplier; - blue *= percentMultiplier; - green *= percentMultiplier; - - alpha = alpha << 24; - red = red << 16; - green = green << 8; - - return alpha | red | green | blue; - } -} diff --git a/java/ImageProcessing/filters/DissolveFilter.java b/java/ImageProcessing/filters/DissolveFilter.java deleted file mode 100644 index 0225aad6ad1..00000000000 --- a/java/ImageProcessing/filters/DissolveFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -/** - * A derivation of RGBImageFilter that partially or wholly - * dissolves an image.<p> - * - * Extent of dissolving is set by the setOpacity(int) method, - * which is passed an integer between 0 and 255 (inclusive). - * The integer represents the alpha value to be applied to - * every color in the image.<p> - * - * An alpha value of 255 signifies an opaque color, while an - * alpha value of 0 signifies a translucent color.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see RGBImageFilter - */ -public class DissolveFilter extends RGBImageFilter implements MedFilter -{ - private int opacity; - - public DissolveFilter() { - this(0); - } - public DissolveFilter(int opacity) { - canFilterIndexColorModel = true; - setOpacity(opacity); - } - public String info () - { - return "Dissolves an image"; - } - public void setOpacity(int opacity) { - Assert.notFalse(opacity >= 0 && opacity <= 255); - this.opacity = opacity; - } - public int filterRGB(int x, int y, int rgb) { - DirectColorModel cm = - (DirectColorModel)ColorModel.getRGBdefault(); - int alpha = cm.getAlpha(rgb); - int red = cm.getRed (rgb); - int green = cm.getGreen(rgb); - int blue = cm.getBlue (rgb); - - alpha = opacity; - - return alpha << 24 | red << 16 | green << 8 | blue; - } -} diff --git a/java/ImageProcessing/filters/EmbossFilter.java b/java/ImageProcessing/filters/EmbossFilter.java deleted file mode 100644 index 4fb61842ebc..00000000000 --- a/java/ImageProcessing/filters/EmbossFilter.java +++ /dev/null @@ -1,90 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class EmbossFilter extends SpatialFilter -{ - int[] grey_raster_; - - public EmbossFilter() - { - } - - public String info () - { - return "Embosses an image."; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error: " + status); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_grey = 0; - int alpha; - - for (int x = 1; x < rows_; x++) - { - for (int y = 1; y < columns_; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 1) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_grey = - (- grey_raster_[row1 - 1] - - grey_raster_[row1] - - grey_raster_[row2 - 1] - + grey_raster_[row2 + 1] - + grey_raster_[row3] - + grey_raster_[row3 + 1])/6 + 128; - - if (new_grey > 255) - new_grey = 255; - - pixels[y - 1] = (alpha << 24) | (new_grey << 16) | (new_grey << 8) | new_grey; - - } - consumer.setPixels(0, x-1, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index = columns_; - int pixel; - grey_raster_ = new int[(rows_ + 1)*(columns_ + 1)]; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y ++) - { - index++; - pixel = raster_[off]; - grey_raster_[index] = (int)(((double).212671*(double)defaultRGB_.getRed(pixel)) - + (double)((double).715160*(double)defaultRGB_.getGreen(pixel)) - + (double)((double).072169*(double)defaultRGB_.getBlue(pixel))); - - off++; - } - } - } -} diff --git a/java/ImageProcessing/filters/FivebyfiveFilter.java b/java/ImageProcessing/filters/FivebyfiveFilter.java deleted file mode 100644 index af548c8d549..00000000000 --- a/java/ImageProcessing/filters/FivebyfiveFilter.java +++ /dev/null @@ -1,181 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class FivebyfiveFilter extends SpatialFilter -{ - protected int[] red_raster_; - protected int[] green_raster_; - protected int[] blue_raster_; - protected int[] new_matrix_; - - public FivebyfiveFilter() - { - } - - public FivebyfiveFilter(int[] matrix, int degree, int div_factor, int offset) - { - new_matrix_ = matrix; - degree_ = degree; - div_factor_ = div_factor; - offset_ = offset; - } - - public String info () - { - return "Base class filter. Doesn't do much"; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error: " + status); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = 2; x < rows_ + 2; x++) - { - for (int y = 2; y < columns_ + 2; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 2) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_red = - (red_raster_[row1 - 2] * new_matrix_[0] - + red_raster_[row1 - 1] * new_matrix_[1] - + red_raster_[row1] * new_matrix_[2] - + red_raster_[row1 + 1] * new_matrix_[3] - + red_raster_[row1 + 2] * new_matrix_[4] - + red_raster_[row2 - 2] * new_matrix_[5] - + red_raster_[row2 - 1] * new_matrix_[6] - + red_raster_[row2] * new_matrix_[7] - + red_raster_[row2 + 1] * new_matrix_[8] - + red_raster_[row2 + 2] * new_matrix_[9] - + red_raster_[row3 - 2] * new_matrix_[10] - + red_raster_[row3 - 1] * new_matrix_[11] - + red_raster_[row3] * new_matrix_[12] - + red_raster_[row3 + 1] * new_matrix_[13] - + red_raster_[row3 + 2] * new_matrix_[14] - + red_raster_[row4 - 2] * new_matrix_[15] - + red_raster_[row4 - 1] * new_matrix_[16] - + red_raster_[row4] * new_matrix_[17] - + red_raster_[row4 + 1] * new_matrix_[18] - + red_raster_[row4 + 2] * new_matrix_[19] - + red_raster_[row5 - 2] * new_matrix_[20] - + red_raster_[row5 - 1] * new_matrix_[21] - + red_raster_[row5] * new_matrix_[22] - + red_raster_[row5 + 1] * new_matrix_[23] - + red_raster_[row5 + 2] * new_matrix_[24])/div_factor_; - - new_green = - (green_raster_[row1 - 2] * new_matrix_[0] - + green_raster_[row1 - 1] * new_matrix_[1] - + green_raster_[row1] * new_matrix_[2] - + green_raster_[row1 + 1] * new_matrix_[3] - + green_raster_[row1 + 2] * new_matrix_[4] - + green_raster_[row2 - 2] * new_matrix_[5] - + green_raster_[row2 - 1] * new_matrix_[6] - + green_raster_[row2] * new_matrix_[7] - + green_raster_[row2 + 1] * new_matrix_[8] - + green_raster_[row2 + 2] * new_matrix_[9] - + green_raster_[row3 - 2] * new_matrix_[10] - + green_raster_[row3 - 1] * new_matrix_[11] - + green_raster_[row3] * new_matrix_[12] - + green_raster_[row3 + 1] * new_matrix_[13] - + green_raster_[row3 + 2] * new_matrix_[14] - + green_raster_[row4 - 2] * new_matrix_[15] - + green_raster_[row4 - 1] * new_matrix_[16] - + green_raster_[row4] * new_matrix_[17] - + green_raster_[row4 + 1] * new_matrix_[18] - + green_raster_[row4 + 2] * new_matrix_[19] - + green_raster_[row5 - 2] * new_matrix_[20] - + green_raster_[row5 - 1] * new_matrix_[21] - + green_raster_[row5] * new_matrix_[22] - + green_raster_[row5 + 1] * new_matrix_[23] - + green_raster_[row5 + 2] * new_matrix_[24])/div_factor_; - - new_blue = - (blue_raster_[row1 - 2] * new_matrix_[0] - + blue_raster_[row1 - 1] * new_matrix_[1] - + blue_raster_[row1] * new_matrix_[2] - + blue_raster_[row1 + 1] * new_matrix_[3] - + blue_raster_[row1 + 2] * new_matrix_[4] - + blue_raster_[row2 - 2] * new_matrix_[5] - + blue_raster_[row2 - 1] * new_matrix_[6] - + blue_raster_[row2] * new_matrix_[7] - + blue_raster_[row2 + 1] * new_matrix_[8] - + blue_raster_[row2 + 2] * new_matrix_[9] - + blue_raster_[row3 - 2] * new_matrix_[10] - + blue_raster_[row3 - 1] * new_matrix_[11] - + blue_raster_[row3] * new_matrix_[12] - + blue_raster_[row3 + 1] * new_matrix_[13] - + blue_raster_[row3 + 2] * new_matrix_[14] - + blue_raster_[row4 - 2] * new_matrix_[15] - + blue_raster_[row4 - 1] * new_matrix_[16] - + blue_raster_[row4] * new_matrix_[17] - + blue_raster_[row4 + 1] * new_matrix_[18] - + blue_raster_[row4 + 2] * new_matrix_[19] - + blue_raster_[row5 - 2] * new_matrix_[20] - + blue_raster_[row5 - 1] * new_matrix_[21] - + blue_raster_[row5] * new_matrix_[22] - + blue_raster_[row5 + 1] * new_matrix_[23] - + blue_raster_[row5 + 2] * new_matrix_[24])/div_factor_; - - if (new_red > 255) - new_red = 255; - - if (new_green > 255) - new_green = 255; - - if (new_blue > 255) - new_blue = 255; - - pixels[y - 2] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x-2, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index = columns_; - int pixel; - red_raster_ = new int[(rows_ + 4)*(columns_ + 4)]; - green_raster_ = new int[red_raster_.length]; - blue_raster_ = new int[red_raster_.length]; - - for (int x = 2; x < rows_ + 2; x++) - { - for (int y = 2; y < columns_ + 2; y ++) - { - index++; - pixel = raster_[off]; - red_raster_[index] = defaultRGB_.getRed(pixel); - green_raster_[index] = defaultRGB_.getGreen(pixel); - blue_raster_[index] = defaultRGB_.getBlue(pixel); - off++; - } - } - } -} diff --git a/java/ImageProcessing/filters/Makefile b/java/ImageProcessing/filters/Makefile deleted file mode 100644 index a83e237446c..00000000000 --- a/java/ImageProcessing/filters/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes -DOCDIR = $(JACE_WRAPPER)/doc - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) - -clean: - rm -rf *~ - -realclean: clean - rm -rf $(JACE_WRAPPER)/classes/*.class - -files = MedFilter.java \ - Assert.java \ - BleachFilter.java \ - DarkenFilter.java \ - DissolveFilter.java \ - EmbossFilter.java \ - FivebyfiveFilter.java \ - MeanFilter.java \ - NinebynineFilter.java \ - RotateFilter.java \ - SharpenFilter.java \ - SobelFilter.java \ - SpatialFilter.java \ - Timer.java \ - ThreebythreeFilter.java \ - UnsharpFilter.java - diff --git a/java/ImageProcessing/filters/MeanFilter.java b/java/ImageProcessing/filters/MeanFilter.java deleted file mode 100644 index 95969246524..00000000000 --- a/java/ImageProcessing/filters/MeanFilter.java +++ /dev/null @@ -1,147 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class MeanFilter extends FivebyfiveFilter -{ - public MeanFilter() - { - } - - public String info () - { - return "Blurs an image."; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = 2; x < rows_ + 2; x++) - { - for (int y = 2; y < columns_ + 2; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 2) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_red = - (red_raster_[row1 - 2] - + red_raster_[row1 - 1] - + red_raster_[row1] - + red_raster_[row1 + 1] - + red_raster_[row1 + 2] - + red_raster_[row2 - 2] - + red_raster_[row2 - 1] - + red_raster_[row2] - + red_raster_[row2 + 1] - + red_raster_[row2 + 2] - + red_raster_[row3 - 2] - + red_raster_[row3 - 1] - + red_raster_[row3] - + red_raster_[row3 + 1] - + red_raster_[row3 + 2] - + red_raster_[row4 - 2] - + red_raster_[row4 - 1] - + red_raster_[row4] - + red_raster_[row4 + 1] - + red_raster_[row4 + 2] - + red_raster_[row5 - 2] - + red_raster_[row5 - 1] - + red_raster_[row5] - + red_raster_[row5 + 1] - + red_raster_[row5 + 2])/25; - - new_green = - (green_raster_[row1 - 2] - + green_raster_[row1 - 1] - + green_raster_[row1] - + green_raster_[row1 + 1] - + green_raster_[row1 + 2] - + green_raster_[row2 - 2] - + green_raster_[row2 - 1] - + green_raster_[row2] - + green_raster_[row2 + 1] - + green_raster_[row2 + 2] - + green_raster_[row3 - 2] - + green_raster_[row3 - 1] - + green_raster_[row3] - + green_raster_[row3 + 1] - + green_raster_[row3 + 2] - + green_raster_[row4 - 2] - + green_raster_[row4 - 1] - + green_raster_[row4] - + green_raster_[row4 + 1] - + green_raster_[row4 + 2] - + green_raster_[row5 - 2] - + green_raster_[row5 - 1] - + green_raster_[row5] - + green_raster_[row5 + 1] - + green_raster_[row5 + 2])/25; - - new_blue = - (blue_raster_[row1 - 2] - + blue_raster_[row1 - 1] - + blue_raster_[row1] - + blue_raster_[row1 + 1] - + blue_raster_[row1 + 2] - + blue_raster_[row2 - 2] - + blue_raster_[row2 - 1] - + blue_raster_[row2] - + blue_raster_[row2 + 1] - + blue_raster_[row2 + 2] - + blue_raster_[row3 - 2] - + blue_raster_[row3 - 1] - + blue_raster_[row3] - + blue_raster_[row3 + 1] - + blue_raster_[row3 + 2] - + blue_raster_[row4 - 2] - + blue_raster_[row4 - 1] - + blue_raster_[row4] - + blue_raster_[row4 + 1] - + blue_raster_[row4 + 2] - + blue_raster_[row5 - 2] - + blue_raster_[row5 - 1] - + blue_raster_[row5] - + blue_raster_[row5 + 1] - + blue_raster_[row5 + 2])/25; - - - if (new_red > 255) - new_red = 255; - - if (new_green > 255) - new_green = 255; - - if (new_blue > 255) - new_blue = 255; - - pixels[y - 2] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x-2, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - -} diff --git a/java/ImageProcessing/filters/MedFilter.java b/java/ImageProcessing/filters/MedFilter.java deleted file mode 100644 index def0bd2075a..00000000000 --- a/java/ImageProcessing/filters/MedFilter.java +++ /dev/null @@ -1,6 +0,0 @@ -package imaging.filters; - -public interface MedFilter -{ - String info (); -} diff --git a/java/ImageProcessing/filters/NinebynineFilter.java b/java/ImageProcessing/filters/NinebynineFilter.java deleted file mode 100644 index 8c3694033b2..00000000000 --- a/java/ImageProcessing/filters/NinebynineFilter.java +++ /dev/null @@ -1,349 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class NinebynineFilter extends SpatialFilter -{ - int[] red_raster_; - int[] green_raster_; - int[] blue_raster_; - int[] new_matrix_; - - public NinebynineFilter(int[] matrix, int degree, int div_factor, int offset) - { - new_matrix_ = matrix; - degree_ = degree; - div_factor_ = div_factor; - offset_ = offset; - } - - public String info () - { - return "Base class filter. Doesn't do much"; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5, row6, row7, row8, row9; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = 4; x < rows_ + 4; x++) - { - for (int y = 4; y < columns_ + 4; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 4) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - row6 = row5 + columns_; - row7 = row6 + columns_; - row8 = row7 + columns_; - row9 = row8 + columns_; - - new_red = - (red_raster_[row1 - 4] * new_matrix_[0] - + red_raster_[row1 - 3] * new_matrix_[1] - + red_raster_[row1 - 2] * new_matrix_[2] - + red_raster_[row1 - 1] * new_matrix_[3] - + red_raster_[row1] * new_matrix_[4] - + red_raster_[row1 + 1] * new_matrix_[5] - + red_raster_[row1 + 2] * new_matrix_[6] - + red_raster_[row1 + 3] * new_matrix_[7] - + red_raster_[row1 + 4] * new_matrix_[8] - + red_raster_[row2 - 4] * new_matrix_[9] - + red_raster_[row2 - 3] * new_matrix_[10] - + red_raster_[row2 - 2] * new_matrix_[11] - + red_raster_[row2 - 1] * new_matrix_[12] - + red_raster_[row2] * new_matrix_[13] - + red_raster_[row2 + 1] * new_matrix_[14] - + red_raster_[row2 + 2] * new_matrix_[15] - + red_raster_[row2 + 3] * new_matrix_[16] - + red_raster_[row2 + 4] * new_matrix_[17] - + red_raster_[row3 - 4] * new_matrix_[18] - + red_raster_[row3 - 3] * new_matrix_[19] - + red_raster_[row3 - 2] * new_matrix_[20] - + red_raster_[row3 - 1] * new_matrix_[21] - + red_raster_[row3] * new_matrix_[22] - + red_raster_[row3 + 1] * new_matrix_[23] - + red_raster_[row3 + 2] * new_matrix_[24] - + red_raster_[row3 + 3] * new_matrix_[25] - + red_raster_[row3 + 4] * new_matrix_[26] - + red_raster_[row4 - 4] * new_matrix_[27] - + red_raster_[row4 - 3] * new_matrix_[28] - + red_raster_[row4 - 2] * new_matrix_[29] - + red_raster_[row4 - 1] * new_matrix_[30] - + red_raster_[row4] * new_matrix_[31] - + red_raster_[row4 + 1] * new_matrix_[32] - + red_raster_[row4 + 2] * new_matrix_[33] - + red_raster_[row4 + 3] * new_matrix_[34] - + red_raster_[row4 + 4] * new_matrix_[35] - + red_raster_[row5 - 4] * new_matrix_[36] - + red_raster_[row5 - 3] * new_matrix_[37] - + red_raster_[row5 - 2] * new_matrix_[38] - + red_raster_[row5 - 1] * new_matrix_[39] - + red_raster_[row5] * new_matrix_[40] - + red_raster_[row5 + 1] * new_matrix_[41] - + red_raster_[row5 + 2] * new_matrix_[42] - + red_raster_[row5 + 3] * new_matrix_[43] - + red_raster_[row5 + 4] * new_matrix_[44] - + red_raster_[row6 - 4] * new_matrix_[45] - + red_raster_[row6 - 3] * new_matrix_[46] - + red_raster_[row6 - 2] * new_matrix_[47] - + red_raster_[row6 - 1] * new_matrix_[48] - + red_raster_[row6] * new_matrix_[49] - + red_raster_[row6 + 1] * new_matrix_[50] - + red_raster_[row6 + 2] * new_matrix_[51] - + red_raster_[row6 + 3] * new_matrix_[52] - + red_raster_[row6 + 4] * new_matrix_[53] - + red_raster_[row7 - 4] * new_matrix_[54] - + red_raster_[row7 - 3] * new_matrix_[55] - + red_raster_[row7 - 2] * new_matrix_[56] - + red_raster_[row7 - 1] * new_matrix_[57] - + red_raster_[row7] * new_matrix_[58] - + red_raster_[row7 + 1] * new_matrix_[59] - + red_raster_[row7 + 2] * new_matrix_[60] - + red_raster_[row7 + 3] * new_matrix_[61] - + red_raster_[row7 + 4] * new_matrix_[62] - + red_raster_[row1 - 4] * new_matrix_[63] - + red_raster_[row1 - 3] * new_matrix_[64] - + red_raster_[row1 - 2] * new_matrix_[65] - + red_raster_[row1 - 1] * new_matrix_[66] - + red_raster_[row1] * new_matrix_[67] - + red_raster_[row1 + 1] * new_matrix_[68] - + red_raster_[row1 + 2] * new_matrix_[69] - + red_raster_[row1 + 3] * new_matrix_[70] - + red_raster_[row1 + 4] * new_matrix_[71] - + red_raster_[row1 - 4] * new_matrix_[72] - + red_raster_[row1 - 3] * new_matrix_[73] - + red_raster_[row1 - 2] * new_matrix_[74] - + red_raster_[row1 - 1] * new_matrix_[75] - + red_raster_[row1] * new_matrix_[76] - + red_raster_[row1 + 1] * new_matrix_[77] - + red_raster_[row1 + 2] * new_matrix_[78] - + red_raster_[row1 + 3] * new_matrix_[79] - + red_raster_[row1 + 4] * new_matrix_[80])/div_factor_; - - new_green = - (green_raster_[row1 - 4] * new_matrix_[0] - + green_raster_[row1 - 3] * new_matrix_[1] - + green_raster_[row1 - 2] * new_matrix_[2] - + green_raster_[row1 - 1] * new_matrix_[3] - + green_raster_[row1] * new_matrix_[4] - + green_raster_[row1 + 1] * new_matrix_[5] - + green_raster_[row1 + 2] * new_matrix_[6] - + green_raster_[row1 + 3] * new_matrix_[7] - + green_raster_[row1 + 4] * new_matrix_[8] - + green_raster_[row2 - 4] * new_matrix_[9] - + green_raster_[row2 - 3] * new_matrix_[10] - + green_raster_[row2 - 2] * new_matrix_[11] - + green_raster_[row2 - 1] * new_matrix_[12] - + green_raster_[row2] * new_matrix_[13] - + green_raster_[row2 + 1] * new_matrix_[14] - + green_raster_[row2 + 2] * new_matrix_[15] - + green_raster_[row2 + 3] * new_matrix_[16] - + green_raster_[row2 + 4] * new_matrix_[17] - + green_raster_[row3 - 4] * new_matrix_[18] - + green_raster_[row3 - 3] * new_matrix_[19] - + green_raster_[row3 - 2] * new_matrix_[20] - + green_raster_[row3 - 1] * new_matrix_[21] - + green_raster_[row3] * new_matrix_[22] - + green_raster_[row3 + 1] * new_matrix_[23] - + green_raster_[row3 + 2] * new_matrix_[24] - + green_raster_[row3 + 3] * new_matrix_[25] - + green_raster_[row3 + 4] * new_matrix_[26] - + green_raster_[row4 - 4] * new_matrix_[27] - + green_raster_[row4 - 3] * new_matrix_[28] - + green_raster_[row4 - 2] * new_matrix_[29] - + green_raster_[row4 - 1] * new_matrix_[30] - + green_raster_[row4] * new_matrix_[31] - + green_raster_[row4 + 1] * new_matrix_[32] - + green_raster_[row4 + 2] * new_matrix_[33] - + green_raster_[row4 + 3] * new_matrix_[34] - + green_raster_[row4 + 4] * new_matrix_[35] - + green_raster_[row5 - 4] * new_matrix_[36] - + green_raster_[row5 - 3] * new_matrix_[37] - + green_raster_[row5 - 2] * new_matrix_[38] - + green_raster_[row5 - 1] * new_matrix_[39] - + green_raster_[row5] * new_matrix_[40] - + green_raster_[row5 + 1] * new_matrix_[41] - + green_raster_[row5 + 2] * new_matrix_[42] - + green_raster_[row5 + 3] * new_matrix_[43] - + green_raster_[row5 + 4] * new_matrix_[44] - + green_raster_[row6 - 4] * new_matrix_[45] - + green_raster_[row6 - 3] * new_matrix_[46] - + green_raster_[row6 - 2] * new_matrix_[47] - + green_raster_[row6 - 1] * new_matrix_[48] - + green_raster_[row6] * new_matrix_[49] - + green_raster_[row6 + 1] * new_matrix_[50] - + green_raster_[row6 + 2] * new_matrix_[51] - + green_raster_[row6 + 3] * new_matrix_[52] - + green_raster_[row6 + 4] * new_matrix_[53] - + green_raster_[row7 - 4] * new_matrix_[54] - + green_raster_[row7 - 3] * new_matrix_[55] - + green_raster_[row7 - 2] * new_matrix_[56] - + green_raster_[row7 - 1] * new_matrix_[57] - + green_raster_[row7] * new_matrix_[58] - + green_raster_[row7 + 1] * new_matrix_[59] - + green_raster_[row7 + 2] * new_matrix_[60] - + green_raster_[row7 + 3] * new_matrix_[61] - + green_raster_[row7 + 4] * new_matrix_[62] - + green_raster_[row1 - 4] * new_matrix_[63] - + green_raster_[row1 - 3] * new_matrix_[64] - + green_raster_[row1 - 2] * new_matrix_[65] - + green_raster_[row1 - 1] * new_matrix_[66] - + green_raster_[row1] * new_matrix_[67] - + green_raster_[row1 + 1] * new_matrix_[68] - + green_raster_[row1 + 2] * new_matrix_[69] - + green_raster_[row1 + 3] * new_matrix_[70] - + green_raster_[row1 + 4] * new_matrix_[71] - + green_raster_[row1 - 4] * new_matrix_[72] - + green_raster_[row1 - 3] * new_matrix_[73] - + green_raster_[row1 - 2] * new_matrix_[74] - + green_raster_[row1 - 1] * new_matrix_[75] - + green_raster_[row1] * new_matrix_[76] - + green_raster_[row1 + 1] * new_matrix_[77] - + green_raster_[row1 + 2] * new_matrix_[78] - + green_raster_[row1 + 3] * new_matrix_[79] - + green_raster_[row1 + 4] * new_matrix_[80])/div_factor_; - - new_blue = - (blue_raster_[row1 - 4] * new_matrix_[0] - + blue_raster_[row1 - 3] * new_matrix_[1] - + blue_raster_[row1 - 2] * new_matrix_[2] - + blue_raster_[row1 - 1] * new_matrix_[3] - + blue_raster_[row1] * new_matrix_[4] - + blue_raster_[row1 + 1] * new_matrix_[5] - + blue_raster_[row1 + 2] * new_matrix_[6] - + blue_raster_[row1 + 3] * new_matrix_[7] - + blue_raster_[row1 + 4] * new_matrix_[8] - + blue_raster_[row2 - 4] * new_matrix_[9] - + blue_raster_[row2 - 3] * new_matrix_[10] - + blue_raster_[row2 - 2] * new_matrix_[11] - + blue_raster_[row2 - 1] * new_matrix_[12] - + blue_raster_[row2] * new_matrix_[13] - + blue_raster_[row2 + 1] * new_matrix_[14] - + blue_raster_[row2 + 2] * new_matrix_[15] - + blue_raster_[row2 + 3] * new_matrix_[16] - + blue_raster_[row2 + 4] * new_matrix_[17] - + blue_raster_[row3 - 4] * new_matrix_[18] - + blue_raster_[row3 - 3] * new_matrix_[19] - + blue_raster_[row3 - 2] * new_matrix_[20] - + blue_raster_[row3 - 1] * new_matrix_[21] - + blue_raster_[row3] * new_matrix_[22] - + blue_raster_[row3 + 1] * new_matrix_[23] - + blue_raster_[row3 + 2] * new_matrix_[24] - + blue_raster_[row3 + 3] * new_matrix_[25] - + blue_raster_[row3 + 4] * new_matrix_[26] - + blue_raster_[row4 - 4] * new_matrix_[27] - + blue_raster_[row4 - 3] * new_matrix_[28] - + blue_raster_[row4 - 2] * new_matrix_[29] - + blue_raster_[row4 - 1] * new_matrix_[30] - + blue_raster_[row4] * new_matrix_[31] - + blue_raster_[row4 + 1] * new_matrix_[32] - + blue_raster_[row4 + 2] * new_matrix_[33] - + blue_raster_[row4 + 3] * new_matrix_[34] - + blue_raster_[row4 + 4] * new_matrix_[35] - + blue_raster_[row5 - 4] * new_matrix_[36] - + blue_raster_[row5 - 3] * new_matrix_[37] - + blue_raster_[row5 - 2] * new_matrix_[38] - + blue_raster_[row5 - 1] * new_matrix_[39] - + blue_raster_[row5] * new_matrix_[40] - + blue_raster_[row5 + 1] * new_matrix_[41] - + blue_raster_[row5 + 2] * new_matrix_[42] - + blue_raster_[row5 + 3] * new_matrix_[43] - + blue_raster_[row5 + 4] * new_matrix_[44] - + blue_raster_[row6 - 4] * new_matrix_[45] - + blue_raster_[row6 - 3] * new_matrix_[46] - + blue_raster_[row6 - 2] * new_matrix_[47] - + blue_raster_[row6 - 1] * new_matrix_[48] - + blue_raster_[row6] * new_matrix_[49] - + blue_raster_[row6 + 1] * new_matrix_[50] - + blue_raster_[row6 + 2] * new_matrix_[51] - + blue_raster_[row6 + 3] * new_matrix_[52] - + blue_raster_[row6 + 4] * new_matrix_[53] - + blue_raster_[row7 - 4] * new_matrix_[54] - + blue_raster_[row7 - 3] * new_matrix_[55] - + blue_raster_[row7 - 2] * new_matrix_[56] - + blue_raster_[row7 - 1] * new_matrix_[57] - + blue_raster_[row7] * new_matrix_[58] - + blue_raster_[row7 + 1] * new_matrix_[59] - + blue_raster_[row7 + 2] * new_matrix_[60] - + blue_raster_[row7 + 3] * new_matrix_[61] - + blue_raster_[row7 + 4] * new_matrix_[62] - + blue_raster_[row1 - 4] * new_matrix_[63] - + blue_raster_[row1 - 3] * new_matrix_[64] - + blue_raster_[row1 - 2] * new_matrix_[65] - + blue_raster_[row1 - 1] * new_matrix_[66] - + blue_raster_[row1] * new_matrix_[67] - + blue_raster_[row1 + 1] * new_matrix_[68] - + blue_raster_[row1 + 2] * new_matrix_[69] - + blue_raster_[row1 + 3] * new_matrix_[70] - + blue_raster_[row1 + 4] * new_matrix_[71] - + blue_raster_[row1 - 4] * new_matrix_[72] - + blue_raster_[row1 - 3] * new_matrix_[73] - + blue_raster_[row1 - 2] * new_matrix_[74] - + blue_raster_[row1 - 1] * new_matrix_[75] - + blue_raster_[row1] * new_matrix_[76] - + blue_raster_[row1 + 1] * new_matrix_[77] - + blue_raster_[row1 + 2] * new_matrix_[78] - + blue_raster_[row1 + 3] * new_matrix_[79] - + blue_raster_[row1 + 4] * new_matrix_[80])/div_factor_; - - if (new_red > 255) - new_red = 255; - - if (new_green > 255) - new_green = 255; - - if (new_blue > 255) - new_blue = 255; - - pixels[y - 4] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x-5, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index; - int pixel; - red_raster_ = new int[(rows_ + 4)*(columns_ + 4)]; - green_raster_ = new int[red_raster_.length]; - blue_raster_ = new int[red_raster_.length]; - - for (int x = 2; x < rows_ + 2; x++) - { - for (int y = 2; y < columns_ + 2; y ++) - { - index = x*columns_ + y; - pixel = raster_[off]; - red_raster_[index] = defaultRGB_.getRed(pixel); - green_raster_[index] = defaultRGB_.getGreen(pixel); - blue_raster_[index] = defaultRGB_.getBlue(pixel); - off++; - } - } - } -} diff --git a/java/ImageProcessing/filters/RotateFilter.java b/java/ImageProcessing/filters/RotateFilter.java deleted file mode 100644 index 161392bb28d..00000000000 --- a/java/ImageProcessing/filters/RotateFilter.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved. - * - * Permission to use, copy, modify, and distribute this software - * and its documentation for NON-COMMERCIAL purposes and without - * fee is hereby granted provided that this copyright notice - * appears in all copies. Please refer to the file "copyright.html" - * for further important copyright and licensing information. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF - * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED - * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. - */ -package imaging.filters; - -import java.awt.image.ColorModel; -import java.awt.image.ImageFilter; -import java.util.Hashtable; -import java.awt.Rectangle; - -public class RotateFilter extends ImageFilter implements MedFilter -{ - - private static ColorModel defaultRGB = ColorModel.getRGBdefault(); - - private double angle; - private double sin; - private double cos; - private double coord[] = new double[2]; - - private int raster[]; - private int xoffset, yoffset; - private int srcW, srcH; - private int dstW, dstH; - - public RotateFilter () - { - this.angle = 90; - sin = Math.sin(this.angle); - cos = Math.cos(this.angle); - } - - - public RotateFilter(double angle) { - this.angle = angle; - sin = Math.sin(angle); - cos = Math.cos(angle); - } - - public String info () - { - return "Rotates an image"; - } - - public void transform(double x, double y, double[] retcoord) { - // Remember that the coordinate system is upside down so apply - // the transform as if the angle were negated. - // cos(-angle) = cos(angle) - // sin(-angle) = -sin(angle) - retcoord[0] = cos * x + sin * y; - retcoord[1] = cos * y - sin * x; - } - - public void itransform(double x, double y, double[] retcoord) { - // Remember that the coordinate system is upside down so apply - // the transform as if the angle were negated. Since inverting - // the transform is also the same as negating the angle, itransform - // is calculated the way you would expect to calculate transform. - retcoord[0] = cos * x - sin * y; - retcoord[1] = cos * y + sin * x; - } - - public void transformBBox(Rectangle rect) { - double minx = Double.POSITIVE_INFINITY; - double miny = Double.POSITIVE_INFINITY; - double maxx = Double.NEGATIVE_INFINITY; - double maxy = Double.NEGATIVE_INFINITY; - for (int y = 0; y <= 1; y++) { - for (int x = 0; x <= 1; x++) { - transform(rect.x + x * rect.width, - rect.y + y * rect.height, - coord); - minx = Math.min(minx, coord[0]); - miny = Math.min(miny, coord[1]); - maxx = Math.max(maxx, coord[0]); - maxy = Math.max(maxy, coord[1]); - } - } - rect.x = (int) Math.floor(minx); - rect.y = (int) Math.floor(miny); - rect.width = (int) Math.ceil(maxx) - rect.x + 1; - rect.height = (int) Math.ceil(maxy) - rect.y + 1; - } - - public void setDimensions(int width, int height) { - Rectangle rect = new Rectangle(0, 0, width, height); - transformBBox(rect); - xoffset = -rect.x; - yoffset = -rect.y; - srcW = width; - srcH = height; - dstW = rect.width; - dstH = rect.height; - raster = new int[srcW * srcH]; - consumer.setDimensions(dstW, dstH); - } - - public void setColorModel(ColorModel model) { - consumer.setColorModel(defaultRGB); - } - - public void setHints(int hintflags) { - consumer.setHints(TOPDOWNLEFTRIGHT - | COMPLETESCANLINES - | SINGLEPASS - | (hintflags & SINGLEFRAME)); - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, - byte pixels[], int off, int scansize) { - int srcoff = off; - int dstoff = y * srcW + x; - for (int yc = 0; yc < h; yc++) { - for (int xc = 0; xc < w; xc++) { - raster[dstoff++] = model.getRGB(pixels[srcoff++] & 0xff); - } - srcoff += (scansize - w); - dstoff += (srcW - w); - } - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, - int pixels[], int off, int scansize) { - int srcoff = off; - int dstoff = y * srcW + x; - if (model == defaultRGB) { - for (int yc = 0; yc < h; yc++) { - srcoff += scansize; - dstoff += srcW; - } - } else { - for (int yc = 0; yc < h; yc++) { - for (int xc = 0; xc < w; xc++) { - raster[dstoff++] = model.getRGB(pixels[srcoff++]); - } - srcoff += (scansize - w); - dstoff += (srcW - w); - } - } - } - - public void imageComplete(int status) { - - if (status == IMAGEERROR || status == IMAGEABORTED) { - consumer.imageComplete(status); - return; - } - int pixels[] = new int[dstW]; - for (int dy = 0; dy < dstH; dy++) { - itransform(0 - xoffset, dy - yoffset, coord); - double x1 = coord[0]; - double y1 = coord[1]; - itransform(dstW - xoffset, dy - yoffset, coord); - double x2 = coord[0]; - double y2 = coord[1]; - double xinc = (x2 - x1) / dstW; - double yinc = (y2 - y1) / dstW; - for (int dx = 0; dx < dstW; dx++) { - int sx = (int) Math.round(x1); - int sy = (int) Math.round(y1); - if (sx < 0 || sy < 0 || sx >= srcW || sy >= srcH) { - pixels[dx] = 0; - } else { - pixels[dx] = raster[sy * srcW + sx]; - } - x1 += xinc; - y1 += yinc; - } - consumer.setPixels(0, dy, dstW, 1, defaultRGB, pixels, 0, dstW); - } - consumer.imageComplete(status); - } -} diff --git a/java/ImageProcessing/filters/SharpenFilter.java b/java/ImageProcessing/filters/SharpenFilter.java deleted file mode 100644 index 865132daded..00000000000 --- a/java/ImageProcessing/filters/SharpenFilter.java +++ /dev/null @@ -1,137 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class SharpenFilter extends SpatialFilter -{ - int[] red_raster_; - int[] green_raster_; - int[] blue_raster_; - int[] new_matrix_; - - public SharpenFilter() - { - } - - public String info () - { - return "Sharpens an image."; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 1) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_red = - (red_raster_[row1 - 1] - - (red_raster_[row1] << 1) - + red_raster_[row1 + 1] - - (red_raster_[row2 - 1] << 1) - + (red_raster_[row2] << 3) - - (red_raster_[row2 + 1] << 1) - + red_raster_[row3 - 1] - - (red_raster_[row3] << 1) - + red_raster_[row3 + 1]) >> 2; - - new_green = - (green_raster_[row1 - 1] - - (green_raster_[row1] << 1) - + green_raster_[row1 + 1] - - (green_raster_[row2 - 1] << 1) - + (green_raster_[row2] << 3) - - (green_raster_[row2 + 1] << 1) - + green_raster_[row3 - 1] - - (green_raster_[row3] << 1) - + green_raster_[row3 + 1]) >> 2; - - - new_blue = - (blue_raster_[row1 - 1] - - (blue_raster_[row1] << 1) - + blue_raster_[row1 + 1] - - (blue_raster_[row2 - 1] << 1) - + (blue_raster_[row2] << 3) - - (blue_raster_[row2 + 1] << 1) - + blue_raster_[row3 - 1] - - (blue_raster_[row3] << 1) - + blue_raster_[row3 + 1]) >> 2; - - - if (new_red > 255) - new_red = 255; - - if (new_green > 255) - new_green = 255; - - if (new_blue > 255) - new_blue = 255; - - if (new_red < 0) - new_red = 0; - - if (new_green < 0) - new_green = 0; - - if (new_blue < 0) - new_blue = 0; - - - pixels[y - 1] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x-1, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index = columns_; - int pixel; - red_raster_ = new int[(rows_ + 2)*(columns_ + 2)]; - green_raster_ = new int[red_raster_.length]; - blue_raster_ = new int[red_raster_.length]; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y ++) - { - index++; - pixel = raster_[off]; - red_raster_[index] = defaultRGB_.getRed(pixel); - green_raster_[index] = defaultRGB_.getGreen(pixel); - blue_raster_[index] = defaultRGB_.getBlue(pixel); - off++; - } - } - } -} diff --git a/java/ImageProcessing/filters/SobelFilter.java b/java/ImageProcessing/filters/SobelFilter.java deleted file mode 100644 index 649c7963220..00000000000 --- a/java/ImageProcessing/filters/SobelFilter.java +++ /dev/null @@ -1,117 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class SobelFilter extends FivebyfiveFilter -{ - public SobelFilter() - { - } - - public String info () - { - return "Edge detection filter."; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_red1 = 0, new_green1 = 0, new_blue1 = 0, - new_red2 = 0, new_green2 = 0, new_blue2 = 0; - int alpha; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 1) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_red1 = - (red_raster_[row1 - 1] - + (red_raster_[row1] << 1) - + red_raster_[row1 + 1] - - red_raster_[row3 - 1] - - (red_raster_[row3] << 1) - - red_raster_[row3 + 1]); - - new_green1 = - (green_raster_[row1 - 1] - + (green_raster_[row1] << 1) - + green_raster_[row1 + 1] - - green_raster_[row3 - 1] - - (green_raster_[row3] << 1) - - green_raster_[row3 + 1]); - - new_blue1 = - (blue_raster_[row1 - 1] - + (blue_raster_[row1] << 1) - + blue_raster_[row1 + 1] - - blue_raster_[row3 - 1] - - (blue_raster_[row3] << 1) - - blue_raster_[row3 + 1]); - - new_red2 = - (- red_raster_[row1 - 1] - + red_raster_[row1 + 1] - - (red_raster_[row2 - 1] << 1) - + (red_raster_[row2 + 1] << 1) - - red_raster_[row3 - 1] - + red_raster_[row3 + 1]); - - new_green2 = - (- green_raster_[row1 - 1] - + green_raster_[row1 + 1] - - (green_raster_[row2 - 1] << 1) - + (green_raster_[row2 + 1] << 1) - - green_raster_[row3 - 1] - + green_raster_[row3 + 1]); - - new_blue2 = - (- blue_raster_[row1 - 1] - + blue_raster_[row1 + 1] - - (blue_raster_[row2 - 1] << 1) - + (blue_raster_[row2 + 1] << 1) - - blue_raster_[row3 - 1] - + blue_raster_[row3 + 1]); - - new_red1 = (int)Math.sqrt(new_red1*new_red1 + new_red2*new_red2); - new_green1 = (int)Math.sqrt(new_green1*new_green1 + new_green2*new_green2); - new_blue1 = (int)Math.sqrt(new_blue1*new_blue1 + new_blue2*new_blue2); - - if (new_red1 > 255) - new_red1 = 255; - - if (new_green1 > 255) - new_green1 = 255; - - if (new_blue1 > 255) - new_blue1 = 255; - - pixels[y - 1] = (alpha << 24) | (new_red1 << 16) | (new_green1 << 8) | new_blue1; - - } - consumer.setPixels(0, x-1, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } -} diff --git a/java/ImageProcessing/filters/SpatialFilter.java b/java/ImageProcessing/filters/SpatialFilter.java deleted file mode 100644 index 12befc0e614..00000000000 --- a/java/ImageProcessing/filters/SpatialFilter.java +++ /dev/null @@ -1,187 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class SpatialFilter extends ImageFilter implements MedFilter -{ - public SpatialFilter() - { - } - - public SpatialFilter(int[][] matrix, int degree) - { - this(matrix, degree, 1, 0); - } - - public SpatialFilter(int[][] matrix, int degree, int div_factor, int offset) - { - matrix_ = matrix; - div_factor_ = div_factor; - offset_ = offset; - degree_ = degree; - } - - public String info () - { - return "Base Filter class. Doesn't do much"; - } - - public void setDimensions(int width, int height) - { - rows_ = height; - columns_ = width; - raster_ = new int[width * height]; - consumer.setDimensions(width, height); - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, - byte pixels[], int off, int scansize) - { - int source_offset = off; - int dest_offset = y * columns_ + x; - - for (int y_ind = 0; y_ind < h; y_ind++) - { - for (int x_ind = 0; x_ind < w; x_ind++) - { - raster_[dest_offset] = model.getRGB(pixels[source_offset] & 0xff); - dest_offset++; - source_offset++; - } - - source_offset += (scansize - w); - dest_offset += (columns_ - w); - } - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, - int pixels[], int off, int scansize) - { - int source_offset = off; - int dest_offset = y * columns_ + x; - - if (model == defaultRGB_) - { - for (int yc = 0; yc < h; yc++) - { - System.arraycopy(pixels, source_offset, raster_, dest_offset, w); - source_offset += scansize; - dest_offset += columns_; - } - } - else - { - - for (int yc = 0; yc < h; yc++) - { - for (int xc = 0; xc < w; xc++) - { - raster_[dest_offset] = model.getRGB(pixels[source_offset]); - dest_offset++; - source_offset++; - } - source_offset += (scansize - w); - dest_offset += (columns_ - w); - } - } - } - - public void setColorModel(ColorModel model) - { - consumer.setColorModel(defaultRGB_); - } - - public void setHints(int hintflags) - { - consumer.setHints(TOPDOWNLEFTRIGHT - | COMPLETESCANLINES - | SINGLEPASS - | (hintflags & SINGLEFRAME)); - } - - - public void imageComplete(int status) - { - System.out.println("Image Complete called"); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - int[][] new_raster= expandRaster(); - int pixel = 0; - int red, green, blue; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = raster_offset_; x < rows_; x++) - { - for (int y = raster_offset_; y < columns_; y++) - { - new_red = 0; new_green = 0; new_blue = 0; - alpha = defaultRGB_.getAlpha(new_raster[x][y]); - for (int i = 0; i < degree_; i++) - { - for (int j = 0; j < degree_; j++) - { - pixel = new_raster[x + (i - raster_offset_)][y + (j - raster_offset_)]; - - red = defaultRGB_.getRed(pixel) * matrix_[i][j]; - blue = defaultRGB_.getBlue(pixel) * matrix_[i][j]; - green = defaultRGB_.getGreen(pixel) * matrix_[i][j]; - - new_red += red; - new_green += green; - new_blue += blue; - } - } - - new_red /= div_factor_; - new_green /= div_factor_; - new_blue /= div_factor_; - - new_red = Math.min(new_red, 255); - new_green = Math.min(new_green, 255); - new_blue = Math.min(new_blue, 255); - - pixels[y] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - System.out.println("Finished altering image"); - consumer.imageComplete(status); - } - - protected int[][] expandRaster() - { - int[][] new_raster; - int index = 0; - - raster_offset_ = degree_ / 2; - new_raster = new int[rows_ + raster_offset_*2][columns_ + raster_offset_*2]; - - for (int x = 0; x < rows_; x++) - { - for (int y = 0; y < columns_; y++) - { - new_raster[x + raster_offset_][y + raster_offset_] = raster_[index]; - index++; - } - } - - return new_raster; - } - - protected static ColorModel defaultRGB_ = ColorModel.getRGBdefault(); - protected int[][] matrix_; - protected int[] raster_; - protected int rows_ = 0, columns_ = 0; - protected int div_factor_ = 1, offset_, degree_; - protected int raster_offset_ = 0; - -} diff --git a/java/ImageProcessing/filters/ThreebythreeFilter.java b/java/ImageProcessing/filters/ThreebythreeFilter.java deleted file mode 100644 index 134487123dd..00000000000 --- a/java/ImageProcessing/filters/ThreebythreeFilter.java +++ /dev/null @@ -1,133 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class ThreebythreeFilter extends SpatialFilter -{ - int[] red_raster_; - int[] green_raster_; - int[] blue_raster_; - int[] new_matrix_; - - public ThreebythreeFilter() - { - } - - public ThreebythreeFilter(int[] matrix, int degree, int div_factor, int offset) - { - new_matrix_ = matrix; - degree_ = degree; - div_factor_ = div_factor; - offset_ = offset; - } - - public String info () - { - return "Base Filter class. Doesn't do much"; - } - - public void imageComplete(int status) - { - Timer timer = new Timer(); - - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_]; - createColorRasters(); - int pixel = 0; - int red, green, blue; - int row1, row2, row3, row4, row5; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y++) - { - alpha = defaultRGB_.getAlpha(raster_[pixel++]); - - row1 = columns_*(x - 1) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - row4 = row3 + columns_; - row5 = row4 + columns_; - - new_red = - (red_raster_[row1 - 1] * new_matrix_[0] - + red_raster_[row1] * new_matrix_[1] - + red_raster_[row1 + 1] * new_matrix_[2] - + red_raster_[row2 - 1] * new_matrix_[3] - + red_raster_[row2] * new_matrix_[4] - + red_raster_[row2 + 1] * new_matrix_[5] - + red_raster_[row3 - 1] * new_matrix_[6] - + red_raster_[row3] * new_matrix_[7] - + red_raster_[row3 + 1] * new_matrix_[8])/div_factor_; - - new_green = - (green_raster_[row1 - 1] * new_matrix_[0] - + green_raster_[row1] * new_matrix_[1] - + green_raster_[row1 + 1] * new_matrix_[2] - + green_raster_[row2 - 1] * new_matrix_[3] - + green_raster_[row2] * new_matrix_[4] - + green_raster_[row2 + 1] * new_matrix_[5] - + green_raster_[row3 - 1] * new_matrix_[6] - + green_raster_[row3] * new_matrix_[7] - + green_raster_[row3 + 1] * new_matrix_[8])/div_factor_; - - new_blue = - (blue_raster_[row1 - 1] * new_matrix_[0] - + blue_raster_[row1] * new_matrix_[1] - + blue_raster_[row1 + 1] * new_matrix_[2] - + blue_raster_[row2 - 1] * new_matrix_[3] - + blue_raster_[row2] * new_matrix_[4] - + blue_raster_[row2 + 1] * new_matrix_[5] - + blue_raster_[row3 - 1] * new_matrix_[6] - + blue_raster_[row3] * new_matrix_[7] - + blue_raster_[row3 + 1] * new_matrix_[8])/div_factor_; - - if (new_red > 255) - new_red = 255; - - if (new_green > 255) - new_green = 255; - - if (new_blue > 255) - new_blue = 255; - - pixels[y - 1] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - consumer.setPixels(0, x-1, columns_, 1, defaultRGB_, pixels, 0, columns_); - } - // System.out.println(timer); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index; - int pixel; - red_raster_ = new int[(rows_ + 2)*(columns_ + 2)]; - green_raster_ = new int[red_raster_.length]; - blue_raster_ = new int[red_raster_.length]; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y ++) - { - index = x*columns_ + y; - pixel = raster_[off]; - red_raster_[index] = defaultRGB_.getRed(pixel); - green_raster_[index] = defaultRGB_.getGreen(pixel); - blue_raster_[index] = defaultRGB_.getBlue(pixel); - off++; - } - } - } -} diff --git a/java/ImageProcessing/filters/Timer.java b/java/ImageProcessing/filters/Timer.java deleted file mode 100644 index 609ec8aa366..00000000000 --- a/java/ImageProcessing/filters/Timer.java +++ /dev/null @@ -1,23 +0,0 @@ -package imaging.filters; - -public class Timer -{ - long start_time_; - long stop_time_; - - public void start() - { - start_time_ = System.currentTimeMillis(); - } - - public void stop() - { - stop_time_ = System.currentTimeMillis(); - } - - public String toString() - { - long total = stop_time_ - start_time_; - return "Total Time:" + total + " ms"; - } -} diff --git a/java/ImageProcessing/filters/UnsharpFilter.java b/java/ImageProcessing/filters/UnsharpFilter.java deleted file mode 100644 index 26ac01d3e24..00000000000 --- a/java/ImageProcessing/filters/UnsharpFilter.java +++ /dev/null @@ -1,241 +0,0 @@ -package imaging.filters; - -import java.awt.image.*; - -public class UnsharpFilter extends SpatialFilter -{ - - int[] red_raster_; - int[] green_raster_; - int[] blue_raster_; - - private int sharp_ = 1; - private int smooth_ = 5; - private float frac_ = (float)((float).8/(float)2); - - public UnsharpFilter() - { - } - - public UnsharpFilter(int sharp, int smooth, float frac) - { - float div = (float)2.0; - sharp_ = sharp; - smooth_ = smooth; - frac_ = frac/div; - } - - public String info () - { - return "Sharpens an image."; - } - - public void imageComplete(int status) - { - if (status == IMAGEERROR || status == IMAGEABORTED) - { - consumer.imageComplete(status); - System.out.println("Image Error"); - return; - } - - int[] pixels = new int[columns_*rows_], temp; - int[] blurred_red = new int[columns_* rows_]; - int[] blurred_blue = new int[columns_* rows_]; - int[] blurred_green = new int[columns_* rows_]; - int pixel = 0; - int red, green, blue; - int row1, row2, row3; - int index, sum, index_pixels; - int new_red = 0, new_green = 0, new_blue = 0; - int alpha, iterations; - - if (sharp_ > smooth_) - iterations = sharp_; - else - iterations = smooth_; - - createColorRasters(); - for (int i = 0; i < iterations; i++) - { - for (int x = 1; x < rows_ - 1; x++) - { - for (int y = 1; y < columns_ - 1; y++) - { - row1 = columns_*(x - 1) + y; - row2 = row1 + columns_; - row3 = row2 + columns_; - - alpha = defaultRGB_.getAlpha(raster_[row2]); - - new_red = - (red_raster_[row1 - 1] - + red_raster_[row1 + 1] - + red_raster_[row3 - 1] - + red_raster_[row3 + 1] - + ((red_raster_[row1] - + red_raster_[row2 - 1] - + red_raster_[row2 + 1] - + red_raster_[row3]) << 1) - + (red_raster_[row2] << 2)) >> 4; - - new_green = - (green_raster_[row1 - 1] - + green_raster_[row1 + 1] - + green_raster_[row3 - 1] - + green_raster_[row3 + 1] - + ((green_raster_[row1] - + green_raster_[row2 - 1] - + green_raster_[row2 + 1] - + green_raster_[row3]) << 1) - + (green_raster_[row2] << 2)) >> 4; - - new_blue = - (blue_raster_[row1 - 1] - + blue_raster_[row1 + 1] - + blue_raster_[row3 - 1] - + blue_raster_[row3 + 1] - + ((blue_raster_[row1] - + blue_raster_[row2 - 1] - + blue_raster_[row2 + 1] - + blue_raster_[row3]) << 1) - + (blue_raster_[row2] << 2)) >> 4; - - pixels[x*columns_ + y] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - } - } - - sum = columns_ - 1; - for (int y = 1; y < rows_ + 1; y++) - { - index = y*columns_; - index_pixels = (y-1)*columns_; - - alpha = defaultRGB_.getAlpha(raster_[index_pixels]); - new_red = red_raster_[index]; - new_blue = blue_raster_[index]; - new_green = green_raster_[index]; - pixels[index_pixels] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - index += sum; - index_pixels += sum; - - alpha = defaultRGB_.getAlpha(raster_[index_pixels]); - new_red = red_raster_[index]; - new_blue = blue_raster_[index]; - new_green = green_raster_[index]; - pixels[index_pixels] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - } - - sum = columns_*(rows_ -1); - for (int x = 1; x < columns_ + 1; x++) - { - alpha = defaultRGB_.getAlpha(raster_[x-1]); - new_red = red_raster_[x]; - new_blue = blue_raster_[x]; - new_green = green_raster_[x]; - pixels[x-1] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - - index = x + sum; - - alpha = defaultRGB_.getAlpha(raster_[index-1]); - new_red = red_raster_[index]; - new_blue = blue_raster_[index]; - new_green = green_raster_[index]; - - pixels[index-1] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - } - - temp = pixels; - pixels = raster_; - raster_ = temp; - - createColorRasters(); - - if (i == sharp_ - 1) - { - sum = 0; - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y ++) - { - index = x*columns_ + y; - blurred_red[sum] = red_raster_[index]; - blurred_blue[sum] = blue_raster_[index]; - blurred_green[sum] = green_raster_[index]; - sum++; - } - } - } - } - - sum = 0; - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y++) - { - index = x*columns_ + y; - - alpha = defaultRGB_.getAlpha(raster_[sum]); - - new_red = blurred_red[sum] - (int)((float)red_raster_[index]*frac_); - if (new_red < 0) - new_red = 0; - else if (new_red > 255) - new_red = 255; - - blurred_red[sum] = new_red; - - new_blue = blurred_blue[sum] - (int)((float)blue_raster_[index]*frac_); - if (new_blue < 0) - new_blue = 0; - else if (new_blue > 255) - new_blue = 255; - - blurred_blue[sum] = new_blue; - - new_green = blurred_green[sum] - (int)((float)green_raster_[index]*frac_); - if (new_green < 0) - new_green = 0; - else if (new_green > 255) - new_green = 255; - - blurred_green[sum] = new_green; - - pixels[sum] = (alpha << 24) | (new_red << 16) | (new_green << 8) | new_blue; - sum++; - } - } - - consumer.setPixels(0, 0, columns_, rows_, defaultRGB_, pixels, 0, columns_); - consumer.imageComplete(status); - } - - protected void createColorRasters() - { - int off = 0; - int index; - int pixel; - red_raster_ = new int[(rows_ + 2)*(columns_ + 2)]; - green_raster_ = new int[red_raster_.length]; - blue_raster_ = new int[red_raster_.length]; - - for (int x = 1; x < rows_ + 1; x++) - { - for (int y = 1; y < columns_ + 1; y ++) - { - index = x*columns_ + y; - pixel = raster_[off]; - red_raster_[index] = defaultRGB_.getRed(pixel); - green_raster_[index] = defaultRGB_.getGreen(pixel); - blue_raster_[index] = defaultRGB_.getBlue(pixel); - off++; - } - } - } -} - - - - diff --git a/java/ImageProcessing/framework/BaseButton.java b/java/ImageProcessing/framework/BaseButton.java deleted file mode 100644 index f8208d2ed13..00000000000 --- a/java/ImageProcessing/framework/BaseButton.java +++ /dev/null @@ -1,229 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import imaging.filters.*; - -public class BaseButton extends Panel -{ - public BaseButton (String title, String description, ImageApp parent) - { - this.setLayout (new BorderLayout ()); - this.button_ = new Button (title); - this.add ("Center", this.button_); - this.resize (100, 100); - this.description_ = description; - this.parent_ = parent; - } - - public boolean mouseEnter(Event evt, int x, int y) - { - this.parent_.displayStatus (this.description_); - return true; - } - - public boolean mouseExit(Event evt, int x, int y) - { - this.parent_.displayStatus (""); - return true; - } - - protected ImageApp parent_; - private String description_; - private Button button_; -} - -class URLDialogButton extends BaseButton -{ - public URLDialogButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - this.openURLFrame_ = new URLFrame ("Open URL", this.parent_); - } - - public boolean action (Event e, Object arg) - { - this.openURLFrame_.show (); - return true; - } - private URLFrame openURLFrame_; -} - -class SaveButton extends BaseButton -{ - public SaveButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.saveFile (); - return true; - } -} - -class ReloadButton extends BaseButton -{ - public ReloadButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.reloadFilters (); - return true; - } -} - -class ApplyButton extends BaseButton -{ - public ApplyButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.apply (); - return true; - } -} - -class ResetButton extends BaseButton -{ - public ResetButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.resetImage (); - return true; - } -} - -class ZoomInButton extends BaseButton -{ - public ZoomInButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.zoomFactor (1.6); - return true; - } -} - -class ZoomOutButton extends BaseButton -{ - public ZoomOutButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - this.parent_.zoomFactor (0.625); - return true; - } -} - - -class AboutButton extends BaseButton -{ - public AboutButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - DialogManager.popDialog (DialogType.ABOUT, null); - return true; - } -} - -class HelpButton extends BaseButton -{ - public HelpButton (String title, String desc, ImageApp parent) - { - super (title, desc, parent); - } - - public boolean action (Event e, Object arg) - { - System.out.println ("Help selected"); - return true; - } -} - -class ChoicePanel extends Panel -{ - public ChoicePanel (String desc, ImageApp parent) - { - this.description_ = desc; - this.parent_ = parent; - - this.loadFilters (); - // Set the layout of the Choice Panel. Note that the Choice Panel - // holds the choice button of filters. - this.setLayout (new FlowLayout ()); - this.resize (150, 100); - } - - public void choice (Choice choice) - { - this.choice_ = choice; - } - - public Choice choice () - { - return this.choice_; - } - - public void loadFilters () - { - // First remove all components of the panel including the - // choices of filters - this.removeAll (); - - // Now create new choices - this.choice_ = this.parent_.getFilters (); - - // Add the choices to our choice panel - this.add (this.choice_); - } - - public boolean mouseEnter(Event evt, int x, int y) - { - MedFilter filter = null; - String displayString = null; - String filterName = this.choice_.getSelectedItem (); - - if (filterName.compareTo ("None") == 0) - displayString = "No filter selected"; - else - { - filter = (MedFilter) this.parent_.getFilter (filterName); - displayString = filter.info (); - } - this.parent_.displayStatus (displayString); - // this.parent_.displayStatus (this.description_); - return true; - } - - public boolean mouseExit(Event evt, int x, int y) - { - this.parent_.displayStatus (""); - return true; - } - - private Choice choice_; - private ImageApp parent_; - String description_; -} - diff --git a/java/ImageProcessing/framework/DialogManager.java b/java/ImageProcessing/framework/DialogManager.java deleted file mode 100644 index 2a169675e0b..00000000000 --- a/java/ImageProcessing/framework/DialogManager.java +++ /dev/null @@ -1,174 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; - -class DialogManager -{ - public static void popDialog (int type, String message) - { - Frame frame = null; - - switch (type) - { - case DialogType.ABOUT: - frame = new AboutFrame (); - break; - case DialogType.MALFORMED_URL: - case DialogType.URL_NOT_FOUND: - frame = new MessageFrame ("Error", message); - break; - case DialogType.NOT_YET_IMPLEMENTED: - frame = new MessageFrame ("", message); - break; - } - Dimension d = Toolkit.getDefaultToolkit ().getScreenSize (); - frame.move ((d.width - frame.size ().width)/2, - (d.height - frame.size ().height)/2); - /* frame.reshape ((d.width - frame.size ().width)/2, - (d.height - frame.size ().height)/2, - frame.size ().width, - frame.size ()); - */ - frame.show (); - } -} - -class MessageFrame extends Frame -{ - public MessageFrame (String title, String message) - { - super (title); - - this.resize (250,100); - this.setLayout (new BorderLayout ()); - - this.text_ = new TextField (message); - this.text_.setEditable (false); - - Panel okButtonPanel = new Panel (); - okButtonPanel.add (this.okButton_); - okButtonPanel.resize (100, 100); - - this.add ("Center", this.text_); - this.add ("South", okButtonPanel); - } - - public boolean handleEvent (Event evt) - { - if (evt.id == Event.WINDOW_DESTROY) - { - this.dispose (); - return true; - } - return super.handleEvent (evt); - } - - // Handle all action events - public boolean action (Event e, Object arg) - { - if (e.target instanceof Button) - { - if (e.target == this.okButton_) - { - this.dispose (); - } - return true; - } - else - return false; - } - - private Button okButton_ = new Button (" ok "); - private TextField text_ = null; -} - -class AboutFrame extends Frame -{ - public AboutFrame () - { - super ("About"); - this.setText (); - - this.resize (500,700); - this.setLayout (new BorderLayout ()); - - Panel okButtonPanel = new Panel (); - okButtonPanel.add (this.okButton_); - - this.add ("South", okButtonPanel); - } - - public void paint (Graphics g) - { - g.clearRect (0, 0, this.size ().width, this.size ().height); - g.setFont (new Font ("TimesRoman", Font.PLAIN, 18)); - this.setBackground (Color.white); - int x = 20; - int y = 100; - - for (int i = 0; i < AboutFrame.MAXROWS; i++) - { - g.drawString(this.text_[i], x, y); - y += g.getFont ().getSize () + 5; - } - } - - // Handle window destroy events - public boolean handleEvent (Event evt) - { - if (evt.id == Event.WINDOW_DESTROY) - { - this.dispose (); - return true; - } - return super.handleEvent (evt); - } - - // Handle all action events - public boolean action (Event e, Object arg) - { - if (e.target instanceof Button) - { - if (e.target == this.okButton_) - { - this.dispose (); - } - return true; - } - else - return false; - } - - private void setText () - { - text_[0] = "This is a prototype of a large scale distributed medical"; - text_[1] = "imaging system. It has been developed using Java, in"; - text_[2] = "particular, several components of Java ACE."; - text_[3] = ""; - text_[4] = "The prototype allows images to be downloaded across the"; - text_[5] = "network. It then provides several filters that can be"; - text_[6] = "used to do image processing. The image filters are"; - text_[7] = "configured into the system dynamically using the Service"; - text_[8] = "Configurator pattern. In the current implementation, the"; - text_[9] = "filters are specified via a configuration file located at"; - text_[10] = "server. The file can be modified at runtime to add"; - text_[11] = "additional filters or to remove some filters. This allows"; - text_[12] = "filters to be configured and reconfigured dynamically."; - text_[13] = ""; - text_[14] = "Currently, images can not be uploaded. This is mainly due"; - text_[15] = "to security restrictions imposed by current servers. Our"; - text_[16] = "goal is to use the prototpe in conjunction with JAWS, an"; - text_[17] = "adaptive web server we are currently developing in which we"; - text_[18] = "plan to provide support for image uploading."; - text_[19] = ""; - text_[20] = "For more information about this prototype, please contact"; - text_[21] = "Prashant Jain (pjain@cs.wustl.edu)."; - } - - private final static int MAXROWS = 22; - private Button okButton_ = new Button (" ok "); - private TextArea textArea_ = null; - private String [] text_ = new String [AboutFrame.MAXROWS]; -} - diff --git a/java/ImageProcessing/framework/DialogType.java b/java/ImageProcessing/framework/DialogType.java deleted file mode 100644 index 33652d227f8..00000000000 --- a/java/ImageProcessing/framework/DialogType.java +++ /dev/null @@ -1,9 +0,0 @@ -package imaging.framework; - -public class DialogType -{ - public static final int ABOUT = 0; - public static final int MALFORMED_URL = 1; - public static final int URL_NOT_FOUND = 2; - public static final int NOT_YET_IMPLEMENTED = 10; -} diff --git a/java/ImageProcessing/framework/FileBrowser.java b/java/ImageProcessing/framework/FileBrowser.java deleted file mode 100644 index 27245b1f2f4..00000000000 --- a/java/ImageProcessing/framework/FileBrowser.java +++ /dev/null @@ -1,173 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; -import java.net.*; -import java.applet.*; -import gjt.Separator; -import gjt.ComponentScroller; - -class FileNode extends HierarchyAdapter -{ - public FileNode (String name, - Icon icon, - boolean root, - ImageApp app) - { - super (name, icon, root); - this.app_ = app; - } - - public FileNode (String name, - Icon icon, - ListFiles list, - ImageApp app) - { - super (name, icon); - this.list_ = list; - this.app_ = app; - } - - public ImageApp app () - { - return this.app_; - } - - public void handleEvent () - { - String s = null; - String pString = ""; - Hierarchy p = this.getHierarchyParent (); - - while (p != null) - { - pString = p.getName () + pString; - p = p.getHierarchyParent (); - } - - if (pString.endsWith ("/")) - s = "http://" + pString + this.getName (); - else - s = "http://" + pString + "/" + this.getName (); - - System.out.println ("Opening: " + s); - - // If list is null, then it is a file, else it is a directory and - // use list to get the rest of the directory. - if (this.list_ == null) - this.app_.openURL (s); // It is a file - else - this.list_.listFiles (s, this); // It is a directory. - } - - private ListFiles list_ = null; - private ImageApp app_ = null; -} - -class BrowserPanel extends Panel -{ - public BrowserPanel (ImageApp parent) - { - this.resize (300, 300); - this.parent_ = parent; - this.setLayout (new BorderLayout ()); - } - - public int initialize (String url, ListFiles list) - { - String directory = null; - int index = -1; - - String pString = list.stripProtocolHeader (url); - if (!pString.endsWith ("/")) - pString = pString + "/"; - - try - { - Icon dirIcon = new Icon (this.parent_.getCodeBase () + - "../ImageProcessing/framework/" + - "file03.gif", (Applet) this.parent_); - System.out.println (this.parent_.getCodeBase () + - "../ImageProcessing/framework/" + - "file03.gif"); - this.root_ = new FileNode (pString, - dirIcon, true, this.parent_); - } - catch (MalformedURLException e) - { - } - - int count = list.listFiles (url, this.root_); - // System.out.println ("Count: " + count); - if (count > 0) - { - // Add the root to the component scroller and then add the - // component scroller to the panel. - this.scroller_ = new ComponentScroller (this.root_); - this.add ("Center", this.scroller_); - } - return count; - } - - private FileNode root_ = null; - private ImageApp parent_; - private ComponentScroller scroller_; -} - -class FileBrowser extends Frame -{ - public FileBrowser (String title, ImageApp parent) - { - super (title); - this.resize (300, 300); - this.browser_ = new BrowserPanel (parent); - this.setLayout (new BorderLayout ()); - - this.cancelButton_ = new Button (" cancel "); - Panel buttonPanel = new Panel (); - buttonPanel.add (this.cancelButton_); - buttonPanel.resize (100, 100); - - Panel southPanel = new Panel (); - southPanel.setLayout (new BorderLayout ()); - southPanel.add ("North", new Separator ()); - southPanel.add ("South", buttonPanel); - this.add ("South", southPanel); - this.add ("Center", this.browser_); - } - - public int initialize (String url, ListFiles list) - { - return this.browser_.initialize (url, list); - } - - // Handle window destroy events - public boolean handleEvent (Event evt) - { - if (evt.id == Event.WINDOW_DESTROY) - { - this.dispose (); - return true; - } - return super.handleEvent (evt); - } - - // Handle all action events - public boolean action (Event e, Object arg) - { - if (e.target instanceof Button) - { - if (e.target == this.cancelButton_) - { - this.dispose (); - } - validate (); - return true; - } - else - return false; - } - - private Button cancelButton_;; - private BrowserPanel browser_; -} diff --git a/java/ImageProcessing/framework/FilePanel.java b/java/ImageProcessing/framework/FilePanel.java deleted file mode 100644 index 0f233eda8ff..00000000000 --- a/java/ImageProcessing/framework/FilePanel.java +++ /dev/null @@ -1,147 +0,0 @@ -package imaging.framework; - -import java.awt.*; - -// Create a panel for all the buttons -class FilePanel extends Panel -{ - FilePanel (ImageApp parent) - { - this.parent_ = parent; - - this.setLayout (new GridLayout (2, 1)); - - // First create all the buttons - this.URLDialogButton_ = new URLDialogButton ("Open URL", "Download an image", this.parent_); - this.saveButton_ = new SaveButton ("Save", "Upload an image", this.parent_); - - // Place the created buttons in the panel - this.add (this.URLDialogButton_); - this.add (this.saveButton_); - - // Disable the save button for now - this.saveButton_.disable (); - this.resize (400, 400); - } - - // All the created buttons - private URLDialogButton URLDialogButton_; - private SaveButton saveButton_; - - private ImageApp parent_; -} - -// Create a panel for all the buttons -class ResetPanel extends Panel -{ - ResetPanel (ImageApp parent) - { - this.parent_ = parent; - - this.setLayout (new GridLayout (2, 1)); - - // First create all the buttons - this.reloadButton_ = new ReloadButton ("Reload Filters", "Reload all filters", this.parent_); - this.resetButton_ = new ResetButton ("Reset", "Reset the image", this.parent_); - - - // Place the created buttons in the panel - this.add (this.resetButton_); - this.add (this.reloadButton_); - - this.resize (400, 400); - } - - // All the created buttons - private ReloadButton reloadButton_; - private ResetButton resetButton_; - - private ImageApp parent_; -} - - -class ZoomPanel extends Panel -{ - ZoomPanel (ImageApp parent) - { - this.parent_ = parent; - - this.setLayout (new GridLayout (2, 1)); - - // First create the two zoom buttons - this.zoomInButton_ = new ZoomInButton ("<< Zoom in", "Zoom into the image", this.parent_); - this.zoomOutButton_ = new ZoomOutButton ("Zoom out >>", "Zoom out of the image", this.parent_); - - // Now add the buttons to the panel - this.add (this.zoomInButton_); - this.add (this.zoomOutButton_); - - this.resize (100, 100); - } - - private ZoomInButton zoomInButton_; - private ZoomOutButton zoomOutButton_; - - private ImageApp parent_; -} - - -class FilterPanel extends Panel -{ - FilterPanel (ImageApp parent) - { - this.parent_ = parent; - - this.setLayout (new GridLayout (2, 1)); - this.applyButton_ = new ApplyButton ("Apply", "Apply the selected filter", this.parent_); - - // Set the layout of the Choice Panel. Note that the Choice Panel - // holds the choice button of filters. - this.choicePanel_ = new ChoicePanel ("Select filter", this.parent_); - - this.add (this.applyButton_); - this.add (this.choicePanel_); - this.resize (200,200); - } - - public Choice choice () - { - return this.choicePanel_.choice (); - } - - public void loadFilters () - { - this.choicePanel_.loadFilters (); - } - - private ChoicePanel choicePanel_; - private ApplyButton applyButton_; - private ImageApp parent_; -} - -class HelpPanel extends Panel -{ - HelpPanel (ImageApp parent) - { - this.parent_ = parent; - - this.setLayout (new GridLayout (2, 1)); - - this.aboutButton_ = new AboutButton ("About", "About the applet", this.parent_); - this.helpButton_ = new HelpButton ("Help", "Help on how to use the applet", this.parent_); - - // Now add the buttons to the panel - this.add (this.aboutButton_); - this.add (this.helpButton_); - - // Disable the Help button for now - this.helpButton_.disable (); - - this.resize (100, 100); - } - - private AboutButton aboutButton_; - private HelpButton helpButton_; - - private ImageApp parent_; -} diff --git a/java/ImageProcessing/framework/FilterTest.java b/java/ImageProcessing/framework/FilterTest.java deleted file mode 100644 index b1e33482be9..00000000000 --- a/java/ImageProcessing/framework/FilterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; -import imaging.filters.Timer; - -public class FilterTest -{ - public static void main(String[] args) - { - Timer timer = new Timer(); - ImageProcessor ip = new ImageProcessor(); - ImageFilterFactory iff = new ImageFilterFactory(); - Frame frame = new Frame("Rotate Example"); - Toolkit tk = Toolkit.getDefaultToolkit(); - Dimension d = tk.getScreenSize(); - Image old_image = tk.getImage("myphoto.gif"), image; - int image_x, image_y, x = 50, y = 50; - Graphics g; - - frame.reshape(d.width/4, d.height/8, d.width/2, 3*d.height/4); - frame.show(); - g = frame.getGraphics(); - d = frame.size(); - - MediaTracker tracker = new MediaTracker(frame); - tracker.addImage(old_image, 0); - try { tracker.waitForID(0); } catch(InterruptedException excp) {} - g.drawImage(old_image, x, y, frame); - x += old_image.getWidth(frame) + 50; - - timer.start(); - image = ip.processImage(old_image, iff.createMeanImageFilter(), frame); - timer.stop(); - System.out.println(timer); - g.drawImage(image, x, y, frame); - x += old_image.getWidth(frame) + 50; - - timer.start(); - image = ip.processImage(old_image, iff.createSobelFilter(), frame); - timer.stop(); - System.out.println(timer); - g.drawImage(image, x, y, frame); - x = 50; - y += old_image.getHeight(frame) + 50; - - timer.start(); - image = ip.processImage(old_image, iff.createEmbossFilter(), frame); - timer.stop(); - System.out.println(timer); - g.drawImage(image, x, y, frame); - x += old_image.getWidth(frame) + 50; - - image = ip.processImage(old_image, iff.createSharpenFilter(), frame); - g.drawImage(image, x, y, frame); - x = 50; - y += old_image.getHeight(frame) + 50; - - image = ip.processImage(old_image, iff.createRotateImageFilter(), frame); - g.drawImage(image, x, y, frame); - } -} diff --git a/java/ImageProcessing/framework/Hierarchy.java b/java/ImageProcessing/framework/Hierarchy.java deleted file mode 100644 index 41b1825ef4d..00000000000 --- a/java/ImageProcessing/framework/Hierarchy.java +++ /dev/null @@ -1,347 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.util.Vector; - -public class Hierarchy extends Canvas -{ - // Attributes - private String name_; - private Hierarchy root_; - private Hierarchy parent_; - private Icon icon_ = null; - - // State - private boolean collapsed_ = true; - private boolean deadend_ = true; - private Vector contained_ = new Vector(); - private Rectangle self_; - private Rectangle scope_; - - // Constants - private Color COLOR = Color.black; - private Font FONT = new Font("Dialog", Font.BOLD, 12); - private static int TRI_HEIGHT = 8; - private int SPACE = 15; - - static Hierarchy last_lit_ = null; - - public Hierarchy(String name, boolean root) - { - name_ = name; - - if (root) - { - deadend_ = false; - root_ = this; - parent_ = null; - } - } - - public Hierarchy(String name, Icon icon, boolean root) - { - this(name, root); - icon_ = icon; - } - - public Hierarchy(String name) - { - this(name, false); - } - - public Hierarchy(String name, Icon icon) - { - this(name, icon, false); - } - - public void setExpandable(boolean expandable) - { - deadend_ = ! expandable; - - /* - if (root_ != null) - root_.repaint(); - */ - } - - public void setCollapsed(boolean collapsed) - { - collapsed_ = collapsed; - - if (root_ != null) - root_.repaint(); - } - - public void addEntry(Hierarchy entry) - { - deadend_ = false; - entry.parent_ = this; - entry.root_ = root_; - entry.FONT = FONT; - entry.COLOR = COLOR; - entry.SPACE = SPACE; - - contained_.addElement(entry); - } - - public boolean removeEntry(String name) - { - if (contained_.size() == 1) - deadend_ = true; - - return contained_.removeElement(name); - } - - public String getName() - { - return name_; - } - - public void setName(String name) - { - name_ = name; - } - - public Hierarchy getHierarchyParent() - { - return parent_; - } - - public void setFont(Font font) - { - FONT = font; - } - - public void setColor(Color color) - { - COLOR = color; - } - - public void setSpace(int space) - { - SPACE = space; - } - - public void handleEvent() {} - - public boolean mouseDown(Event evt, int x, int y) - { - Hierarchy value = mouseInside(x, y); - - if (value != null) - { - if (! value.deadend_) - { - if (x < value.self_.x + TRI_HEIGHT + SPACE) - { - value.collapsed_ = ! value.collapsed_; - if (value.contained_.isEmpty()) - value.handleEvent(); - repaint(); - } - } - else - { - if (value.contained_.isEmpty()) - value.handleEvent(); - } - } - - return false; - } - - public boolean mouseMove(Event evt, int x, int y) - { - Hierarchy value = mouseInside(x, y); - - if ((value != last_lit_) && (last_lit_ != null)) - last_lit_.highlight(getGraphics(), false); - - if (value != null && value.deadend_) - value.highlight(getGraphics(), true); - - last_lit_ = value; - - return false; - } - - public void paint(Graphics g) - { - Dimension d = size(); - - drawLevel(g, SPACE, SPACE); - - if (d.width < scope_.width || d.height < scope_.height || - d.width > scope_.width || d.height > scope_.height) - resize(scope_.width, scope_.height); - } - - - private Point drawLevel(Graphics g, int x, int y) - { - g.setFont(FONT); - FontMetrics font_metrics = g.getFontMetrics(); - int string_height = font_metrics.getHeight(); - int string_width = font_metrics.stringWidth(name_); - int entry_height = string_height; - int entry_width = string_width + 2*SPACE + TRI_HEIGHT; - int total_height, total_width, initial_x = x, initial_y = y; - int indent = SPACE + TRI_HEIGHT/2; - int temp_x = x; - Point place_marker; - Hierarchy entry; - - if (icon_ != null) - { - entry_height = Math.max(string_height, icon_.iconSize().height); - entry_width += icon_.iconSize().width + SPACE; - indent += icon_.iconSize().width/2; - if (! deadend_) - drawShape(g, x, y + (entry_height - TRI_HEIGHT)/2, deadend_, collapsed_); - } - else - drawShape(g, x, y + (entry_height - TRI_HEIGHT)/2, deadend_, collapsed_); - - self_ = new Rectangle(initial_x, initial_y, entry_width, entry_height); - - temp_x += TRI_HEIGHT + SPACE; - - if (icon_ != null) - { - icon_.drawIcon(g, temp_x, y, root_); - temp_x += SPACE + icon_.iconSize().width; - } - - g.setColor(COLOR); - - g.drawString(name_, temp_x, y + (entry_height + string_height)/2); - - total_width = entry_width; - y += entry_height + SPACE; - - if (! (deadend_ || collapsed_)) - { - x += indent; - for (int i = 0; i < contained_.size(); i++) - { - entry = (Hierarchy)contained_.elementAt(i); - place_marker = entry.drawLevel(g, x, y); - total_width = Math.max(total_width, entry.scope_.width + indent + SPACE); - x = place_marker.x; - y = place_marker.y; - } - x -= indent; - } - - total_height = y - initial_y; - scope_ = new Rectangle(initial_x, initial_y, total_width, total_height); - - return new Point(x, y); - } - - private Hierarchy mouseInside(int x, int y) - { - Hierarchy entry; - Hierarchy return_value = null; - - if (self_.inside(x, y)) - { - return_value = this; - } - else - { - if (scope_.inside(x, y) && (! collapsed_)) - { - for (int i = 0; i < contained_.size(); i++) - { - entry = (Hierarchy)contained_.elementAt(i); - if ((return_value = entry.mouseInside(x, y)) != null) - break; - } - } - else - return_value = null; - } - - return return_value; - } - - private void highlight(Graphics g, boolean lit) - { - g.setFont(FONT); - FontMetrics fm = g.getFontMetrics(); - int string_height = fm.getHeight(); - int x = self_.x + SPACE + TRI_HEIGHT; - int y = self_.y; - - if (icon_ != null) - x += icon_.iconSize().width + SPACE; - - if (lit) - g.setColor(Color.magenta); - else - g.setColor(COLOR); - - g.drawString(name_, x, y + (self_.height + string_height)/2); - } - - - private static void drawShape(Graphics g, int x, int y, boolean dead_end, boolean collapsed) - { - int xpoints[] = new int[3]; - int ypoints[] = new int[3]; - - xpoints[0] = x; - ypoints[0] = y; - - if (dead_end) - { - g.fillOval(x, y, TRI_HEIGHT, TRI_HEIGHT); - } - else - { - // Draw a small collapsed triangle: |> - if (collapsed) - { - xpoints[1] = x; - xpoints[2] = x + TRI_HEIGHT; - ypoints[1] = y + TRI_HEIGHT; - ypoints[2] = y + TRI_HEIGHT/2; - g.fillPolygon(xpoints, ypoints, 3); - } - //Draw a small uncollapsed triangle - else - { - xpoints[1] = x + TRI_HEIGHT; - xpoints[2] = x + TRI_HEIGHT/2; - ypoints[1] = y; - ypoints[2] = y + TRI_HEIGHT; - g.fillPolygon(xpoints, ypoints, 3); - } - } - } - - private static void drawVertHashedLine(Graphics g, int x, int y1, int y2, int hashsize) - { - for (int ytemp = y1; ytemp < y2; ytemp += hashsize*3) - { - if (y2 - hashsize < ytemp) - g.drawLine(x, ytemp, x, y2); - else - g.drawLine(x, ytemp, x, ytemp + hashsize); - } - } - - private static void drawHoroHashedLine(Graphics g, int y, int x1, int x2, Color color, int hashsize) - { - for (int xtemp = x1; xtemp < x2; xtemp += hashsize*3) - { - if (x2 - hashsize < xtemp) - g.drawLine(xtemp, y, x1, y); - else - g.drawLine(xtemp, y, xtemp + hashsize, y); - } - } -} - - diff --git a/java/ImageProcessing/framework/HierarchyAdapter.java b/java/ImageProcessing/framework/HierarchyAdapter.java deleted file mode 100644 index a265be656ea..00000000000 --- a/java/ImageProcessing/framework/HierarchyAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -package imaging.framework; - -import java.awt.*; - -class HierarchyAdapter extends Hierarchy -{ - public HierarchyAdapter(String name, boolean root) - { - super(name, root); - } - - public HierarchyAdapter(String name, Icon icon, boolean root) - { - super(name, icon, root); - } - - public HierarchyAdapter(String name) - { - super(name); - } - - public HierarchyAdapter(String name, Icon icon) - { - super(name, icon); - } - - public void paint(Graphics g) - { - super.paint(g); - - Container p = getParent().getParent(); - p.getLayout ().layoutContainer (p); - } -} diff --git a/java/ImageProcessing/framework/Icon.java b/java/ImageProcessing/framework/Icon.java deleted file mode 100644 index eed91ed55c7..00000000000 --- a/java/ImageProcessing/framework/Icon.java +++ /dev/null @@ -1,70 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.applet.*; -import java.net.*; - -public class Icon -{ - protected Image icon_; - protected Dimension iconSize_; - - Icon() - { - super(); - } - - Icon(String file_name, Component comp) - { - this.icon_ = Toolkit.getDefaultToolkit().getImage(file_name); - this.loadImage(comp); - } - - Icon(Image icon_image, Component comp) - { - this.icon_ = icon_image; - this.loadImage(comp); - } - - Icon(String url, Applet applet) throws MalformedURLException - { - this.icon_ = applet.getImage(new URL(url)); - loadImage(applet); - } - - public void drawIcon(Graphics g, int x, int y, Component comp) - { - g.drawImage(this.icon_, x, y, comp); - } - - private void loadImage(Component comp) - { - try - { - MediaTracker tracker = new MediaTracker(comp); - tracker.addImage(this.icon_, 0); - tracker.waitForID(0); - - this.iconSize_ = new Dimension(this.icon_.getWidth(comp), this.icon_.getHeight(comp)); - } - catch (InterruptedException excp) - { - System.err.println("Icon::getIcon image failed to load"); - } - } - - public Dimension iconSize() - { - return this.iconSize_; - } - - public Image getIconImage() - { - return this.icon_; - } - -} - - - - diff --git a/java/ImageProcessing/framework/ImageApp.java b/java/ImageProcessing/framework/ImageApp.java deleted file mode 100644 index 5c16b2c6fa5..00000000000 --- a/java/ImageProcessing/framework/ImageApp.java +++ /dev/null @@ -1,279 +0,0 @@ -package imaging.framework; - -import java.util.*; -import java.awt.*; -import java.net.*; -import java.io.*; -import java.awt.image.*; -import java.applet.*; -import gjt.Separator; -import gjt.Util; -import imaging.filters.Timer; - -public class ImageApp extends Applet -{ - public void init () - { - // Use BorderLayout for our applet frame - this.setLayout (new BorderLayout ()); - - // Now load all the filters specified in the config file - // this.loadFilters (); - this.setupButtonPanel (); - this.add ("Center", this.imageCanvas_); - } - - private void setupButtonPanel () - { - Panel southPanel = new Panel (); - southPanel.setLayout (new BorderLayout ()); - - Panel buttonPanel = new Panel (); - buttonPanel.setLayout (new GridLayout (1, 5)); - - this.statusDisplay_ = new StatusDisplay (); - // Create a panel for all the buttons - this.filePanel_ = new FilePanel (this); - this.resetPanel_ = new ResetPanel (this); - this.zoomPanel_ = new ZoomPanel (this); - this.filterPanel_ = new FilterPanel (this); - this.helpPanel_ = new HelpPanel (this); - - buttonPanel.add (this.filePanel_); - buttonPanel.add (this.resetPanel_); - buttonPanel.add (this.zoomPanel_); - buttonPanel.add (this.filterPanel_); - buttonPanel.add (this.helpPanel_); - - southPanel.add ("North", new Separator ()); - southPanel.add ("Center", buttonPanel); - southPanel.add ("South", this.statusDisplay_); - - southPanel.resize (400, 400); - - // Now add all these components to the main frame - this.add ("South", southPanel); - this.add ("North", new Panel ()); // Empty panel (for aesthetics) - // this.add ("East", new Panel ()); // Empty panel (for aesthetics) - // this.add ("West", new Panel ()); // Empty panel (for aesthetics) - } - - public void displayStatus (String s) - { - this.statusDisplay_.setText (s); - } - - // Handle all action events - public void zoomFactor (double zoomFactor) - { - this.imageCanvas_.zoomFactor (zoomFactor); - } - - public void reloadFilters () - { - this.filterPanel_.loadFilters (); - repaint (); - } - - public ImageFilter getFilter (String s) - { - return (ImageFilter) this.filterTable_.get (s); - } - - public void apply () - { - ImageFilter filter = this.getFilter (this.filterPanel_.choice ().getSelectedItem ()); - if (filter != null) - { - Util.getFrame (this).setCursor (Frame.WAIT_CURSOR); - this.imageCanvas_.applyFilter (filter); - Util.getFrame (this).setCursor (Frame.DEFAULT_CURSOR); - } - } - - public void resetImage () - { - this.imageCanvas_.applyFilter (null); - } - - public void openURL (String url) - { - if (url == null) - { - DialogManager.popDialog (DialogType.MALFORMED_URL, - "Error: Malformed URL"); - return; - } - Image image; - try - { - if (url.compareTo ("pj") == 0) // This is just for debugging... - image = getImage (new URL ("http://www.cs/~pjain/myphoto.gif")); - else - image = getImage (new URL (url)); - } - catch (MalformedURLException e) - { - DialogManager.popDialog (DialogType.MALFORMED_URL, - "Error: Malformed URL"); - return; - } - - if (image != null) - this.imageCanvas_.setImage (image); - else - DialogManager.popDialog (DialogType.URL_NOT_FOUND, - "Error: URL not found"); - } - - public void saveFile () - { - DialogManager.popDialog (DialogType.NOT_YET_IMPLEMENTED, - "Save File: Not yet implemented "); - } - - public Choice getFilters () - { - Choice choice = new Choice (); - - // Add the default choice first - choice.addItem ("None"); - - // Now do the file processing -- to determine which filters need - // to be loaded. - - // Check if the filename has been previously specified and - // if not then check if the user has specified the name of the - // config file - if (this.configFile_ == null) - this.configFile_ = getParameter ("configFile"); - if (this.configFile_ == null) - this.configFile_ = "http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/framework/filter.conf"; - - if (this.filterContext_ == null) - this.filterContext_ = getParameter ("filterContext"); - if (this.filterContext_ == null) - this.filterContext_ = "http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/"; - - URL url; - String configInfo= null; - try - { - System.out.println ("Configuration File: " + this.configFile_); - // Create a new URL - url = new URL (this.configFile_); - - // Get the input stream and pipe it to a DataInputStream - DataInputStream iStream = new DataInputStream (url.openStream ()); - - // Create a buffer to hold all the data we get - StringBuffer tempBuf = new StringBuffer (); - // Keep reading the data until we are done - String tempString = iStream.readLine (); - while (tempString != null) - { - tempBuf.append (tempString); - tempBuf.append (" "); - tempString = iStream.readLine (); - } - configInfo = tempBuf.toString (); - } - catch (MalformedURLException e) - { - System.err.println (e); - } - catch (IOException e) - { - System.err.println (e); - } - - if (configInfo != null) - { - try - { - StringTokenizer tokens = new StringTokenizer (configInfo); - String fullFilterName = null; - String filterName = null; - // Now parse the string, picking up filter names. Use these - // names to load the actual filters as well add new choices to - // the filter choices. - while (tokens.hasMoreTokens ()) - { - // Get the next token - fullFilterName = tokens.nextToken (); - filterName = this.extractFilterName (fullFilterName); - - // URL filter = new URL (this.filterContext_ + fullFilterName + ".class"); - System.out.println ("Loading: " + fullFilterName); - // Load the filter class - Class c = Class.forName (fullFilterName); - // Class c = this.filterRepository_.load (filter); - - // Add the filter to the Filter Repository - this.filterTable_.put (filterName, - (ImageFilter) c.newInstance ()); - - // Add filter name to the list of filter choices - choice.addItem (filterName); - } - } - catch (ClassNotFoundException e) - { - System.err.println ("Filter not found: " + e); - return null; - } - catch (IllegalAccessException e) - { - System.err.println ("Filter not found: " + e); - return null; - } - catch (InstantiationException e) - { - System.err.println ("Filter not found: " + e); - return null; - } - } - return choice; - } - - // Extract the short filter name from the full filter name. For - // example, this method returns "EmbossFilter" if it is given the - // string "imaging/filters/EmbossFilter" - private String extractFilterName (String s) - { - String filterName = null; - StringTokenizer tokens = new StringTokenizer (s, "."); - while (tokens.hasMoreTokens ()) - filterName = tokens.nextToken (); - return filterName; - } - - private Panel centerPanel_ = new Panel (); - private String configFile_ = null; - private String filterContext_ = null; - private Choice choice_ = null; - private ImageCanvas imageCanvas_ = new ImageCanvas (); - private FilePanel filePanel_; - private ResetPanel resetPanel_; - private ZoomPanel zoomPanel_; - private FilterPanel filterPanel_; - private HelpPanel helpPanel_; - - private StatusDisplay statusDisplay_; - - // Now create all the buttons - private Button URLDialogButton_ = new Button ("Open URL"); - private Button saveButton_ = new Button ("Save"); - private Button reloadButton_ = new Button ("Reload Filters"); - private Button applyButton_ = new Button ("Apply"); - private Button resetButton_ = new Button ("Reset"); - private Button aboutButton_ = new Button ("About"); - - private Button zoomInButton_ = new Button ("<< Zoom in"); - private Button zoomOutButton_ = new Button ("Zoom out >>"); - - - private Hashtable filterTable_ = new Hashtable (); - private ImageFilterFactory iff_ = new ImageFilterFactory (); - // private FilterRepository filterRepository_ = new FilterRepository (); -} diff --git a/java/ImageProcessing/framework/ImageCanvas.java b/java/ImageProcessing/framework/ImageCanvas.java deleted file mode 100644 index d334be45ef4..00000000000 --- a/java/ImageProcessing/framework/ImageCanvas.java +++ /dev/null @@ -1,147 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; -import gjt.Util; - -class ImageCanvas extends Canvas -{ - public static final double MAX_ZOOM = 4.0; - public static final double MIN_ZOOM = 0.5; - - public void setImage (Image image) - { - if (image != null) - { - this.image_ = image; - this.originalImage_ = this.image_; - - // Load the image - this.tracker_.addImage(this.image_, 0); - try { this.tracker_.waitForID(0); } catch(InterruptedException excp) {} - - this.x_ = (this.size ().width - this.image_.getWidth (this))/2; - this.y_ = (this.size ().height - this.image_.getHeight (this))/2; - this.original_x_ = this.x_; - this.original_y_ = this.y_; - repaint (); - } - } - - public void paint (Graphics g) - { - this.setBackground (Color.white); - if (this.image_ != null) - g.drawImage(this.image_, - this.x_, this.y_, - (int) (this.image_.getWidth (this) * this.zoom_), - (int) (this.image_.getHeight (this) * this.zoom_), - this); - } - - public void applyFilter (ImageFilter filter) - { - if (this.image_ != null) - { - Image temp; - if (filter == null) - { - temp = this.originalImage_; - this.x_ = this.original_x_; - this.y_ = this.original_y_; - this.zoom_ = 1.0; - } - else - temp = this.ip_.processImage(this.image_, filter, this); - - this.tracker_.addImage(temp, 0); - try { this.tracker_.waitForID(0); } catch(InterruptedException excp) {} - - this.image_ = temp; - - // Originally I needed to flush the pixel data for the image to be - // drawn properly. When running the applet in appletviewer, the - // image used to jump around, but running in a browser seems to be - // ok. - //this.image_.flush(); - repaint (); - } - } - - public void zoomFactor (double zoom) - { - this.zoom_ *= zoom; - if (this.zoom_ > ImageCanvas.MAX_ZOOM) - this.zoom_ = ImageCanvas.MAX_ZOOM; - else if (this.zoom_ < ImageCanvas.MIN_ZOOM) - this.zoom_ = ImageCanvas.MIN_ZOOM; - - repaint (); - } - - public boolean mouseDown (Event evt, int x, int y) - { - if (inBounds (x, y)) - { - this.selected_ = true; - this.last_x_ = x; - this.last_y_ = y; - } - return true; - } - - public boolean mouseUp (Event evt, int x, int y) - { - this.selected_ = false; - return true; - } - - public boolean mouseDrag (Event evt, int x, int y) - { - if (this.selected_) - { - this.x_ = x - (this.last_x_ - this.x_); - this.y_ = y - (this.last_y_ - this.y_); - this.last_x_ = x; - this.last_y_ = y; - repaint (); - } - return true; - } - - public boolean mouseMove (Event evt, int x, int y) - { - if (this.image_ != null && inBounds (x, y)) - Util.getFrame (this).setCursor (Frame.HAND_CURSOR); - else - Util.getFrame (this).setCursor (Frame.DEFAULT_CURSOR); - return true; - } - - public boolean mouseExit (Event evt, int x, int y) - { - Util.getFrame (this).setCursor (Frame.DEFAULT_CURSOR); - return true; - } - - // Check if mouse is within the bounds of the image - private boolean inBounds (int x, int y) - { - return (x >= this.x_) && - (y >= this.y_) && - (x <= (this.x_ + this.zoom_ * this.image_.getWidth (this))) && - (y <= (this.y_ + this.zoom_ * this.image_.getHeight (this))); - } - - private MediaTracker tracker_ = new MediaTracker(this); - private Image image_, originalImage_; - private int x_ = 0, y_ = 0; - private int original_x_ = 0, original_y_ = 0; - private int width_ = 0, height_ = 0; - private ImageProcessor ip_ = new ImageProcessor (); - private boolean selected_ = false; - private int last_x_ = 0, last_y_ = 0; - private double zoom_ = 1.0; - -} - diff --git a/java/ImageProcessing/framework/ImageFilterFactory.java b/java/ImageProcessing/framework/ImageFilterFactory.java deleted file mode 100644 index e854a41904f..00000000000 --- a/java/ImageProcessing/framework/ImageFilterFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -package imaging.framework; - -import java.awt.image.*; -import imaging.filters.*; - -public class ImageFilterFactory -{ - public ImageFilterFactory() - { - } - - public RotateFilter createRotateFilter() - { - return new RotateFilter(Math.PI/3); - } - - public MeanFilter createMeanFilter() - { - return new MeanFilter(); - } - - public EmbossFilter createEmbossFilter() - { - return new EmbossFilter(); - } - - public SobelFilter createSobelFilter() - { - return new SobelFilter(); - } - - public SharpenFilter createSharpenFilter() - { - return new SharpenFilter(); - } - - public DarkenFilter createDarkenFilter() - { - return new DarkenFilter(50); - } - - public DissolveFilter createDissolveFilter() - { - return new DissolveFilter(85); - } - -} diff --git a/java/ImageProcessing/framework/ImageProcessor.java b/java/ImageProcessing/framework/ImageProcessor.java deleted file mode 100644 index 422298d508f..00000000000 --- a/java/ImageProcessing/framework/ImageProcessor.java +++ /dev/null @@ -1,111 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; -import java.util.Vector; - -public class ImageProcessor -{ - private Vector pipeline_ = new Vector(); - - - public ImageProcessor() - { - } - - public void addFilter(String filter_name, ImageFilter filter) - { - pipeline_.addElement(new FilterNode(filter_name, filter)); - } - - public boolean removeFilter(String name) - { - FilterNode filter_node; - - for (int i = 0; i < pipeline_.size(); i++) - { - filter_node = (FilterNode)pipeline_.elementAt(i); - if (name.equals(filter_node.getName())) - { - pipeline_.removeElementAt(i); - pipeline_.trimToSize(); - return true; - } - } - - return false; - } - - public Image processImage(Image image, ImageFilter filter, Component component) - { - Image old_image = image, new_image = old_image; - MediaTracker tracker = new MediaTracker(component); - - try - { - new_image = component.createImage(new FilteredImageSource(old_image.getSource(), filter)); - tracker.addImage(new_image, 0); - tracker.waitForID(0); - } - catch(InterruptedException excp) - { - System.out.println("ImageProcessor::processImage Image failed to load."); - System.out.println(excp); - return null; - } - - return new_image; - } - - public Image processImage(Image image, Component component) - { - Image old_image = image, new_image = null; - ImageFilter image_filter; - FilterNode filter_node; - MediaTracker tracker = new MediaTracker(component); - - try - { - for (int i = 0; i < pipeline_.size(); i++) - { - filter_node = (FilterNode) pipeline_.elementAt(i); - image_filter = filter_node.getFilter(); - new_image = component.createImage(new FilteredImageSource(old_image.getSource(), image_filter)); - old_image = new_image; - tracker.addImage(new_image, 0); - tracker.waitForID(0); - } - } - catch(InterruptedException excp) - { - System.out.println("ImageProcessor::processImage Image failed to load."); - System.out.println(excp); - return null; - } - - return new_image; - } -} - - -class FilterNode -{ - private String name_; - private ImageFilter filter_; - - FilterNode(String name, ImageFilter filter) - { - name_ = name; - filter_ = filter; - } - - String getName() - { - return name_; - } - - ImageFilter getFilter() - { - return filter_; - } -} diff --git a/java/ImageProcessing/framework/ListFiles.java b/java/ImageProcessing/framework/ListFiles.java deleted file mode 100644 index 7abe067341c..00000000000 --- a/java/ImageProcessing/framework/ListFiles.java +++ /dev/null @@ -1,167 +0,0 @@ -package imaging.framework; - -import java.net.*; -import java.io.*; -import java.applet.*; - -public class ListFiles -{ - public ListFiles () - { - } - - public ListFiles (FileBrowser browser, Applet parent) - { - this.browser_ = browser; - try - { - this.fileIcon_ = new Icon (parent.getCodeBase () + - "../ImageProcessing/framework/" + - "doc01.gif", - parent); - this.dirIcon_ = new Icon (parent.getCodeBase () + - "../ImageProcessing/framework/" + - "file03.gif", - parent); - } - catch (MalformedURLException e) - { - } - } - - public String stripProtocolHeader (String url) - { - if (url.startsWith ("http://")) - { - return url.substring (7); - } - else - return url; - } - - public int listFiles (String url, FileNode fileNode) - { - String s = this.stripProtocolHeader (url); - String hostname = s; - String directory = null; - int index = -1; - - if ((index = s.indexOf ("/")) != -1) - { - hostname = s.substring (0, index); - directory = s.substring (index); - } - return this.listFiles (hostname, directory, fileNode); - } - - public int listFiles (String url, String directory, FileNode fileNode) - { - boolean validDirectory = false; - int count = 0; - String hostname = this.stripProtocolHeader (url); - this.url_ = url; - this.directory_ = directory; - try - { - Socket sock = new Socket (hostname, 80); - PrintStream out = new PrintStream (sock.getOutputStream ()); - DataInputStream in = new DataInputStream (sock.getInputStream ()); - System.out.println ("Connected to: " + hostname); - - String request = null; - if (directory.endsWith ("/")) - request = "GET " + directory + "\n\n"; - else - request = "GET " + directory + "/\n\n"; - - System.out.println ("Sending request: " + request); - - // Send the request - out.println (request); - - String reply = null; - // Receive the reply - - // Read all the data in a loop. Search for "Parent Directory" - // to verify that this indeed is a directory. If we encounter - // the string "<HTML>" then assume that this is an HTML page - // and therefore the directory contained "index.html" - while ((reply = in.readLine ()) != null) - { - if (validDirectory) - this.parse (reply, fileNode); - else - { - // Take a guess at the type of data we get back - if (reply.indexOf ("Parent Directory") != -1) - validDirectory = true; - else if ((reply.toUpperCase ().indexOf ("<HTML>") != -1) || - (reply.toUpperCase ().indexOf ("<P>") != -1) || - (reply.toUpperCase ().indexOf ("<TABLE") != -1)) - return 0; - } - } - } - catch (MalformedURLException e) - { - System.err.println (e); - } - catch (IOException e) - { - System.err.println (e); - } - if (validDirectory == false) - return -1; - return 1; - } - - private int parse (String s, FileNode fileNode) - { - int i= -1; - int j = -1; - int startIndex = -1; - int endIndex = -1; - boolean isFile = true; - String name = null; - - if ((i = s.indexOf ("HREF=")) != -1) - startIndex = i + 6; - else - return -1; - - if ((j = s.indexOf (">", i)) != -1) - endIndex = j - 1; - else - return -1; - - // Check if this is a directory - if (s.charAt (endIndex - 1) == '/') - isFile = false; - - if (endIndex >= startIndex) - { - name = s.substring (startIndex, endIndex); - if (browser_ != null) - { - // System.out.println (name); - if (isFile) - fileNode.addEntry (new FileNode (name, this.fileIcon_, null, - fileNode.app ())); - else - { - FileNode f = new FileNode (name, this.dirIcon_, this, - fileNode.app ()); - fileNode.addEntry (f); - f.setExpandable (true); - } - } - } - return 0; - } - - private FileBrowser browser_ = null; - private String url_ = null; - private String directory_ = null; - private Icon fileIcon_; - private Icon dirIcon_; -} diff --git a/java/ImageProcessing/framework/Makefile b/java/ImageProcessing/framework/Makefile deleted file mode 100644 index 2c22671febd..00000000000 --- a/java/ImageProcessing/framework/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes -DOCDIR = $(JACE_WRAPPER)/doc - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) - -clean: - rm -rf *~ - -realclean: clean - rm -rf $(JACE_WRAPPER)/classes/imaging/framework - -files = ImageFilterFactory.java \ - ImageProcessor.java \ - DialogType.java \ - URLFrame.java \ - DialogManager.java \ - ImageCanvas.java \ - ImageApp.java \ - BaseButton.java \ - FilePanel.java \ - StatusDisplay.java \ - Icon.java \ - Hierarchy.java \ - HierarchyAdapter.java \ - FileBrowser.java \ - ListFiles.java diff --git a/java/ImageProcessing/framework/Options.java b/java/ImageProcessing/framework/Options.java deleted file mode 100644 index edbe90ba904..00000000000 --- a/java/ImageProcessing/framework/Options.java +++ /dev/null @@ -1,25 +0,0 @@ -package imaging.framework; - -import java.awt.*; - -class Options -{ - // Set GridBagConstraints - public static void constrain (Container container, Component component, - int gridx, int gridy, - int gridwidth, int gridheight, - int fill, int anchor) - { - GridBagConstraints c = new GridBagConstraints (); - GridBagLayout gbl = (GridBagLayout) container.getLayout (); - - c.gridx = gridx; - c.gridy = gridy; - c.gridwidth = gridwidth; - c.gridheight = gridheight; - c.fill = fill; - c.anchor = anchor; - gbl.setConstraints (component, c); - container.add (component); - } -} diff --git a/java/ImageProcessing/framework/Separator.java b/java/ImageProcessing/framework/Separator.java deleted file mode 100644 index 6bd610e1ad9..00000000000 --- a/java/ImageProcessing/framework/Separator.java +++ /dev/null @@ -1,90 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A separator that is drawn either vertically or horizontally - * depending upon how it is laid out. Can be drawn either - * etched-in or etched-out, with varying thicknesses. Both - * thickness and etching are settable at construction time - * only.<p> - * - * Default thickness is 2 pixels and default etching is - * Etching.IN. Note that thicknesses greater than 4 loose the - * etching effect.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Etching - * @see gjt.test.SeparatorTest - */ -public class Separator extends Canvas { - static private Etching _defaultEtching = Etching.IN; - static private int _defaultThickness = 2; - - private Etching etching; - private int thickness; - - public Separator() { - this(_defaultThickness, _defaultEtching); - } - public Separator(int thickness) { - this(thickness, _defaultEtching); - } - public Separator(Etching etching) { - this(_defaultThickness, etching); - } - public Separator(int thickness, Etching etching) { - this.etching = etching; - this.thickness = thickness; - resize(thickness, thickness); - } - public Dimension minimumSize() { - return preferredSize(); - } - public Dimension preferredSize() { - return new Dimension(thickness, thickness); - } - public void paint(Graphics g) { - Dimension size = size(); - Color brighter = getBackground().brighter().brighter(); - Color darker = getBackground().darker().darker(); - - if(etching == Etching.IN) { - if(size.width > size.height) - paintHorizontal(g, size, darker, brighter); - else - paintVertical(g, size, darker, brighter); - } - else { - if(size.width > size.height) - paintHorizontal(g, size, brighter, darker); - else - paintVertical(g, size, brighter, darker); - } - } - public String paramString() { - Dimension size = size(); - Orientation orient = size.width > size.height ? - Orientation.HORIZONTAL : - Orientation.VERTICAL; - return super.paramString() + "thickness=" + - thickness + "," + etching + "," + orient; - } - private void paintHorizontal(Graphics g, Dimension size, - Color top, Color bottom) { - g.setColor(top); - g.fillRect(0, (size.height/2) - (thickness/2), - size.width, thickness/2); - g.setColor(bottom); - g.fillRect(0, size.height/2, size.width, thickness/2); - } - private void paintVertical(Graphics g, Dimension size, - Color left, Color right) { - g.setColor(left); - g.fillRect((size.width/2) - (thickness/2), - 0, thickness/2, size.height); - g.setColor(right); - g.fillRect(size.width/2, 0, thickness/2, size.height); - } -} diff --git a/java/ImageProcessing/framework/StatusDisplay.java b/java/ImageProcessing/framework/StatusDisplay.java deleted file mode 100644 index e20e9b8384d..00000000000 --- a/java/ImageProcessing/framework/StatusDisplay.java +++ /dev/null @@ -1,23 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import gjt.Separator; - -class StatusDisplay extends Panel -{ - public StatusDisplay () - { - this.setLayout (new BorderLayout ()); - this.textField_.setEditable (false); - this.add ("North", new Separator ()); - this.add ("Center", this.textField_); - this.add ("South", new Separator ()); - } - - public void setText (String s) - { - this.textField_.setText (s); - } - - private TextField textField_ = new TextField (); -} diff --git a/java/ImageProcessing/framework/URLFrame.java b/java/ImageProcessing/framework/URLFrame.java deleted file mode 100644 index d9cdca04a5c..00000000000 --- a/java/ImageProcessing/framework/URLFrame.java +++ /dev/null @@ -1,106 +0,0 @@ -package imaging.framework; - -import java.awt.*; -import java.awt.image.*; -import java.net.*; -import java.io.*; -import gjt.ComponentScroller; - -class URLFrame extends Frame -{ - public URLFrame (String title, ImageApp parent) - { - super (title); - - this.parent_ = parent; - this.resize (500,130); - this.setLayout (new BorderLayout ()); - - Panel textPanel = new Panel (); - textPanel.setLayout (new BorderLayout ()); - textPanel.add ("North", new Label ("Image Location:")); - textPanel.add ("Center", this.openURLText_); - - Panel buttonPanel = new Panel (); - buttonPanel.setLayout (new FlowLayout (FlowLayout.CENTER)); - buttonPanel.add (this.browseButton_); - buttonPanel.add (this.loadButton_); - buttonPanel.add (this.clearButton_); - buttonPanel.add (this.cancelButton_); - - this.add ("North", textPanel); - this.add ("South", buttonPanel); - this.loadButton_.nextFocus (); - } - - private int browseFiles () - { - String pString = this.openURLText_.getText (); - if (pString.compareTo ("ru") == 0) - pString = "http://www.cs/~pjain/java"; - - fileBrowser_ = new FileBrowser ("Browse", this.parent_); - // this.scroller_ = new ComponentScroller (fileBrowser_); - ListFiles list = new ListFiles (this.fileBrowser_, this.parent_); - return this.fileBrowser_.initialize (pString, list); - } - - // Handle all action events - public boolean action (Event e, Object arg) - { - if (e.target instanceof Button) - { - if (e.target == this.loadButton_) - { - this.parent_.openURL (this.openURLText_.getText ()); - this.dispose (); - } - else if (e.target == this.clearButton_) - { - this.openURLText_.setText (new String ()); - this.openURLText_.requestFocus (); - } - else if (e.target == this.cancelButton_) - this.dispose (); - else if (e.target == this.browseButton_) - { - this.dispose (); - ListFiles list = new ListFiles (); - switch (this.browseFiles ()) - { - case 1: - this.fileBrowser_.show (); - break; - case 0: - DialogManager.popDialog (DialogType.MALFORMED_URL, - "Error: Directory contains index.html"); - break; - default: - DialogManager.popDialog (DialogType.MALFORMED_URL, - "Error: Malformed URL"); - break; - } - } - - validate (); - return true; - } - else - return false; - } - - // Create the Open URL Frame and also the buttons which appear in - // it - private Button browseButton_ = new Button ("Browse"); - private Button loadButton_ = new Button ("Load"); - private Button clearButton_ = new Button ("Clear"); - private Button cancelButton_ = new Button ("Cancel"); - - private TextField openURLText_ = new TextField (40); - - private FileBrowser fileBrowser_ = null; - private ImageApp parent_; - private ComponentScroller scroller_; - -} - diff --git a/java/ImageProcessing/framework/doc01.gif b/java/ImageProcessing/framework/doc01.gif Binary files differdeleted file mode 100644 index 51262529f6d..00000000000 --- a/java/ImageProcessing/framework/doc01.gif +++ /dev/null diff --git a/java/ImageProcessing/framework/file03.gif b/java/ImageProcessing/framework/file03.gif Binary files differdeleted file mode 100644 index c98654c604b..00000000000 --- a/java/ImageProcessing/framework/file03.gif +++ /dev/null diff --git a/java/ImageProcessing/framework/filter.conf b/java/ImageProcessing/framework/filter.conf deleted file mode 100644 index 6b08bb69725..00000000000 --- a/java/ImageProcessing/framework/filter.conf +++ /dev/null @@ -1,5 +0,0 @@ -imaging.filters.UnsharpFilter -imaging.filters.MeanFilter -imaging.filters.SobelFilter -imaging.filters.SharpenFilter -imaging.filters.EmbossFilter diff --git a/java/ImageProcessing/framework/test.html b/java/ImageProcessing/framework/test.html deleted file mode 100644 index eedc08fb924..00000000000 --- a/java/ImageProcessing/framework/test.html +++ /dev/null @@ -1,15 +0,0 @@ -<HTML> - -<BODY text = "#000000" -link="#000fff" -vlink="#ff0f0f" -bgcolor="#888888"> - -<HR> -<APPLET CODEBASE="../../classes" CODE="imaging.framework.ImageApp.class" width=700 height=700> -<!param name=filename value="cow.gif"> -<param name=filename value="myphoto.gif"> -</APPLET> -<HR> - -</HTML>
\ No newline at end of file diff --git a/java/apps/NexusII/README b/java/apps/NexusII/README deleted file mode 100644 index 60a630cef5a..00000000000 --- a/java/apps/NexusII/README +++ /dev/null @@ -1,58 +0,0 @@ -Nexus II - A chat application in Java with image support --------------------------------------------------------- - - Rajeev Bector (rajeev@cs.wustl.edu) - Aravind Gopalan (aravind@cs.wustl.edu) - Sumedh Mungee (sumedh@cs.wustl.edu) - -This is the README file. This distribution contains the NexusII -server, which is a java application that can be started by a command -similar to the one contained in the sample "start" shell-script. - -It also contains a "start.html" file, which serves as an example on how -a client applet can be included within a .html file. - -A sample use of this, alongwith a simple users manual, can be found at -http://cumbia.cs.wustl.edu/NexusII/ - -Compiling (optional, all the class files are already present) -------------------------------------------------------------- - -All the source .java files, alongwith the makefile should be placed in -the same directory, and can then be compiled using make. - -The client/server use the following packages: - - awtCommand: This package provides a GUI toolkit for the applet - ACE: This is used both by the client/server for - networking. ACE documentation can be found at: - http://www.cs.wustl.edu/~schmidt/ACE.html - -Running -------- - -See the "start" and "start.html" files for examples on how to run the -server and client applet, respectively. The "mywebaddress" variable is -the "temporary" URL of the server, and the "mywebdir" variable is the -temporary directory in which images are cached by the server. Make -sure that both these exist and are world-readable. The "mywebdir" -should be writable to by the server. The "mywebdir" and "mywebaddress" -variables should thus point to the same location, of which mywebdir -contains the path, and mywebaddress contains the URL. - -See "start" for an example on how to do this. - -If you only want to use an existing running server, all you need to -know is the server host-name and port number, and you can directly run -the start.html file via appletviewer. - -Notes ------ - -1. You can compile the client and server using the same makefile. -2. The client applet MUST reside on the same host as the server is running on. -4. run the server using start script. Change the paramters in the start script, - suitable to your configurations. The start script contains further - information on this. - - diff --git a/java/apps/NexusII/classes/ClientHandler.class b/java/apps/NexusII/classes/ClientHandler.class Binary files differdeleted file mode 100644 index c6bf722c54f..00000000000 --- a/java/apps/NexusII/classes/ClientHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/FrameHandler.class b/java/apps/NexusII/classes/FrameHandler.class Binary files differdeleted file mode 100644 index 72d0c67ce70..00000000000 --- a/java/apps/NexusII/classes/FrameHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/ImageCanvas.class b/java/apps/NexusII/classes/ImageCanvas.class Binary files differdeleted file mode 100644 index eefcfe0f323..00000000000 --- a/java/apps/NexusII/classes/ImageCanvas.class +++ /dev/null diff --git a/java/apps/NexusII/classes/NexusClientApplet.class b/java/apps/NexusII/classes/NexusClientApplet.class Binary files differdeleted file mode 100644 index 8157ac32759..00000000000 --- a/java/apps/NexusII/classes/NexusClientApplet.class +++ /dev/null diff --git a/java/apps/NexusII/classes/NexusIIserver.class b/java/apps/NexusII/classes/NexusIIserver.class Binary files differdeleted file mode 100644 index f8e566ce282..00000000000 --- a/java/apps/NexusII/classes/NexusIIserver.class +++ /dev/null diff --git a/java/apps/NexusII/classes/Room.class b/java/apps/NexusII/classes/Room.class Binary files differdeleted file mode 100644 index a9d0d4f97bb..00000000000 --- a/java/apps/NexusII/classes/Room.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomFactory.class b/java/apps/NexusII/classes/RoomFactory.class Binary files differdeleted file mode 100644 index c1f92d83728..00000000000 --- a/java/apps/NexusII/classes/RoomFactory.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomFrame.class b/java/apps/NexusII/classes/RoomFrame.class Binary files differdeleted file mode 100644 index 4b648e1a8cc..00000000000 --- a/java/apps/NexusII/classes/RoomFrame.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomThread.class b/java/apps/NexusII/classes/RoomThread.class Binary files differdeleted file mode 100644 index 829fa4175cb..00000000000 --- a/java/apps/NexusII/classes/RoomThread.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CApplet.class b/java/apps/NexusII/classes/awtCommand/CApplet.class Binary files differdeleted file mode 100644 index 3af0361de76..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CApplet.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CApplet.java b/java/apps/NexusII/classes/awtCommand/CApplet.java deleted file mode 100644 index a8680d9abf3..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CApplet.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; -import java.applet.*; - -public class CApplet extends Applet { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - - /** - * Constructs a new CApplet. - */ - public CApplet() { - super(); - } - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /* - * set...Command methods - */ - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CButton.class b/java/apps/NexusII/classes/awtCommand/CButton.class Binary files differdeleted file mode 100644 index b64fecd5bbf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CButton.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CButton.java b/java/apps/NexusII/classes/awtCommand/CButton.java deleted file mode 100644 index ff0f3385bad..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CButton.java +++ /dev/null @@ -1,41 +0,0 @@ - -package awtCommand; - -import java.lang.*; -import java.awt.*; - -public class CButton extends java.awt.Button { - protected Command actionCommand = null; - - /** - * Constructs a CButton. - */ - public CButton() { - super(); - } - - /** - * Constructs a CButton with the given name. - */ - public CButton(String name) { - super(name); - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Called when the button is selected.. - * This results in a call to the actionCommand object - * with <code>what</code> set to the button's label. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CCanvas.class b/java/apps/NexusII/classes/awtCommand/CCanvas.class Binary files differdeleted file mode 100644 index 5d697017b5b..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CCanvas.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CCanvas.java b/java/apps/NexusII/classes/awtCommand/CCanvas.java deleted file mode 100644 index 837b6f56f7a..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CCanvas.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CCanvas extends Canvas { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - - /** - * Constructs a new CCanvas. - */ - public CCanvas() { - super(); - } - - /** - * Handles the event. - * Calls methods for variousL events and passes - * others to its superclass method. - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /* - * set...Command methods - */ - - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} diff --git a/java/apps/NexusII/classes/awtCommand/CFrame.class b/java/apps/NexusII/classes/awtCommand/CFrame.class Binary files differdeleted file mode 100644 index 66f25773c76..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CFrame.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CFrame.java b/java/apps/NexusII/classes/awtCommand/CFrame.java deleted file mode 100644 index f63d3ce8b9a..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CFrame.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CFrame extends Frame { - - protected Command destroyCommand = null, - deiconifyCommand = null, - iconifyCommand = null, - movedCommand = null; - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - /** - * Constructs a new, initially invisible CFrame. - */ - public CFrame() { - super(); - } - - /** - * Constructs a new, initially invisible CFrame with the - * specified title. - */ - public CFrame(String title) { - super(title); - } - - /** - * Handles the event - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.WINDOW_DESTROY: - return windowDestroy(evt); - case Event.WINDOW_DEICONIFY: - return windowDeiconify(evt); - case Event.WINDOW_ICONIFY: - return windowIconify(evt); - case Event.WINDOW_MOVED: - return windowMoved(evt); - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - /** - * Called if the dialog's window is destroyed. This results in a call to - * the destroyCommand object with <code>what</code> set to null - */ - public boolean windowDestroy(Event evt) { - if (destroyCommand != null) - destroyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog's window is deiconified. This results in a call to - * the deiconifyCommand object with <code>what</code> set to null - */ - public boolean windowDeiconify(Event evt) { - if (deiconifyCommand != null) - deiconifyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog is iconified. This results in a call to - * the iconifyCommand object with <code>what</code> set to null - */ - public boolean windowIconify(Event evt) { - if (iconifyCommand != null) - iconifyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog's window is moved. This results in a call to - * the movedCommand object with <code>what</code> set to Point(x, y) - */ - public boolean windowMoved(Event evt) { - if (movedCommand != null) - movedCommand.execute(this, evt, new Point(evt.x, evt.y)); - return false; - } - - /* - * I don't know where what objects this next set should belong - * to. Putting them at the top is ok for now - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /* - * set...Command methods - */ - - - /** - * Sets the destroyCommand object. - */ - public void setDestroyCommand(Command c) { - destroyCommand = c; - } - - /** - * Sets the deiconifyCommand object. - */ - public void setDeiconifyCommand(Command c) { - deiconifyCommand = c; - } - - /** - * Sets the iconifyCommand object. - */ - public void setIconifyCommand(Command c) { - iconifyCommand = c; - } - - /** - * Sets the movedCommand object. - */ - public void setMovedCommand(Command c) { - movedCommand = c; - } - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - public void setGotFocusCommand(Command c) { - gotFocusCommand = c ; - } - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} - - - - - - - - - - - - - diff --git a/java/apps/NexusII/classes/awtCommand/CList.class b/java/apps/NexusII/classes/awtCommand/CList.class Binary files differdeleted file mode 100644 index c595ce7786b..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CList.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CList.java b/java/apps/NexusII/classes/awtCommand/CList.java deleted file mode 100644 index 110e6a01db2..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CList.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - - -package awtCommand; - -import java.awt.*; - -public class CList extends List { - protected Command selectCommand = null; - protected Command deselectCommand = null; - protected Command actionCommand = null; - - /** - * Handles the event - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - - /** - * Called if the Enter key is pressed. - * This results in a call to the actionCommand object - * with <code>what</code> set to the selected item. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /** - * Sets the actionCommand. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CPanel.class b/java/apps/NexusII/classes/awtCommand/CPanel.class Binary files differdeleted file mode 100644 index d00477a30f5..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CPanel.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CPanel.java b/java/apps/NexusII/classes/awtCommand/CPanel.java deleted file mode 100644 index 1c8d39f8537..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CPanel.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CPanel extends Panel { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - /** - * Constructs a new CPanel. - */ - public CPanel() { - super(); - } - - - /** - * Handles the event. - * Calls methods for variousL events and passes - * others to its superclass method. - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - /* - * set...Command methods - */ - - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} diff --git a/java/apps/NexusII/classes/awtCommand/CTextArea.class b/java/apps/NexusII/classes/awtCommand/CTextArea.class Binary files differdeleted file mode 100644 index 9ec6e238cdf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextArea.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CTextArea.java b/java/apps/NexusII/classes/awtCommand/CTextArea.java deleted file mode 100644 index eacaf526929..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextArea.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CTextArea extends TextArea { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - - /** - * Constructs a new TextArea. - */ - public CTextArea() { - super(); - } - - /** - * Constructs a new TextArea with the specified number of rows and columns. - * @param rows the number of rows - * @param cols the number of columns - */ - public CTextArea(int rows, int cols) { - super(rows, cols); - } - - /** - * Constructs a new TextArea with the specified text displayed. - * @param text the text to be displayed - */ - public CTextArea(String text) { - super(text); - } - - /** - * Constructs a new TextArea with the specified text and the - * specified number of rows - * and columns. - * @param text the text to be displayed - * @param rows the number of rows - * @param cols the number of cols - */ - public CTextArea(String text, int rows, int cols) { - super(text, rows, cols); - } - - - /** - * Called when the text area gains the focus. - * This results in a call to the gotFocusCommand object - * with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text area loses the focus. - * This results in a call to the lostFocusCommand object - * with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Sets the gotFocusCommand object. - */ - public void setGotFocusCommand(Command c) { - gotFocusCommand = c; - } - - /** - * Sets the lostFocusCommand object. - */ - public void setLostFocusCommand(Command c) { - lostFocusCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CTextField.class b/java/apps/NexusII/classes/awtCommand/CTextField.class Binary files differdeleted file mode 100644 index 6f298a43348..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextField.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CTextField.java b/java/apps/NexusII/classes/awtCommand/CTextField.java deleted file mode 100644 index 146f13206e5..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextField.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CTextField extends TextField { - - protected Command actionCommand = null, - gotFocusCommand = null, - lostFocusCommand = null; - - /** - * Constructs a new CTextField. - */ - public CTextField() { - super(); - } - - /** - * Constructs a new CTextField initialized with the specified columns. - * @param cols the number of columns - */ - public CTextField(int cols) { - super(cols); - } - - /** - * Constructs a new CTextField initialized with the specified text. - * @param text the text to be displayed - */ - public CTextField(String text) { - super(text); - } - - - /** - * Constructs a new CTextField initialized with the specified text and columns. - * @param text the text to be displayed - * @param cols the number of columns - */ - public CTextField(String text, int cols) { - super(text, cols); - } - - - /** - * Called when Enter is pressed in the text field. - * This results in a call to the actionCommand object - * with <code>what</code> set to the text contents. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text field gains the focus. - * This results in a call to the gotFocusCommand object - * with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text field loses the focus. - * This results in a call to the lostFocusCommand object - * with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command c) { - actionCommand = c; - } - - - /** - * Sets the gotFocusCommand object. - */ - public void setGotFocusCommand(Command c) { - gotFocusCommand = c; - } - - /** - * Sets the lostFocusCommand object. - */ - public void setLostFocusCommand(Command c) { - lostFocusCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/Command.class b/java/apps/NexusII/classes/awtCommand/Command.class Binary files differdeleted file mode 100644 index 6b3c12c24f7..00000000000 --- a/java/apps/NexusII/classes/awtCommand/Command.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/Command.java b/java/apps/NexusII/classes/awtCommand/Command.java deleted file mode 100644 index 373c7a363cf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/Command.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - - - -package awtCommand; - -import java.awt.*; - -public interface Command { - - /** - * Executes application logic. - * Called by events occurring in associated objects - */ - public abstract void execute(Object target, Event evt, Object what); -} diff --git a/java/apps/NexusII/classes/commandHandler.class b/java/apps/NexusII/classes/commandHandler.class Binary files differdeleted file mode 100644 index 53033fb6b6b..00000000000 --- a/java/apps/NexusII/classes/commandHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/commandParser.class b/java/apps/NexusII/classes/commandParser.class Binary files differdeleted file mode 100644 index 62da40871e6..00000000000 --- a/java/apps/NexusII/classes/commandParser.class +++ /dev/null diff --git a/java/apps/NexusII/classes/connectionHandler.class b/java/apps/NexusII/classes/connectionHandler.class Binary files differdeleted file mode 100644 index 8708229c0eb..00000000000 --- a/java/apps/NexusII/classes/connectionHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/joinHandler.class b/java/apps/NexusII/classes/joinHandler.class Binary files differdeleted file mode 100644 index 7669e7faed7..00000000000 --- a/java/apps/NexusII/classes/joinHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/roomHandler.class b/java/apps/NexusII/classes/roomHandler.class Binary files differdeleted file mode 100644 index 9eaa6cc0899..00000000000 --- a/java/apps/NexusII/classes/roomHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/textHandler.class b/java/apps/NexusII/classes/textHandler.class Binary files differdeleted file mode 100644 index c52764a236b..00000000000 --- a/java/apps/NexusII/classes/textHandler.class +++ /dev/null diff --git a/java/apps/NexusII/src/Consumer.java b/java/apps/NexusII/src/Consumer.java deleted file mode 100644 index 84df9b3a3ae..00000000000 --- a/java/apps/NexusII/src/Consumer.java +++ /dev/null @@ -1,74 +0,0 @@ - -// This class encapsulates a Consumer. The consumer dq's from the queue -// Supports both a timed and blocking consumer. -// Each instance of this class creates a different thread of control. -// On timeout, the producer returns. -// The producer tries to dq "iteration" number of times, unless it times out - -//package NexusII.util ; - -public class Consumer extends Thread -{ -public static final int DEFAULT_ITERATIONS = 1 ; -public Consumer(MT_Bounded_Queue queue) - { - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -public Consumer(MT_Bounded_Queue queue, String name) - { - super(name); - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - - -public Consumer(MT_Bounded_Queue queue, String name, Integer iterations) - { - super(name); - this.queue_ = queue ; - this.iterations_ = iterations ; - this.time_out_ = -1 ; - } - - -public Consumer(MT_Bounded_Queue queue, String name, Integer iterations, long msec_timeout) - { - super(name); - this.queue_ = queue ; - this.iterations_ = iterations ; - this.time_out_ = msec_timeout ; - } - - - -public void run() - { - for(int i=0;i<iterations_.intValue();i++) - { - if(time_out_ < 0) - System.out.println(getName() + ": dequeued " + queue_.dq()); - else - { - Object err = queue_.dq(time_out_); - if(err == null) - { - System.out.println(getName() + ": Timedout\n"); - return ; - } - - else - System.out.println(getName() + ": dequeued " + err); - } - } - } - - -protected MT_Bounded_Queue queue_ ; -private Integer iterations_ ; -private long time_out_ ; -} - diff --git a/java/apps/NexusII/src/MT_Bounded_Queue.java b/java/apps/NexusII/src/MT_Bounded_Queue.java deleted file mode 100644 index a9b493fa263..00000000000 --- a/java/apps/NexusII/src/MT_Bounded_Queue.java +++ /dev/null @@ -1,226 +0,0 @@ - -// package NexusII.util ; - -// The minimun functionality to be associated with a queue -interface Queue -{ -public void nq(Object item); -public Object dq(); -public boolean is_full(); -public boolean is_empty(); -public static final int DEF_SIZE = 1; -}; - -// Specific Conditions associated with MT_Bounded_Queue -// Is true if there is space in the queue - -class Not_Full_Condition extends Timed_Wait -{ - -public Not_Full_Condition(MT_Bounded_Queue q) - { - super(q); - } - -public synchronized boolean condition() - { - MT_Bounded_Queue mq_ = (MT_Bounded_Queue) object_; - return !mq_.is_full (); - } - -} - -// Is true if there's something in the queue - -class Not_Empty_Condition extends Timed_Wait -{ - -public Not_Empty_Condition(MT_Bounded_Queue q) - { - super(q); - } - -public synchronized boolean condition() - { - // Delegate to the appropriate conditional - // check on the MessageQueue. - MT_Bounded_Queue mq_ = (MT_Bounded_Queue) object_; - return !mq_.is_empty (); - } - -private MT_Bounded_Queue mq_ ; -} - - - - -// Encapsulates a bounded - synchronized queue - -public class MT_Bounded_Queue implements Queue -{ - - -private Object[] queue_ ; -private int front_ ; -private int back_ ; -private int max_size_ ; -private int size_ ; -private Not_Empty_Condition not_empty_condition_ ; -private Not_Full_Condition not_full_condition_ ; -private int nq_count_ ; -private int dq_count_ ; - -// The counters counts the number of nq's and dq's operations made on this -// instance of the queue - -public int dq_count() -{ - return dq_count_ ; -} - -public int nq_count() -{ - return nq_count_ ; -} - -public MT_Bounded_Queue() - { - // call the other constructor with DEF_SIZE - this(DEF_SIZE); - } - -public MT_Bounded_Queue(int max_size) - { - this.front_ = 0 ; - this.back_ = 0 ; - this.max_size_ = max_size ; - this.size_ = 0 ; - // these are included for STATISTICS - this.nq_count_ = 0 ; - this.dq_count_ = 0 ; - this.queue_ = new Object[this.max_size_]; - not_full_condition_ = new Not_Full_Condition(this); - not_empty_condition_ = new Not_Empty_Condition(this); - } - -// Blocking nq -public synchronized void nq(Object item) - { - // Wait till the queue has space - while(is_full()) - { - try { - wait(); - } catch (InterruptedException e) {} - } - - // enqueue here - queue_[back_] = item ; - back_ = (back_ + 1) % max_size_ ; - size_++ ; - // One more enqueue operation has occured - nq_count_ ++ ; - // wakeup the sleeping guys - notifyAll(); - } - - // Timed nq -// returns -1 if timed_out -public synchronized int nq(Object item,long msec_timeout) - { - // Wait till the queue has space - try { - not_full_condition_.timed_wait(msec_timeout); - } catch (InterruptedException e) {} - catch (TimeoutException t) - { - return -1 ; - } - - // enqueue here - queue_[back_] = item ; - back_ = (back_ + 1) % max_size_ ; - size_++ ; - - // One more enqueue operation has occured - nq_count_ ++ ; - // wakeup the sleeping consumers - not_empty_condition_.broadcast (); - return 0 ; - } - - - - - // Blockin dq -public synchronized Object dq() - { - // wait till the queue has something in it - while(is_empty()) - { - try { - wait(); - } catch (InterruptedException e) {} - } - - // dequeue here - Object return_object = queue_[front_] ; - front_ = (front_ + 1) % max_size_ ; - size_ -- ; - // One more enqueue operation has occured - dq_count_ ++ ; - //wake up the sleeping producers - notifyAll(); - return return_object ; - } - - - // Timed dq - -public synchronized Object dq(long msec_timeout) - { - // wait till the queue has something in it - try { - not_empty_condition_.timed_wait(msec_timeout); - } catch (InterruptedException e) {} - catch (TimeoutException t) - { - return null; - } - - // dequeue here - Object return_object = queue_[front_] ; - front_ = (front_ + 1) % max_size_ ; - size_ -- ; - - // One more enqueue operation has occured - dq_count_ ++ ; - - //wake up the sleeping guys - not_full_condition_.broadcast(); - return return_object ; - } - -public boolean is_empty() - { - if (size_ == 0) - return true ; - else - return false ; - - } - -public boolean is_full() - { - if (size_ == max_size_) - return true ; - else - return false ; - } - -} - - - - - diff --git a/java/apps/NexusII/src/MT_Bounded_Queue_Group.java b/java/apps/NexusII/src/MT_Bounded_Queue_Group.java deleted file mode 100644 index 734dc51a84b..00000000000 --- a/java/apps/NexusII/src/MT_Bounded_Queue_Group.java +++ /dev/null @@ -1,79 +0,0 @@ -//package NexusII.server; - -//import NexusII.util.*; -import java.util.*; - - -public class MT_Bounded_Queue_Group { - - public Vector q_group_ = new Vector(); - - public MT_Bounded_Queue_Group(int num) { - - q_group_ = new Vector(num); - - } - - public MT_Bounded_Queue_Group() { - - // q_group_ = new Vector(); - - } - - public String toString() { - - return q_group_.toString(); - - } - - // always returns true - public boolean addToGroup(MT_Bounded_Queue q) { - - q_group_.addElement(q); - return true; // for now - - } - - - // returns false if the q was not part of the group - public boolean delFromGroup(MT_Bounded_Queue q) { - - return q_group_.removeElement(q); - - } - - - public boolean checkInGroup(MT_Bounded_Queue q) { - - return q_group_.contains(q); - - } - - - // returns number of q's on which data was successfully enqueued - public int nq(Object o) { - - if(q_group_.isEmpty() ) - return 0; - - Enumeration e = q_group_.elements(); - - int i = 0; - while(e.hasMoreElements()) { - - MT_Bounded_Queue q = (MT_Bounded_Queue) e.nextElement(); - q.nq(o); - i++; - - } - - return i; - } - -} - - - - - - diff --git a/java/apps/NexusII/src/NexusClientApplet.java b/java/apps/NexusII/src/NexusClientApplet.java deleted file mode 100644 index 58b26930718..00000000000 --- a/java/apps/NexusII/src/NexusClientApplet.java +++ /dev/null @@ -1,494 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:10:59 sumedh - Added the Nexus II source code files. - -# Revision 1.3 1996/12/06 07:25:29 rajeev -# Got SetRoomName to work -- needed for LROOMS -# -# Revision 1.2 1996/12/06 04:48:21 rajeev -# added handling for l_users and L_room packets from server -# -# Revision 1.1 1996/12/06 03:37:22 rajeev -# Initial revision -# - - This is the client applet - Part of Nexus-II project !! - Copyright : Aravind Gopalan, Rajeev Bector, Sumedh Mungee -*/ - -// package NexusII; - -// I hate packages - -import java.applet.Applet; -import java.awt.* ; -import java.io.*; -import java.net.*; -import java.util.*; - -//import NexusII.networking.* ; -//import NexusII.client.* ; -//import NexusII.util.* ; - -// get the awtCommand package now -import awtCommand.* ; - -// The applet runs the root thread -- easy access to graphics now ... - -public class NexusClientApplet extends CApplet implements consts,Runnable { - - // Who am I -- will be modified if the /nick command is given - public static String myName = new String("anonymous"); - - /* All Event Handlers */ - - // To check if applet is connected - boolean connected = false; - - // The connector handler - connectionHandler nexusConnector ; - - // join handler - joinHandler nexusJoiner ; - - // command handler - commandParser nexusParser ; - - commandHandler commandLineHandler ; - // Streams for writing and reading from Socket - DataOutputStream outStream; - DataInputStream inStream; - - // Thread which does everything for the applet - Thread mainThread ; - - // this is just a visit - // host where I live actually ;-) - String host; - - // Which server to connect to - Integer serverPort ; - - // Where are the queues for reading and writing - // reader and writers will access these and also the interpretor and dep. - - MT_Bounded_Queue read_q ; - MT_Bounded_Queue write_q ; - MT_Bounded_Queue root_q ; - // Where Aravind writes his commands - MT_Bounded_Queue command_q ; - - - - - // *********************************************************** - // Graphics objects - // *********************************************************** - - // Total applet size - int minWidth_ = 500; - int minHeight_ = 450; - - // State variables needed to be maintained - boolean connected_ = false; - int numRooms_ = 0; - - // Buttons - private CButton bConn; - private CButton bJoin; - private CButton bLeave; - private CButton bRooms; - private CButton bUsers; - - private CTextField tfCommandLine = new CTextField(80); - private CTextField tfRoomName = new CTextField(16); - private List lRooms = new List(10,false); - private Label roomLabel = new Label("Rooms:"); - private List lUsers = new List(10,false); - private Label userLabel = new Label("Users:"); - -// private RoomSpace roomspace = new RoomSpace(); - private Panel roomspace = new Panel(); - - public Dimension preferredSize() { - return minimumSize(); - } - - public Dimension minimumSize() { - return new Dimension(minWidth_, minHeight_); - } - - // ----------------------------------------------------------------- - // Basically draws up all the components (not sub-components) of the - // Applet window ... - // Pretty much straightforward barring quirks of AWT -- ArGo - void SetUpButtons(GridBagLayout gbl, GridBagConstraints gbc) { - // The Connect Button - gbc.weightx = 1.0; - gbc.weighty = 0.5; - gbc.gridx = 2; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.CENTER; - gbc.ipady = 5; - bConn = new CButton("Connect"); - bConn.setActionCommand(nexusConnector); - gbl.setConstraints(bConn, gbc); - add(bConn); - gbc.ipady = 0; - - // The remaining buttons - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.CENTER; - gbc.weightx = 1.0; - gbc.weighty = 0.5; - gbc.insets = new Insets(2,2,2,2); - gbc.ipadx = 2; - gbc.ipady = 2; - - // Join Button - gbc.gridx = 0; - gbc.gridy = 3; - bJoin = new CButton("Join"); - gbl.setConstraints(bJoin,gbc); - add(bJoin); - - // Leave Button - gbc.gridx = 1; - gbc.gridy = 3; - bLeave = new CButton("Leave"); - gbl.setConstraints(bLeave,gbc); - add(bLeave); - - // List Rooms Button - gbc.gridx = 0; - gbc.gridy = 4; - bRooms = new CButton("List Rooms"); - gbl.setConstraints(bRooms,gbc); - add(bRooms); - - // List Users Button - gbc.gridx = 1; - gbc.gridy = 4; - bUsers = new CButton("List Users"); - gbl.setConstraints(bUsers,gbc); - add(bUsers); - - } // of SetUpButtons - - void SetUpGraphics() { - - resize(preferredSize()); - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(new Font("Helvetica", Font.PLAIN, 14)); - setLayout (gbl); - - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // For the list of rooms - // First the Room list label - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.SOUTHWEST; - gbc.fill = GridBagConstraints.NONE; - gbl.setConstraints(roomLabel,gbc); - add(roomLabel); - // Now the Room combo -- list + text field - // the actual list - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.anchor = GridBagConstraints.NORTH; - // gbc.insets = new Insets(0,2,0,2); - gbl.setConstraints(lRooms,gbc); - add(lRooms); - if (DEBUG) - lRooms.addItem("Room_1"); - // The text field - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy = 2; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(0,0,0,0); - gbl.setConstraints(tfRoomName,gbc); - add(tfRoomName); - - // Similarly for the list of users - // label - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.SOUTHWEST; - gbc.fill = GridBagConstraints.NONE; - gbc.insets = new Insets(0,0,0,0); - gbl.setConstraints(userLabel,gbc); - add(userLabel); - // The list - gbc.weightx = 1; - gbc.weighty = 1; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.anchor = GridBagConstraints.NORTH; - gbl.setConstraints(lUsers,gbc); - add(lUsers); - if (DEBUG) - lUsers.addItem("USer #1"); - - // Setup all the buttons - SetUpButtons(gbl,gbc) ; - - // The command line - gbc.gridx = 0; - gbc.gridy = 5; - gbc.ipadx = 0; - gbc.ipady = 0; - gbc.insets = new Insets(0,0,0,0); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.CENTER; - gbl.setConstraints(tfCommandLine,gbc); - add(tfCommandLine); - - - // We are done -- startup with all buttons except connect disabled - OnDisconnect(); - return; - } - - public void init() { - //Get the address of the host the applet was downloaded from - host = getCodeBase().getHost(); - // Get servers portnumber from the home page - serverPort = Integer.valueOf(getParameter("serverport")); - - - // Create the nexusconnector object whose execute will be called later - // on pressing the connect button - nexusConnector = new connectionHandler(host,serverPort,this); - - if(DEBUG){ - System.out.println("Server Portnumber is " + serverPort + "\n"); - } - - // initialize the graphics - SetUpGraphics(); - } // of method init - - public synchronized void start() { - // Aravind will create the "connect" button here and register an instance - - if (DEBUG) { - System.out.println("In start() method."); - } - } - - - // Here is the stop for the applet - // Called when the user goes away from the page - public synchronized void stop() { - if (!DEBUG) { - showStatus("Stop has been called "); - } - - if (connected) { - nexusConnector.execute(null,null,null); - } - } - - - - - // ----------------------------------------------------------------------- - // Public Access functions - public Hashtable Mapper() { - return nexusJoiner.Mapper(); - } - - public String GetRoomName() { - StringTokenizer t = new StringTokenizer(tfRoomName.getText()); - if(t.hasMoreTokens()) { - return t.nextToken(); - } - else - return "" ; - } - - public void AddRoomName(String name) { - int count = lRooms.countItems(); - for (int i=0;i<count;i++) - if (lRooms.getItem(i).equalsIgnoreCase(name)) - return; - lRooms.addItem(name); - } - - public void SetRoomName(String name) { - int count = lRooms.countItems(); - for(int i=0;i<count;i++) { - if(lRooms.getItem(i).equalsIgnoreCase(name)) { - // Have to simulate a select event by doing the selection ourselves - lRooms.select(i); - tfRoomName.setText(lRooms.getSelectedItem()); - tfRoomName.selectAll(); - break ; - } - } - } - - public void sendNickToServer(String name) { - nexusJoiner.sendTestPacket("ROOT","NICK",name,nexusConnector.writer_q()); - } - - - // will run the mainthread - public void run() { - if(DEBUG) { - System.out.println("Root thread is starting -- "); - } - - root_q = new MT_Bounded_Queue(QUEUE_SIZE); - nexusJoiner.Mapper().put("ROOT",root_q); - // continously wait for something to read and then update the graphics - // objects ---- - if(DEBUG) { - nexusJoiner.sendTestPacket("ROOT","LROOMS","a b c d",root_q); - } - - for(;;) { - dataPacket rootPacket = (dataPacket)root_q.dq(); - if(DEBUG) { - System.out.println("Root got a packet --- "); - } - if(rootPacket.contentType().equalsIgnoreCase("LROOMS")) { - update_lrooms(rootPacket.content()); - } - else if(rootPacket.contentType().equalsIgnoreCase("LUSERS")) { - update_lusers(rootPacket.destination(),rootPacket.content()); - } - } - - } - - - - // This method will update the graphics of lrooms - void update_lrooms(String data) { - lRooms.disable(); - tfRoomName.disable(); - lRooms.clear(); - - StringTokenizer t = new StringTokenizer(data); - while(t.hasMoreTokens()) { - lRooms.addItem(t.nextToken()); - } - if (lRooms.countItems() != 0) { - lRooms.select(0); - tfRoomName.setText(lRooms.getItem(0)); - } - tfRoomName.enable(); - lRooms.enable(); - repaint(); - } - - void update_lusers(String name,String data) { - lUsers.disable(); - userLabel.setText("Users: "+ name); - lUsers.clear(); - StringTokenizer t = new StringTokenizer(data); - while(t.hasMoreTokens()) { - lUsers.addItem(t.nextToken()); - } - lUsers.enable(); - repaint(); - } - - // ----------------------------------------------------------------------- - // User Input handling -- ArGo - - // Function to handle Connect button being pressed - public void OnConnect(){ - // Create the event handlers -- - nexusJoiner = new joinHandler(nexusConnector.writer_q(),this); - nexusParser = new commandParser(nexusConnector.writer_q(),this); - commandLineHandler = new commandHandler(this); - // start the main thread in the applets context - mainThread = new Thread(this); - mainThread.start(); - // test - // Graphics here -- - bJoin.enable(); - bJoin.setActionCommand(nexusJoiner); - bLeave.enable(); - bLeave.setActionCommand(nexusJoiner); - bRooms.enable(); - bRooms.setActionCommand(nexusParser); - bUsers.enable(); - bUsers.setActionCommand(nexusParser); - tfCommandLine.enable(); - tfCommandLine.setActionCommand(commandLineHandler); - tfRoomName.enable(); - lRooms.enable(); - lUsers.enable(); - // Change the name to "Disconnect" and ensure that update happens - bConn.setLabel("Disconnect"); - validate(); // Don't know if this is necessary - connected = true; // Applet is now connected - } - - // Function to handle Connect button being pressed - public void OnDisconnect(){ - bJoin.disable(); - bLeave.disable(); - bRooms.disable(); - bUsers.disable(); - tfCommandLine.disable(); - tfRoomName.disable(); - lRooms.disable(); - lUsers.disable(); - // Change the name back to "Connect" and ensure update happens - bConn.setLabel("Connect"); - validate(); - // Stop the ROOT room thread - if (connected) { - mainThread.stop(); - connected = false; // Applet is disconnected - } - } - - // Basically take care of the inputs - public boolean handleEvent(Event event) { - if (event.target == lRooms) { - if (event.id == Event.LIST_SELECT) { // selected the item - tfRoomName.setText(lRooms.getSelectedItem()); - tfRoomName.selectAll(); - if (DEBUG) - System.out.println("Actually handling the select event"); - return true; - } - } - return super.handleEvent(event); - } - - public void update(Graphics g) { - paint(g); - } -} // of class NexusClientApplet - - - diff --git a/java/apps/NexusII/src/NexusIIserver.java b/java/apps/NexusII/src/NexusIIserver.java deleted file mode 100644 index e3b5a52acd5..00000000000 --- a/java/apps/NexusII/src/NexusIIserver.java +++ /dev/null @@ -1,280 +0,0 @@ -// The Nexus II server. -// Sumedh Mungee <sumedh@cs.wustl.edu> - -import java.net.*; -import java.io.*; -import java.util.*; -import ACE.OS.*; -import ACE.SOCK_SAP.*; - -public class NexusIIserver implements consts { - - // Entry point into the server - public static void main(String args[]) throws IOException { - - if(args.length != 1) { - System.out.println("Usage: java NexusIIserver <port_num>"); - return; - } - - // Create a "Hotel", which is a factory to generate Rooms - // as and when required. - RoomFactory Hotel = new RoomFactory(); - - System.out.println("NexusII server booting"); - SOCKAcceptor sacceptor = new SOCKAcceptor( (new Integer(args[0])).intValue()); - - System.out.println("NexusII is now accepting connections on port " + (new Integer(args[0])).intValue()); - - for(;;) { - - SOCKStream s = new SOCKStream(); - sacceptor.accept(s); - // Accepted connection - // construct a client handler.. - // Pass in the connected socket as an argument, - // and a reference to the Hotel, in case it needs - // to create rooms.. - // and away you go.. - new Thread(new ClientHandler(s, Hotel)).start(); - - } - } -} - - -// This thread handles the clients.. -// It uses 2 additional threads for read/write network operations -// These threads are dedicated to read/write from the -// respective read/write queues.. -class ClientHandler implements Runnable,consts { - - private SOCKStream s_; - private RoomFactory Hotel_; - private MT_Bounded_Queue rq_ = new MT_Bounded_Queue(QUEUE_SIZE); - private MT_Bounded_Queue wq_ = new MT_Bounded_Queue(QUEUE_SIZE); - private String my_name_; - private Vector roomlist_ = new Vector(); - private boolean finished_ = false; - private String init_image_; - - public ClientHandler(SOCKStream s, RoomFactory h) { - s_ = s; - Hotel_ = h; - init_image_ = new String(System.getProperty("mywebaddress") + NEXUS_LOGO); - } - - public void run() { - // Construct the reader/writer threads with the queues and the - // corresponding socket data streams as parameters. - Thread r_ = new socketReaderThread(rq_, new DataInputStream(s_.inputStream())); - Thread w_ = new socketWriterThread(wq_, new DataOutputStream(s_.outputStream())); - r_.start(); - w_.start(); - - // now start parsing the messages, and take action.. - // todo: optimize the below.. - - while(!finished_) { - dataPacket d = (dataPacket) rq_.dq(); - if(d.contentType().startsWith("INIT")) - nexus_init(d); - if(d.contentType().startsWith("JOIN")) - nexus_join(d); - if(d.contentType().startsWith("LEAVE")) - nexus_leave(d); - if(d.contentType().startsWith("QUIT")) - nexus_quit(d); - if(d.contentType().startsWith("TEXT")) - nexus_text(d); - if(d.contentType().startsWith("LUSERS")) - nexus_lusers(d); - if(d.contentType().startsWith("LROOMS")) - nexus_lrooms(d); - if(d.contentType().startsWith("NICK")) - nexus_nick(d); - if(d.contentType().startsWith("URL")) - nexus_url(d); - } - } - - // The following classes implement the server functions.. - - private void nexus_init(dataPacket packet) { - my_name_ = new String(packet.clientName()); - wq_.nq(packet); - } - - private void nexus_join(dataPacket packet) { - Room r = Hotel_.getRoom(packet.content()); - if(r.checkClient(this)) - return; - r.addClient(this); - roomlist_.addElement(r); - writeRoom(r, my_name_ + " has joined the room "); - String contenttype = new String("url"); - dataPacket d = new dataPacket(my_name_, packet.content(), contenttype, (new Integer(init_image_.length())).toString() , init_image_); - wq_.nq(d); - } - - private void nexus_text(dataPacket packet) { - Room r = Hotel_.getRoom(packet.destination()); - r.getQ().nq(packet); - } - - private void nexus_lusers(dataPacket packet) { - - Room r = Hotel_.getRoom(packet.content()); - Enumeration e = r.clientList(); - StringBuffer sb = new StringBuffer(); - while(e.hasMoreElements()) - sb.append(" " + ((ClientHandler)e.nextElement()).getName() + " "); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(sb.length())).toString(), sb.toString()); - wq_.nq(d); - } - - private void nexus_lrooms(dataPacket packet) { - String s = Hotel_.listRooms(); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(s.length())).toString(), s.toString()); - wq_.nq(d); - } - - private void nexus_nick(dataPacket packet) { - Enumeration e = roomlist_.elements(); - while(e.hasMoreElements()) - writeRoom((Room)e.nextElement(), my_name_ + " is now known as " + packet.content()); - - my_name_ = new String(packet.content()); - } - - private void nexus_leave(dataPacket packet) { - - Room r = Hotel_.getRoom(packet.content()); - writeRoom(r, my_name_ + " has left the room " + packet.content()); - if(r.delClient(this)) Hotel_.delRoom(r); - roomlist_.removeElement(r); - } - - private void nexus_quit(dataPacket packet) { - - Enumeration e = roomlist_.elements(); - while(e.hasMoreElements()) { - Room r = (Room)e.nextElement(); - writeRoom(r, my_name_ + " has quit " ); - r.delClient(this); - } - finished_ = true; - } - - private void nexus_url(dataPacket packet) { - try { - URL u = new URL(packet.content()); - - // first extract the filename stripped of its path. - int index = u.getFile().lastIndexOf("/"); - String infilename = u.getFile().substring(index + 1); - - // next construct the name of the temporary file - String outfilename = (System.getProperty("mywebdir") + "_" + packet.destination() + "." + infilename); - - // now the temporary URL assigned to this request - String imageURL = new String(System.getProperty("mywebaddress") + "_" + packet.destination() + "." + infilename); - - // Open temporary file for writing - FileOutputStream fout = new FileOutputStream(outfilename); - - // Now contact alien ship - InputStream i = u.openStream(); - byte[] buffer = new byte[1024]; - - // And download the image - for(;;) { - int num = i.read(buffer); - if(num < 0) - break; - fout.write(buffer, 0, num); - } - - fout.close(); - i.close(); - - // Get room for which this request was issued - Room r = Hotel_.getRoom(packet.destination()); - - // invalidate previous entry - File f = new File(r.getLastImageName()); - if(f.exists()) f.delete(); - - // add new image name - r.putNextImageName(outfilename); - writeRoom(r,"Asynchronously transferring image " + packet.content() + " from " + my_name_ ); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(imageURL.length())).toString(), imageURL); - r.getQ().nq(d); // multicast this imageURL onto the room.. - - } - catch(java.net.MalformedURLException ue) { - System.out.println("warning:Invalid URL requested"); - } - catch(java.io.IOException e) { - System.out.println("warning: IOException occurred"); - } - - } - - // Sends a "system" message msg onto room r - private void writeRoom(Room r, String msg) { - StringBuffer sb = new StringBuffer(); - sb.append("==>"); - sb.append(msg); - dataPacket d = new dataPacket(my_name_, r.getName() , "TEXT" , (new Integer(sb.length())).toString(), sb.toString()); - r.getQ().nq(d); - } - - public String getName() { - return my_name_; - } - - public MT_Bounded_Queue getQ() { - return wq_; - } - -} -// ---------------------------------------------------------------------- -/** This class implements a room factory. getRoom returns an existing room, - or else creates it and returns a reference to a new room. - -**/ -class RoomFactory implements consts { - - private Vector Hotel_; - public RoomFactory() { - Hotel_ = new Vector(); - } - public synchronized Room getRoom(String name) { - Enumeration e = Hotel_.elements(); - while(e.hasMoreElements()) { - Room r = (Room) e.nextElement(); - if(r.getName().equals(name)) - return r; - } - addRoom(name); - return getRoom(name); - } - - private synchronized void addRoom(String name) { - Room r = new Room(name); - Hotel_.addElement(r); - } - public synchronized void delRoom(Room r) { - Hotel_.removeElement(r); - } - public synchronized String listRooms() { - Enumeration e = Hotel_.elements(); - StringBuffer sb = new StringBuffer(); - while(e.hasMoreElements()) - sb.append(" " + ((Room)e.nextElement()).getName() + " "); - return sb.toString(); - } -} - - diff --git a/java/apps/NexusII/src/Producer.java b/java/apps/NexusII/src/Producer.java deleted file mode 100644 index 4153f7d79df..00000000000 --- a/java/apps/NexusII/src/Producer.java +++ /dev/null @@ -1,87 +0,0 @@ -// This class encapsulates a Producer. Each new instance of this class -// creates a different thread which tries to nq into the queue -// Currently queues random values generated by the Random class -// If timeout expires, the Producer instance returns - -//package NexusII.util ; - -import java.util.Random ; - -public class Producer extends Thread -{ - -// If no time out is desired, timeout value is set to one. so the run method -// knows which nq to call - -public Producer(MT_Bounded_Queue queue) - { - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -// Include the name of the thread as a parameter -public Producer(MT_Bounded_Queue queue, String name) - { - super(name); - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -// If the number of iterations are also included -- -public Producer(MT_Bounded_Queue queue, String name, Integer iterations) - { - super(name); - this.queue_ = queue ; - iterations_ = iterations ; - this.time_out_ = -1 ; - } - -// Finally, if the timeout period is also included - -public Producer(MT_Bounded_Queue queue, String name, Integer iterations, long msec_timeout) - { - super(name); - this.queue_ = queue ; - iterations_ = iterations ; - this.time_out_ = msec_timeout ; - } - -// The hook method called by start() - -public void run() - { - // Initialize the random number generator - Random rand = new Random(); - for(int i=0;i<iterations_.intValue();i++) - { - int err = 0 ; - // Get the next random value for insertion into queue - Integer new_item = new Integer(rand.nextInt()) ; - - // Doesnt make sense to have a negative timeout -- default - if(time_out_ < 0) - queue_.nq(new_item); - else - err = queue_.nq(new_item,time_out_); - - // If timedout stop this thread - if(err == -1) - { - System.out.println(getName() + ": Timed Out \n"); - return ; - } - - System.out.println(getName() + ": enqueued " + new_item.intValue()); - } - - } - -private static final int DEFAULT_ITERATIONS = 1 ; -protected MT_Bounded_Queue queue_ ; -private Integer iterations_ ; -private long time_out_ ; -} - - diff --git a/java/apps/NexusII/src/Room.java b/java/apps/NexusII/src/Room.java deleted file mode 100644 index 4a9a294c653..00000000000 --- a/java/apps/NexusII/src/Room.java +++ /dev/null @@ -1,97 +0,0 @@ -// RoomThread and Room implement the concept of a chat "room" -// Sumedh Mungee <sumedh@cs.wustl.edu> - - -import java.util.*; -import java.io.File; - -// This class(&thread) is responsible for multicasting -// packets on its incoming "client" queues, onto one or -// more outgoing queues, which are picked up by the client. -class RoomThread implements Runnable, consts { - - private MT_Bounded_Queue rq_; - private Vector clientlist_; - - public RoomThread(MT_Bounded_Queue rq, Vector clientlist) { - rq_ = rq; - clientlist_ = clientlist; - } - - public void run() { - for(;;) { - dataPacket d = (dataPacket) rq_.dq(); // Extract packet - Enumeration e = clientlist_.elements(); // Iterate over clients - while(e.hasMoreElements()) - ((ClientHandler)e.nextElement()).getQ().nq(d); // Enqueue packet - } - } -} - - -public class Room implements consts { - - private String name_; // name of this "room" - private String last_image_ = new String("NexusII.gif"); // filename of the last image broadcast - private Thread roomthread_; - private MT_Bounded_Queue rq_ = new MT_Bounded_Queue(); - private Vector clientlist_ = new Vector(); - - // Constructors - public Room(String name) { - int i; - name_ = new String(name); - roomthread_ = new Thread(new RoomThread(rq_, clientlist_)); - roomthread_.start(); - } - - // Client management methods follow.. - - public synchronized void addClient(ClientHandler client) { - clientlist_.addElement(client); - } - // Returns true if this room has now become empty - public synchronized boolean delClient(ClientHandler client) { - clientlist_.removeElement(client); - return clientlist_.isEmpty(); - } - - public synchronized boolean checkClient(ClientHandler client) { - return clientlist_.contains(client); - } - - public synchronized Enumeration clientList() { - return clientlist_.elements(); - } - - public String getName() { - return name_; - } - - public MT_Bounded_Queue getQ() { - return rq_; - } - - public synchronized String getLastImageName() { - return last_image_; - } - - public synchronized void putNextImageName(String s) { - last_image_ = s; - } - - protected void finalize() { - roomthread_.stop(); - File f = new File(last_image_); - if(f.exists()) - f.delete(); - roomthread_ = null; - } -} - - - - - - - diff --git a/java/apps/NexusII/src/RoomFrame.java b/java/apps/NexusII/src/RoomFrame.java deleted file mode 100644 index e9da19b31d6..00000000000 --- a/java/apps/NexusII/src/RoomFrame.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:02 sumedh - Added the Nexus II source code files. - -# Revision 1.2 1996/12/07 06:25:18 rajeev -# backup -# -# Revision 1.1 1996/12/07 06:15:12 rajeev -# Initial revision -# - - -*/ -import java.awt.*; -import awtCommand.*; -import java.util.* ; - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.*; - -class RoomFrame extends CFrame implements consts { - private static String rcsId = new String("$Id$"); - - // Graphics Objects - private CTextField tfInput ; - private CTextArea taOutput ; - private CButton bLeave ; - private ImageCanvas icOutput; - private Font normalFont = new Font("Helvetica", Font.PLAIN, 14); - private Font boldFont = new Font("Helvetica", Font.BOLD, 14); - private Font italicFont = new Font("Helvetica", Font.ITALIC, 14); - private static final int LINE_LENGTH = 70; - - // Other required objects - private MT_Bounded_Queue write_q_ ; - private NexusClientApplet applet_ ; - private String myName_ ; - - public RoomFrame(MT_Bounded_Queue write_q, - NexusClientApplet applet, - String name) { - super(name); - write_q_ = write_q ; - applet_ = applet ; - myName_ = name ; - SetUpGraphics(); - this.pack(); - this.show(); - } - - void SetUpGraphics() { - // Initialize the graphics objects - // The input text line - tfInput = new CTextField(LINE_LENGTH); - textHandler handlerT = new textHandler(write_q_,applet_,myName_); - tfInput.setActionCommand(handlerT); - // The leave button - bLeave = new CButton(LEAVE_STR); - bLeave.setActionCommand(applet_.nexusJoiner); - - icOutput = new ImageCanvas(myName_); - taOutput = new CTextArea(10,LINE_LENGTH); - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(normalFont); - setLayout (gbl); - - gbc.insets = new Insets(5,5,5,5); - gbc.ipadx = 5; - gbc.ipady = 5; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // First the Image so that sizes are fixed - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(icOutput, gbc); - add(icOutput); - - // The Text Output Area - gbc.gridx = 0; - gbc.gridy = 0; - gbc.weighty = 0.0; - gbc.anchor = GridBagConstraints.SOUTH; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(taOutput,gbc); - taOutput.setEditable(false); - add(taOutput); - - // The Text Input Field - gbc.gridx = 0; - gbc.gridy = 1; - gbc.weighty = 0.0; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(tfInput,gbc); - add(tfInput); - - // The Leave Button - gbc.gridx = 1; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(bLeave,gbc); - add(bLeave); - - resize(800,280); - setResizable(true); // Allow the user to resize - validate(); - } - - public boolean handleEvent(Event event) { - if (event.id == Event.WINDOW_DESTROY) - dispose(); - return super.handleEvent(event); - } - - // This function will be called by the RoomHandler when it receives - // anything for this room and will add the data - public void addText(String tobeadded) { - if (false) { - String speaker = null; - String msg = null; - int pos = tobeadded.indexOf(':'); - if (pos >= 0) - speaker = tobeadded.substring(0,pos+1); - else - speaker = new String(""); - msg = tobeadded.substring(pos+1); - Font oldf = taOutput.getFont(); - taOutput.setFont(boldFont); - taOutput.appendText(speaker); - taOutput.setFont(italicFont); - taOutput.appendText(msg+"\n"); - taOutput.setFont(oldf); - } - else { - taOutput.appendText(tobeadded+"\n"); - } - return; - } - - // This function will also be called by the RoomHandler whenit receives - // Image data for this room. - public void updateImage(Image im) { - if(DEBUG) { - System.out.println("Room : I got an image"); - } - icOutput.setImage(im); - } - - -} - - - -/** - * The ImageCanvas Class -- for the image in the class - */ -class ImageCanvas extends Canvas implements consts { - - Image image_ = null; - int defWidth_ = 128; - int defHeight_ = 128; - int margin = 5; - - String name_ = new String("Nexus Room"); - Font nameFont = new Font("Helvetica",0,14); - - public ImageCanvas(String s) - { - name_ = s; - } - - public Dimension preferredSize() { - return minimumSize(); - } - public Dimension minimumSize() { - return new Dimension(defWidth_, defHeight_); - } - - public void setImage(Image newIm) { - image_ = newIm; - repaint(); - } - public Image getImage() { - return image_; - } - - public void name(String n) { - name_ = n; - } - public String name() { - return name_; - } - - public void paint(Graphics g) { - Dimension d = size(); - int width = d.width; - int height = d.height; - - if (DEBUG) - System.out.println("ImageCanvas:: width = "+width+ " height="+height); - - g.setColor(Color.black); - g.fillRect(0,0,width-1,height-1); - g.setColor(Color.white); - g.fillRect(margin,margin,width-2*margin,height-2*margin); - // Create image if reqd - if (image_ == null) - image_ = createImage(width-2*margin,height-2*margin); - - g.drawImage(image_, margin, margin, - width-2*margin, height-2*margin, Color.white, this); - g.setColor(Color.blue); - g.setFont(nameFont); - FontMetrics fm = g.getFontMetrics(); - g.drawString(name_,(width - fm.stringWidth(name_))/2, - (int)(height*0.9 - fm.getMaxDescent())); - validate(); - return; - } - - public void update(Graphics g) { - paint(g); - } - -} // End of the Image Canvas Class - - - -// this is the event handler for the textfield -- whenever anything is typed -class textHandler implements Command,consts,Runnable { - private MT_Bounded_Queue write_q_ ; - private NexusClientApplet applet_ ; - private String name_ ; - Object what_ ; - - public textHandler(MT_Bounded_Queue write_q, - NexusClientApplet applet, - String name) { - write_q_ = write_q ; - applet_ = applet ; - name_ = name ; - } - - public void execute(Object target, Event evt, Object what) { - // get the string and send it across in a different thread - what_ = what ; - // clear the field in the gui - ((TextField)target).setText(""); - // send it off - new Thread(this).start(); - } - - // send off the string in a different thread - public void run() { - String data = (String)what_; - // check if data begins with / and is followed by url - if(!data.startsWith("/url")) { - - String user = NexusClientApplet.myName ; - String command = user + ":" + data ; - String len = Integer.toString(command.length()); - dataPacket packet = new dataPacket(NexusClientApplet.myName,name_, - "TEXT",len,command); - write_q_.nq(packet); - } - else { - // it is /url - StringTokenizer t = new StringTokenizer(data); - // take out the /url from here - String ur = t.nextToken(); - // data now - String command = t.nextToken(); - String len = Integer.toString(command.length()); - dataPacket packet = new dataPacket(NexusClientApplet.myName,name_, - "URL",len,command); - write_q_.nq(packet); - } - } -} // end of class - - - diff --git a/java/apps/NexusII/src/RoomSpace.java b/java/apps/NexusII/src/RoomSpace.java deleted file mode 100644 index 9afb78ddff1..00000000000 --- a/java/apps/NexusII/src/RoomSpace.java +++ /dev/null @@ -1,110 +0,0 @@ -import java.awt.*; - -class RoomFrame extends Frame // implements Runnable -{ - - // Graphics Objects - private Panel panel = new Panel(); - private TextField tfInput = new TextField(80); - private TextArea taOutput = new TextArea(80,10); - Button bLeave = new Button("Leave"); - ImageCanvas icOutput = new ImageCanvas(); - - void InitGraphics() - { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(new Font("Helvetica", Font.PLAIN, 14)); - panel.setLayout (gbl); - - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // First the Image so that sizes are fixed - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.fill = GridBagConstraints.NONE; - gbl.setConstraints(icOutput, gbc); - panel.add(icOutput); - - // The Text Output Area - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(taOutput,gbc); - taOutput.setEditable(false); - panel.add(taOutput); - - // The Text Input Field - gbc.gridx = 0; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(tfInput,gbc); - panel.add(tfInput); - - // The Leave Button - gbc.gridx = 1; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(bLeave,gbc); - panel.add(bLeave); - } - - - public RoomFrame() - { - this("Anonymous"); - } - - public RoomFrame(String s) - { - InitGraphics(); - super(s); - this.pack(); - this.show(); - } - - public boolean handleEvent(Event event) - { - if (event.id == Event.WINDOW_DESTROY) - dispose(); - return super.handleEvent(event); - } - -} - -class ImageCanvas extends Canvas { - - Image image_; - int imgWidth_ = 128; - int imgHeight_ = 128; - - public Dimension preferredSize() { - return minimumSize(); - } - - public Dimension minimumSize() { - return new Dimension(imgWidth_, imgHeight_); - } - - public void image(Image newIm) { - image_ = newIm; - } - - public Image image() { - return image_; - } - - public void paint(Graphics g) { - g.drawImage(image_,0,0,this); - } - - public void update() { - paint(); - } - -} // End of the Image Canvas Class diff --git a/java/apps/NexusII/src/Timed_Wait.java b/java/apps/NexusII/src/Timed_Wait.java deleted file mode 100644 index 792db39ceb9..00000000000 --- a/java/apps/NexusII/src/Timed_Wait.java +++ /dev/null @@ -1,86 +0,0 @@ -// package NexusII.util ; - - -// Subclass the Exception class to get TimeoutException - -class TimeoutException extends Exception -{ - public TimeoutException() - { - super(); - } - - public TimeoutException(String s) - { - super(s); - } - -} - -// Timed_wait class. This can used by enq and deq to do timed_waits -public abstract class Timed_Wait -{ - // By default the object is itself -public Timed_Wait () - { - object_ = this; - } - // If the calling class specifies objects, delegate to it. -public Timed_Wait (Object obj) - { - object_ = obj; - } - - // This is the object we delegate to if a - // subclass gives us a particular object, - // otherwise, we ``delegate'' to ourself - // (i.e., to this). -protected Object object_; - - // This hook method must be overridden - // by a subclass to provide the condition. - -public abstract boolean condition (); - - // This will borrow the monitor lock from the calling class - -public final void timed_wait(long msec_timeout) -throws InterruptedException, TimeoutException - { - // wait if the condition is false - if (!condition()) - { - long start = System.currentTimeMillis() ; - long wait_time = msec_timeout ; - - for(;;) - { - // anyway have to wait atleast till waittime - object_.wait(wait_time); - - // on coming out check for the condition again - if(!condition()) - { - long now = System.currentTimeMillis() ; - long time_so_far = now - start ; - - // if timed out - if(time_so_far >= msec_timeout) - throw new TimeoutException() ; - else - // retry !! we have some time left - wait_time = msec_timeout - time_so_far ; - } - else // the condition is true here - break ; - } - } - } - - // Notify all threads waiting on the object_. -public final void broadcast () - { - object_.notifyAll (); - } -} - diff --git a/java/apps/NexusII/src/Timer.java b/java/apps/NexusII/src/Timer.java deleted file mode 100644 index df781274913..00000000000 --- a/java/apps/NexusII/src/Timer.java +++ /dev/null @@ -1,31 +0,0 @@ -// This class encapsulates a Timer mechanism -// Can be used for Profiling of parts of code and gathering statistics - -package NexusII ; - -public class Timer { - -public Timer() -{ - start_ = 0 ; -} - -public void start() - -{ - start_ = System.currentTimeMillis(); -} - -public long elapsed_time() -{ - return System.currentTimeMillis() - start_ ; -} - -public void stop() -{ - start_ = 0 ; -} - -private long start_ = 0 ; - -} diff --git a/java/apps/NexusII/src/commandHandler.java b/java/apps/NexusII/src/commandHandler.java deleted file mode 100644 index 4cf80d04235..00000000000 --- a/java/apps/NexusII/src/commandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -// To handle the events generated by command-line. The user will be saying -// /nick <nick-name> - -import java.awt.* ; -import java.util.* ; - -//import NexusII.client.* ; - -import awtCommand.* ; - - -public class commandHandler implements Command,consts { - NexusClientApplet applet_ ; - // will handle the /nick command for now -- urgent - public commandHandler(NexusClientApplet applet ) { - applet_ = applet ; - } - - public void execute(Object target,Event evt,Object what) { - // Right now assume that it is just a nick command - if(DEBUG) { - System.out.println("Nick typed in ---- "); - } - StringTokenizer t = new StringTokenizer((String)what) ; - // string for holding /nick and <nickname> - String command = null ; - if(t.hasMoreTokens()) { - command = t.nextToken(); - } - - if(command.equalsIgnoreCase("/nick")) { - if(t.hasMoreTokens()) { - // have to send a nick packet to server - applet_.myName = new String(t.nextToken()); - applet_.sendNickToServer(applet_.myName); - - } - } - // clear the field in the gui - ((TextField)target).setText(""); - - } -} -// of class diff --git a/java/apps/NexusII/src/commandParser.java b/java/apps/NexusII/src/commandParser.java deleted file mode 100644 index 64e6da66122..00000000000 --- a/java/apps/NexusII/src/commandParser.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:06 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:05:08 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// why not use java utilities !! - -import java.util.* ; -import java.lang.* ; -import java.awt.* ; - - - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.* ; - - - -import awtCommand.* ; - -// This class takes a command parses it and packetizes it and puts it in the -// global send queue. It works in its own thread of control and after nqing -// its run() method falls off. It does its work and dies -// Will act as an eventHandler for TextField most probably - -public class commandParser implements Command,consts,Runnable { - - String command ; - MT_Bounded_Queue q_ ; - NexusClientApplet applet_ ; - // constructor - - public commandParser(MT_Bounded_Queue write_q,NexusClientApplet applet) { - // create a reference to the write_q - q_ = write_q ; - // note the applet name - applet_ = applet ; - - } - - - public void execute(Object target, Event evt, Object what) { - // Get the text which was entered there -- - command = new String((String) what) ; - // run in a separate thread - Thread main = new Thread(this); - main.start(); - } - - // The parser etc. run here - public synchronized void run() { - String actual_command = new String(); - String data = new String(); - String data_len = new String(); - if(DEBUG) { - System.out.println("commandParser thread running --- \n"); - } - - // Do the parsing first - if(command.equalsIgnoreCase(LUSERS_STR)) { - actual_command = new String("LUSERS") ; - data = applet_.GetRoomName() ; - data_len = new String(String.valueOf(data.length())); - if(data.length() == 0) - return ; - } - - else if(command.equalsIgnoreCase(LROOMS_STR)) { - actual_command = new String("LROOMS") ; - data = new String("") ; - data_len = new String("0") ; - } - - String room = new String("ROOT"); - - if(DEBUG) { - System.out.println("The room is " + room + "\n"); - } - - /* - StringBuffer databuffer = new StringBuffer(); - - // Get the data - while(t.hasMoreTokens()) { - databuffer.append(t.nextToken()); - } - String data = new String(databuffer); - if(DEBUG) { - System.out.println("The data is " + data + "\n"); - } - - // data length - String data_len = String.valueOf(data.length()); - // Now make a packet - */ - - dataPacket pack = new dataPacket(NexusClientApplet.myName,room,actual_command,data_len,data); - // enqueue it now - q_.nq(pack); - - } // my job is over - -} -// of class - diff --git a/java/apps/NexusII/src/connectionHandler.java b/java/apps/NexusII/src/connectionHandler.java deleted file mode 100644 index 5e9d3823a68..00000000000 --- a/java/apps/NexusII/src/connectionHandler.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:07 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:05:30 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// This class will handle the event generated when user presses "connect/dis -// connect" button. It will maintain all the state associated with a -// connection ; -// In particular, it will create reader,writer and demux threads and stop -// them when user pressed disconnect. It also sends the init and quit -// packet to the server -// -- Rajeev Bector 11/26/96 - -// package NexusII.networking ; - -import awtCommand.* ; - -import java.net.* ; -import java.awt.* ; -import java.io.* ; -import java.util.* ; -import ACE.OS.*; -import ACE.SOCK_SAP.*; - -public class connectionHandler implements Command,consts,Runnable { - - // The socket for reading and writing - // private Socket nexusSocket; - private SOCKConnector nexusConnector_ = new SOCKConnector(); - private SOCKStream nexusStream_ = new SOCKStream(); - - // Threads which will do reading and writing from Socket - private Thread readerThread ; - private Thread writerThread ; - - // Threads which demuxes the data from Write Queue - private Thread demuxThread; - - // The socket - // private Socket nexusSocket_ ; - - // Data Streams which flow the data out - private DataInputStream is_ ; - private DataOutputStream os_ ; - - // links to the outside world - private MT_Bounded_Queue read_q_ ; - private MT_Bounded_Queue write_q_ ; - - Integer port_ ; - String host_ ; - - NexusClientApplet applet_ ; - // Constructor - public connectionHandler(String host,Integer port,NexusClientApplet applet) { - host_ = host ; - port_ = port ; - applet_ = applet ; - } // of constructor - - // This will be called when the "connect/disconnet" button is pressed - - public void execute(Object target, Event evt, Object what) { - // run in a separate thread - new Thread(this).start(); - } - - public synchronized void run() { - - // If not connected -- then connect - if(!applet_.connected) { - - // Initialize the queues now - read_q_ = new MT_Bounded_Queue(QUEUE_SIZE); - write_q_ = new MT_Bounded_Queue(QUEUE_SIZE); - - // Try to connect to the server now - // nexusSocket_ = new Socket(host_,port_.intValue()); - try { - nexusConnector_.connect(nexusStream_, host_, port_.intValue()); - } - catch(SocketException s) { } - catch(IOException i) { } - // Attach Streams to read and write end os socket - os_ = new DataOutputStream(nexusStream_.outputStream()); - is_ = new DataInputStream(nexusStream_.inputStream()); - - // do something now - - // create and start the socket reader first - readerThread = new socketReaderThread(read_q_,is_); - readerThread.start(); - - // now create the writer also -- subclass of consumer - writerThread = new socketWriterThread(write_q_,os_); - writerThread.start(); - // Have to send the init packet to the server - sayHelloToServer(); - - - // Do all the graphics needed and also init the join handlers etc. - applet_.OnConnect(); - - // make sure that when demux is created -- joinHandler is there ... !! - - // Create the demux here -- he'll spawn off the rooms - demuxThread = new nexusDemuxThread(read_q_,applet_.Mapper()); - demuxThread.start(); - - } // of if !connected - - // if connected already then I have to disconnect --- have to - // write code for this - else { - - // first leave all the rooms - for(Enumeration e = applet_.Mapper().keys(); e.hasMoreElements();) { - String name = (String) e.nextElement() ; - applet_.SetRoomName(name); - applet_.nexusJoiner.execute(null,null,LEAVE_STR); - } - // send a quit packet to the server - sayByeToServer(); - - // Have to send a leave for all the rooms and leave all the rooms - - // stop the running threads - readerThread.stop(); - demuxThread.stop(); - - // Again meddle with graphics - applet_.OnDisconnect(); - return ; - } - } // of run - - // This method returns the underlying socket descriptor - public Socket handle() { - return nexusStream_.socket(); - } - - public DataInputStream getinStream() { - return is_ ; - } - - public DataOutputStream getoutStream() { - return os_ ; - } - - public MT_Bounded_Queue reader_q() { - return read_q_ ; - } - - - public MT_Bounded_Queue writer_q() { - if(write_q_ == null) - System.out.println("Sending a null write_q"); - return write_q_ ; - } - - // This method will compose a hello packet and send it off -- cannot run - // this in a separate thread. Has to send this first surely to our TCP - // Connection - - public void sayHelloToServer() { - // hello doesnt have any body - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("INIT"); - String contentLength = new String("0"); - - // Make a proper packet out of it - dataPacket initPacket = new dataPacket(clientID,roomID,contentType,contentLength); - - // enqueue that packet for socketWriter to read - write_q_.nq(initPacket); - - } - - // This method send a Quit command to the server -- to say that it is - // pushing off - public void sayByeToServer() { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("null"); - String contentType = new String("QUIT"); - String contentLength = new String("0"); - - // Make a proper packet out of it - dataPacket quitPacket = new dataPacket(clientID,roomID,contentType,contentLength); - - // enqueue that packet for socketWriter to read - write_q_.nq(quitPacket); - } // of sayByeToServer - -} // of class - - - - - - - - - - - - - - - - - - - - - diff --git a/java/apps/NexusII/src/consts.java b/java/apps/NexusII/src/consts.java deleted file mode 100644 index 304ec41a41e..00000000000 --- a/java/apps/NexusII/src/consts.java +++ /dev/null @@ -1,40 +0,0 @@ -// package NexusII.client ; - -// An interface for all the public constants shared by clientApplet -// All classes that need to access constants will implement this - -public interface consts { - // Length of each field in the header - public static final int FIELD_LENGTH = 32 ; - - // Total length of header - public static final int PACKET_HEADER_LENGTH = 128; - - // Offset where we can find the data length - public static final int DATA_LEN_OFFSET = 96; - - // Size of Queues where reader and writer work - public static final int QUEUE_SIZE = 20 ; - - // Separator used by tokens in the packet - public static final String SEPARATOR = " " ; - - // End of message - public static final String END_OF_DATA = "\n" ; - - // Useful for debugging -- set to false for release version (demo) -- Aravind - public static final boolean DEBUG = false; - - // Size of hash tables - public static final int HASH_SIZE = 16 ; - - public static final String JOIN_STR = "Join" ; - public static final String LEAVE_STR = "Leave" ; - public static final String LUSERS_STR = "List Users" ; - public static final String LROOMS_STR = "List Rooms" ; - - public static final int SERVER_PORT = 42429 ; - public static final String NEXUS_LOGO = "Nexus_Logo.gif"; -} - - diff --git a/java/apps/NexusII/src/dataPacket.java b/java/apps/NexusII/src/dataPacket.java deleted file mode 100644 index 1bd2dfeb6ab..00000000000 --- a/java/apps/NexusII/src/dataPacket.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:08 sumedh - Added the Nexus II source code files. - -# Revision 1.2 1996/12/07 06:27:38 rajeev -# yaah paranoid backup ... -# -# Revision 1.1 1996/12/06 18:23:45 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:07:53 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// This class encapsulates a dataPacket -// Will encapsulate the byteStream as a characterStream into a single thing -// no packets for now -// package NexusII.networking ; - -//import NexusII.client.* ; - -public class dataPacket implements consts, Cloneable{ - - private String clientName ; - private String roomName ; - private String contentType ; - private String contentLength ; - private String content ; - - // constructor -- will create the data packet - public dataPacket(byte[] header, byte[] body) { - int len = FIELD_LENGTH ; - clientName = new String(header,0,0,len); - roomName = new String(header,0,1*len,len); - contentType = new String(header,0,2*len,len); - contentLength = new String(header,0,3*len,len); - content = new String(body,0); - if(DEBUG) - System.out.println("datapacket: Constructed packet with header " + header + " and body " + body); - } - - // another constructor for length 0 packets - public dataPacket(String client, String room, String type,String len) - { - clientName = new String(client); - roomName = new String(room); - contentType = new String(type); - contentLength = new String(len); - content = new String(); - } - - // another one for some data also - public dataPacket(String client, String room, String type,String len,String data) - { - this(client,room,type,len); - content = new String(data); - } - - // return the data in bytized header and body - public void bytize(byte[] header, byte[] body) - { - // clear the header and body -- fill them with whitespace - String white_space = new String(" "); - - if(DEBUG) { - System.out.println("dataPacket: length is " + new Integer(contentLength.trim()).intValue() + "\n"); - } - - int len = FIELD_LENGTH ; - // copy the header - clientName.getBytes(0,clientName.length(),header,0); - roomName.getBytes(0,roomName.length(),header,len*1); - contentType.getBytes(0,contentType.length(),header,len*2); - contentLength.getBytes(0,contentLength.length(),header,len*3); - - int body_len = (new Integer(contentLength.trim())).intValue(); - // copy the body also - content.getBytes(0,body_len,body,0); - } - - public int contentLength() { - return new Integer(contentLength.trim()).intValue(); - } - - // Returns the destination for the current packet - public String destination(){ - return roomName.trim() ; - } - - public String contentType() { - return contentType.trim() ; - } - - - public String content() { - return content.trim() ; - } - - public String clientName() { - return clientName.trim() ; - } - -} -// of class datapacket - - - - - - - - diff --git a/java/apps/NexusII/src/joinHandler.java b/java/apps/NexusII/src/joinHandler.java deleted file mode 100644 index 3ff071c26ed..00000000000 --- a/java/apps/NexusII/src/joinHandler.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:09 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:06:22 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ - -// This class will handle the event generated when user presses "join/leave" -// button. It will maintain all the state associated with all the rooms -// It'll also create and maintain the rooms -// -- Rajeev Bector 11/26/96 - -// package NexusII.networking ; - -// This is a SINGLETON - - -import java.net.* ; -import java.util.* ; -import java.awt.* ; -import java.io.* ; - - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.* ; - -import awtCommand.* ; - -public class joinHandler implements Command,consts { - MT_Bounded_Queue write_q_ ; - Hashtable name_to_q_ ; - Hashtable name_to_handler_ ; - NexusClientApplet applet_ ; - - // This will be called when the "join/leave" button is pressed - public joinHandler(MT_Bounded_Queue writer_q,NexusClientApplet applet) { - write_q_ = writer_q ; - applet_ = applet ; - // init. the Hashtables - name_to_q_ = new Hashtable(HASH_SIZE); - name_to_handler_ = new Hashtable(HASH_SIZE); - - } - - public Hashtable Mapper() { - return name_to_q_ ; - } - - public void execute(Object target, Event evt, Object what) { - - String roomName = applet_.GetRoomName() ; - if(roomName.length()==0) { - return ; - } - - // if it is the join button - if(((String)what).equalsIgnoreCase(JOIN_STR)) { - //if already joined -- return - if(name_to_q_.get(roomName) != null) - return ; - - // room doesnt exist - // Just in case the room name isn't listed - applet_.AddRoomName(roomName); - // create a new queue for the room to use - - MT_Bounded_Queue q_ = new MT_Bounded_Queue(QUEUE_SIZE); - if(DEBUG) { - System.out.println("joinHandler: inserted the queue in hash "); - } - name_to_q_.put(roomName,q_); - roomHandler handler = new roomHandler(roomName,q_,write_q_,applet_); - name_to_handler_.put(roomName,handler); - - // send a request to the server - sayJoinToServer(roomName); - // sendTestPacket(roomName,"URL","http://cumbia.cs.wustl.edu:4242/~sumedh/NexusII/NexusII.gif",q_); - } // of join - - else { - // its a "leave packet" - if(name_to_q_.get(roomName) == null) - return ; - // remove the entry from the queue - name_to_q_.remove(roomName); - - roomHandler handle = (roomHandler) name_to_handler_.get(roomName); - if(DEBUG) - System.out.println("joinHandler:Stopiing the room thread" + roomName); - handle.mystop(); - // handle = null ; - - // remove the entry from the queue - name_to_handler_.remove(roomName); - sayLeaveToServer(roomName); - } // of else - } // of execute - - private void sayJoinToServer(String roomName) { - //if (DEBUG) - // System.out.println("In the say J to server..."); - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("JOIN"); - String contentLength = String.valueOf(roomName.length()); - String content = new String(roomName); - // Make a proper packet out of it - dataPacket joinPacket = new dataPacket(clientID,roomID,contentType,contentLength,content); - - // enqueue that packet for socketWriter to read - write_q_.nq(joinPacket); - } - - private void sayLeaveToServer(String roomName) { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("LEAVE"); - String contentLength = new String(Integer.toString(roomName.length())); - String content = new String(roomName); - - // Make a proper packet out of it - dataPacket leavePacket = new dataPacket(clientID,roomID,contentType,contentLength,content); - - // enqueue that packet for socketWriter to read - write_q_.nq(leavePacket); - } - - - public void sendTestPacket(String roomName,String type,String content,MT_Bounded_Queue readq) { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String contentLength = new String(Integer.toString(content.length())); - - - // Make a proper packet out of it - dataPacket testPacket = new dataPacket(clientID,roomName,type,contentLength,content); - - // enqueue that packet for socketWriter to read - readq.nq(testPacket); - } - - -} - -// of class - - - - - - - - - - - - - - - - diff --git a/java/apps/NexusII/src/makefile b/java/apps/NexusII/src/makefile deleted file mode 100644 index c3cff521511..00000000000 --- a/java/apps/NexusII/src/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all: client server - -client: ../classes/NexusClientApplet.class - -../classes/NexusClientApplet.class: - javac -d ../classes -depend -g NexusClientApplet.java - -server: ../classes/NexusIIserver.class - -../classes/NexusIIserver.class: - javac -d ../classes -depend -g NexusIIserver.java - -clean: - rm -f ../classes/*.class *~ - diff --git a/java/apps/NexusII/src/nexusDemuxThread.java b/java/apps/NexusII/src/nexusDemuxThread.java deleted file mode 100644 index 96d0fdd06e1..00000000000 --- a/java/apps/NexusII/src/nexusDemuxThread.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:10 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.2 1996/12/05 05:39:47 sumedh -# ok -# -# Revision 1.1 1996/12/02 06:08:20 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ - -// Will take the packets from the input queue -// Parse the packet -// Call the room handler thread which Aravind will provide - -// Mapper object is the one which returns the room_q reference if you pass -// it the room number. Aravind has to implement this object called roomMapper -// which has an instance called mapper in the Applet context. This will be -// referred by nexusDemuxThread whenever it has anything to put in the room_q - -// package NexusII.networking ; - -//import NexusII.util.* ; -//import NexusII.client.* ; - -import java.util.* ; - -public class nexusDemuxThread extends Thread implements consts { - MT_Bounded_Queue q_ ; - dataPacket packet ; - Hashtable mapper_ ; - - // constructor - public nexusDemuxThread(MT_Bounded_Queue read_q,Hashtable mapper) { - q_ = read_q ; - mapper_ = mapper ; - } - - public void run() { - // run till infinity - for(;;) { - if(DEBUG) { - System.out.println("Demux running ---- "); - } - // take out packets from the queue - // parse to find out which room they belong to - packet = ((dataPacket)q_.dq()); - if(DEBUG) { - System.out.println("Demux got something ---- "); - } - - String roomName = packet.destination().trim(); - if(DEBUG) { - System.out.println("demux: destination is : " + roomName); - } - if(DEBUG) { - System.out.println("Hashtable size is " + new Integer(mapper_.size())); - } - // Get a reference to which queue to put it in - MT_Bounded_Queue room_q = (MT_Bounded_Queue)mapper_.get(roomName); - - // nq the packet on the room q - if(room_q != null) { - room_q.nq(packet); - System.out.println("deMux: I have enqueued it successfully"); - } - else - { - System.out.println("demux: room_q was null: i couldnt do much"); - } - } - } - // of run -} -// of class - - - - - -// 11/24/96 -- Rajeev Bector diff --git a/java/apps/NexusII/src/roomHandler.java b/java/apps/NexusII/src/roomHandler.java deleted file mode 100644 index bd125631b74..00000000000 --- a/java/apps/NexusII/src/roomHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:11 sumedh - Added the Nexus II source code files. - -# Revision 1.4 1996/12/07 06:22:49 rajeev -# taking a backup ! -# -# Revision 1.3 1996/12/06 06:20:07 rajeev -# Changes to include leave handler -# -# Revision 1.2 1996/12/06 04:49:44 rajeev -# working now hopefully ! -# -# Revision 1.1 1996/12/06 03:44:32 rajeev -# Initial revision -# - -*/ - -// per room -import java.awt.* ; -import awtCommand.* ; -import java.io.* ; -import java.net.* ; -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.*; - -public class roomHandler implements Runnable,consts{ - - String roomName_ ; - MT_Bounded_Queue read_q_ ; - MT_Bounded_Queue write_q_ ; - RoomFrame rf_; - Thread mainThread ; - NexusClientApplet applet_ ; - - // I dont know what to do currently - public roomHandler(String roomName, MT_Bounded_Queue reader_q,MT_Bounded_Queue writer_q,NexusClientApplet applet) { - roomName_ = roomName ; - read_q_ = reader_q ; - write_q_ = writer_q ; - applet_ = applet ; - rf_ = new RoomFrame(write_q_,applet_,roomName_); - // whenever this frame gets the mouse focus, handler will be called - FrameHandler fh_ = new FrameHandler(applet_); - rf_.setGotFocusCommand(fh_); - mainThread = new Thread(this); - mainThread.start(); - } - - - public void mystop() { - // dispose the graphics part here - if(DEBUG) - System.out.println("Roomhandlers stop called \n"); - rf_.hide(); - rf_.dispose(); - // no longer need the roomframe - rf_ = null ; - mainThread.stop(); - } - - public void run() { - if(DEBUG) { - System.out.println("Room receiver running ---- "); - } - while(Thread.currentThread() == mainThread) { - // get the data packet - dataPacket packet = (dataPacket)(read_q_.dq()) ; - if(DEBUG) - System.out.println("Room - I got something\n"); - - // if the packet is of text type -- display it - if(packet.contentType().trim().equalsIgnoreCase("TEXT")) { - rf_.addText(packet.content()); - } - // if the packet is a url address -- pull the image across - // this url has to be an image as of now - if(packet.contentType().equalsIgnoreCase("URL")) { - Image im = null ; - try { - im = applet_.getImage(new URL(packet.content())); - } catch (MalformedURLException i) { - // nothing as of now - } - // display the image - rf_.updateImage(im); - - } - - if (DEBUG) - System.out.println("roomhandler" + roomName_ + " got data"); - } - } - - public String toString() { - return roomName_ ; - } - -} // of class roomHandler - -// is executed when the room frame gets mouse focus - -class FrameHandler implements Command { - NexusClientApplet applet_ ; - public FrameHandler(NexusClientApplet applet) { - applet_ = applet ; - } - - public void execute(Object target, Event evt, Object what) { - if(target instanceof Frame) { - applet_.SetRoomName(((RoomFrame)target).getTitle()); - } - } -} - diff --git a/java/apps/NexusII/src/socketReaderThread.java b/java/apps/NexusII/src/socketReaderThread.java deleted file mode 100644 index 35679c504b4..00000000000 --- a/java/apps/NexusII/src/socketReaderThread.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:11 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.3 1996/12/03 01:35:37 rajeev -# fixed a big bug with respect to trim() -# -# Revision 1.2 1996/12/03 01:01:27 rajeev -# // fixed the bug at line 76 -# -# Revision 1.1 1996/12/02 06:08:56 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// The socketReaderThread is like a Producer who reads from the socket and -// nqs it onto the queue. Thats it ... Big Deal. huh ! - -// This threads task is -// 1. Take things from SocketBuffer. -// 2. Ensure that Full Packets are read -// 3. Put the packet onto the queue - -//package NexusII.networking ; - -// get hold of java classes -//import NexusII.client.* ; -//import NexusII.util.* ; - -import java.io.* ; - - -public class socketReaderThread extends Producer implements Runnable,consts -{ - DataInputStream is_ ; - - // new constructor - // Pass the queue and socketid to the constructor - - public socketReaderThread(MT_Bounded_Queue q, DataInputStream is) { - // call the super constructor - super(q); - is_ = is ; - } - - // This will just override the run method and thats it - // I want to have my own run ! - - public void run() { - // run indefinitely -- i am a daemon anyway - if(DEBUG) { - System.out.println("--- This is socketReaderThread --- \n"); - } - - for(;;) { - - // read header bytes from stream - int field_len = FIELD_LENGTH ; - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH]; - try { - is_.readFully(packetHeader,0,PACKET_HEADER_LENGTH); - } - catch (IOException e) { - // do something here - System.out.println("socketReader: I/O exception in read: I am quitting"); - // what to do here -- right now quit - return ; - } - if(DEBUG){ - System.out.println("socketReader read:" + new String(packetHeader,0)); - } - - // take out the length field from this - String length = new String(packetHeader,0,DATA_LEN_OFFSET,field_len); - - // Read this much more from the socket - if(DEBUG) { - System.out.println("The length of packet is " + length); - } - - Integer Test = new Integer(length.trim()); - int len = Test.intValue(); - if(DEBUG) { - System.out.println("srt: attempting to read " + Test + " bytes "); - } - - byte[] packetBody = new byte[len] ; - try { - if(len != 0) - is_.readFully(packetBody,0,len); - } - catch (IOException e) { - // do something here - System.out.println("socketReader: I/O exception in read: I am quitting"); - // what to do here -- right now quit - return ; - } - - // The header and the body are there now -- so make a packet - dataPacket packet = new dataPacket(packetHeader,packetBody); - if(DEBUG) - System.out.println("srt: Now nq'ing item body " + packet.content() ); - queue_.nq(packet); - if(DEBUG) - System.out.println("srt: Done nq'ing.."); - - // go back to reading the socket now - } - // of for(;;) - } - // of method run -} diff --git a/java/apps/NexusII/src/socketWriterThread.java b/java/apps/NexusII/src/socketWriterThread.java deleted file mode 100644 index 395449b6a53..00000000000 --- a/java/apps/NexusII/src/socketWriterThread.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:12 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:09:22 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// The socketWriterThread is like a Consumer who reads from the write_q and -// puts it onto the socket. Thats it ... Big Deal. huh ! - -// This threads task is -// 1. Write things to SocketBuffer. -// 2. Ensure that Full Packets are sent -// 3. Read the packet off the queue - -//package NexusII.networking ; - -// get hold of java classes - -import java.io.* ; - -//import NexusII.client.* ; -//import NexusII.util.* ; - -public class socketWriterThread extends Consumer implements Runnable,consts -{ - DataOutputStream os_ ; - - // new constructor - // Pass the queue and outstream to the constructor - - public socketWriterThread(MT_Bounded_Queue q, DataOutputStream os) { - // call the super constructor - super(q); - os_ = os ; - } - - // This will just override the run method and thats it - // I want to have my own run ! - - public void run() { - // run indefinitely -- i am a daemon anyway - if(DEBUG) { - System.out.println("--- This is socketWriterThread --- \n"); - } - boolean bye_sent = false ; - while(!bye_sent) { - - // read the packet from the queue - dataPacket packet = (dataPacket) queue_.dq(); - if(DEBUG){ - System.out.println("socketWriterThread: I got something -- \n"); - } - - // read length bytes from packet - int len = packet.contentLength() ; - if(DEBUG) { - System.out.println("socketWriterThread: length is " + new Integer(len)); - } - - - int field_len = FIELD_LENGTH ; - - // Allocate storage for holding the fields - - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH]; - byte[] packetBody = new byte[len] ; - - // Fill them - packet.bytize(packetHeader,packetBody); - - // put it on the wire now -- - - try { - os_.write(packetHeader,0,PACKET_HEADER_LENGTH); - } - catch (IOException e) { - // do something here - } - if(DEBUG){ - System.out.println("I wrote:" + new String(packetHeader,0)); - } - - try { - os_.write(packetBody,0,len); - } - catch (IOException e) { - // do something here - } - if(DEBUG){ - System.out.println("I wrote:" + new String(packetBody,0)); - } - // this is to handle if the user presses disconnect without leaving the - // room - if(packet.contentType().equalsIgnoreCase("QUIT")) - bye_sent = true ; - // go back to reading the queue now - } - // of for(;;) - } - // of method run - -} diff --git a/java/apps/NexusII/src/url_to_url.java b/java/apps/NexusII/src/url_to_url.java deleted file mode 100644 index 0fe08ab6db3..00000000000 --- a/java/apps/NexusII/src/url_to_url.java +++ /dev/null @@ -1,33 +0,0 @@ -// This method takes in a url and a prefix name and pulls that url across the -// network, stores it in a local file named prefix - -// for now it assumes that the url is an image only ! - -import java.net.* ; -import java.io.* ; -import java.awt.* ; -public class url_to_url { - Image im ; - - public url_to_url(URL url,String prefix) { - try { - im = (Image)url.getContent(); - } catch (IOException i) {} - String www_path = System.getProperty("www-path"); - String home_dir = System.getProperty("user.home"); - String dir = home_dir + www_path ; - System.out.println("web dir is this : " + dir); - - } - - public static void main(String[] argv) { - URL test = null ; - try { - test = new URL("http://www.cs.wustl.edu/~rajeev/images/sand.jpg"); - } catch ( MalformedURLException e) {} - - url_to_url t = new url_to_url(test,"root") ; - - } - -} diff --git a/java/apps/NexusII/start b/java/apps/NexusII/start deleted file mode 100755 index c699c96da60..00000000000 --- a/java/apps/NexusII/start +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh - -## This is an example script to launch the server. - -# the mywebaddress variable should point to a URL which is world-readable -# the mywebdir variable should point to the actual pathname of the URL -# which is specified by the mywebaddress variable -# The server needs to have write access to the mywebdir directory. -# Thus, the server saves images into the "mywebdir", and clients -# can access them via the "mywebaddress" URL. - -# the 222222 number is the port number on which the server is to be launched -# the same port number should appear in the html document containing -# the client applet (see start.html for an example) - -# while running the server, the ./classes should be part of the CLASSPATH. -# while running the client, the client classes as well as the awtCommand -# toolkit should be world-readable. (The awtcommand toolkit is included -# in this toolkit, under the classes directory.) - - -umask 022 -java -Dmywebaddress=http://cumbia.cs.wustl.edu/NexusII/tmp/ -Dmywebdir=/project/cumbia/sumedh/web/apache/root/NexusII/tmp/ NexusIIserver 222222 - - - - diff --git a/java/apps/NexusII/start.html b/java/apps/NexusII/start.html deleted file mode 100644 index cd591295b4a..00000000000 --- a/java/apps/NexusII/start.html +++ /dev/null @@ -1,3 +0,0 @@ -<applet code=NexusClientApplet.class width=550 height=500> - <param name=serverport value="222222"> -</applet> diff --git a/java/doc/images/GridBagEx.gif b/java/doc/images/GridBagEx.gif Binary files differdeleted file mode 100644 index 16c326d88ca..00000000000 --- a/java/doc/images/GridBagEx.gif +++ /dev/null diff --git a/java/doc/images/OpenBookIcon.gif b/java/doc/images/OpenBookIcon.gif Binary files differdeleted file mode 100644 index 86384f7733f..00000000000 --- a/java/doc/images/OpenBookIcon.gif +++ /dev/null diff --git a/java/doc/images/blue-ball-small.gif b/java/doc/images/blue-ball-small.gif Binary files differdeleted file mode 100644 index d4c5cde5b00..00000000000 --- a/java/doc/images/blue-ball-small.gif +++ /dev/null diff --git a/java/doc/images/blue-ball.gif b/java/doc/images/blue-ball.gif Binary files differdeleted file mode 100644 index edc29b786ce..00000000000 --- a/java/doc/images/blue-ball.gif +++ /dev/null diff --git a/java/doc/images/class-index.gif b/java/doc/images/class-index.gif Binary files differdeleted file mode 100644 index 7f276bcb242..00000000000 --- a/java/doc/images/class-index.gif +++ /dev/null diff --git a/java/doc/images/constructor-index.gif b/java/doc/images/constructor-index.gif Binary files differdeleted file mode 100644 index 435cac42386..00000000000 --- a/java/doc/images/constructor-index.gif +++ /dev/null diff --git a/java/doc/images/constructors.gif b/java/doc/images/constructors.gif Binary files differdeleted file mode 100644 index d1a6ae507ca..00000000000 --- a/java/doc/images/constructors.gif +++ /dev/null diff --git a/java/doc/images/cyan-ball-small.gif b/java/doc/images/cyan-ball-small.gif Binary files differdeleted file mode 100644 index 7f74357443a..00000000000 --- a/java/doc/images/cyan-ball-small.gif +++ /dev/null diff --git a/java/doc/images/cyan-ball.gif b/java/doc/images/cyan-ball.gif Binary files differdeleted file mode 100644 index 97ca1f2b6e3..00000000000 --- a/java/doc/images/cyan-ball.gif +++ /dev/null diff --git a/java/doc/images/error-index.gif b/java/doc/images/error-index.gif Binary files differdeleted file mode 100644 index 22835ff8c64..00000000000 --- a/java/doc/images/error-index.gif +++ /dev/null diff --git a/java/doc/images/exception-index.gif b/java/doc/images/exception-index.gif Binary files differdeleted file mode 100644 index e3830d9c52e..00000000000 --- a/java/doc/images/exception-index.gif +++ /dev/null diff --git a/java/doc/images/green-ball-small.gif b/java/doc/images/green-ball-small.gif Binary files differdeleted file mode 100644 index 17fea5b32bb..00000000000 --- a/java/doc/images/green-ball-small.gif +++ /dev/null diff --git a/java/doc/images/green-ball.gif b/java/doc/images/green-ball.gif Binary files differdeleted file mode 100644 index 71e1b2ec2db..00000000000 --- a/java/doc/images/green-ball.gif +++ /dev/null diff --git a/java/doc/images/interface-index.gif b/java/doc/images/interface-index.gif Binary files differdeleted file mode 100644 index bf93dda9e35..00000000000 --- a/java/doc/images/interface-index.gif +++ /dev/null diff --git a/java/doc/images/magenta-ball-small.gif b/java/doc/images/magenta-ball-small.gif Binary files differdeleted file mode 100644 index bd0584b3c67..00000000000 --- a/java/doc/images/magenta-ball-small.gif +++ /dev/null diff --git a/java/doc/images/magenta-ball.gif b/java/doc/images/magenta-ball.gif Binary files differdeleted file mode 100644 index 5da03b84d2b..00000000000 --- a/java/doc/images/magenta-ball.gif +++ /dev/null diff --git a/java/doc/images/method-index.gif b/java/doc/images/method-index.gif Binary files differdeleted file mode 100644 index a05e7051160..00000000000 --- a/java/doc/images/method-index.gif +++ /dev/null diff --git a/java/doc/images/methods.gif b/java/doc/images/methods.gif Binary files differdeleted file mode 100644 index 949e01b8a33..00000000000 --- a/java/doc/images/methods.gif +++ /dev/null diff --git a/java/doc/images/package-index.gif b/java/doc/images/package-index.gif Binary files differdeleted file mode 100644 index f894d4210d7..00000000000 --- a/java/doc/images/package-index.gif +++ /dev/null diff --git a/java/doc/images/red-ball-small.gif b/java/doc/images/red-ball-small.gif Binary files differdeleted file mode 100644 index f6b3c372ca1..00000000000 --- a/java/doc/images/red-ball-small.gif +++ /dev/null diff --git a/java/doc/images/red-ball.gif b/java/doc/images/red-ball.gif Binary files differdeleted file mode 100644 index dca92960148..00000000000 --- a/java/doc/images/red-ball.gif +++ /dev/null diff --git a/java/doc/images/variable-index.gif b/java/doc/images/variable-index.gif Binary files differdeleted file mode 100644 index 65cc029e722..00000000000 --- a/java/doc/images/variable-index.gif +++ /dev/null diff --git a/java/doc/images/variables.gif b/java/doc/images/variables.gif Binary files differdeleted file mode 100644 index e8a735399a6..00000000000 --- a/java/doc/images/variables.gif +++ /dev/null diff --git a/java/doc/images/yellow-ball-small.gif b/java/doc/images/yellow-ball-small.gif Binary files differdeleted file mode 100644 index 8e5f57cdfcb..00000000000 --- a/java/doc/images/yellow-ball-small.gif +++ /dev/null diff --git a/java/doc/images/yellow-ball.gif b/java/doc/images/yellow-ball.gif Binary files differdeleted file mode 100644 index 2b8c0bb3d6b..00000000000 --- a/java/doc/images/yellow-ball.gif +++ /dev/null diff --git a/java/examples/Logger/README b/java/examples/Logger/README deleted file mode 100644 index 1da7dbcbb19..00000000000 --- a/java/examples/Logger/README +++ /dev/null @@ -1,29 +0,0 @@ -This directory contains a simple client/server Java implementation of the -distributed logging server described in several papers in the C++ -Report (which can be obtained via the following WWW URLs: -http://www.cs.wustl.edu/~schmidt/{Reactor1-93.ps.gz,Reactor2-93.ps.gz}). - -The example consists of the following two directories: - - . client - NOT YET CONVERTED - This program talks directly to the server logging - daemon. The server daemon must be started before you - can run this test. - - . simple-server - - This program runs a simple - implementation of the - distributed logging server daemon. It also contains - code for a simple client as well. - - . Acceptor-server - NOT YET CONVERTED - This program runs templated, Acceptor-based - single-threaded Reactive implementation of the - distributed logging server daemon. - -The server implemented in "simple" is completely compatible with the -client defined in the C++ version of ACE. - diff --git a/java/examples/Logger/simple-server/LogRecord.java b/java/examples/Logger/simple-server/LogRecord.java deleted file mode 100644 index 4b7e7e87003..00000000000 --- a/java/examples/Logger/simple-server/LogRecord.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Class used to communicate logging information; compatible with - * the C++ ACE ACE_Log_Record class. - * - * @author Chris Cleeland - */ - -//package ACE.SimpleLogger; - -import java.util.Date; -import java.io.DataOutputStream; -import java.io.DataInputStream; -import java.io.PrintStream; -import java.io.IOException; - -public class LogRecord -{ - final public int MAXLOGMSGLEN = 4 * 1024; - - private int type_; - private int length_; - private int timeStamp_; - private int pid_; - private byte[] msgData_ = new byte[MAXLOGMSGLEN]; - private final static int numIntMembers = 4; - private final static int sizeofIntInBytes = 4; - - /** - * Create a default instance. - */ - public LogRecord() - { - this(0, (int) ((new Date()).getTime()/1000), 0); - } - - /** - * Create a LogRecord. This is the designated initializer. - * @param priority a numeric specification of the priority (ascending) - * @param time_stamp time attached to the log entry in Unix <pre>time_t</pre> format - * @param pid the process ID; not currently used - */ - public LogRecord(int priority, - int timeStamp, - int pid) - { - type(priority); - timeStamp(timeStamp); - length(0); - pid(pid); - } - - /** - * Conversion to string. Only includes the <pre>msgData_</pre> member. - */ - public String toString() - { - return new String(msgData_, 0); - } - - /** - * Place a textual representation of the record on a PrintStream. - * @param hostname name of the host generating this record - * @param verbose if <b>true</b>, print information in the form, (give example) - * @param ps A PrintStream instance to which the output should go. - * @see PrintStream,String - */ - public void print(String hostname, - boolean verbose, - PrintStream ps) - { - String toprint; - if (verbose) - { - long cur = (long)timeStamp() * (long)1000; - Date now = new Date(cur); - - /* 01234567890123456789012345 */ - /* Wed Oct 18 14:25:36 1989n0 */ - toprint = now.toString().substring(4) + "@" - + hostname + "@" + pid_ + "@" + type_ + "@" - + this.toString(); - } - else - { - toprint = this.toString(); - } - ps.println(toprint); - } - - /** - * Streaming methods - */ - public void streamInFrom(DataInputStream dis) throws IOException - { - // Order here must match layout order in the C++ class. - // This, of course, is VERY fragile, and ought not be used as - // a model for anything except how NOT to do anything. - type(dis.readInt()); - length(dis.readInt()); - timeStamp(dis.readInt()); - pid(dis.readInt()); - - // Does readFully() allocate space for the buffer? Either - // way, we won't have memory leaks :-) - int dataLength = (int) (length_ - numIntMembers * sizeofIntInBytes); - msgData_ = new byte[dataLength]; - dis.readFully(msgData_, 0, dataLength); - } - - public void streamOutTo(DataOutputStream dos) throws IOException - { - dos.writeInt(type()); - dos.writeInt(length()); - dos.writeInt(timeStamp()); - dos.writeInt(pid()); - int dataLength = (int) (length_ - numIntMembers * sizeofIntInBytes); - dos.write(msgData_, 0, dataLength); - } - - /** - * Accessor methods - */ - public int type() { return type_; } - public void type(int t) { type_ = t; } - - public int length() { return length_; } - public void length(int l) { length_ = l; } - private void setLen(int msgLen) - { length(msgLen + numIntMembers * sizeofIntInBytes); } - - public int timeStamp() { return timeStamp_; } - public void timeStamp(int t){ timeStamp_ = t; } - - public int pid() { return pid_; } - public void pid(int p) { pid_ = p; } - - public byte[] msgData() { return msgData_; } - public void msgData(byte[] m){ msgData_ = m; setLen(m.length); } - public void msgData(String m) - { - m.getBytes(0, m.length(), msgData_, 0); - setLen(m.length()); - } -}; - diff --git a/java/examples/Logger/simple-server/LoggerConstants.java b/java/examples/Logger/simple-server/LoggerConstants.java deleted file mode 100644 index db62d2fff6e..00000000000 --- a/java/examples/Logger/simple-server/LoggerConstants.java +++ /dev/null @@ -1,7 +0,0 @@ -// package ACE.Logger; - -public class LoggerConstants -{ - final public static int DEFAULT_SERVER_PORT = 4000; - final public static String DEFAULT_SERVER_HOSTNAME = "localhost"; -} diff --git a/java/examples/Logger/simple-server/LoggingAcceptor.java b/java/examples/Logger/simple-server/LoggingAcceptor.java deleted file mode 100644 index 7925e3d5a15..00000000000 --- a/java/examples/Logger/simple-server/LoggingAcceptor.java +++ /dev/null @@ -1,33 +0,0 @@ -//package ACE.SimpleLogger; - -import JACE.SOCK_SAP.*; -import java.io.IOException; - -public class LoggingAcceptor extends Thread -{ - private SOCKAcceptor peerAcceptor_; - - public LoggingAcceptor(int port) throws IOException - { - peerAcceptor_ = new SOCKAcceptor(port); - this.setName("LoggingAcceptor"); - System.err.println("Waiting for connection on port " + - port); - } - - public void run() - { - try - { - while (true) - { - LoggingHandler handler = new LoggingHandler(); - peerAcceptor_.accept(handler.stream()); - handler.open(); - } - } - catch (IOException e) - { - } - } -}; diff --git a/java/examples/Logger/simple-server/LoggingClient.java b/java/examples/Logger/simple-server/LoggingClient.java deleted file mode 100644 index 3c8a7fe3a2e..00000000000 --- a/java/examples/Logger/simple-server/LoggingClient.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Main class that acts as an example logging client. - */ - -import java.io.*; -import java.net.*; -import JACE.SOCK_SAP.*; -import LogRecord; -import LoggerConstants; - -public class LoggingClient implements Runnable -{ - private String loggerHost_; - private int port_; - private int maxIter_; - private static final int DEFAULT_ITERATIONS = 10; - - public static void main(String[] args) - { - // Really need to put code in here to parse options - int iter; - int port; - String host; - - iter = (args.length > 0) ? Integer.parseInt(args[0]) - : DEFAULT_ITERATIONS; - port = (args.length > 1) ? Integer.parseInt(args[1]) - : LoggerConstants.DEFAULT_SERVER_PORT; - host = (args.length > 2) ? args[2] - : LoggerConstants.DEFAULT_SERVER_HOSTNAME; - - LoggingClient lc = new LoggingClient(iter, port, host); - lc.run(); - } - - public LoggingClient() - { - - this(DEFAULT_ITERATIONS, - LoggerConstants.DEFAULT_SERVER_PORT, - LoggerConstants.DEFAULT_SERVER_HOSTNAME); - } - - public LoggingClient(int iterations, int thePort, String theHost) - { - maxIter_ = iterations; - port_ = thePort; - loggerHost_ = theHost; - } - - public void run() - { - SOCKStream logger = new SOCKStream(); - SOCKConnector connector = new SOCKConnector(); - // INETAddr addr = new INETAddr(port_, loggerHost_); - - LogRecord rec = new LogRecord(9, 2, 0); - - try - { - connector.connect(logger, loggerHost_, port_); - - int oneSecond = 1000; - // Currently SOCKStream uses DataInputStream for its input stream, - // and PrintStream for its output stream. It probably ought to use - // DataOutputStream for the output stream for symmetry, or at least - // provide a mechanism for changing the type of the filter stream - // used (which might be better in the long run...give it the class - // id). - DataOutputStream dos = new DataOutputStream((OutputStream) logger.outputStream()); - - for (int i = 0; i < maxIter_; i++) - { - // Need to overload LogRecord.msgData to take a String - // argument so that it's easy to create instances with text - // inside. - rec.msgData("message = " + i); - try - { - dos.writeInt(rec.length()); - rec.streamOutTo(dos); - rec.print("localhost", true, System.err); - } - catch (IOException ex) { } - - try - { - Thread.sleep(oneSecond); - } - catch (InterruptedException ex) { } - } - - try { logger.close(); } catch (IOException ex) { } - - } - catch (SocketException ex) - { - System.err.println("socket exception: " + ex); - } - catch (IOException ex) - { - System.err.println("io exception: " + ex); - } - - } -} diff --git a/java/examples/Logger/simple-server/LoggingHandler.java b/java/examples/Logger/simple-server/LoggingHandler.java deleted file mode 100644 index aeffc991ac3..00000000000 --- a/java/examples/Logger/simple-server/LoggingHandler.java +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************* - * - *@author Chris Cleeland - * - * What we really need to define is a run() (or whatever - * the Thread class has as its method to execute code), and - * have that do the usual delegated work of handle_input. - * We also need to figure out the best place to close the - * the socket, which probably ISN'T the finalizer. - * - *************************************************/ - -//package ACE.SimpleLogger; - -import JACE.SOCK_SAP.*; -import java.util.*; -import java.io.*; - -// Should this extend or simply be handed to a Thread instance to -// be run? -public class LoggingHandler extends Thread -{ - private SOCKStream cliStream_; - - /** - * Create a default Logging Handler - */ - public LoggingHandler() - { - this(new SOCKStream()); - } - - /** - * Create a LoggingHandler with an existing stream - */ - public LoggingHandler(SOCKStream aStream) - { - cliStream_ = aStream; - setName(); - } - - private void setName() - { - int portnum = ((cliStream_.socket() == null) - ? 0 - : cliStream_.socket().getLocalPort()); - this.setName("LoggingHandler#" + portnum); - } - - /** - * Start - */ - public void open() - { - this.start(); - } - - /** - */ - public SOCKStream stream() - { - return cliStream_; - } - - /** - * Handle logging events - */ - public void run() - { - DataInputStream dis = (DataInputStream) cliStream_.inputStream(); - - for (;;) - { - // Messages arrive in the following format: - // o 4 byte length (network format) - // o message, in ACE.LogRecord format - // - // Hey! We need exception catching in here too! - try - { - // Reconstitute a log message from the wire - LogRecord rec = new LogRecord(); - - // We don't really need this, because - // the object already knows how to - // extract itself properly. However, - // in order to interoperate with the - // C++ version, this must be extracted. - // Plus, it makes a convenient way to - // check everything. - int length = dis.readInt(); - - rec.streamInFrom(dis); - - if (rec.length() == length) - { - rec.print(cliStream_.socket().getInetAddress().getHostName(), - true, System.out); - System.out.flush(); - } - else - { - System.err.println("Logging_Handler: Length error receiving logging message\n"); - } - } - catch (EOFException eof) - { - System.err.println(Thread.currentThread().getName() - + ": end-of-file condition found; terminating."); - try { cliStream_.close(); } catch (IOException n) { } - this.stop(); - } - catch (IOException ioe) - { - System.err.println(Thread.currentThread().getName() - + ": IOException received -- " - + ioe.getMessage()); - } - } - } -}; diff --git a/java/examples/Logger/simple-server/Makefile b/java/examples/Logger/simple-server/Makefile deleted file mode 100644 index 5be1b0d048e..00000000000 --- a/java/examples/Logger/simple-server/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.SUFFIXES: .java .class - -CLASSDIR = . -DOCDIR = . - -JC = javac_g -JCOPTS = -g -d $(CLASSDIR) -JD = javadoc -JDOPTS = -d $(DOCDIR) - -COMPILE.java = $(JC) $(JCOPTS) $< -DOCCOMP.java = $(JD) $(JDOPTS) $< - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -CLASSES = LoggerConstants LogRecord LoggingHandler \ - LoggingAcceptor SimpleLogger LoggingClient -CLASSFILES = $(addsuffix .class,$(CLASSES)) -DOCFILES = $(addsuffix .html,$(CLASSES)) - -%.class: %.java - $(COMPILE.java) - -%.html: %.java - $(DOCCOMP.java) - -all: classes doc - -classes: $(CLASSFILES) -doc: $(DOCFILES) - -clean: - $(RM) *~ $(CLASSFILES) $(DOCFILES) - diff --git a/java/examples/Logger/simple-server/README b/java/examples/Logger/simple-server/README deleted file mode 100644 index 8f7c390ef1a..00000000000 --- a/java/examples/Logger/simple-server/README +++ /dev/null @@ -1,28 +0,0 @@ -====== -BASICS -====== - -This directory contains both the client (LoggingClient.java) and the -server (SimpleLogger.java). To compile, use GNU make with no specific -target. - -To execute, use "java <classname>" where <classname> is from the -following table: - - Application <classname> - =========================================== - client LoggingClient - server SimpleLogger - - -============== -KNOWN PROBLEMS -============== - -Interoperability between the C++ client and the Java server -implementation is fine. However, interoperability between the C++ -server and the Java client doesn't work right now. I believek that -it's due to the C++ server taking a naive approach and expecting to be -able to read an entire C/C++ structure at once, and the Java client -can't support that. Thus, the only "fix" I can envision is to rework -the C++ server. diff --git a/java/examples/Logger/simple-server/SimpleLogger.java b/java/examples/Logger/simple-server/SimpleLogger.java deleted file mode 100644 index f562689e283..00000000000 --- a/java/examples/Logger/simple-server/SimpleLogger.java +++ /dev/null @@ -1,44 +0,0 @@ -//package ACE.SimpleLogger; - -import java.io.IOException; - -class SimpleLogger implements Runnable -{ - private LoggingAcceptor la; - private int port; - - public static void main(String[] args) - { - SimpleLogger sl = new SimpleLogger(); - sl.run(); - } - - public SimpleLogger() - { - this(LoggerConstants.DEFAULT_SERVER_PORT); - } - - public SimpleLogger(int port) - { - try - { - la = new LoggingAcceptor(port); - } - catch (IOException ioe) - { - System.err.println("SimpleLogger: unable to create LoggingAcceptor (" - + ioe.getMessage() + ")"); - } - } - - public void run() - { - la.run(); - try - { - la.join(); - } - catch (InterruptedException ie) - { } - } -}; diff --git a/java/gjt/Assert.java b/java/gjt/Assert.java deleted file mode 100644 index b11f2ec4add..00000000000 --- a/java/gjt/Assert.java +++ /dev/null @@ -1,33 +0,0 @@ -package gjt; - -/** - * A simple assertion mechanism for asserting validity of - * arguments.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - */ -class Assert { - static public void notFalse(boolean b) - throws IllegalArgumentException { - if(b == false) - throw new IllegalArgumentException( - "boolean expression false"); - } - static public void notNull(Object obj) - throws IllegalArgumentException { - if(obj == null) - throw new IllegalArgumentException("null argument"); - } - - static public void notFalse(boolean b, String s) - throws IllegalArgumentException { - if(b == false) - throw new IllegalArgumentException(s); - } - static public void notNull(Object obj, String s) - throws IllegalArgumentException { - if(obj == null) - throw new IllegalArgumentException(s); - } -} diff --git a/java/gjt/Bargauge.java b/java/gjt/Bargauge.java deleted file mode 100644 index 27be8afad7b..00000000000 --- a/java/gjt/Bargauge.java +++ /dev/null @@ -1,80 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A bargauge which can be filled (wholly or partially) with a - * client-specified color. Fill color is specified at - * construction time; both fill color and fill percent may be - * set after construction time.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ThreeDRectangle - * @see gjt.test.BargaugeTest - */ -public class Bargauge extends Canvas { - private double percentFill = 0; - private ThreeDRectangle border = new ThreeDRectangle(this); - private Color fillColor; - - public Bargauge(Color fillColor) { - setFillColor(fillColor); - } - public void setFillColor(Color fillColor) { - this.fillColor = fillColor; - } - public void setFillPercent(double percentage) { - Assert.notFalse(percentage >= 0 && percentage <= 100); - percentFill = percentage; - } - public void resize(int w, int h) { - reshape(location().x, location().y, w, h); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x,y,w,h); - border.resize(w,h); - } - public Dimension minimumSize() { return preferredSize(); } - - public Dimension preferredSize() { - int w = border.getThickness() * 3; - return new Dimension(w, w*4); - } - public void paint(Graphics g) { - border.raise(); - border.paint(); - fill(); - } - public void fill() { - Graphics g = getGraphics(); - - if((g != null) && (percentFill > 0)) { - Rectangle b = border.getInnerBounds(); - int fillw = b.width; - int fillh = b.height; - - if(b.width > b.height) fillw *= percentFill/100; - else fillh *= percentFill/100; - - g.setColor(fillColor); - border.clearInterior(); - - if(b.width > b.height) - g.fillRect(b.x, b.y, fillw, b.height); - else - g.fillRect(b.x, b.y + b.height - fillh, - b.width, fillh); - } - } - protected String paramString() { - Dimension size = size(); - Orientation orient = size.width > size.height ? - Orientation.HORIZONTAL : - Orientation.VERTICAL; - String str = "fill percent=" + percentFill + "," + - "orientation=" + orient + "," + - "color" + fillColor; - return str; - } -} diff --git a/java/gjt/Border.java b/java/gjt/Border.java deleted file mode 100644 index ba80ef2e76a..00000000000 --- a/java/gjt/Border.java +++ /dev/null @@ -1,105 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A panel containing a single component, around which a border - * is drawn. Of course, the single component may be a - * container which may contain other components, so a Border - * can surround multiple components.<p> - * - * Thickness of the border, and the gap between the Component - * and the border are specified at time of construction. - * Default border thickness is 2 - default gap is 0.<p> - * - * Border color may be set via setLineColor(Color).<p> - * - * Border employs a DrawnRectangle to paint the border. Derived - * classes are free to override DrawnRectangle border() if they - * wish to use an extension of DrawnRectangle for drawing their - * border.<p> - * - * The following code snippet, from gjt.test.BorderTest creates - * and AWT Button, and embeds the button in a border. That - * border is then embedded in another border. The AWT Button - * winds up inside of a cyan border with a pixel width of 7, - * inside of a black border (pixel width 2):<p> - * - * <pre> - * private Border makeBorderedAWTButton() { - * Button button; - * Border cyanBorder, blackBorder; - * - * button = new Button("Button Inside Two Borders"); - * cyanBorder = new Border(button, 7); - * cyanBorder.setLineColor(Color.cyan); - * - * blackBorder = new Border(cyanBorder); - * - * return blackBorder; - * } - *</pre> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see DrawnRectangle - * @see ThreeDBorder - * @see EtchedBorder - * @see gjt.test.BorderTest - */ -public class Border extends Panel { - protected int thickness; - protected int gap; - protected DrawnRectangle border; - - protected static int _defaultThickness = 2; - protected static int _defaultGap = 0; - - public Border(Component borderMe) { - this(borderMe, _defaultThickness, _defaultGap); - } - public Border(Component borderMe, int thickness) { - this(borderMe, thickness, _defaultGap); - } - public Border(Component borderMe, int thickness, int gap) { - this.thickness = thickness; - this.gap = gap; - - setLayout(new BorderLayout()); - add("Center", borderMe); - } - public Insets insets() { - return new Insets(thickness+gap, thickness+gap, - thickness+gap, thickness+gap); - } - public Rectangle getInnerBounds() { - return border().getInnerBounds(); - } - public void setLineColor(Color c) { - border().setLineColor(c); - } - public Color getLineColor() { - return border().getLineColor(); - } - public void paint(Graphics g) { - border().paint(); - } - public void resize(int w, int h) { - Point location = location(); - reshape(location.x, location.y, w, h); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x, y, w, h); - border().resize(w, h); - } - protected String paramString() { - return super.paramString() + ",border=" + - border().toString() + ",thickness=" + thickness - + ",gap=" + gap; - } - protected DrawnRectangle border() { - if(border == null) - border = new DrawnRectangle(this, thickness); - return border; - } -} diff --git a/java/gjt/Box.java b/java/gjt/Box.java deleted file mode 100644 index 8feda366942..00000000000 --- a/java/gjt/Box.java +++ /dev/null @@ -1,81 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A Panel containing a single component; an etched rectangle is - * drawn around the component, and a Label is centered at the top - * of the rectangle. Of course, the single component may be - * a container, and therefore a Box may surround many components. - * <p> - * - * Both the Component around which the box is drawn, and the - * String drawn at the top of the box are specified at - * construction time.<p> - * - * Etching of the box is controlled by etchedIn() and - * etchedOut(). Default etching is etched in.<p> - * - * <em>Note: AWT 1.0.2 contains a bug which causes the - * Label.CENTER argument of the Label created for the title - * to be ignored, under Win95. Therefore, under Win95, the - * title will be off-center.</em><p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see EtchedRectangle - * @see gjt.test.BoxTest - */ -public class Box extends Panel { - private EtchedRectangle box = new EtchedRectangle(this); - private Label titleLabel; - - public Box(Component surrounded, String title) { - this(surrounded, new Label(title, Label.CENTER)); - } - public Box(Component surrounded, Label label) { - Assert.notNull(surrounded); - Assert.notNull(label); - - titleLabel = label; - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - - setLayout(gbl); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.anchor = GridBagConstraints.NORTH; - gbl.setConstraints(titleLabel, gbc); - add(titleLabel); - - gbc.insets = new Insets(0,10,10,10); - gbc.anchor = GridBagConstraints.CENTER; - gbc.weighty = 1.0; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(surrounded,gbc); - add(surrounded); - } - public void etchedIn () { box.etchedIn (); } - public void etchedOut() { box.etchedOut(); } - public void paint (Graphics g) { box.paint(); } - - public void resize(int w, int h) { - reshape(location().x, location().y, w, h); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x,y,w,h); - - FontMetrics fm = titleLabel.getFontMetrics( - titleLabel.getFont()); - int top = insets().top + fm.getAscent(); - Dimension size = size(); - - box.reshape(0, top, size.width-1, size.height-top-1); - } - protected String paramString() { - return super.paramString() + ",etching=" + - (box.isEtchedIn() ? Etching.IN : Etching.OUT) + - ",title=" + titleLabel; - } -} diff --git a/java/gjt/BulletinLayout.java b/java/gjt/BulletinLayout.java deleted file mode 100644 index 848a280de03..00000000000 --- a/java/gjt/BulletinLayout.java +++ /dev/null @@ -1,100 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Lays out components as though they were pinned to - * a bulletin board.<p> - * - * Components are simply reshaped to their location and their - * preferred size. BulletinLayout is preferrable to setting - * a container's layout manager to null and explicitly positioning - * and sizing components.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - */ -public class BulletinLayout implements LayoutManager { - public BulletinLayout() { - } - public void addLayoutComponent(String name, Component comp) { - } - public void removeLayoutComponent(Component comp) { - } - public Dimension preferredLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - Rectangle preferredBounds = new Rectangle(0,0); - Rectangle compPreferredBounds; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.preferredSize(); - compPreferredBounds = - new Rectangle(comp.location()); - compPreferredBounds.width = d.width; - compPreferredBounds.height = d.height; - - preferredBounds = - preferredBounds.union(compPreferredBounds); - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - public Dimension minimumLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - Rectangle minimumBounds = new Rectangle(0,0); - Rectangle compMinimumBounds; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.minimumSize(); - compMinimumBounds = - new Rectangle(comp.location()); - compMinimumBounds.width = d.width; - compMinimumBounds.height = d.height; - - minimumBounds = - minimumBounds.union(compMinimumBounds); - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - public void layoutContainer(Container target) { - Insets insets = target.insets(); - int ncomponents = target.countComponents(); - Component comp; - Dimension ps; - Point loc; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - ps = comp.preferredSize(); - loc = comp.location(); - - comp.reshape(insets.left + loc.x, - insets.top + loc.y, - ps.width, ps.height); - } - } - } -} diff --git a/java/gjt/ButtonPanel.java b/java/gjt/ButtonPanel.java deleted file mode 100644 index 6fc72ecaab2..00000000000 --- a/java/gjt/ButtonPanel.java +++ /dev/null @@ -1,51 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Button panel employs a BorderLayout to lay out a Separator in - * the north, and a Panel to which Buttons are added in the - * center.<p> - * - * Buttons may be added to the panel via two methods: - * <dl> - * <dd> void add(Button) - * <dd> Button add(String) - * </dl> - * <p> - * - * Button add(String) creates a Button and adds it to the - * panel, then returns the Button created, as a convenience to - * clients so that they do not have to go through the pain - * and agony of creating an ImageButton.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see MessageDialog - * @see QuestionDialog - * @see YesNoDialog - * @see gjt.test.DialogTest - * @see gjt.test.ComponentScrollerTest - */ -public class ButtonPanel extends Panel { - Panel buttonPanel = new Panel(); - Separator separator = new Separator(); - - public ButtonPanel() { - setLayout(new BorderLayout(0,5)); - add("North", separator); - add("Center", buttonPanel); - } - public void add(Button button) { - buttonPanel.add(button); - } - public Button add(String buttonLabel) { - Button addMe = new Button(buttonLabel); - buttonPanel.add(addMe); - return addMe; - } - protected String paramString() { - return super.paramString() + "buttons=" + - countComponents(); - } -} diff --git a/java/gjt/CardPanel.java b/java/gjt/CardPanel.java deleted file mode 100644 index c2ab1a9033c..00000000000 --- a/java/gjt/CardPanel.java +++ /dev/null @@ -1,48 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * CardPanel employs a BorderLayout to lay out North and Center - * panels; extensions of CardPanel must implement - * Component viewSelector(). The component returned from - * Component viewSelector() is centered in the North panel, and - * should contain UI controls that allow selection of the - * component to be displayed in the Center panel.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see IconCardPanel - * @see ChoiceCardPanel - * @see gjt.test.ChoiceCardPanelTest - * @see gjt.test.IconCardPanelTest - */ -public abstract class CardPanel extends Panel { - private Panel north, center; - private CardLayout cards; - - abstract public Component viewSelector(); - - public CardPanel() { - center = new Panel(); - north = new Panel(); - - setLayout(new BorderLayout()); - center.setLayout(cards = new CardLayout()); - north.setLayout (new BorderLayout()); - - add("North", north); - add("Center", center); - } - public void addNotify() { - super.addNotify(); - north.add("Center", viewSelector()); - north.add("South", new Separator()); - } - protected void addView(String name, Component component) { - center.add(name, component); - } - protected void showView(String name) { - cards.show(center, name); - } -} diff --git a/java/gjt/ChoiceCardPanel.java b/java/gjt/ChoiceCardPanel.java deleted file mode 100644 index 6273e03a5aa..00000000000 --- a/java/gjt/ChoiceCardPanel.java +++ /dev/null @@ -1,53 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * ChoiceCardPanel is an extension of CardPanel which presents - * an awt.Choice for selecting the panel to be displayed - * in the center panel.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CardPanel - * @see IconCardPanel - * @see gjt.test.IconCardPanelTest - * @see gjt.test.ChoiceCardPanelTest - */ -public class ChoiceCardPanel extends CardPanel { - private ChoiceViewSelector viewSelector; - - public ChoiceCardPanel() { - viewSelector = new ChoiceViewSelector(this); - } - public Component viewSelector() { - return viewSelector; - } - public void addChoice(String name, - Component component) { - viewSelector.addItem(name); - super.addView(name, component); - } -} - -class ChoiceViewSelector extends Panel { - private ChoiceCardPanel mvp; - private Choice choice; - - public ChoiceViewSelector(ChoiceCardPanel panel) { - setLayout(new FlowLayout()); - add(choice = new Choice()); - mvp = panel; - } - public void addItem(String name) { - choice.addItem(name); - } - public boolean handleEvent(Event event) { - if(event.id == Event.ACTION_EVENT) { - if(event.target instanceof Choice) { - mvp.showView(choice.getSelectedItem()); - } - } - return super.handleEvent(event); - } -} diff --git a/java/gjt/ColumnLayout.java b/java/gjt/ColumnLayout.java deleted file mode 100644 index bc51b44e456..00000000000 --- a/java/gjt/ColumnLayout.java +++ /dev/null @@ -1,154 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * ColumnLayout lays out components in a column. At - * construction time, both horizontal orientation and vertical - * orientation may be specified, along with the gap to use - * between components.<p> - * - * Horizontal orientation must be one of the following: - * <dl> - * <dd> LEFT - * <dd> CENTER - * <dd> RIGHT - * </dl> - * - * Vertical orientation must be one of the following: - * <dl> - * <dd> TOP - * <dd> CENTER - * <dd> BOTTOM - * </dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Orientation - * @see RowLayout - */ -public class ColumnLayout implements LayoutManager { - static private int _defaultGap = 5; - - private int gap; - private Orientation horizontalOrientation; - private Orientation verticalOrientation; - - public ColumnLayout() { - this(Orientation.CENTER, - Orientation.CENTER, _defaultGap); - } - public ColumnLayout(int gap) { - this(Orientation.CENTER, Orientation.CENTER, gap); - } - public ColumnLayout(Orientation horizontalOrient, - Orientation verticalOrient) { - this(horizontalOrient, verticalOrient, _defaultGap); - } - public ColumnLayout(Orientation horizontalOrient, - Orientation verticalOrient, int gap) { - Assert.notFalse(gap >= 0); - Assert.notFalse( - horizontalOrient == Orientation.LEFT || - horizontalOrient == Orientation.CENTER || - horizontalOrient == Orientation.RIGHT); - Assert.notFalse( - verticalOrient == Orientation.TOP || - verticalOrient == Orientation.CENTER || - verticalOrient == Orientation.BOTTOM); - - this.gap = gap; - this.verticalOrientation = verticalOrient; - this.horizontalOrientation = horizontalOrient; - } - - public void addLayoutComponent(String name, - Component comp) { - } - public void removeLayoutComponent(Component comp) { - } - - public Dimension preferredLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.preferredSize(); - if(i > 0) - dim.height += gap; - - dim.height += d.height; - dim.width = Math.max(d.width, dim.width); - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - return dim; - } - public Dimension minimumLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.minimumSize(); - - dim.width = Math.max(d.width, dim.width); - dim.height += d.height; - - if(i > 0) dim.height += gap; - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - public void layoutContainer(Container target) { - Insets insets = target.insets(); - int top = insets.top; - int left = 0; - int ncomponents = target.countComponents(); - Dimension preferredSize = target.preferredSize(); - Dimension targetSize = target.size(); - Component comp; - Dimension ps; - - if(verticalOrientation == Orientation.CENTER) - top += (targetSize.height/2) - - (preferredSize.height/2); - else if(verticalOrientation == Orientation.BOTTOM) - top = targetSize.height - preferredSize.height + - insets.top; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - left = insets.left; - - if(comp.isVisible()) { - ps = comp.preferredSize(); - - if(horizontalOrientation == Orientation.CENTER) - left = (targetSize.width/2) - (ps.width/2); - else if( - horizontalOrientation == Orientation.RIGHT) { - left = targetSize.width - ps.width - - insets.right; - } - comp.reshape(left,top,ps.width,ps.height); - top += ps.height + gap; - } - } - } -} diff --git a/java/gjt/ComponentScroller.java b/java/gjt/ComponentScroller.java deleted file mode 100644 index 3aef71c4ea2..00000000000 --- a/java/gjt/ComponentScroller.java +++ /dev/null @@ -1,42 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Scrolls any component. Component to be scrolled may be a - * container, so ultimately many components may be scrolled - * at once.<p> - * - * Component to be scrolled may be specified at construction - * time, or may be set after construction via - * void setComponent(Component).<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see BulletinLayout - * @see Scroller - * @see ScrollerLayout - * @see ImageScroller - * @see gjt.test.ComponentScrollerTest - */ -public class ComponentScroller extends Scroller { - private Component scrollMe; - - public ComponentScroller() { - } - public ComponentScroller(Component component) { - setComponent(component); - } - public void setComponent(Component component) { - scrollMe = component; - viewport.setLayout(new BulletinLayout()); - viewport.add (scrollMe); - viewport.move (0,0); - } - public void scrollTo(int x, int y) { - scrollMe.move(-x,-y); - } - public Dimension getScrollAreaSize() { - return scrollMe.preferredSize(); - } -} diff --git a/java/gjt/DialogClient.java b/java/gjt/DialogClient.java deleted file mode 100644 index 7e67cea758e..00000000000 --- a/java/gjt/DialogClient.java +++ /dev/null @@ -1,20 +0,0 @@ -package gjt; - -import java.awt.Dialog; - -/** - * DialogClients are notified when the Dialog with which they - * are associated is dismissed. A reference to the dismissed - * Dialog is passed as a parameter of dialogDismissed() in case - * a DialogClient is a client of more than one Dialog.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see MessageDialog - * @see QuestionDialog - * @see YesNoDialog - * @see gjt.test.DialogTest - */ -public interface DialogClient { - abstract public void dialogDismissed(Dialog d); -} diff --git a/java/gjt/DrawingPanel.java b/java/gjt/DrawingPanel.java deleted file mode 100644 index cda3fd69431..00000000000 --- a/java/gjt/DrawingPanel.java +++ /dev/null @@ -1,72 +0,0 @@ -package gjt; - -import java.awt.*; -import gjt.rubberband.*; - -/** - * An extension of gjt.rubberband.RubberbandPanel which serves - * as a panel used for drawing simple shapes (lines, rectangles, - * and ellipses). The shapes may be filled (except for lines, - * of course), and the color of the shapes may be specified.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.rubberband.RubberbandPanel - * @see gjt.rubberband.RubberbandEllipse - * @see gjt.rubberband.RubberbandLine - * @see gjt.rubberband.RubberbandRectangle - * @see gjt.test.RubberbandTest - * @see gjt.test.ToolbarTest - */ -public class DrawingPanel extends RubberbandPanel { - private Rubberband rbLine, rbRect, rbEllipse; - private Color color; - private boolean fill; - - public DrawingPanel() { - rbLine = new RubberbandLine (this); - rbRect = new RubberbandRectangle(this); - rbEllipse = new RubberbandEllipse (this); - - setRubberband(rbLine); - } - public void drawLines () { setRubberband(rbLine); } - public void drawRectangles() { setRubberband(rbRect); } - public void drawEllipses () { setRubberband(rbEllipse); } - - public void setColor(Color color) { this.color = color; } - public Color getColor() { return color; } - - public void setFill(boolean b) { fill = b; } - public boolean getFill() { return fill; } - - public boolean mouseUp(Event event, int x, int y) { - Rubberband rb = getRubberband(); - Graphics g = getGraphics(); - - super.mouseUp(event, x, y); - g.setColor(color); - - if(rb == rbLine) drawLine (rb, g); - else if(rb == rbRect) drawRectangle(rb, g); - else if(rb == rbEllipse) drawEllipse (rb, g); - - return true; - } - protected void drawLine(Rubberband rb, Graphics g) { - Point anchor = rb.getAnchor(), end = rb.getEnd(); - g.drawLine(anchor.x, anchor.y, end.x, end.y); - } - protected void drawRectangle(Rubberband rb, Graphics g) { - Rectangle r = rb.bounds(); - - if(fill) g.fillRect(r.x, r.y, r.width, r.height); - else g.drawRect(r.x, r.y, r.width, r.height); - } - protected void drawEllipse(Rubberband rb, Graphics g) { - Rectangle r = rb.bounds(); - - if(fill) g.fillArc(r.x, r.y, r.width, r.height, 0, 360); - else g.drawArc(r.x, r.y, r.width, r.height, 0, 360); - } -} diff --git a/java/gjt/DrawnRectangle.java b/java/gjt/DrawnRectangle.java deleted file mode 100644 index e96fd8d3673..00000000000 --- a/java/gjt/DrawnRectangle.java +++ /dev/null @@ -1,136 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A Rectangle which draws itself inside of a Component.<p> - * - * DrawnRectangles may have their thickness and line color set, - * and are capable of reporting their inner bounds (the area - * inside the lines).<p> - * - * Default thickness is 2.<p> - * - * If not set explicitly, the line color used is three shades - * darker than the background color of the Component being - * drawn into.<p> - * - * DrawnRectangles may be clear()ed, which clears both the - * exterior (the lines) and the interior (the area inside of - * the lines) of the DrawnRectangle.<p> - * - * DrawnRectangles may also be fill()ed with a specified color - * by calling fill(Color), or by calling setFillColor(Color) - * followed by fill().<p> - * - * By default, the fill Color is the background color of the - * Component drawn into.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ThreeDRectangle - * @see EtchedRectangle - * @see Border - * @see EtchedBorder - * @see ThreeDBorder - * @see gjt.test.DrawnRectangleTest - */ -public class DrawnRectangle extends Rectangle { - protected static int _defaultThickness = 2; - - protected Component drawInto; - private int thick; - private Color lineColor, fillColor; - - public DrawnRectangle(Component drawInto) { - this(drawInto, _defaultThickness, 0, 0, 0, 0); - } - public DrawnRectangle(Component drawInto, int thick) { - this(drawInto, thick, 0, 0, 0, 0); - } - public DrawnRectangle(Component drawInto, int x, int y, - int w, int h) { - this(drawInto, _defaultThickness, x, y, w, h); - } - public DrawnRectangle(Component drawInto, int thick, - int x, int y, int w, int h) { - Assert.notNull(drawInto); - Assert.notFalse(thick > 0); - - this.drawInto = drawInto; - this.thick = thick; - reshape(x,y,w,h); - } - public Component component() {return drawInto; } - public int getThickness () {return thick; } - public void setThickness (int thick) {this.thick = thick; } - - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } - public void setFillColor(Color fillColor) { - this.fillColor = fillColor; - } - public void fill() { - fill(getFillColor()); - } - public Color getLineColor() { - if(lineColor == null) - lineColor = - drawInto.getBackground().darker().darker().darker(); - return lineColor; - } - public Color getFillColor() { - if(fillColor == null) - fillColor = drawInto.getBackground(); - return fillColor; - } - public Rectangle getInnerBounds() { - return new Rectangle(x+thick, y+thick, - width-(thick*2), height-(thick*2)); - } - public void paint() { - Graphics g = drawInto.getGraphics(); - paintFlat(g, getLineColor()); - } - private void paintFlat(Graphics g, Color color) { - if(g != null) { - g.setColor(color); - for(int i=0; i < thick; ++i) - g.drawRect(x+i, y+i, - width-(i*2)-1, height-(i*2)-1); - } - } - public void clearInterior() { - fill(drawInto.getBackground()); - } - public void clearExterior() { - paintFlat(drawInto.getGraphics(), - drawInto.getBackground()); - } - public void clear() { - clearExterior(); - clearInterior(); - } - public void fill(Color color) { - Graphics g = drawInto.getGraphics(); - - if(g != null) { - Rectangle r = getInnerBounds(); - g.setColor(color); - g.fillRect(r.x, r.y, r.width, r.height); - setFillColor(color); - } - } - public String toString() { - return super.toString() + "[" + paramString() + "]"; - } - public String paramString() { - return "color=" + getLineColor() + ",thickness=" + - thick + ",fillColor=" + getFillColor(); - } - protected Color brighter() { - return - getLineColor().brighter().brighter().brighter().brighter(); - } -} diff --git a/java/gjt/EtchedBorder.java b/java/gjt/EtchedBorder.java deleted file mode 100644 index 09ff845014b..00000000000 --- a/java/gjt/EtchedBorder.java +++ /dev/null @@ -1,59 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * An extension of Border that draws an etched border. - * - * Drawn etchedIn by default, drawing style used by paint() is - * controlled by etchedIn() and etchedOut(). Note that - * etchedIn() and etchedOut() do not result in anything being - * painted, but only set the state for the next call to paint(). - * To set the state and paint in one operation, use - * paintEtchedIn() and paintEtchedOut().<p> - * - * The current state of the border may be obtained by calling - * isEtchedIn().<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Border - * @see ThreeDRectangle - * @see gjt.test.BorderTest - */ -public class EtchedBorder extends Border { - public EtchedBorder(Component borderMe) { - this(borderMe, _defaultThickness, _defaultGap); - } - public EtchedBorder(Component borderMe, - int borderThickness) { - this(borderMe, borderThickness, _defaultGap); - } - public EtchedBorder(Component borderMe, - int borderThickness, int gap) { - super(borderMe, borderThickness, gap); - } - public void etchedIn() { - ((EtchedRectangle)border()).etchedIn(); - } - public void etchedOut() { - ((EtchedRectangle)border()).etchedOut(); - } - public void paintEtchedIn() { - ((EtchedRectangle)border()).paintEtchedIn (); - } - public void paintEtchedOut() { - ((EtchedRectangle)border()).paintEtchedOut(); - } - public boolean isEtchedIn() { - return ((EtchedRectangle)border()).isEtchedIn(); - } - protected String paramString() { - return super.paramString() + (EtchedRectangle)border(); - } - protected DrawnRectangle border() { - if(border == null) - border = new EtchedRectangle(this, thickness); - return border; - } -} diff --git a/java/gjt/EtchedRectangle.java b/java/gjt/EtchedRectangle.java deleted file mode 100644 index b8026d42f8d..00000000000 --- a/java/gjt/EtchedRectangle.java +++ /dev/null @@ -1,97 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A DrawnRectangle that draws an etched border.<p> - * - * Drawn etched in by default, drawing style used by paint() is - * controlled by etchedIn() and etchedOut(). Note that - * etchedIn() and etchedOut() do not result in anything being - * painted, but only set the state for the next call to paint(). - * To set the state and paint in one operation, use - * paintEtchedIn() and paintEtchedOut().<p> - * - * Although it is permissible to set the thickness of - * EtchedRectangles, they tend to loose the etching effect - * if thickness is greater than 4.<p> - * - * The current state of the rectangle may be obtained by - * calling isEtchedIn(). - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see DrawnRectangle - * @see ThreeDRectangle - * @see gjt.test.DrawnRectangleTest - */ -public class EtchedRectangle extends DrawnRectangle { - protected static Etching _defaultEtching = Etching.IN; - private Etching etching; - - public EtchedRectangle(Component drawInto) { - this(drawInto, _defaultEtching, - _defaultThickness, 0, 0, 0, 0); - } - public EtchedRectangle(Component drawInto, int thickness) { - this(drawInto, _defaultEtching, thickness, 0, 0, 0, 0); - } - public EtchedRectangle(Component drawInto, int x, int y, - int w, int h) { - this(drawInto, _defaultEtching, - _defaultThickness, x, y, w, h); - } - public EtchedRectangle(Component drawInto, int thickness, - int x, int y, - int w, int h) { - this(drawInto, _defaultEtching, thickness, x, y, w, h); - } - public EtchedRectangle(Component drawInto, Etching etching, - int thickness, int x, int y, - int w, int h) { - super(drawInto, thickness, x, y, w, h); - this.etching = etching; - } - public void etchedIn () { etching = Etching.IN; } - public void etchedOut () { etching = Etching.OUT; } - public boolean isEtchedIn() { return etching == Etching.IN;} - - public void paint() { - if(etching == Etching.IN) paintEtchedIn(); - else paintEtchedOut(); - } - public void paintEtchedIn() { - Graphics g = drawInto.getGraphics(); - if(g != null) - paintEtched(g, getLineColor(), brighter()); - - etchedIn(); - } - public void paintEtchedOut() { - Graphics g = drawInto.getGraphics(); - if(g != null) - paintEtched(g, brighter(), getLineColor()); - - etchedOut(); - } - public String paramString() { - return super.paramString() + "," + etching; - } - private void paintEtched(Graphics g, - Color topLeft, - Color bottomRight) { - int thickness = getThickness(); - int w = width - thickness; - int h = height - thickness; - - g.setColor(topLeft); - for(int i=0; i < thickness/2; ++i) - g.drawRect(x+i, y+i, w, h); - - g.setColor(bottomRight); - - for(int i=0; i < thickness/2; ++i) - g.drawRect(x+(thickness/2)+i, - y+(thickness/2)+i, w, h); - } -} diff --git a/java/gjt/Etching.java b/java/gjt/Etching.java deleted file mode 100644 index ad40d9caaea..00000000000 --- a/java/gjt/Etching.java +++ /dev/null @@ -1,22 +0,0 @@ -package gjt; - -/** - * Constants for Etching. - * - * This class may not be instantiated. - * - * @version 1.0, Apr 11 1996 - * @author David Geary - */ -public class Etching { - public static final Etching OUT = new Etching(); - public static final Etching IN = new Etching(); - - public String toString() { - if(this == Etching.OUT) - return getClass().getName() + "=OUT"; - else - return getClass().getName() + "=IN"; - } - private Etching() { } -} diff --git a/java/gjt/ExclusiveImageButtonPanel.java b/java/gjt/ExclusiveImageButtonPanel.java deleted file mode 100644 index f1d0878a499..00000000000 --- a/java/gjt/ExclusiveImageButtonPanel.java +++ /dev/null @@ -1,47 +0,0 @@ -package gjt; - -import java.awt.Image; - -/** - * An ImageButtonPanel which fits all of its ImageButtons with - * a StickyImageButtonController. ExclusiveImageButtonPanel - * relies upon its superclass' controller: a - * RadioImageButtonPanelController, which ensures that only one - * of the ImageButtons is selected at a time.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonPanel - * @see gjt.test.ToolbarTest - */ -public class ExclusiveImageButtonPanel extends - ImageButtonPanel { - public ExclusiveImageButtonPanel(Orientation orient) { - this(orient, 5); - } - public ExclusiveImageButtonPanel(Orientation orient, - int gap) { - super(orient, gap); - } - public ExclusiveImageButtonPanel(Orientation orient, - Orientation horient, - Orientation vorient, - int gap) { - super(orient, horient, vorient, gap); - } - public void add(ImageButton button) { - super.add(button); - new StickyImageButtonController(button); - } - public ImageButton add(Image image) { - ImageButton button = super.add(image); - new StickyImageButtonController(button); - return button; - } - public ImageButton add(Image image, String name) { - ImageButton button = super.add(image, name); - new StickyImageButtonController(button); - return button; - } -} diff --git a/java/gjt/FontDialog.java b/java/gjt/FontDialog.java deleted file mode 100644 index 182ca582884..00000000000 --- a/java/gjt/FontDialog.java +++ /dev/null @@ -1,362 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A dialog used for selecting a font. FontDialog is - * constructed with a Frame, DialogClient, initial font to - * display, and boolean that indicates modality.<p> - * - * FontDialog contains a preview panel which previews the - * currently selected font. Updating of the preview panel is - * triggered by a preview button at the bottom of the dialog.<p> - * - * FontDialog contains 3 methods which define the labels for - * the buttons it contains: - * <dl> - * <dd> String getPreviewButtonLabel() - * <dd> String getOkButtonLabel() - * <dd> String getCancelButtonLabel() - * </dl><p> - * - * By default the 3 methods return "Preview", "Ok" and "Cancel" - * respectively. FontDialog may be extended and the 3 methods - * overridden to customize the labels displayed in the - * buttons.<p> - * - * FontDialog uses Toolkit to get a list of fonts by invoking - * Toolkit.getFontList(). This is done in the getFontNames() - * method, which may be overridden by extensions of FontDialog - * in case the standard set of font names are inadequate.<p> - * - * Finally, font sizes are obtained by the getFontSizes() - * method. FontDialog defines 8 sizes by default: 8, 12, 14, - * 16, 18, 24, 48 and 64. Extensions of FontDialog may override - * getFontSizes() to provide a different list of sizes.<p> - * - * See gjt.test.FontDialogTest for an example of an extension - * of FontDialog which overrides the methods discussed above.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see java.awt.Dialog - * @see java.awt.Toolkit - * @see DialogClient - * @see gjt.test.FontDialogTest - */ -public class FontDialog extends Dialog { - private static String _defaultSizes[] = - { "8", "12", "14", "16", "18", "24", "48", "64" }; - - private FontPanel fontPanel; - private Font fontSelected; - private DialogClient client; - - public FontDialog(Frame frame, - DialogClient client, - Font font, // initial font - boolean modal) { - super(frame, "Select A Font", modal); - this.client = client; - - setLayout(new BorderLayout()); - add("Center", fontPanel = new FontPanel(this, font)); - } - public boolean handleEvent(Event event) { - if(event.id == Event.WINDOW_DESTROY) - done(null); - - return super.handleEvent(event); - } - public String[] getFontNames() { - return getToolkit().getFontList(); - } - public String[] getFontSizes() { - return _defaultSizes; - } - - public String getPreviewButtonLabel() { return "Preview"; } - public String getOkButtonLabel () { return "Ok"; } - public String getCancelButtonLabel () { return "Cancel"; } - - public void show() { - Point frameLoc = getParent().location(); - reshape(frameLoc.x + 50, frameLoc.x + 50, 550, 450); - super.show(); - } - public void done(Font font) { - fontSelected = font; - client.dialogDismissed(this); - hide (); - dispose(); - } - public Font getFontSelected() { - return fontSelected; - } - public void listSelectedInPicker() { - fontPanel.getPreviewButton().requestFocus(); - } -} - -class FontPanel extends Panel { - private static Font defaultFont = - new Font("TimesRoman", Font.PLAIN, 12); - - private FontPreviewPanel preview; - private FontSelectionPanel fsp; - - public FontPanel(FontDialog dialog, Font f) { - Font font = f == null ? defaultFont : f; - - setLayout(new BorderLayout()); - add("North", preview = new FontPreviewPanel ()); - add("Center", fsp = - new FontSelectionPanel(dialog, preview, font)); - } - public Button getPreviewButton() { - return fsp.getPreviewButton(); - } -} - -class FontPreviewPanel extends Panel { - TextField textField = new TextField(); - Box box = new Box(textField, "Preview"); - - public FontPreviewPanel() { - textField.setEditable(false); - - setLayout(new BorderLayout()); - add("Center", box); - } - public void setPreviewFont(Font font) { - String name = font.getName(); - String size = String.valueOf(font.getSize()); - String style = new String(); - - if(font.isPlain () == true) style = "Plain"; - else { - if(font.isBold () == true) style += "Bold"; - if(font.isItalic() == true) style += "Italic"; - } - textField.setFont(font); - textField.setText(name + " " + style + " " + size); - retrofitPreviewPanel(); - } - private void retrofitPreviewPanel() { - Dimension tfps, tfs; - FontPanel fontPanel = (FontPanel)getParent(); - - tfps = textField.preferredSize(); - tfs = textField.size(); - - if(tfps.width != tfs.width || - tfps.height != tfs.height) { - fontPanel.invalidate(); - fontPanel.getParent().validate(); - box.repaint(); // Only necessary on Win95 - } - } -} - -class FontSelectionPanel extends Panel { - private FontPickerPanel picker; - private FontButtonsPanel buttons; - private FontPreviewPanel preview; - private Font initialFont; - - public FontSelectionPanel(FontDialog dialog, - FontPreviewPanel preview, - Font initialFont) { - this.preview = preview; - this.initialFont = initialFont; - - picker = new FontPickerPanel (dialog, initialFont); - buttons = new FontButtonsPanel(dialog, picker, preview); - - setLayout(new BorderLayout()); - add("Center", picker); - add("South", buttons); - } - public void addNotify() { - super.addNotify(); - preview.setPreviewFont(initialFont); - } - public Button getPreviewButton() { - return buttons.getPreviewButton(); - } -} - -class FontPickerPanel extends Panel { - private FontDialog dialog; - private Button previewButton; - private List fonts = new List(); - private List styles = new List(); - private List sizes = new List(); - private Font initialFont; - - public FontPickerPanel(FontDialog dialog, - Font initialFont) { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - Label family = new Label("Family"); - Label style = new Label("Style"); - Label size = new Label("Size"); - - this.initialFont = initialFont; - this.dialog = dialog; - - populateFonts (); - populateStyles(); - populateSizes (); - - setLayout(gbl); - - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = 1; - gbl.setConstraints(family, gbc); add(family); - gbl.setConstraints(style, gbc); add(style); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbl.setConstraints(size, gbc); add(size); - - gbc.gridwidth = 1; - gbc.weighty = 1.0; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(fonts, gbc); add(fonts); - gbl.setConstraints(styles, gbc); add(styles); - gbl.setConstraints(sizes, gbc); add(sizes); - } - public boolean handleEvent(Event event) { - if(event.id == Event.LIST_SELECT) { - dialog.listSelectedInPicker(); - return true; - } - return false; - } - public void addNotify() { - super.addNotify(); - String initialFamily = initialFont.getName(); - int initialSize = initialFont.getSize(); - int initialStyle = initialFont.getStyle(); - - styles.select(initialStyle); - - for(int i=0; i < fonts.countItems(); ++i) { - String nextFamily = fonts.getItem(i); - if(nextFamily.equals(initialFamily)) - fonts.select(i); - } - for(int i=0; i < sizes.countItems(); ++i) { - String nextSize = sizes.getItem(i); - if(nextSize.equals(String.valueOf(initialSize))) - sizes.select(i); - } - } - public String fontSelected() { - return fonts.getSelectedItem (); - } - public String styleSelected() { - return styles.getSelectedItem(); - } - public int sizeSelected() { - String szstring = sizes.getSelectedItem(); - - if(szstring != null) { - Integer integer = new Integer(szstring); - return integer.intValue(); - } - else - return 0; - } - private void populateFonts() { - String names[] = dialog.getFontNames(); - - for(int i=0; i < names.length; ++i) { - fonts.addItem(names[i]); - } - } - private void populateSizes() { - String sizeArray[] = dialog.getFontSizes(); - - for(int i=0; i < sizeArray.length; ++i) { - sizes.addItem(sizeArray[i]); - } - } - private void populateStyles() { - styles.addItem("Plain"); - styles.addItem("Bold"); - styles.addItem("Italic"); - styles.addItem("BoldItalic"); - } -} - -class FontButtonsPanel extends Panel { - private FontDialog dialog; - private FontPickerPanel picker; - private FontPreviewPanel preview; - private Button previewButton, - okButton, - cancelButton; - - public FontButtonsPanel(FontDialog dialog, - FontPickerPanel picker, - FontPreviewPanel preview) { - this.picker = picker; - this.preview = preview; - this.dialog = dialog; - - add(previewButton = - new Button(dialog.getPreviewButtonLabel())); - add(cancelButton = - new Button(dialog.getCancelButtonLabel())); - add(okButton = - new Button(dialog.getOkButtonLabel())); - } - public void addNotify() { - super.addNotify(); - cancelButton.requestFocus(); - } - public boolean action(Event event, Object object) { - Button button = (Button)event.target; - boolean handledEvent = true; - - if(event.target == previewButton) { - Font selectedFont = fontSelected(); - - if(selectedFont != null) { - preview.setPreviewFont(selectedFont); - okButton.requestFocus(); - } - } - else if(event.target == okButton) - dialog.done(fontSelected()); - else if(event.target == cancelButton) - dialog.done(null); - else - handledEvent = false; - - return handledEvent; - } - public Button getPreviewButton() { - return previewButton; - } - private Font fontSelected() { - String font = picker.fontSelected (); - String style = picker.styleSelected(); - int size = picker.sizeSelected (); - int istyle = Font.PLAIN; - - if(font != null && style != null && size > 0) { - if(style.equals("Bold")) istyle = Font.BOLD; - if(style.equals("Plain")) istyle = Font.PLAIN; - if(style.equals("Italic")) istyle = Font.ITALIC; - - if(style.equals("BoldItalic")) - istyle = Font.BOLD + Font.ITALIC; - - return new Font(font, istyle, size); - } - else - return null; - } -} diff --git a/java/gjt/GJTDialog.java b/java/gjt/GJTDialog.java deleted file mode 100644 index 7fc0bd39f40..00000000000 --- a/java/gjt/GJTDialog.java +++ /dev/null @@ -1,51 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A base class for gjt dialog classes, this concrete class - * establishes the relationship between a dialog and its - * client (DialogClient).<p> - * - * Note that show() is overridden to ensure that the dialog is - * centered in the frame which is specified as its parent. This - * is necessary due to a bug in the Win95 implementation of the - * AWT (version 1.0.2) that causes dialogs to be displayed at - * a screen coordinate of 0,0. While the overridden show() is - * not necessary under non-Win95 Java implementations, it - * alleviates the Win95 bug and results in no dire consequences - * on other platforms.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see MessageDialog - * @see QuestionDialog - * @see YesNoDialog - * @see ProgressDialog - * @see gjt.test.DialogTest - */ -public class GJTDialog extends Dialog { - protected DialogClient client; - - public GJTDialog(Frame frame, - String title, - DialogClient client, - boolean modal) { - super(frame, title, modal); - setClient(client); - } - public void setClient(DialogClient client) { - this.client = client; - } - public void show() { // Fixes bug under Win95 - Dimension frameSize = getParent().size(); - Point frameLoc = getParent().location(); - Dimension mySize = size(); - int x,y; - - x = frameLoc.x + (frameSize.width/2) -(mySize.width/2); - y = frameLoc.y + (frameSize.height/2)-(mySize.height/2); - reshape(x,y,size().width,size().height); - super.show(); - } -} diff --git a/java/gjt/IconCardPanel.java b/java/gjt/IconCardPanel.java deleted file mode 100644 index 78940bf8f4f..00000000000 --- a/java/gjt/IconCardPanel.java +++ /dev/null @@ -1,55 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A CardPanel whose Component viewSelector() returns - * a panel with image buttons to control the selection of the - * panel to be displayed beneath the view selector panel.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CardPanel - * @see ChoiceCardpanel - * @see gjt.test.IconCardPanelTest - */ -public class IconCardPanel extends CardPanel { - private ImageButtonPanel viewSelector; - - public IconCardPanel() { - viewSelector = new IconViewSelector(this); - } - public Component viewSelector() { - return viewSelector; - } - public void addImageButton(Image image, - String name, - Component component) { - ImageButton newButton; - - viewSelector.add( - newButton = new ImageButton(image), name); - newButton.setController( - new StickyImageButtonController(newButton)); - super.addView(name, component); - } -} - -class IconViewSelector extends ImageButtonPanel { - private IconCardPanel mvp; - - public IconViewSelector(IconCardPanel panel) { - super(Orientation.HORIZONTAL); - setLayout(new FlowLayout()); - mvp = panel; - } - public boolean handleEvent(Event event) { - if(event.id == Event.MOUSE_DOWN) { - if(event.target instanceof ImageButton) { - ImageButton ib = (ImageButton)event.target; - mvp.showView(getButtonName(ib)); - } - } - return super.handleEvent(event); - } -} diff --git a/java/gjt/ImageButton.java b/java/gjt/ImageButton.java deleted file mode 100644 index 07bdeff0ef8..00000000000 --- a/java/gjt/ImageButton.java +++ /dev/null @@ -1,209 +0,0 @@ -package gjt; - -import java.awt.*; -import java.awt.image.FilteredImageSource; - -import gjt.image.BleachImageFilter; - -/** - * An Image painted in a Canvas, bordered by a ThreeDRectangle. - * <p> - * - * ImageButtons have two constructors, both of which take an - * Image. The Image passed to the constructor must not be null; - * this is enforced by an assertion.<p> - * - * Default border thickness is 2 pixels - thickness may be set - * at construction time only.<p> - * - * Event handling is delegated to an ImageButtonController. By - * default, all ImageButtons are fitted with an instance of - * SpringyImageButtonController, however, - * setController(ImageButtonController) may be used to fit an - * ImageButton with a different derivation of - * ImageButtonController after construction.<p> - * - * ImageButtons ensure that their Images are completely loaded - * before they are displayed.<p> - * - * Drawn either raised or inset, current state may be queried - * via the isRaised() method.<p> - * - * disable() disables response to input and repaints the image - * with a bleached version. enable() restores the original - * image and enables response to input. The intensity of the - * bleaching effect may be controlled (for all ImageButtons) - * via the static setBleachPercent(int) method.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ThreeDRectangle - * @see ImageButtonController - * @see ImageButtonEvent - * @see SpringyImageButtonController - * @see StickyImageButtonController - * @see BleachImageFilter - * @see gjt.test.ImageButtonTest - */ -public class ImageButton extends Canvas { - private static BleachImageFilter _bleachFilter; - private static int _bleachPercent = 50; - private static int _offset = 1; - private static int _defaultThickness = 2; - - private ThreeDRectangle border = new ThreeDRectangle(this); - private boolean isDisabled = false; - private Dimension preferredSize = new Dimension(0,0); - private int thickness; - private Image image, disabledImage; - private ImageButtonController controller; - - public static int setBleachPercent() { - return _bleachPercent; - } - public static void getBleachPercent(int p) { - _bleachPercent = p; - } - public ImageButton(Image image) { - this(image, _defaultThickness, null); - } - public ImageButton(Image image, - ImageButtonController controller) { - this(image, _defaultThickness, controller); - } - public ImageButton(Image image, int thickness, - ImageButtonController controller) { - Assert.notNull(image); - Assert.notFalse(thickness > 0); - - if(controller == null) - this.controller = - new SpringyImageButtonController(this); - else - this.controller = controller; - - border.setThickness(this.thickness = thickness); - setImage(image); - } - public void setImage(Image image) { - Util.waitForImage(this, this.image = image); - - preferredSize.width = image.getWidth (this) + - (2*thickness); - preferredSize.height = image.getHeight(this) + - (2*thickness); - } - public Dimension minimumSize() { - return preferredSize; - } - public Dimension preferredSize() { - return preferredSize; - } - public boolean isRaised () { return border.isRaised(); } - public boolean isDisabled() { return isDisabled; } - - public void enable() { - isDisabled = false; - repaint(); - } - public void disable() { - isDisabled = true; - - if(disabledImage == null) - createDisabledImage(); - - repaint(); - } - public void resize(int w, int h) { - reshape(location().x, location().y, w, h); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x,y,w,h); - border.resize(w,h); - } - public void paint(Graphics g) { - if(isRaised()) paintRaised(); - else paintInset (); - } - public void paintInset() { - Point upperLeft = findUpperLeft(); - Graphics g = getGraphics(); - Image image = isDisabled() ? - disabledImage : this.image; - Dimension size = size(); - - if(g != null) { - border.clearInterior(); - g.drawImage(image, - upperLeft.x + thickness + _offset, - upperLeft.y + thickness + _offset,this); - - g.setColor(getBackground().darker()); - for(int i=0; i < _offset; ++i) { - g.drawLine(thickness+i,thickness+i, - size.width-thickness-i,thickness+i); - g.drawLine(thickness+i,thickness+i, - thickness+i,size.height-thickness-i); - } - border.paintInset(); - } - } - public void paintRaised() { - Point upperLeft = findUpperLeft(); - Graphics g = getGraphics(); - Image image = isDisabled() ? - disabledImage : this.image; - - if(g != null) { - border.clearInterior(); - g.drawImage(image, upperLeft.x + thickness, - upperLeft.y + thickness, this); - border.paintRaised(); - } - } - public boolean isInside(int x, int y) { - Dimension size = size(); - return x >= 0 && x < size.width && y >= 0 && - y < size.height; - } - public void setController(ImageButtonController controller){ - this.controller = controller; - } - public ImageButtonController getController() { - return controller; - } - public boolean mouseDown(Event event, int x, int y) { - if(isDisabled()) return false; - else return controller.mouseDown(event,x,y); - } - public boolean mouseUp(Event event, int x, int y) { - if(isDisabled()) return false; - else return controller.mouseUp(event,x,y); - } - public boolean mouseDrag(Event event, int x, int y) { - if(isDisabled()) return false; - else return controller.mouseDrag(event,x,y); - } - - private void createDisabledImage() { - if(_bleachFilter == null) - _bleachFilter = - new BleachImageFilter(_bleachPercent); - - if(_bleachPercent != _bleachFilter.percent()) - _bleachFilter.percent(_bleachPercent); - - FilteredImageSource fis = - new FilteredImageSource(image.getSource(), - _bleachFilter); - - Util.waitForImage(this, disabledImage=createImage(fis)); - } - private Point findUpperLeft() { - Dimension size = size(); - return new Point((size.width/2) - - (preferredSize.width/2), - (size.height/2) - - (preferredSize.height/2)); - } -} diff --git a/java/gjt/ImageButtonController.java b/java/gjt/ImageButtonController.java deleted file mode 100644 index 0f6aa6f4add..00000000000 --- a/java/gjt/ImageButtonController.java +++ /dev/null @@ -1,79 +0,0 @@ -package gjt; -import java.awt.Event; - -/** - * A controller for an ImageButton, this abstract class - * establishes the association between itself and an ImageButton - * and delivers events to its ImageButton.<p> - * - * ImageButtonControllers must be constructed with an - * ImageButton; the ImageButton's controller gets set by - * ImageButtonController's constructor.<p> - * - * The ImageButton passed into the constructor must not be null; - * this is enforced by an assertion.<p> - * - * Methods defined in the MouseController interface are left - * for subclasses to implement. ImageButtonController defines - * mouseMove(), mouseEnter() and mouseExit() as no-ops, so - * that extensions of ImageButtonController only have to - * implement mouseDown(), mouseUp() and mouseDrag(). Note - * that extensions are still free to override mouseMove(), - * mouseEnter() and mouseExit() if desired.<p> - * - * Subclasses should also call the protected XXXButton(Event) - * methods below, where XXX is either arm, disarm, activate, or - * deactivate as appropriate. SpringyImageButtonController is - * a good example of this (so is StickyImageButtonController, - * but it is more complicated than it's springy sibling).<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see MouseController - * @see ImageButton - * @see ImageButtonEvent - * @see SpringyImageButtonController - * @see StickyImageButtonController - * @see gjt.test.ImageButtonTest - */ -public abstract class ImageButtonController - implements MouseController { - private ImageButton button; - - ImageButtonController(ImageButton button) { - Assert.notNull(button); - this.button = button; - button.setController(this); - } - public ImageButton getButton() { - return button; - } - public boolean mouseEnter(Event event, int x, int y) { - return false; - } - public boolean mouseExit (Event event, int x, int y) { - return false; - } - public boolean mouseMove (Event event, int x, int y) { - return false; - } - - protected void armButton(Event event) { - button.deliverEvent( - new ImageButtonEvent(button, - event, - ImageButtonEvent.ARM)); - } - protected void disarmButton(Event event) { - button.deliverEvent( - new ImageButtonEvent(button, - event, - ImageButtonEvent.DISARM)); - } - protected void activateButton(Event event) { - button.deliverEvent( - new ImageButtonEvent(button, - event, - ImageButtonEvent.ACTIVATE)); - } -} diff --git a/java/gjt/ImageButtonEvent.java b/java/gjt/ImageButtonEvent.java deleted file mode 100644 index bb7f196698f..00000000000 --- a/java/gjt/ImageButtonEvent.java +++ /dev/null @@ -1,103 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * An extension of java.awt.Event, specifically designed for - * ImageButton events.<p> - * - * ImageButtonEvents are constructed with 3 arguments: - * <dl> - * <dd> ImageButton in which the event occurred - * <dd> The AWT event that triggered the image button event - * <dd> The id of the event. - * </dl> - * - * An ImageButtonEvent's id (the constructor's 3rd argument), - * must be one of the following: - * - * <dl> - * <dd> ImageButtonEvent.ARM - * <dd> ImageButtonEvent.DISARM - * <dd> ImageButtonEvent.ACTIVATE - * </dl> - * - * ImageButtonEvent has only a constructor and a paramString() - * method. Containers that contain ImageButtons should check - * for ImageButtonEvents like so: <p> - * - * <pre> - * // handleEvent(Event) method of a container that - * // contains ImageButtons. - * - * public boolean handleEvent(Event event) { - * if(event instanceof ImageButtonEvent) { - * ImageButtonEvent ibevent = - * (ImageButtonEvent)event; - * - * if(ibevent.isArmed()) { - * // do something for arming - * } - * if(ibevent.isDisarmed()) { - * // do something for disarming - * } - * if(ibevent.isActivated()) { - * // do something for activation - * } - * } - * } - * </pre> - * - * ImageButtonController is the only GJT class that creates - * ImageButtonEvents. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonController - * @see SpringyImageButtonController - * @see StickyImageButtonController - * @see gjt.test.ImageButtonTest - */ -public class ImageButtonEvent extends Event { - public static final int ARM = 1; - public static final int DISARM = 2; - public static final int ACTIVATE = 3; - - private int eventType; - - public ImageButtonEvent(ImageButton button, - Event event, - int type) { - super(button, event.when, event.id, event.x, event.y, - event.key, event.modifiers, event.arg); - - Assert.notFalse(type == ARM || - type == DISARM || - type == ACTIVATE); - - eventType = type; - id = -1; - } - public boolean isArmed() { - return eventType == ARM; - } - public boolean isDisarmed() { - return eventType == DISARM; - } - public boolean isActivated() { - return eventType == ACTIVATE; - } - protected String paramString() { - String str = new String(); - - if(eventType == ImageButtonEvent.ARM) - str = "ARM"; - else if(eventType == ImageButtonEvent.DISARM) - str = "DISARM"; - else if(eventType == ImageButtonEvent.ACTIVATE) - str = "ACTIVATE"; - - return super.paramString() + str; - } -} diff --git a/java/gjt/ImageButtonPanel.java b/java/gjt/ImageButtonPanel.java deleted file mode 100644 index 0d033b7967b..00000000000 --- a/java/gjt/ImageButtonPanel.java +++ /dev/null @@ -1,106 +0,0 @@ -package gjt; - -import java.awt.*; -import java.util.Enumeration; -import java.util.Hashtable; - -/** - * A panel which contains a collection of ImageButtons, - * arranged either horizontally or vertically.<p> - * - * Handling of mouse events is delegated to an image button - * panel controller. By default, an image button panel is - * outfitted with an instance of RadioImageButtonPanelController - * which implements mutually exclusive selection behavior. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see RadioImageButtonPanelController - * @see gjt.test.ToolbarTest - */ -public class ImageButtonPanel extends Panel { - static private int _defaultGap = 5; - - private Hashtable nameAndButtonPairs = new Hashtable(); - private ImageButtonPanelController controller; - - public ImageButtonPanel(Orientation orient) { - this(orient, Orientation.CENTER, - Orientation.CENTER, _defaultGap); - } - public ImageButtonPanel(Orientation orient, int gap) { - this(orient, Orientation.CENTER, - Orientation.CENTER, gap); - } - public ImageButtonPanel(Orientation orient, - Orientation horient, - Orientation vorient, int gap) { - Assert.notFalse(orient == Orientation.HORIZONTAL || - orient == Orientation.VERTICAL); - - if(orient == Orientation.VERTICAL) - setLayout(new ColumnLayout(horient, vorient, gap)); - else - setLayout(new RowLayout(horient, vorient, gap)); - - setController( - new RadioImageButtonPanelController(this)); - } - public void setController(ImageButtonPanelController c) { - this.controller = c; - } - public Insets insets() { return new Insets(10,10,10,10); } - - public ImageButton add(Image image, String name) { - ImageButton button = new ImageButton(image); - add(button); - nameAndButtonPairs.put(name, button); - return button; - } - public ImageButton add(Image image) { - return add(image, "noname"); - } - public void add(ImageButton button) { - add(button, "noname"); - } - public void add(ImageButton button, String name) { - nameAndButtonPairs.put(name, button); - super.add(button); - } - public ImageButton getButtonByName(String name) { - return (ImageButton)nameAndButtonPairs.get(name); - } - public String getButtonName(ImageButton button) { - Enumeration e = nameAndButtonPairs.keys(); - ImageButton nbutt; - String nstr; - - while(e.hasMoreElements()) { - nstr = (String)e.nextElement(); - nbutt = (ImageButton)nameAndButtonPairs.get(nstr); - - if(nbutt.equals(button)) - return nstr; - } - return null; - } - public void addSpacer(int sizeInPixels) { - Assert.notFalse(sizeInPixels > 0); - Canvas spacer = new Canvas(); - spacer.resize(sizeInPixels, sizeInPixels); - add(spacer); - } - public boolean mouseDown(Event event, int x, int y) { - return controller != null ? - controller.mouseDown(event,x,y) : false; - } - public boolean mouseDrag(Event event, int x, int y) { - return controller != null ? - controller.mouseDrag(event,x,y) : false; - } - public boolean mouseUp(Event event, int x, int y) { - return controller != null ? - controller.mouseUp(event,x,y) : false; - } -} diff --git a/java/gjt/ImageButtonPanelController.java b/java/gjt/ImageButtonPanelController.java deleted file mode 100644 index 74f900001b6..00000000000 --- a/java/gjt/ImageButtonPanelController.java +++ /dev/null @@ -1,47 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * A controller for an ImageButtonPanel, this abstract class - * does nothing more than establish the association between an - * ImageButton and its controller.<p> - * - * ImageButtonControllers must be constructed with an - * ImageButtonPanel; the ImageButtonPanels' controller gets set - * by the constructor.<p> - * - * The ImageButton passed into the constructor must not be null; - * this is enforced by an assertion.<p> - * - * Methods defined in the MouseController interface are left - * for subclasses to implement.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see MouseController - * @see ImageButtonPanel - * @see gjt.test.Toolbar - */ -abstract class ImageButtonPanelController implements - MouseController { - private ImageButtonPanel panel; - - ImageButtonPanelController(ImageButtonPanel panel) { - Assert.notNull(panel); - this.panel = panel; - panel.setController(this); - } - public ImageButtonPanel panel() { - return panel; - } - public boolean mouseEnter(Event event, int x, int y) { - return false; - } - public boolean mouseExit (Event event, int x, int y) { - return false; - } - public boolean mouseMove (Event event, int x, int y) { - return false; - } -} diff --git a/java/gjt/ImageCanvas.java b/java/gjt/ImageCanvas.java deleted file mode 100644 index 49e3bc72f3f..00000000000 --- a/java/gjt/ImageCanvas.java +++ /dev/null @@ -1,31 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A Canvas that displays an image.<p> - * - * update() is overridden to call paint() directly, thus - * bypassing the default implementation of update() which - * erases the background of the canvas before calling paint(). - * This eliminates nasty flashing.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Util - */ -class ImageCanvas extends Canvas { - private Image image; - - public ImageCanvas(Image image) { - this.image = image; - Util.waitForImage(this, image); - resize(image.getWidth(this), image.getHeight(this)); - } - public void paint(Graphics g) { - g.drawImage(image, 0, 0, this); - } - public void update(Graphics g) { - paint(g); - } -} diff --git a/java/gjt/ImageScroller.java b/java/gjt/ImageScroller.java deleted file mode 100644 index 79fdc86ea3c..00000000000 --- a/java/gjt/ImageScroller.java +++ /dev/null @@ -1,62 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * An extension of Scroller that smoothly scrolls an Image.<p> - * - * An Image must be supplied at construction time. The image - * may be reset any time after construction.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Scroller - * @see ImageCanvas - * @see gjt.test.ScrollerTest - */ -public class ImageScroller extends Scroller { - private Image image; - private ScrollerImageCanvas canvas; - - public ImageScroller(Image image) { - viewport.setLayout(new BorderLayout()); - setImage(image); - } - public void resetImage(Image image) { - viewport.remove(canvas); - setImage(image); - invalidate(); - validate(); - } - public void scrollTo(int x, int y) { - Graphics g = canvas.getGraphics(); - if(g != null) { - g.translate(-x,-y); - g.drawImage(image, 0, 0, this); - } - } - public Dimension getScrollAreaSize() { - return new Dimension(image.getWidth(this), - image.getHeight(this)); - } - private void setImage(Image image) { - this.image = image; - hbar.setValue(0); - vbar.setValue(0); - viewport.add("Center", - canvas = new ScrollerImageCanvas(this, image)); - } -} - -class ScrollerImageCanvas extends ImageCanvas { - private ImageScroller scroller; - - public ScrollerImageCanvas(ImageScroller scroller, - Image image) { - super(image); - this.scroller = scroller; - } - public void paint(Graphics g) { - scroller.repaint(); - } -} diff --git a/java/gjt/LabelCanvas.java b/java/gjt/LabelCanvas.java deleted file mode 100644 index ba733249b76..00000000000 --- a/java/gjt/LabelCanvas.java +++ /dev/null @@ -1,93 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A selectable label. Clients can set the insets around the - * label via setInsets(Insets). - * - * LabelCanvases generate SelectionEvents when they are - * selected or deselected.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see SelectionEvent - * @see gjt.test.LabelCanvasTest - */ -public class LabelCanvas extends Canvas { - private String label; - private boolean selected = false; - private Insets insets = new Insets(2,2,2,2); - private Point labelLoc = new Point(0,0); - - public LabelCanvas(String label) { - this.label = label; - } - public void paint(Graphics g) { - if(selected == true) paintSelected(g); - else - g.drawString(label, labelLoc.x, labelLoc.y); - } - public void setInsets(Insets insets) { - this.insets = insets; - repaint(); - } - public String getLabel () { return label; } - public boolean isSelected() { return selected; } - public void select () { selected = true; repaint(); } - public void deselect () { selected = false; repaint(); } - - public void resize(int w, int h) { - reshape(location().x, location().y, w, h); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x, y, w, h); - labelLoc = labelLocation(getGraphics()); - } - public Dimension minimumSize() { - return preferredSize(); - } - public Dimension preferredSize() { - FontMetrics fm = getFontMetrics(getFont()); - return new Dimension( - insets.left + fm.stringWidth(label) + - insets.right, - insets.top + fm.getHeight() + - insets.bottom); - } - public boolean mouseDown(Event event, int x, int y) { - if(selected) deselect(); - else select (); - - int eventType = isSelected() ? - SelectionEvent.SELECT : - SelectionEvent.DESELECT; - - Event newEvent = new SelectionEvent(this, - event, - eventType); - deliverEvent(newEvent); - - return true; - } - protected void paintSelected(Graphics g) { - Point labelLoc = labelLocation(g); - - g.setColor(getForeground()); - g.fillRect(0,0,size().width,size().height); - g.setColor(getBackground()); - g.drawString(label, labelLoc.x, labelLoc.y); - } - protected String paramString() { - return super.paramString() + ",text=" + label; - } - private Point labelLocation(Graphics g) { - Dimension size = size(); - FontMetrics fm = g.getFontMetrics(); - - int x = (size.width/2) - (fm.stringWidth(label)/2); - int y = (size.height/2) + (fm.getAscent()/2) - - fm.getLeading(); - return new Point(x,y); - } -} diff --git a/java/gjt/Makefile b/java/gjt/Makefile deleted file mode 100644 index ef6e80748a7..00000000000 --- a/java/gjt/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = .. -CLASSDIR = $(JACE_WRAPPER)/classes -DOCDIR = $(JACE_WRAPPER)/doc - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) - -clean: - rm -rf *~ - -realclean: clean - rm -rf $(JACE_WRAPPER)/classes/gjt - -files = Assert.java \ - Border.java \ - BulletinLayout.java \ - CardPanel.java \ - ChoiceCardPanel.java \ - ColumnLayout.java \ - ComponentScroller.java \ - DialogClient.java \ - DrawingPanel.java \ - DrawnRectangle.java \ - EtchedBorder.java \ - EtchedRectangle.java \ - Etching.java \ - ExclusiveImageButtonPanel.java \ - FontDialog.java \ - GJTDialog.java \ - IconCardPanel.java \ - ImageButton.java \ - ImageButtonController.java \ - ImageButtonEvent.java \ - ImageButtonPanel.java \ - ImageButtonPanelController.java \ - ImageCanvas.java \ - ImageScroller.java \ - LabelCanvas.java \ - MessageDialog.java \ - MouseController.java \ - Orientation.java \ - ProgressDialog.java \ - QuestionDialog.java \ - RadioImageButtonPanelController.java \ - RowLayout.java \ - Scroller.java \ - ScrollerLayout.java \ - SelectionEvent.java \ - Separator.java \ - SpringyImageButtonController.java \ - StateButton.java \ - StateButtonController.java \ - StickyImageButtonController.java \ - Stopwatch.java \ - StopwatchClient.java \ - ThreeDBorder.java \ - ThreeDBorderStyle.java \ - ThreeDRectangle.java \ - Toolbar.java \ - Util.java \ - YesNoDialog.java diff --git a/java/gjt/MessageDialog.java b/java/gjt/MessageDialog.java deleted file mode 100644 index 4b00bc7033f..00000000000 --- a/java/gjt/MessageDialog.java +++ /dev/null @@ -1,77 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A dialog that displays a message and comes equipped with an - * Ok button with which the dialog is dismissed.<p> - * - * Note that there is only one MessageDialog, that gets - * reused. Clients must call getMessageDialog() in order to - * access the one and only MessageDialog.<p> - * - * <em>Note: The 1.0.2 version of the AWT seems to have - * introduced a bug that causes pack() to work incorrectly - * under Win95.</em> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see GJTDialog - * @see gjt.test.MessageDialogTest - * @see gjt.test.DialogTest - */ -public class MessageDialog extends GJTDialog { - static private MessageDialog _theMessageDialog; - - private Button okButton; - private String message; - private ButtonPanel buttonPanel = new ButtonPanel(); - - static public MessageDialog getMessageDialog(Frame frame, - DialogClient client, - String title, - String message) { - if(_theMessageDialog == null) - _theMessageDialog = new MessageDialog(frame, - client, - title, - message); - else { - _theMessageDialog.setClient (client); - _theMessageDialog.setTitle (title); - _theMessageDialog.setMessage(message); - } - return _theMessageDialog; - } - private MessageDialog(Frame frame, DialogClient client, - String title, String message) { - super(frame, title, client, true); - okButton = buttonPanel.add("Ok"); - - setLayout(new BorderLayout()); - add("Center", new MessagePanel(message)); - add("South", buttonPanel); - pack(); - } - public void show() { - okButton.requestFocus(); - super.show(); - } - public boolean action(Event event, Object what) { - hide(); - client.dialogDismissed(this); - return true; - } - private void setMessage(String message) { - this.message = message; - } -} - -class MessagePanel extends Panel { - public MessagePanel(String message) { - add("Center", new Label(message, Label.CENTER)); - } - public Insets insets() { - return new Insets(10,10,10,10); - } -} diff --git a/java/gjt/MouseController.java b/java/gjt/MouseController.java deleted file mode 100644 index f044adee5ba..00000000000 --- a/java/gjt/MouseController.java +++ /dev/null @@ -1,32 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * An interface for handling mouse events.<p> - * - * Components delegate handling of mouse events to a - * MouseController derivation.<p> - * - * For instance:<p> - *<pre> - * mouseDown(Event event, int x, int y) { - * return controller.mouseDown(event,x,y); - * } - *</pre> - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonController - * @see SpringyImageButtonController - * @see StickyImageButtonController - */ -public interface MouseController { - public boolean mouseEnter(Event event, int x, int y); - public boolean mouseExit (Event event, int x, int y); - - public boolean mouseMove (Event event, int x, int y); - public boolean mouseDown (Event event, int x, int y); - public boolean mouseUp (Event event, int x, int y); - public boolean mouseDrag (Event event, int x, int y); -} diff --git a/java/gjt/Orientation.java b/java/gjt/Orientation.java deleted file mode 100644 index f83b27451da..00000000000 --- a/java/gjt/Orientation.java +++ /dev/null @@ -1,87 +0,0 @@ -package gjt; - -/** - * Constants for orientations (and alignments).<p> - * - * This class may not be instantiated. - * - * @version 1.0, Apr 11 1996 - * @author David Geary - */ -public class Orientation { - public static final Orientation BAD = new Orientation(); - public static final Orientation NORTH = new Orientation(); - public static final Orientation SOUTH = new Orientation(); - public static final Orientation EAST = new Orientation(); - public static final Orientation WEST = new Orientation(); - public static final Orientation CENTER = new Orientation(); - public static final Orientation TOP = new Orientation(); - public static final Orientation LEFT = new Orientation(); - public static final Orientation RIGHT = new Orientation(); - public static final Orientation BOTTOM = new Orientation(); - - public static final Orientation HORIZONTAL = - new Orientation(); - public static final Orientation VERTICAL = - new Orientation(); - - static public Orientation fromString(String s) { - Orientation o = BAD; - - if(s.equals("NORTH") || s.equals("north")) o = NORTH; - else if(s.equals("SOUTH") || s.equals("south")) - o = SOUTH; - else if(s.equals("EAST") || s.equals("east")) - o = EAST; - else if(s.equals("WEST") || s.equals("west")) - o = WEST; - else if(s.equals("CENTER") || s.equals("center")) - o = CENTER; - else if(s.equals("TOP") || s.equals("top")) - o = TOP; - else if(s.equals("LEFT") || s.equals("left")) - o = LEFT; - else if(s.equals("RIGHT") || s.equals("right")) - o = RIGHT; - else if(s.equals("BOTTOM") || s.equals("bottom")) - o = BOTTOM; - else if(s.equals("VERTICAL") || s.equals("vertical")) - o = VERTICAL; - else if(s.equals("HORIZONTAL") || - s.equals("horizontal")) - o = HORIZONTAL; - - return o; - } - public String toString() { - String s = new String(); - - if(this == Orientation.NORTH) - s = getClass().getName() + "=NORTH"; - else if(this == Orientation.SOUTH) - s = getClass().getName() + "=SOUTH"; - else if(this == Orientation.EAST) - s = getClass().getName() + "=EAST"; - else if(this == Orientation.WEST) - s = getClass().getName() + "=WEST"; - else if(this == Orientation.CENTER) - s = getClass().getName() + "=CENTER"; - else if(this == Orientation.TOP) - s = getClass().getName() + "=TOP"; - else if(this == Orientation.LEFT) - s = getClass().getName() + "=LEFT"; - else if(this == Orientation.RIGHT) - s = getClass().getName() + "=RIGHT"; - else if(this == Orientation.BOTTOM) - s = getClass().getName() + "=BOTTOM"; - else if(this == Orientation.HORIZONTAL) - s = getClass().getName() + "=HORIZONTAL"; - else if(this == Orientation.VERTICAL) - s = getClass().getName() + "=VERTICAL"; - else if(this == Orientation.BAD) - s = getClass().getName() + "=BAD"; - - return s; - } - private Orientation() { } // Defeat instantiation -} diff --git a/java/gjt/ProgressDialog.java b/java/gjt/ProgressDialog.java deleted file mode 100644 index de7d4be1674..00000000000 --- a/java/gjt/ProgressDialog.java +++ /dev/null @@ -1,67 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A dialog that uses a bargauge to indicate progress made on a - * task that presumably takes some time to complete. - * - * ProgressDialog implements the singleton pattern: clients - * may only access the one and only ProgressDialog through the - * static getProgressDialog() method.<p> - * - * <em>Note: The 1.0.2 version of the AWT has introduced a - * bug that breaks the ProgressDialog under Motif - the - * bargauge does not function. This worked fine in 1.0.1.<em> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see GJTDialog - * @see Bargauge - * @see gjt.test.DialogTest - */ -public class ProgressDialog extends GJTDialog { - static private ProgressDialog _theProgressDialog; - static private int _preferredWidth = 400; - static private int _preferredHeight = 75; - static private Color _color; - static private boolean _dialogUp; - - private Bargauge bargauge; - - static public ProgressDialog getProgressDialog( - Frame frame, - String title, - Color color){ - if(_theProgressDialog == null) - _theProgressDialog = new ProgressDialog(frame, - title, - color); - else { - _theProgressDialog.setTitle (title); - _theProgressDialog.reset (); - } - return _theProgressDialog; - } - private ProgressDialog(Frame frame, - String title, - Color color) { - super(frame, title, null, true); - setLayout(new BorderLayout()); - add("Center", bargauge = new Bargauge(color)); - pack(); - } - public void setPercentComplete(double percent) { - bargauge.setFillPercent(percent); - bargauge.fill(); - - if(percent == 100) - hide(); - } - public void reset() { - bargauge.setFillPercent(0); - } - public Dimension preferredSize() { - return new Dimension(_preferredWidth, _preferredHeight); - } -} diff --git a/java/gjt/QuestionDialog.java b/java/gjt/QuestionDialog.java deleted file mode 100644 index 042b491e178..00000000000 --- a/java/gjt/QuestionDialog.java +++ /dev/null @@ -1,130 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A dialog that presents a prompt and a TextField into which - * a reply may be entered. Comes complete with an Ok button - * and a Cancel button, whose uses will be left to the - * imagination.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see GJTDialog - * @see gjt.test.DialogTest - */ -public class QuestionDialog extends GJTDialog { - static private int _defaultTextFieldSize = 20; - private Button okButton; - private Button cancelButton; - private String question; - private TextField textField; - private boolean wasCancelled; - private ButtonPanel buttonPanel = new ButtonPanel(); - - public QuestionDialog(Frame frame, DialogClient client, - String title, String question, - String initialResponse) { - this(frame, client, title, question, initialResponse, - _defaultTextFieldSize); - } - public QuestionDialog(Frame frame, DialogClient client, - String title, String question) { - this(frame, client, title, - question, null, _defaultTextFieldSize); - } - public QuestionDialog(Frame frame, DialogClient client, - String title, String question, - int textFieldSize) { - this(frame, client, title, - question, null, textFieldSize); - } - public QuestionDialog(Frame frame, DialogClient client, - String title, String question, - String initialResponse, - int textFieldSize) { - super(frame, title, client, true); - - QuestionPanel questionPanel; - - okButton = buttonPanel.add("Ok"); - cancelButton = buttonPanel.add("Cancel"); - - setLayout(new BorderLayout()); - add("North", questionPanel = - new QuestionPanel(this, question, - initialResponse, textFieldSize)); - add("South", buttonPanel); - textField = questionPanel.getTextField(); - pack(); - } - public boolean action(Event event, Object what) { - if(event.target == cancelButton) wasCancelled = true; - else wasCancelled = false; - - hide(); - dispose(); - client.dialogDismissed(this); - return true; - } - public void show() { - textField.requestFocus(); - super.show(); - } - public void returnInTextField() { - okButton.requestFocus(); - } - public TextField getTextField() { - return textField; - } - public String getAnswer() { - return textField.getText(); - } - public boolean wasCancelled() { - return wasCancelled; - } - private void setQuestion(String question) { - this.question = question; - } -} - -class QuestionPanel extends Panel { - private TextField field; - private QuestionDialog dialog; - - public QuestionPanel(QuestionDialog dialog, - String question) { - this(dialog, question, null, 0); - } - public QuestionPanel(QuestionDialog dialog, String question, - int columns) { - this(dialog, question, null, columns); - } - public QuestionPanel(QuestionDialog dialog, String question, - String initialResponse, int cols) { - this.dialog = dialog; - setLayout(new RowLayout()); - add(new Label(question)); - - if(initialResponse != null) { - if(cols != 0) - add(field=new TextField(initialResponse, cols)); - else - add(field=new TextField(initialResponse)); - } - else { - if(cols != 0) add(field = new TextField(cols)); - else add(field = new TextField()); - } - } - public TextField getTextField() { - return field; - } - public boolean action(Event event, Object what) { - dialog.returnInTextField(); - return false; - } - public Insets insets() { - return new Insets(10,10,10,10); - } -} diff --git a/java/gjt/RadioImageButtonPanelController.java b/java/gjt/RadioImageButtonPanelController.java deleted file mode 100644 index 8dc34d25bff..00000000000 --- a/java/gjt/RadioImageButtonPanelController.java +++ /dev/null @@ -1,45 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * A controller for an ImageButtonPanel that ensures that only - * one ImageButton in its associated ImageButtonPanel is - * selected at a time.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButtonPanelController - * @see ImageButton - * @see ImageButtonPanel - * @see gjt.test.ToolbarTest - */ -class RadioImageButtonPanelController - extends ImageButtonPanelController { - ImageButton down; - - public RadioImageButtonPanelController( - ImageButtonPanel panel) { - super(panel); - } - public boolean mouseDown(Event event, int x, int y) { - ImageButton button; - - if(event.target instanceof ImageButton) { - button = (ImageButton)event.target; - if(down == button) return false; - - if(down != null) - down.paintRaised(); - - down = button; - } - return false; - } - public boolean mouseUp(Event event, int x, int y) { - return false; - } - public boolean mouseDrag(Event event, int x, int y) { - return false; - } -} diff --git a/java/gjt/RowLayout.java b/java/gjt/RowLayout.java deleted file mode 100644 index eecd074c34f..00000000000 --- a/java/gjt/RowLayout.java +++ /dev/null @@ -1,153 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * RowLayout lays out components in a row. At construction - * time, both horizontal orientation and vertical orientation - * may be specified, along with the gap to use between - * components.<p> - * - * Horizontal orientation must be one of the following: - * <dl> - * <dd> LEFT - * <dd> CENTER - * <dd> RIGHT - * </dl> - * - * Vertical orientation must be one of the following: - * <dl> - * <dd> TOP - * <dd> CENTER - * <dd> BOTTOM - * </dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ColumnLayout - * @see Orientation - */ -public class RowLayout implements LayoutManager { - static private int _defaultGap = 5; - - private int gap; - private Orientation verticalOrientation; - private Orientation horizontalOrientation; - - public RowLayout() { - this(Orientation.CENTER, - Orientation.CENTER, _defaultGap); - } - public RowLayout(int gap) { - this(Orientation.CENTER, Orientation.CENTER, gap); - } - public RowLayout(Orientation horizontalOrient, - Orientation verticalOrient) { - this(horizontalOrient, verticalOrient, _defaultGap); - } - public RowLayout(Orientation horizontalOrient, - Orientation verticalOrient, int gap) { - Assert.notFalse(gap >= 0); - Assert.notFalse( - horizontalOrient == Orientation.LEFT || - horizontalOrient == Orientation.CENTER || - horizontalOrient == Orientation.RIGHT); - Assert.notFalse( - verticalOrient == Orientation.TOP || - verticalOrient == Orientation.CENTER || - verticalOrient == Orientation.BOTTOM); - - this.gap = gap; - this.verticalOrientation = verticalOrient; - this.horizontalOrientation = horizontalOrient; - } - - public void addLayoutComponent(String name, Component comp) { - } - public void removeLayoutComponent(Component comp) { - } - - public Dimension preferredLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.preferredSize(); - - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - - if(i > 0) dim.width += gap; - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - public Dimension minimumLayoutSize(Container target) { - Insets insets = target.insets(); - Dimension dim = new Dimension(0,0); - int ncomponents = target.countComponents(); - Component comp; - Dimension d; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - d = comp.minimumSize(); - - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - - if(i > 0) dim.width += gap; - } - } - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } - public void layoutContainer(Container target) { - Insets insets = target.insets(); - int ncomponents = target.countComponents(); - int top = 0; - int left = insets.left; - Dimension tps = target.preferredSize(); - Dimension targetSize = target.size(); - Component comp; - Dimension ps; - - if(horizontalOrientation == Orientation.CENTER) - left = left + (targetSize.width/2) - (tps.width/2); - if(horizontalOrientation == Orientation.RIGHT) - left = left + targetSize.width - tps.width; - - for (int i = 0 ; i < ncomponents ; i++) { - comp = target.getComponent(i); - - if(comp.isVisible()) { - ps = comp.preferredSize(); - - if(verticalOrientation == Orientation.CENTER) - top = (targetSize.height/2) - (ps.height/2); - else if(verticalOrientation == Orientation.TOP) - top = insets.top; - else if( - verticalOrientation == Orientation.BOTTOM) - top = targetSize.height - - ps.height - insets.bottom; - - comp.reshape(left,top,ps.width,ps.height); - left += ps.width + gap; - } - } - } -} diff --git a/java/gjt/Scroller.java b/java/gjt/Scroller.java deleted file mode 100644 index 61d6e5f55e5..00000000000 --- a/java/gjt/Scroller.java +++ /dev/null @@ -1,154 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Each Scroller contains a Panel (viewport) and two Scrollbars - * (horizontal and vertical). Works in conjunction with a - * ScrollerLayout, that lays out the viewport and two - * scrollbars.<p> - * - * Subclasses must override:<p> - * <dl> - * <dd> abstract public void scrollTo(int x, int y) - * <dd> abstract public Dimension getScrollAreaSize() - * </dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ComponentScroller - * @see ImageScroller - * @see ScrollerLayout - * @see gjt.test.ComponentScrollerTest - * @see gjt.test.ImageScrollerTest - */ -public abstract class Scroller extends Panel { - protected Panel viewport; - protected Scrollbar hbar, vbar; - - abstract public void scrollTo(int x, int y); - abstract public Dimension getScrollAreaSize(); - - public Scroller() { - setLayout(new ScrollerLayout(this)); - add("Scroll", viewport = new Panel()); - add("East", vbar = new Scrollbar(Scrollbar.VERTICAL)); - add("South",hbar = new Scrollbar(Scrollbar.HORIZONTAL)); - } - public Scrollbar getHorizontalScrollbar() {return hbar; } - public Scrollbar getVerticalScrollbar () {return vbar; } - public Panel getViewport () {return viewport;} - - public boolean handleEvent(Event event) { - boolean handledEvent; - - switch(event.id) { - case Event.SCROLL_LINE_UP: scrollLineUp(event); - break; - case Event.SCROLL_LINE_DOWN: scrollLineDown(event); - break; - case Event.SCROLL_PAGE_UP: scrollPageUp (event); - break; - case Event.SCROLL_PAGE_DOWN: scrollPageDown(event); - break; - case Event.SCROLL_ABSOLUTE: scrollAbsolute(event); - break; - } - handledEvent = event.id == Event.SCROLL_LINE_UP || - event.id == Event.SCROLL_LINE_DOWN || - event.id == Event.SCROLL_PAGE_UP || - event.id == Event.SCROLL_PAGE_DOWN || - event.id == Event.SCROLL_ABSOLUTE; - - if(handledEvent) return true; - else return super.handleEvent(event); - } - public void paint (Graphics g) { scroll(); } - public void update(Graphics g) { paint(g); } - - public void manageScrollbars() { - manageHorizontalScrollbar(); - manageVerticalScrollbar (); - } - protected void manageHorizontalScrollbar() { - Dimension size = size(); - Dimension scrollAreaSize = getScrollAreaSize(); - - if(vbar.isVisible()) - size.width -= vbar.size().width; - - if(scrollAreaSize.width > size.width) { - if( ! hbar.isVisible()) - hbar.show(); - } - else if(hbar.isVisible()) { - hbar.hide(); - hbar.setValue(0); - repaint(); - } - } - protected void manageVerticalScrollbar() { - Dimension size = size(); - Dimension scrollAreaSize = getScrollAreaSize(); - - if(hbar.isVisible()) - size.height -= hbar.size().height; - - if(scrollAreaSize.height > size.height) { - if( ! vbar.isVisible()) - vbar.show(); - } - else if(vbar.isVisible()) { - vbar.hide(); - vbar.setValue(0); - repaint(); - } - } - public void setScrollbarValues() { - if(hbar.isVisible()) setHorizontalScrollbarValues(); - if(vbar.isVisible()) setVerticalScrollbarValues(); - } - protected void setHorizontalScrollbarValues() { - Dimension vsize = viewport.size(); - Dimension scrollAreaSize = getScrollAreaSize(); - int max = scrollAreaSize.width - vsize.width; - - hbar.setValues(hbar.getValue(), // value - vsize.width, // amt visible/page - 0, // minimum - max); // maximum - - setHorizontalLineAndPageIncrements(); - } - protected void setVerticalScrollbarValues() { - Dimension vsize = viewport.size(); - Dimension scrollAreaSize = getScrollAreaSize(); - int max = scrollAreaSize.height - vsize.height; - - vbar.setValues(vbar.getValue(), // value - vsize.height, // amt visible/page - 0, // minimum - max); // maximum - - setVerticalLineAndPageIncrements(); - } - protected void scrollLineUp (Event event) { scroll(); } - protected void scrollLineDown(Event event) { scroll(); } - protected void scrollPageUp (Event event) { scroll(); } - protected void scrollPageDown(Event event) { scroll(); } - protected void scrollAbsolute(Event event) { scroll(); } - - protected void setHorizontalLineAndPageIncrements() { - Dimension size = getScrollAreaSize(); - hbar.setLineIncrement(size.width/10); - hbar.setPageIncrement(size.width/5); - } - protected void setVerticalLineAndPageIncrements() { - Dimension size = getScrollAreaSize(); - vbar.setLineIncrement(size.height/10); - vbar.setPageIncrement(size.height/5); - } - protected void scroll() { - scrollTo(hbar.getValue(), vbar.getValue()); - } -} diff --git a/java/gjt/ScrollerLayout.java b/java/gjt/ScrollerLayout.java deleted file mode 100644 index 21012fd5688..00000000000 --- a/java/gjt/ScrollerLayout.java +++ /dev/null @@ -1,160 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Layout manager for a Scroller.<p> - * - * Lays out 3 Components: a horizontal scrollbar, a vertical - * scrollbar and a viewport (Panel).<p> - * - * Valid names/Component pairs that can be added via - * addLayoutComponent(String, Component):<p> - * <dl> - * <dd> "East" Scrollbar (vertical) - * <dd> "West" Scrollbar (vertical) - * <dd> "North" Scrollbar (horizontal) - * <dd> "South" Scrollbar (horizontal) - * <dd> "Scroll" Panel (viewport) - * </dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Scroller - */ -public class ScrollerLayout implements LayoutManager { - private Scroller scroller; - private Scrollbar hbar, vbar; - private String hbarPosition, vbarPosition; - private Component viewport; - private int top, bottom, right, left; - - public ScrollerLayout(Scroller scroller) { - this.scroller = scroller; - } - - public void addLayoutComponent(String name, - Component comp) { - Assert.notFalse(comp != null); - - if(comp instanceof Scrollbar) { - Scrollbar sbar = (Scrollbar)comp; - - if(sbar.getOrientation() == Scrollbar.VERTICAL) { - Assert.notFalse("East".equals(name) == true || - "West".equals(name) == true); - vbar = sbar; - vbarPosition = name; - } - else { - Assert.notFalse("North".equals(name) == true || - "South".equals(name) == true); - hbar = sbar; - hbarPosition = name; - } - } - else { - Assert.notFalse("Scroll".equals(name) == true); - viewport = comp; - } - } - public void removeLayoutComponent(Component comp) { - if(comp == vbar) vbar = null; - if(comp == hbar) hbar = null; - if(comp == viewport) viewport = null; - } - public Dimension preferredLayoutSize(Container parent) { - Dimension dim = new Dimension(0,0); - - if(vbar != null && vbar.isVisible()) { - Dimension d = vbar.preferredSize(); - dim.width += d.width; - dim.height = d.height; - } - if(hbar != null && hbar.isVisible()) { - Dimension d = hbar.preferredSize(); - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - } - if(viewport != null && viewport.isVisible()) { - Dimension d = viewport.preferredSize(); - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - } - return dim; - } - public Dimension minimumLayoutSize(Container parent) { - Dimension dim = new Dimension(0,0); - - if(vbar != null && vbar.isVisible()) { - Dimension d = vbar.minimumSize(); - dim.width += d.width; - dim.height = d.height; - } - if(hbar != null && hbar.isVisible()) { - Dimension d = hbar.minimumSize(); - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - } - if(viewport != null && viewport.isVisible()) { - Dimension d = viewport.minimumSize(); - dim.width += d.width; - dim.height = Math.max(d.height, dim.height); - } - return dim; - } - public void layoutContainer(Container target) { - Insets insets = target.insets(); - Dimension targetSize = target.size(); - - top = insets.top; - bottom = targetSize.height - insets.bottom; - left = insets.left; - right = targetSize.width - insets.right; - - scroller.manageScrollbars(); - - reshapeHorizontalScrollbar(); - reshapeVerticalScrollbar (); - reshapeViewport (); - - scroller.setScrollbarValues(); - } - private void reshapeHorizontalScrollbar() { - if(hbar != null && hbar.isVisible()) { - if("North".equals(hbarPosition)) { - Dimension d = hbar.preferredSize(); - hbar.reshape(left, top, right - left, d.height); - top += d.height; - } - else { // South - Dimension d = hbar.preferredSize(); - hbar.reshape(left, bottom - d.height, - right - left,d.height); - bottom -= d.height; - } - } - } - private void reshapeVerticalScrollbar() { - if(hbar != null && vbar.isVisible()) { - if("East".equals(vbarPosition)) { - Dimension d = vbar.preferredSize(); - vbar.reshape(right - d.width, top, - d.width, bottom - top); - right -= d.width; - } - else { // West - Dimension d = vbar.preferredSize(); - vbar.reshape(left, top, - d.width, bottom - top); - left += d.width; - } - } - } - private void reshapeViewport() { - if(viewport != null && viewport.isVisible()) { - viewport.reshape(left, top, - right - left, bottom - top); - } - } -} diff --git a/java/gjt/SelectionEvent.java b/java/gjt/SelectionEvent.java deleted file mode 100644 index 4bcab59cd0a..00000000000 --- a/java/gjt/SelectionEvent.java +++ /dev/null @@ -1,82 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * An extension of java.awt.Event, specifically designed for - * selection events.<p> - * - * SelectionEvents are constructed with arguments:<p> - * <dl> - * <dd> The AWT event that triggered the image button event - * <dd> The id of the event. - * </dl> - * - * An SelectionEvent's id (the constructor's 3rd argument), - * must be one of the following:<p> - * <dl> - * <dd> SelectionEvent.SELECT - * <dd> SelectionEvent.DESELECT - * </dl> - * - * SelectionEvent has only a constructor and a paramString() - * method. Containers that contain objects which are capable - * of generating SelectionEvents should check the events - * like so: - * - * <pre> - * // handleEvent(Event) method of a container that - * // contain objects that generate SelectionEvents - * - * public boolean handleEvent(Event event) { - * if(event instanceof SelectionEvent) { - * SelectionEvent sevent = - * (SelectionEvent)event; - * - * if(sevent.isSelected()) { - * // do something for selection - * } - * else { - * // do something for deselection - * } - * } - * } - * </pre> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see LabelCanvas - * @see ImageButtonEvent - * @see gjt.test.LabelCanvasTest - */ -public class SelectionEvent extends Event { - public static final int SELECT = 1; - public static final int DESELECT = 2; - - private int eventType; - - public SelectionEvent(Object target, - Event event, - int type) { - super(target, event.when, event.id, event.x, event.y, - event.key, event.modifiers, event.arg); - - Assert.notFalse(type == SELECT || type == DESELECT); - - eventType = type; - id = -1; - } - public boolean isSelected() { - return eventType == SELECT; - } - protected String paramString() { - String typeString = new String(); - - if(eventType == SelectionEvent.SELECT) - typeString = "SELECT"; - else if(eventType == SelectionEvent.DESELECT) - typeString = "DESELECT"; - - return super.paramString() + typeString; - } -} diff --git a/java/gjt/Separator.java b/java/gjt/Separator.java deleted file mode 100644 index 6bd610e1ad9..00000000000 --- a/java/gjt/Separator.java +++ /dev/null @@ -1,90 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A separator that is drawn either vertically or horizontally - * depending upon how it is laid out. Can be drawn either - * etched-in or etched-out, with varying thicknesses. Both - * thickness and etching are settable at construction time - * only.<p> - * - * Default thickness is 2 pixels and default etching is - * Etching.IN. Note that thicknesses greater than 4 loose the - * etching effect.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Etching - * @see gjt.test.SeparatorTest - */ -public class Separator extends Canvas { - static private Etching _defaultEtching = Etching.IN; - static private int _defaultThickness = 2; - - private Etching etching; - private int thickness; - - public Separator() { - this(_defaultThickness, _defaultEtching); - } - public Separator(int thickness) { - this(thickness, _defaultEtching); - } - public Separator(Etching etching) { - this(_defaultThickness, etching); - } - public Separator(int thickness, Etching etching) { - this.etching = etching; - this.thickness = thickness; - resize(thickness, thickness); - } - public Dimension minimumSize() { - return preferredSize(); - } - public Dimension preferredSize() { - return new Dimension(thickness, thickness); - } - public void paint(Graphics g) { - Dimension size = size(); - Color brighter = getBackground().brighter().brighter(); - Color darker = getBackground().darker().darker(); - - if(etching == Etching.IN) { - if(size.width > size.height) - paintHorizontal(g, size, darker, brighter); - else - paintVertical(g, size, darker, brighter); - } - else { - if(size.width > size.height) - paintHorizontal(g, size, brighter, darker); - else - paintVertical(g, size, brighter, darker); - } - } - public String paramString() { - Dimension size = size(); - Orientation orient = size.width > size.height ? - Orientation.HORIZONTAL : - Orientation.VERTICAL; - return super.paramString() + "thickness=" + - thickness + "," + etching + "," + orient; - } - private void paintHorizontal(Graphics g, Dimension size, - Color top, Color bottom) { - g.setColor(top); - g.fillRect(0, (size.height/2) - (thickness/2), - size.width, thickness/2); - g.setColor(bottom); - g.fillRect(0, size.height/2, size.width, thickness/2); - } - private void paintVertical(Graphics g, Dimension size, - Color left, Color right) { - g.setColor(left); - g.fillRect((size.width/2) - (thickness/2), - 0, thickness/2, size.height); - g.setColor(right); - g.fillRect(size.width/2, 0, thickness/2, size.height); - } -} diff --git a/java/gjt/SpringyImageButtonController.java b/java/gjt/SpringyImageButtonController.java deleted file mode 100644 index 3559e040459..00000000000 --- a/java/gjt/SpringyImageButtonController.java +++ /dev/null @@ -1,54 +0,0 @@ -package gjt; - -import java.awt.Event; -import java.awt.Graphics; - -/** - * An ImageButtonController that reacts to mouseDown/mouseUp - * events exactly as a java.awt.Button does.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonController - * @see StickyImageButtonController - */ -public class SpringyImageButtonController - extends ImageButtonController { - public SpringyImageButtonController(ImageButton ib) { - super(ib); - } - public boolean mouseDown(Event event, int x, int y) { - if(event.modifiers == 0) { - getButton().paintInset(); - armButton(event); - } - return false; - } - public boolean mouseUp(Event event, int x, int y) { - if(event.modifiers == 0) { - if(getButton().isRaised() == false) { - getButton().paintRaised(); - activateButton(event); - } - } - return false; - } - public boolean mouseDrag(Event event, int x, int y) { - if(event.modifiers == 0) { - if(getButton().isInside(x,y)) { - if(getButton().isRaised()) { - getButton().paintInset(); - armButton(event); - } - } - else { - if(getButton().isRaised() == false) { - getButton().paintRaised(); - disarmButton(event); - } - } - } - return false; - } -} diff --git a/java/gjt/StateButton.java b/java/gjt/StateButton.java deleted file mode 100644 index 6de20a76f98..00000000000 --- a/java/gjt/StateButton.java +++ /dev/null @@ -1,45 +0,0 @@ -package gjt; - -import java.awt.Image; - -/** - * An ImageButton that cycles through a series of images. The - * image advances to the next image in the series every time - * the button is activated.<p> - * - * Note that the cycling is actually performed by the buttons' - * controller - a StateButtonController.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see StateButtonController - * @see gjt.test.StateButtonTest - */ -public class StateButton extends ImageButton { - private Image[] images; - private int state = 0; - private int numStates; - - public StateButton(Image[] images) { - super(images[0]); - - this.images = images; - numStates = images.length; - setController(new StateButtonController(this)); - waitForImages(); - } - public Image nextImage() { - if(state + 1 < numStates) state++; - else state = 0; - - return images[state]; - } - public int state() { - return state; - } - private void waitForImages() { - for(int i=0; i < images.length; ++i) - Util.waitForImage(this, images[i]); - } -} diff --git a/java/gjt/StateButtonController.java b/java/gjt/StateButtonController.java deleted file mode 100644 index d6fc83830a6..00000000000 --- a/java/gjt/StateButtonController.java +++ /dev/null @@ -1,27 +0,0 @@ -package gjt; - -import java.awt.Event; - -/** - * A controller for a StateButton, that cycles through a - * series of images which reside in the StateButton class. - * Each time a mouse up is detected in the StateButton, the - * buttons image is set to the next image in the array. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see StateButton - * @see SpringyImageButtonController - * @see gjt.test.StateButtonTest - */ -class StateButtonController extends SpringyImageButtonController { - public StateButtonController(StateButton button) { - super(button); - } - public boolean mouseUp(Event event, int x, int y) { - StateButton button = (StateButton)getButton(); - button.setImage(button.nextImage()); - activateButton(event); - return super.mouseUp(event, x, y); - } -} diff --git a/java/gjt/StickyImageButtonController.java b/java/gjt/StickyImageButtonController.java deleted file mode 100644 index c459e5cdae1..00000000000 --- a/java/gjt/StickyImageButtonController.java +++ /dev/null @@ -1,87 +0,0 @@ -package gjt; - -import java.awt.Event; -import java.awt.Graphics; - -/** - * An ImageButtonController that causes its associated - * ImageButton to "stick" when activated. If the ImageButton - * is raised it depresses<b>[1]</b> upon a mouse down and stays - * down upon a subsequent mouse up event. The same "sticky" - * behaviour occurs when a depressed ImageButton encounters a - * mouse down followed by a subsequent mouse up.<p> - * - * Note that false is returned from mouse event handlers; - * therefore mouse events will be propagated to the - * ImageButton's container. While this is not always - * desirable, it was deemed a better default than swallowing - * the event here. Subclasses may, of course, modify this - * behavior.<p> - * - * <b>[1]</b> No psychiatric consultation is necessary.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonController - * @see SpringyImageButtonController - */ -public class StickyImageButtonController - extends ImageButtonController { - private boolean buttonUpOnLastMouseDown = true; - - public StickyImageButtonController(ImageButton ib) { - super(ib); - } - public boolean mouseDown(Event event, int x, int y) { - ImageButton button = getButton(); - - if(event.modifiers == 0) { - if(button.isRaised()) button.paintInset(); - else button.paintRaised(); - - buttonUpOnLastMouseDown = getButton().isRaised(); - armButton(event); - } - return false; - } - public boolean mouseUp(Event event, int x, int y) { - activateButton(event); - return false; - } - public boolean mouseDrag(Event event, int x, int y) { - ImageButton button = getButton(); - - if(event.modifiers == 0) { - if(button.isInside(x,y)) { - if(buttonUpOnLastMouseDown) { - if(button.isRaised() == false) { - button.paintRaised(); - armButton(event); - } - } - else { - if(button.isRaised()) { - button.paintInset(); - armButton(event); - } - } - } - else { - if(buttonUpOnLastMouseDown) { - if(button.isRaised()) { - button.paintInset(); - disarmButton(event); - } - } - else { - if(button.isRaised() == false) { - button.paintRaised(); - disarmButton(event); - } - } - } - } - return false; - } -} diff --git a/java/gjt/Stopwatch.java b/java/gjt/Stopwatch.java deleted file mode 100644 index fc8963e88a1..00000000000 --- a/java/gjt/Stopwatch.java +++ /dev/null @@ -1,94 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A Thread that acts as a stopwatch.<p> - * - * Stopwatch starts running when it is constructed, and may be - * reset by the reset() method. getHour(), getMinute(), - * getSecond(), and getMillisecond() are used to get the - * elapsed time since construction, or since the last reset.<p> - * - * toString() returns the elapsed time in the form of - * HH:MM:SS:mm, where HH == hours, MM == minutes, SS == seconds - * and mm == milliseconds.<p> - * - * Each Stopwatch may have a StopwatchClient associated with it. - * If the StopwatchClient is non-null, the StopwatchClients' - * tick() method is invoked every 50 milliseconds.<p> - * - * @version 1.0, Apr 21 1996 - * @author David Geary - * @see StopwatchClient - * @see gjt.animation.Sequence - * @see gjt.animation.Sprite - */ -public class Stopwatch extends Thread { - private StopwatchClient client; - private long start, now, elapsed; - private long hour, minute, second, millisecond; - - public Stopwatch() { - this(null); - } - public Stopwatch(StopwatchClient client) { - start = System.currentTimeMillis(); - this.client = client; - } - public void update() { - now = System.currentTimeMillis(); - elapsed = now - start; - hour = minute = second = millisecond = 0; - - second = elapsed / 1000; - millisecond = elapsed % 1000; - millisecond = (millisecond == 0) ? 0 : millisecond/10; - - if(second > 59) { - minute = second / 60; - second = second - (minute*60); - } - if(minute > 59) { - hour = minute / 60; - minute = minute - (hour*60); - } - } - public String toString() { - update(); - return new String(stringValueOf(hour) + ":" + - stringValueOf(minute) + ":" + - stringValueOf(second) + ":" + - stringValueOf(millisecond)); - } - public long getHour () { return hour; } - public long getMinute () { return minute; } - public long getSecond () { return second; } - public long getMillisecond () { return millisecond; } - - public long elapsedTime() { - update(); - return elapsed; - } - public void reset() { - start = System.currentTimeMillis(); - } - public void run() { - while(true) { - try { - Thread.currentThread().sleep(50, 0); - update(); - if(client != null) - client.tick(); - } - catch(InterruptedException e) { - Assert.notFalse(false); - } - } - } - private String stringValueOf(long l) { - if(l < 10) return "0" + String.valueOf(l); - else return String.valueOf(l); - - } -} diff --git a/java/gjt/StopwatchClient.java b/java/gjt/StopwatchClient.java deleted file mode 100644 index c2eb5fb0460..00000000000 --- a/java/gjt/StopwatchClient.java +++ /dev/null @@ -1,14 +0,0 @@ -package gjt; - -/** - * Client of a Stopwatch. Stopwatches that have non-null - * clients, call their clients' tick() method every 50 - * milliseconds.<p> - * - * @version 1.0, Apr 21 1996 - * @author David Geary - * @see Stopwatch - */ -public interface StopwatchClient { - public void tick(); -} diff --git a/java/gjt/ThreeDBorder.java b/java/gjt/ThreeDBorder.java deleted file mode 100644 index 0441fdf3052..00000000000 --- a/java/gjt/ThreeDBorder.java +++ /dev/null @@ -1,53 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Extension of Border that draws a 3D border. - * - * Drawn raised by default, drawing style used by paint() is - * controlled by raise() and inset(). Note that raise() and - * inset() do not result in anything being painted, but only set - * the state for the next call to paint(). To set the state and - * paint in one operation, use paintRaised() and paintInset(). - * <p> - * - * The current state of the border may be obtained by calling - * isRaised().<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Border - * @see EtchedRectangle - * @see gjt.test.BorderTest - */ -public class ThreeDBorder extends Border { - public ThreeDBorder(Component borderMe) { - this(borderMe, _defaultThickness, _defaultGap); - } - public ThreeDBorder(Component borderMe, - int borderThickness) { - this(borderMe, borderThickness, _defaultGap); - } - public ThreeDBorder(Component borderMe, - int borderThickness, int gap) { - super(borderMe, borderThickness, gap); - } - public void inset() { ((ThreeDRectangle)border()).inset(); } - public void raise() { ((ThreeDRectangle)border()).raise(); } - - public void paintRaised() { - ((ThreeDRectangle)border()).paintRaised(); - } - public void paintInset() { - ((ThreeDRectangle)border()).paintInset (); - } - public boolean isRaised() { - return ((ThreeDRectangle)border()).isRaised(); - } - protected DrawnRectangle border() { - if(border == null) - border = new ThreeDRectangle(this, thickness); - return border; - } -} diff --git a/java/gjt/ThreeDBorderStyle.java b/java/gjt/ThreeDBorderStyle.java deleted file mode 100644 index b0e1b7d8ab8..00000000000 --- a/java/gjt/ThreeDBorderStyle.java +++ /dev/null @@ -1,24 +0,0 @@ -package gjt; - -/** - * Constants for 3D border styles. - * - * This class may not be instantiated. - * - * @version 1.0, Apr 11 1996 - * @author David Geary - */ -public class ThreeDBorderStyle { - public static final ThreeDBorderStyle RAISED = - new ThreeDBorderStyle(); - public static final ThreeDBorderStyle INSET = - new ThreeDBorderStyle(); - - public String toString() { - if(this == ThreeDBorderStyle.RAISED) - return getClass().getName() + "=RAISED"; - else - return getClass().getName() + "=INSET"; - } - private ThreeDBorderStyle() { } // defeat instantiation -} diff --git a/java/gjt/ThreeDRectangle.java b/java/gjt/ThreeDRectangle.java deleted file mode 100644 index 647129190c5..00000000000 --- a/java/gjt/ThreeDRectangle.java +++ /dev/null @@ -1,105 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A DrawnRectangle which draws in 3D.<p> - * - * Drawn raised by default, drawing style used by paint() is - * controlled by raise() and inset(). Note that raise() and - * inset() do not result in anything being painted, but only set - * the state for the next call to paint(). To set the state and - * paint in one operation, use paintRaised() and paintInset(). - * <p> - * - * The current state of the rectangle may be obtained by - * calling isRaised().<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see DrawnRectangle - * @see EtchedRectangle - * @see gjt.test.DrawnRectangleTest - */ -public class ThreeDRectangle extends DrawnRectangle { - protected static ThreeDBorderStyle - _defaultState = ThreeDBorderStyle.RAISED; - - private ThreeDBorderStyle state; - - public ThreeDRectangle(Component drawInto) { - this(drawInto, _defaultState, - _defaultThickness, 0, 0, 0, 0); - } - public ThreeDRectangle(Component drawInto, int thickness) { - this(drawInto, _defaultState, thickness, 0, 0, 0, 0); - } - public ThreeDRectangle(Component drawInto, - int x, int y, int w, int h) { - this(drawInto, - _defaultState, _defaultThickness, x, y, w, h); - } - public ThreeDRectangle(Component drawInto, int thickness, - int x, int y, - int w, int h) { - this(drawInto, _defaultState, thickness, x, y, w, h); - } - public ThreeDRectangle(Component drawInto, - ThreeDBorderStyle state, - int thickness, int x, int y, - int w, int h) { - super(drawInto, thickness, x, y, w, h); - this.state = state; - } - public void paint() { - if(state == ThreeDBorderStyle.RAISED) paintRaised(); - else paintInset (); - } - public void raise() { state = ThreeDBorderStyle.RAISED; } - public void inset() { state = ThreeDBorderStyle.INSET; } - - public boolean isRaised() { - return state == ThreeDBorderStyle.RAISED; - } - public String paramString() { - return super.paramString() + "," + state; - } - public void paintRaised() { - Graphics g = drawInto.getGraphics(); - - if(g != null) { - raise (); - drawTopLeftLines (g, brighter()); - drawBottomRightLines(g, getLineColor()); - } - } - public void paintInset() { - Graphics g = drawInto.getGraphics(); - - if(g != null) { - inset (); - drawTopLeftLines (g, getLineColor()); - drawBottomRightLines(g, brighter()); - } - } - private void drawTopLeftLines(Graphics g, Color color) { - int thick = getThickness(); - g.setColor(color); - - for(int i=0; i < thick; ++i) { - g.drawLine(x+i, y+i, x + width-(i+1), y+i); - g.drawLine(x+i, y+i+1, x+i, y + height-(i+1)); - } - } - private void drawBottomRightLines(Graphics g, Color color) { - int thick = getThickness(); - g.setColor(color); - - for(int i=1; i <= thick; ++i) { - g.drawLine(x+i-1, y + height-i, - x + width-i, y + height-i); - g.drawLine(x + width-i, y+i-1, - x + width-i, y + height-i); - } - } -} diff --git a/java/gjt/Toolbar.java b/java/gjt/Toolbar.java deleted file mode 100644 index 4d6ebddc217..00000000000 --- a/java/gjt/Toolbar.java +++ /dev/null @@ -1,58 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * A toolbar containing image buttons which are laid out to the - * north of (horizontal) separator.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ImageButton - * @see ImageButtonPanel - * @see gjt.test.ToolbarTest - */ -public class Toolbar extends Panel { - static private int _defaultGap = 0; - static private int _defaultLeftInset = 0; - - private ToolbarButtonPanel buttonPanel; - - public Toolbar() { - this(_defaultLeftInset, _defaultGap); - } - public Toolbar(int leftInset, int gap) { - buttonPanel = new ToolbarButtonPanel(leftInset, gap); - - setLayout(new BorderLayout()); - add ("North", buttonPanel); - add ("South", new Separator()); - } - public ImageButton add(Image image) { - return buttonPanel.add(image); - } - public void add(ImageButton button) { - buttonPanel.add(button); - } - public void addSpacer(int sizeInPixels) { - Assert.notFalse(sizeInPixels > 0); - buttonPanel.addSpacer(sizeInPixels); - } -} - -class ToolbarButtonPanel extends ImageButtonPanel { - private int leftInset; - - public ToolbarButtonPanel(int leftInset, int gap) { - super(Orientation.HORIZONTAL, - Orientation.LEFT, - Orientation.CENTER, - gap); - - this.leftInset = leftInset; - setController(null); - } - public Insets insets() { - return new Insets(5,leftInset,5,5); - } -} diff --git a/java/gjt/Util.java b/java/gjt/Util.java deleted file mode 100644 index 0970a6fd488..00000000000 --- a/java/gjt/Util.java +++ /dev/null @@ -1,69 +0,0 @@ -package gjt; - -import java.applet.Applet; -import java.awt.*; - -/** - * A handy collection of methods for getting a component's - * frame, getting a component's applet, waiting for a - * component's image, and wallpapering a components background. - * <p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - */ -public class Util { - public static Frame getFrame(Component component) { - Component c = component; - - if(c instanceof Frame) - return (Frame)c; - - while((c = c.getParent()) != null) { - if(c instanceof Frame) - return (Frame)c; - } - return null; - } - public static Applet getApplet(Component component) { - Component c = component; - - if(c instanceof Applet) - return (Applet)c; - - while((c = c.getParent()) != null) { - if(c instanceof Applet) - return (Applet)c; - } - return null; - } - public static void waitForImage(Component component, - Image image) { - MediaTracker tracker = new MediaTracker(component); - try { - tracker.addImage(image, 0); - tracker.waitForID(0); - } - catch(InterruptedException e) { Assert.notNull(null); } - } - public static void wallPaper(Component component, - Graphics g, - Image image) { - Dimension compsize = component.size(); - Util.waitForImage(component, image); - - int patchW = image.getWidth(component); - int patchH = image.getHeight(component); - - Assert.notFalse(patchW != -1 && patchH != -1); - - for(int r=0; r < compsize.width; r += patchW) { - for(int c=0; c < compsize.height; c += patchH) - g.drawImage(image, r, c, component); - } - } - public static void setCursor(int cursor, - Component component) { - getFrame(component).setCursor(cursor); - } -} diff --git a/java/gjt/YesNoDialog.java b/java/gjt/YesNoDialog.java deleted file mode 100644 index 2db64ea6e4b..00000000000 --- a/java/gjt/YesNoDialog.java +++ /dev/null @@ -1,80 +0,0 @@ -package gjt; - -import java.awt.*; - -/** - * Similar in fuction to the MessageDialog, YesNoDialog poses - * a question, that is answered by selection of either a Yes - * button or a No button.<p> - * - * Note that the YesNoDialog is a singleton - meaning there is - * only one YesNoDialog in existence per applet. Clients - * may obtain the YesNoDialog by invoking getYesNoDialog().<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see GJTDialog - * @see MessageDialog - * @see gjt.test.DialogTest - */ -public class YesNoDialog extends GJTDialog { - static private YesNoDialog _theYesNoDialog; - private Button yesButton; - private Button noButton; - private String message; - private boolean answer = false; - private ButtonPanel buttonPanel = new ButtonPanel(); - - static public YesNoDialog getYesNoDialog( Frame frame, - DialogClient client, - String title, - String message) { - if(_theYesNoDialog == null) - _theYesNoDialog = new YesNoDialog(frame,client, - title,message); - else { - _theYesNoDialog.setClient (client); - _theYesNoDialog.setTitle (title); - _theYesNoDialog.setMessage(message); - } - return _theYesNoDialog; - } - private YesNoDialog(Frame frame, DialogClient client, - String title, String message) { - super(frame, title, client, true); - yesButton = buttonPanel.add("Yes"); - noButton = buttonPanel.add("No"); - - setLayout(new BorderLayout()); - add("Center", new YesNoPanel(message)); - add("South", buttonPanel); - pack(); - } - public void show() { - yesButton.requestFocus(); - super.show(); - } - public boolean answeredYes() { - return answer; - } - public boolean action(Event event, Object what) { - if(event.target == yesButton) answer = true; - else answer = false; - - hide(); - client.dialogDismissed(this); - return true; - } - private void setMessage(String message) { - this.message = message; - } -} - -class YesNoPanel extends Panel { - public YesNoPanel(String question) { - add("Center", new Label(question, Label.CENTER)); - } - public Insets insets() { - return new Insets(10,10,10,10); - } -} diff --git a/java/gjt/animation/CollisionArena.java b/java/gjt/animation/CollisionArena.java deleted file mode 100644 index defb1a6d86b..00000000000 --- a/java/gjt/animation/CollisionArena.java +++ /dev/null @@ -1,39 +0,0 @@ -package gjt.animation; - -import java.awt.Dimension; -import java.awt.Insets; -import java.util.Vector; -import gjt.Orientation; - -/** - * A CollisionArena is defined as an arena in which collisions - * may take place.<p> - * - * CollisionArenas must be able to report their size and - * insets, and return a Vector of the Sprites contained in the - * arena.<p> - * - * CollisionArenas must also implement two methods for handling - * sprite and edge collisions, respectively. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Playfield - * @see CollisionDetector - * @see EdgeCollisionDetector - * @see SpriteCollisionDetector - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public interface CollisionArena { - abstract public Vector getSprites(); - abstract public Dimension getSize (); - abstract public Insets getInsets (); - - abstract public void spriteCollision(Sprite sprite, - Sprite other); - - abstract public void edgeCollision(Sprite sprite, - Orientation orient); -} diff --git a/java/gjt/animation/CollisionDetector.java b/java/gjt/animation/CollisionDetector.java deleted file mode 100644 index ff05f16c6d3..00000000000 --- a/java/gjt/animation/CollisionDetector.java +++ /dev/null @@ -1,24 +0,0 @@ -package gjt.animation; - -/** - * Collision detectors detect collisions that take place within - * a CollisionArena. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CollisionArena - * @see EdgeCollisionDetector - * @see SpriteCollisionDetector - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -abstract public class CollisionDetector { - protected CollisionArena arena; - - abstract public void detectCollisions(); - - public CollisionDetector(CollisionArena arena) { - this.arena = arena; - } -} diff --git a/java/gjt/animation/EdgeCollisionDetector.java b/java/gjt/animation/EdgeCollisionDetector.java deleted file mode 100644 index 8624b7c2f28..00000000000 --- a/java/gjt/animation/EdgeCollisionDetector.java +++ /dev/null @@ -1,53 +0,0 @@ -package gjt.animation; - -import java.awt.*; -import java.util.Enumeration; -import java.util.Vector; -import gjt.Orientation; - -/** - * A CollisionDetector that detects collisions between Sprites - * and the edges of the CollisionArena in which they reside.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CollisionDetector - * @see Sprite - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public class EdgeCollisionDetector extends CollisionDetector { - public EdgeCollisionDetector(CollisionArena arena) { - super(arena); - } - public void detectCollisions() { - Enumeration sprites = arena.getSprites().elements(); - Dimension arenaSize = arena.getSize(); - Insets arenaInsets = arena.getInsets(); - Sprite sprite; - - while(sprites.hasMoreElements()) { - sprite = (Sprite)sprites.nextElement(); - - Point nl = sprite.nextLocation (); - Point mv = sprite.getMoveVector(); - int nextRightEdge = nl.x + sprite.width(); - int nextBottomEdge = nl.y + sprite.height(); - int arenaBottomEdge = arenaSize.height - - arenaInsets.bottom; - int arenaRightEdge = arenaSize.width - - arenaInsets.right; - - if(nextRightEdge > arenaRightEdge) - arena.edgeCollision(sprite, Orientation.LEFT); - else if(nl.x < arenaInsets.left) - arena.edgeCollision(sprite, Orientation.RIGHT); - - if(nextBottomEdge > arenaBottomEdge) - arena.edgeCollision(sprite, Orientation.BOTTOM); - else if(nl.y < arenaInsets.top) - arena.edgeCollision(sprite, Orientation.TOP); - } - } -} diff --git a/java/gjt/animation/Playfield.java b/java/gjt/animation/Playfield.java deleted file mode 100644 index 386c0fb24c4..00000000000 --- a/java/gjt/animation/Playfield.java +++ /dev/null @@ -1,140 +0,0 @@ -package gjt.animation; - -import java.awt.*; -import java.util.Enumeration; -import java.util.Vector; -import gjt.Util; - -/** - * A surface upon which Sprites are animated. Playfields are - * responsible for animating the sprites.<p> - * - * Each Playfield comes complete with two collision detectors: - * an edge collision detector and a sprite collision detector. - * - * Playfield is an abstract class: extensions must implement - * the following methods: - * <dl> - * <dd> void paintBackground(Graphics) - * <dd> void void spriteCollision(Sprite sprite, Sprite other) - * <dd> void void edgeCollision (Sprite sprite, Sprite other) - * </dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CollisionArena - * @see Sprite - * @see SpriteCollisionDetector - * @see EdgeCollisionDetector - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public abstract class Playfield extends Canvas - implements Runnable, - CollisionArena { - protected Vector sprites = new Vector(); - private boolean running = false; - private Insets insets = new Insets(0,0,0,0); - - private Thread animationThread; - private Image bgoffscreen, - workplaceBuffer; - private Dimension offscreenSize; - private EdgeCollisionDetector edgeCollisionDetector; - private SpriteCollisionDetector spriteCollisionDetector; - - abstract public void paintBackground(Graphics g); - - public Playfield() { - edgeCollisionDetector = - new EdgeCollisionDetector(this); - spriteCollisionDetector = - new SpriteCollisionDetector(this); - } - public void stop () { running = false; } - public boolean running () { return running; } - public Dimension getSize () { return size(); } - public Insets getInsets () { return insets; } - public Vector getSprites() { return sprites; } - - public void addSprite(Sprite sprite) { - sprites.addElement(sprite); - } - public void setInsets(Insets insets) { - this.insets = insets; - } - public void start() { - animationThread = new Thread(this); - running = true; - animationThread.start(); - } - public void paint(Graphics g) { - if(needNewOffscreenBuffer()) { - workplaceBuffer = createOffscreenImage(size()); - bgoffscreen = createOffscreenImage(size()); - paintBackground(bgoffscreen.getGraphics()); - } - g.drawImage(bgoffscreen, 0, 0, this); - paintSprites(); - } - public void reshape(int x, int y, int w, int h) { - super.reshape(x,y,w,h); - repaint(); - } - public void run() { - while(running == true) { - edgeCollisionDetector.detectCollisions (); - spriteCollisionDetector.detectCollisions(); - - animateSprites(); - Thread.currentThread().yield(); - } - animationThread = null; - } - private boolean needNewOffscreenBuffer() { - return (workplaceBuffer == null || - bgoffscreen == null || - size().width != offscreenSize.width || - size().height != offscreenSize.height); - } - private Image createOffscreenImage(Dimension size) { - Image image = createImage(size.width, size.height); - Util.waitForImage(this, image); - offscreenSize = size; - return image; - } - protected void animateSprites() { - Sprite nextSprite; - Enumeration e = sprites.elements(); - - while(e.hasMoreElements()) { - nextSprite = (Sprite)e.nextElement(); - nextSprite.animate(); - } - } - protected void paintSprites() { - Sprite nextSprite; - Enumeration e = sprites.elements(); - - while(e.hasMoreElements()) { - nextSprite = (Sprite)e.nextElement(); - paintSprite(nextSprite); - } - } - protected void paintSprite(Sprite sprite) { - Graphics g = getGraphics(); - Graphics wpg = workplaceBuffer.getGraphics(); - Rectangle clip = sprite.clipRect(); - - wpg.clipRect(clip.x, clip.y, clip.width, clip.height); - wpg.drawImage(bgoffscreen, 0, 0, this); - sprite.paint(wpg); - - g.clipRect (clip.x, clip.y, clip.width, clip.height); - g.drawImage(workplaceBuffer, 0, 0, this); - - g.dispose(); - wpg.dispose(); - } -} diff --git a/java/gjt/animation/Sequence.java b/java/gjt/animation/Sequence.java deleted file mode 100644 index 7b777ecd0d8..00000000000 --- a/java/gjt/animation/Sequence.java +++ /dev/null @@ -1,119 +0,0 @@ -package gjt.animation; - -import java.util.Vector; -import java.awt.*; -import java.awt.image.ImageObserver; -import gjt.Util; -import gjt.Stopwatch; - -/** - * A sequence of images used in an animation. Each sequence - * keeps track of the number of cycles the sequence is to run, - * and reports whether or not the cycles have been completed - * via the boolean animationOver() method. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Sprite - * @see Playfield - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public class Sequence { - private static long infiniteCycle = -1; - - private Vector cells = new Vector(); - private Point lastPaintLocation = new Point(0,0); - private Stopwatch cellAdvanceTimer = new Stopwatch(); - private Image currentImage, lastImagePainted; - private long cellAdvanceInterval = 0, - currentCycle = 0, - cyclesPerAnimation = 0; - - public Sequence() { } - - public Sequence(Component component, Image[] images) { - for(int i=0; i < images.length; ++i) { - addImage(component, images[i]); - } - cyclesPerAnimation = infiniteCycle; - } - public void start () { cellAdvanceTimer.start(); } - public Image getLastImage () { return lastImagePainted; } - public Point getLastLocation() { return lastPaintLocation; } - public int getNumImages () { return cells.size(); } - - public long getCurrentCycle() { return currentCycle; } - public void setCurrentCycle(long c) { currentCycle = c; } - - public long getCyclesPerAnimation() { - return currentCycle; - } - public void setCyclesPerAnimation(long cyclesPerAnimation) { - this.cyclesPerAnimation = cyclesPerAnimation; - } - public Image getFirstImage() { - return (Image)cells.firstElement(); - } - public Image getCurrentImage() { - return currentImage; - } - public int getCurrentImagePosition() { - return cells.indexOf(currentImage); - } - public Image getNextImage() { - int index = cells.indexOf(currentImage); - Image image; - - if(index == cells.size() - 1) - image = (Image)cells.elementAt(0); - else - image = (Image)cells.elementAt(index + 1); - - return image; - } - public void setAdvanceInterval(long interval) { - cellAdvanceInterval = interval; - } - public void addImage(Component component, Image image) { - if(currentImage == null) - currentImage = image; - - Util.waitForImage(component, image); - cells.addElement(image); - } - public void removeImage(Image image) { - cells.removeElement(image); - } - public boolean needsRepainting(Point point) { - return (lastPaintLocation.x != point.x || - lastPaintLocation.y != point.y || - lastImagePainted != currentImage); - } - public void paint(Graphics g, int x, int y, - ImageObserver observer) { - g.drawImage(currentImage, x, y, observer); - lastPaintLocation.x = x; - lastPaintLocation.y = y; - lastImagePainted = currentImage; - } - public boolean isAtLastImage() { - return getCurrentImagePosition() == (cells.size() - 1); - } - public boolean timeToAdvanceCell() { - return - cellAdvanceTimer.elapsedTime() > cellAdvanceInterval; - } - public boolean animationOver() { - return (cyclesPerAnimation != infiniteCycle) && - (currentCycle >= cyclesPerAnimation); - } - public void advance() { - if(isAtLastImage()) - ++currentCycle; - - currentImage = getNextImage(); - cellAdvanceTimer.reset(); - } -} diff --git a/java/gjt/animation/Sprite.java b/java/gjt/animation/Sprite.java deleted file mode 100644 index e7840b7615b..00000000000 --- a/java/gjt/animation/Sprite.java +++ /dev/null @@ -1,191 +0,0 @@ -package gjt.animation; - -import java.awt.*; -import java.util.Vector; -import gjt.Assert; -import gjt.Stopwatch; -import gjt.Util; - -/** - * A sequence of images which are animated and moved about on - * a Playfield.<p> - * - * Each Sprite is constructed with a reference to it's - * Playfield, a Sequence, and a beginning position for it's - * upper left hand corner.<p> - * - * A Sprite's animation is controlled by invoking the following - * methods: - *<dl> - *<dd> setMoveVector(Point) - *<dd> setMoveInterval(long) - *<dd> setImageChangeInterval(long) - *<dd> setMainSequence(Sequence) - *<dd> setSequence(Sequence) - *</dl> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Sequence - * @see Playfield - * @see SpriteCollisionDetector - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public class Sprite { - private Playfield field; - private Sequence currentSequence, mainSequence; - private Stopwatch moveTimer = new Stopwatch(); - - private Point ulhc = new Point(0,0); - private Point start = new Point(0,0); - private Point moveVector = new Point(1,1); - - private Rectangle clip = new Rectangle(0,0); - private Rectangle curBounds, lastBounds; - - private int width, height; - private long moveInterval = 0; - - public Sprite(Playfield field, - Sequence sequence, - Point ulhc) { - Assert.notNull(field); - Assert.notNull(sequence); - Assert.notNull(ulhc); - - this.field = field; - this.ulhc = ulhc; - start.x = ulhc.x; - start.y = ulhc.y; - - setSequence(sequence); - setMainSequence(sequence); - - initializeBounds(); - moveTimer.start(); - currentSequence.start(); - } - public Playfield getPlayfield() { return field; } - public Rectangle clipRect () { return clip; } - public Rectangle curBounds () { return curBounds; } - - public int width () { return width; } - public int height () { return height; } - public void reverseX () { moveVector.x = 0-moveVector.x; } - public void reverseY () { moveVector.y = 0-moveVector.y; } - public void reverse () { reverseX(); reverseY(); } - public Point start () { return start; } - - public void setMoveVector (Point p) { moveVector = p; } - public Point getMoveVector() { return moveVector; } - - public void play(Sequence sequence, long cycles) { - setSequence(sequence); - sequence.setCyclesPerAnimation(cycles); - sequence.setCurrentCycle(0); - } - public void animate() { - if(currentSequence.animationOver()) - currentSequence = mainSequence; - - if(timeToChangeImage()) currentSequence.advance(); - if(timeToMove()) move(); - if(needsRepainting()) field.paintSprite(this); - } - public void setMainSequence(Sequence sequence) { - mainSequence = sequence; - } - public Sequence getMainSequence() { - return mainSequence; - } - public void setSequence(Sequence sequence) { - currentSequence = sequence; - - if(curBounds != null) - updateBounds(); - } - public Sequence getSequence() { - return currentSequence; - } - public boolean intersects(Sprite otherSprite) { - return curBounds().intersects(otherSprite.curBounds()); - } - public boolean willIntersect(Sprite otherSprite) { - return - nextBounds().intersects(otherSprite.nextBounds()); - } - public boolean timeToMove() { - return moveTimer.elapsedTime() > moveInterval; - } - public boolean timeToChangeImage() { - return currentSequence.timeToAdvanceCell(); - } - public void moveTo(Point p) { - ulhc = p; - moveTimer.reset(); - } - public boolean needsRepainting() { - return currentSequence.needsRepainting(ulhc); - } - public void setMoveInterval(long interval) { - moveInterval = interval; - } - public void setImageChangeInterval(long interval) { - currentSequence.setAdvanceInterval(interval); - } - public void move() { - ulhc.x += moveVector.x; - ulhc.y += moveVector.y; - updateBounds(); - moveTimer.reset(); - } - public Point location() { - return ulhc; - } - public Point nextLocation() { - return new Point(ulhc.x + moveVector.x, - ulhc.y + moveVector.y); - } - public Rectangle nextBounds() { - Image nextImage = currentSequence.getNextImage(); - Point nextLoc = nextLocation(); - - return new Rectangle( - nextLoc.x, nextLoc.y, width, height); - } - public void paint(Graphics g) { - currentSequence.paint(g, ulhc.x, ulhc.y, field); - } - private void initializeBounds() { - Image curImage = currentSequence.getCurrentImage(); - - width = curImage.getWidth (field); - height = curImage.getHeight(field); - - curBounds = - new Rectangle(ulhc.x, ulhc.y, width, height); - - lastBounds = new Rectangle(curBounds.x, - curBounds.y, - curBounds.width, - curBounds.height); - - clip = lastBounds.union(curBounds); - } - private void updateBounds() { - Image curImage = currentSequence.getCurrentImage(); - - lastBounds.width = curBounds.width; - lastBounds.height = curBounds.height; - - curBounds.width = width = curImage.getWidth(field); - curBounds.height = height = curImage.getHeight(field); - - lastBounds.move(curBounds.x, curBounds.y); - curBounds.move (ulhc.x, ulhc.y); - - clip = lastBounds.union(curBounds); - } -} diff --git a/java/gjt/animation/SpriteCollisionDetector.java b/java/gjt/animation/SpriteCollisionDetector.java deleted file mode 100644 index 2ef37d79208..00000000000 --- a/java/gjt/animation/SpriteCollisionDetector.java +++ /dev/null @@ -1,45 +0,0 @@ -package gjt.animation; - -import java.awt.*; -import java.util.Enumeration; -import java.util.Vector; -import gjt.Orientation; - -/** - * A CollisionDetector that detects collisions between Sprites - * residing in a CollisionArena.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see CollisionArena - * @see CollisionDetector - * @see Sprite - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public class SpriteCollisionDetector extends CollisionDetector { - public SpriteCollisionDetector(CollisionArena arena) { - super(arena); - } - public void detectCollisions() { - Enumeration sprites = arena.getSprites().elements(); - Sprite sprite; - - while(sprites.hasMoreElements()) { - sprite = (Sprite)sprites.nextElement(); - - Enumeration otherSprites = - arena.getSprites().elements(); - Sprite otherSprite; - - while(otherSprites.hasMoreElements()) { - otherSprite=(Sprite)otherSprites.nextElement(); - - if(otherSprite != sprite) - if(sprite.willIntersect(otherSprite)) - arena.spriteCollision(sprite,otherSprite); - } - } - } -} diff --git a/java/gjt/image/BleachImageFilter.java b/java/gjt/image/BleachImageFilter.java deleted file mode 100644 index f698a218284..00000000000 --- a/java/gjt/image/BleachImageFilter.java +++ /dev/null @@ -1,53 +0,0 @@ -package gjt.image; - -import java.awt.image.*; -import gjt.Assert; - -/** - * A derivation of RGBImageFilter that bleaches an image.<p> - * - * Extent of the bleaching effect is controlled by the only - * constructor argument: an integer representing the percentage - * of bleaching. The percentage of bleaching may also be - * controlled after instantiation by invoking the - * void percent(int) method.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see RGBImageFilter - */ -public class BleachImageFilter extends RGBImageFilter { - private int percent; - - public BleachImageFilter(int percent) { - Assert.notFalse(percent >= 0 && percent <= 100); - this.percent = percent; - canFilterIndexColorModel = true; - } - public int percent() { return percent; } - public void percent(int percent) { percent = percent; } - - public int filterRGB(int x, int y, int rgb) { - DirectColorModel cm = - (DirectColorModel)ColorModel.getRGBdefault(); - - int alpha = cm.getAlpha(rgb); - int red = cm.getRed (rgb); - int green = cm.getGreen(rgb); - int blue = cm.getBlue (rgb); - double percentMultiplier = (double)percent/100; - - red = Math.min((int) - (red + (red * percentMultiplier)), 255); - green = Math.min((int) - (green + (green * percentMultiplier)), 255); - blue = Math.min((int) - (blue + (blue * percentMultiplier)), 255); - - alpha = alpha << 24; - red = red << 16; - green = green << 8; - - return alpha | red | green | blue; - } -} diff --git a/java/gjt/image/DissolveFilter.java b/java/gjt/image/DissolveFilter.java deleted file mode 100644 index 027455b39b6..00000000000 --- a/java/gjt/image/DissolveFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -package gjt.image; - -import java.awt.image.*; -import gjt.Assert; - -/** - * A derivation of RGBImageFilter that partially or wholly - * dissolves an image.<p> - * - * Extent of dissolving is set by the setOpacity(int) method, - * which is passed an integer between 0 and 255 (inclusive). - * The integer represents the alpha value to be applied to - * every color in the image.<p> - * - * An alpha value of 255 signifies an opaque color, while an - * alpha value of 0 signifies a translucent color.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see RGBImageFilter - */ -public class DissolveFilter extends RGBImageFilter { - private int opacity; - - public DissolveFilter() { - this(0); - } - public DissolveFilter(int opacity) { - canFilterIndexColorModel = true; - setOpacity(opacity); - } - public void setOpacity(int opacity) { - Assert.notFalse(opacity >= 0 && opacity <= 255); - this.opacity = opacity; - } - public int filterRGB(int x, int y, int rgb) { - DirectColorModel cm = - (DirectColorModel)ColorModel.getRGBdefault(); - int alpha = cm.getAlpha(rgb); - int red = cm.getRed (rgb); - int green = cm.getGreen(rgb); - int blue = cm.getBlue (rgb); - - alpha = opacity; - - return alpha << 24 | red << 16 | green << 8 | blue; - } -} diff --git a/java/gjt/image/ImageDissolver.java b/java/gjt/image/ImageDissolver.java deleted file mode 100644 index 5d0e6a2daf6..00000000000 --- a/java/gjt/image/ImageDissolver.java +++ /dev/null @@ -1,132 +0,0 @@ -package gjt.image; - -import java.awt.*; -import java.awt.image.*; -import gjt.Util; - -/** - * Given an image, an ImageDissolver produces an array of - * images of varying opacity that are used in the fadeIn() - * and fadeOut() methods for fading the image in and out - * respectively.<p> - * - * As a convenience, ImageDissolver has a static method: - * Image[] createImages() that creates the array of images - * mentioned above, in case clients would like to create their - * own array of images instead of using an ImageDissolver - * directly.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see ThreeDBorder - * @see ImageButtonController - * @see SpringyImageButtonController - * @see StickyImageButtonController - * @see BleachImageFilter - * @see gjt.test.ImageButtonTest - */ -public class ImageDissolver { - private static int _defaultNumImages = 10, - _defaultPause = 50; - Component comp; - int numImages, pauseInterval; - Image image, offscreen; - Image[] dissolvedImages; - - static public Image[] createImages(Image image, - int numImages, - Component component) { - Image images[] = new Image[numImages]; - MediaTracker tracker = new MediaTracker(component); - - DissolveFilter filter; - FilteredImageSource fis; - - for(int i=0; i < numImages; ++i) { - filter = new DissolveFilter((255/(numImages-1))*i); - fis = new FilteredImageSource(image.getSource(), - filter); - - images[i] = component.createImage(fis); - tracker.addImage(images[i], i); - } - try { tracker.waitForAll(); } - catch(InterruptedException e) { } - - return images; - } - - public ImageDissolver(Component comp, Image image) { - this(comp, image, _defaultNumImages, _defaultPause); - } - public ImageDissolver(Component comp, Image im, - int numImages, int pause) { - this.image = im; - this.comp = comp; - this.numImages = numImages; - dissolvedImages = new Image[numImages]; - pauseInterval = pause; - - Util.waitForImage(comp, im); - dissolvedImages = createImages(image, numImages, comp); - } - public void fadeIn(int x, int y) { - if(offscreen == null) - offscreen = comp.createImage(image.getWidth(comp), - image.getHeight(comp)); - - Graphics offg = offscreen.getGraphics(); - Graphics compg = comp.getGraphics(); - - if(offg != null && compg != null) { - clearComponent(compg, x, y); - for(int i=0; i < numImages; ++i) { - blitImage(compg, offg, x, y, i); - pause (); - } - blitOpaqueImage(compg, offg, x, y); - } - } - public void fadeOut(int x, int y) { - if(offscreen == null) - offscreen = comp.createImage(image.getWidth(comp), - image.getHeight(comp)); - - Graphics offg = offscreen.getGraphics(); - Graphics compg = comp.getGraphics(); - - if(offg != null && compg != null) { - blitOpaqueImage(compg, offg, x, y); - for(int i=numImages-1; i >= 0; --i) { - clearOffscreen(); - blitImage (compg, offg, x, y, i); - pause (); - } - } - } - private void blitImage(Graphics compg, Graphics offg, - int x, int y, int index) { - offg.drawImage (dissolvedImages[index], 0, 0, comp); - compg.drawImage(offscreen, x, y, comp); - } - private void blitOpaqueImage(Graphics compg, Graphics offg, - int x, int y) { - offg.drawImage(image, 0, 0, comp); - compg.drawImage(offscreen, x, y, comp); - } - private void clearComponent(Graphics compg, int x, int y) { - clearOffscreen(); - compg.drawImage(offscreen, x, y, comp); - } - private void clearOffscreen() { - Graphics offg = offscreen.getGraphics(); - - offg.setColor(comp.getBackground()); - offg.fillRect(0, 0, - image.getWidth(comp), image.getHeight(comp)); - } - private void pause() { - try { Thread.currentThread().sleep(pauseInterval); } - catch(InterruptedException e) { } - } -} diff --git a/java/gjt/rubberband/Rubberband.java b/java/gjt/rubberband/Rubberband.java deleted file mode 100644 index be4b1b6ac05..00000000000 --- a/java/gjt/rubberband/Rubberband.java +++ /dev/null @@ -1,100 +0,0 @@ -package gjt.rubberband; - -import java.awt.*; - -/** - * A abstract base class for rubberbands.<p> - * - * Rubberbands do their rubberbanding inside of a Component, - * which must be specified at construction time.<p> - * - * Subclasses are responsible for implementing - * <em>void drawLast(Graphics g)</em> and - * <em>void drawNext(Graphics g)</em>. - * - * drawLast() draws the appropriate geometric shape at the last - * rubberband location, while drawNext() draws the appropriate - * geometric shape at the next rubberband location. All of the - * underlying support for rubberbanding is taken care of here, - * including handling XOR mode setting; extensions of Rubberband - * need not concern themselves with anything but drawing the - * last and next geometric shapes.<p> - * - * @version 1.00, 12/27/95 - * @author David Geary - * @see RubberbandLine - * @see RubberbandRectangle - * @see RubberbandEllipse - * @see gjt.test.RubberbandTest - */ -abstract public class Rubberband { - protected Point anchor = new Point(0,0); - protected Point stretched = new Point(0,0); - protected Point last = new Point(0,0); - protected Point end = new Point(0,0); - - private Component component; - private boolean firstStretch = true; - - abstract public void drawLast(Graphics g); - abstract public void drawNext(Graphics g); - - public Rubberband(Component component) { - this.component = component; - } - public Point getAnchor () { return anchor; } - public Point getStretched() { return stretched; } - public Point getLast () { return last; } - public Point getEnd () { return end; } - - public void anchor(Point p) { - firstStretch = true; - anchor.x = p.x; - anchor.y = p.y; - - stretched.x = last.x = anchor.x; - stretched.y = last.y = anchor.y; - } - public void stretch(Point p) { - last.x = stretched.x; - last.y = stretched.y; - stretched.x = p.x; - stretched.y = p.y; - - Graphics g = component.getGraphics(); - if(g != null) { - g.setXORMode(component.getBackground()); - - if(firstStretch == true) firstStretch = false; - else drawLast(g); - - drawNext(g); - } - } - public void end(Point p) { - last.x = end.x = p.x; - last.y = end.y = p.y; - - Graphics g = component.getGraphics(); - if(g != null) { - g.setXORMode(component.getBackground()); - drawLast(g); - } - } - public Rectangle bounds() { - return new Rectangle(stretched.x < anchor.x ? - stretched.x : anchor.x, - stretched.y < anchor.y ? - stretched.y : anchor.y, - Math.abs(stretched.x - anchor.x), - Math.abs(stretched.y - anchor.y)); - } - - public Rectangle lastBounds() { - return new Rectangle( - last.x < anchor.x ? last.x : anchor.x, - last.y < anchor.y ? last.y : anchor.y, - Math.abs(last.x - anchor.x), - Math.abs(last.y - anchor.y)); - } -} diff --git a/java/gjt/rubberband/RubberbandEllipse.java b/java/gjt/rubberband/RubberbandEllipse.java deleted file mode 100644 index 50ddb0cdd6b..00000000000 --- a/java/gjt/rubberband/RubberbandEllipse.java +++ /dev/null @@ -1,32 +0,0 @@ -package gjt.rubberband; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; - -/** - * A Rubberband that does ellipses. - * - * @version 1.00, 12/27/95 - * @author David Geary - * @see Rubberband - * @see gjt.test.RubberbandTest - */ -public class RubberbandEllipse extends Rubberband { - private final int startAngle = 0; - private final int endAngle = 360; - - public RubberbandEllipse(Component component) { - super(component); - } - public void drawLast(Graphics graphics) { - Rectangle r = lastBounds(); - graphics.drawArc(r.x, r.y, - r.width, r.height, startAngle, endAngle); - } - public void drawNext(Graphics graphics) { - Rectangle r = bounds(); - graphics.drawArc(r.x, r.y, - r.width, r.height, startAngle, endAngle); - } -} diff --git a/java/gjt/rubberband/RubberbandLine.java b/java/gjt/rubberband/RubberbandLine.java deleted file mode 100644 index 95daafa32a6..00000000000 --- a/java/gjt/rubberband/RubberbandLine.java +++ /dev/null @@ -1,25 +0,0 @@ -package gjt.rubberband; - -import java.awt.Component; -import java.awt.Graphics; - -/** - * A Rubberband that does lines. - * - * @version 1.0, 12/27/95 - * @author David Geary - * @see Rubberband - * @see gjt.test.RubberbandTest - */ -public class RubberbandLine extends Rubberband { - public RubberbandLine(Component component) { - super(component); - } - public void drawLast(Graphics graphics) { - graphics.drawLine(anchor.x, anchor.y, last.x, last.y); - } - public void drawNext(Graphics graphics) { - graphics.drawLine(anchor.x, anchor.y, - stretched.x, stretched.y); - } -} diff --git a/java/gjt/rubberband/RubberbandPanel.java b/java/gjt/rubberband/RubberbandPanel.java deleted file mode 100644 index e4c25f4efb5..00000000000 --- a/java/gjt/rubberband/RubberbandPanel.java +++ /dev/null @@ -1,38 +0,0 @@ -package gjt.rubberband; - -import java.awt.*; - -/** - * An extension of Panel which is fitted with a Rubberband. - * Handling of mouse events is automatically handled for - * rubberbanding.<p> - * - * Clients may set or get the Rubberband at any time.<p> - * - * @version 1.0, Dec 27 1995 - * @author David Geary - * @see Rubberband - * @see gjt.test.RubberbandTest - */ -public class RubberbandPanel extends Panel { - private Rubberband rubberband; - - public void setRubberband(Rubberband rubberband) { - this.rubberband = rubberband; - } - public Rubberband getRubberband() { - return rubberband; - } - public boolean mouseDown(Event event, int x, int y) { - rubberband.anchor(new Point(x,y)); - return false; - } - public boolean mouseDrag(Event event, int x, int y) { - rubberband.stretch(new Point(x,y)); - return false; - } - public boolean mouseUp(Event event, int x, int y) { - rubberband.end(new Point(x,y)); - return false; - } -} diff --git a/java/gjt/rubberband/RubberbandRectangle.java b/java/gjt/rubberband/RubberbandRectangle.java deleted file mode 100644 index bfcb1bfc32c..00000000000 --- a/java/gjt/rubberband/RubberbandRectangle.java +++ /dev/null @@ -1,29 +0,0 @@ -package gjt.rubberband; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; - -/** - * A Rubberband that does rectangles. - * - * @version 1.00, 12/27/95 - * @author David Geary - * @see Rubberband - * @see gjt.test.RubberbandTest - */ -public class RubberbandRectangle extends Rubberband { - public RubberbandRectangle(Component component) { - super(component); - } - public void drawLast(Graphics graphics) { - Rectangle rect = lastBounds(); - graphics.drawRect(rect.x, rect.y, - rect.width, rect.height); - } - public void drawNext(Graphics graphics) { - Rectangle rect = bounds(); - graphics.drawRect(rect.x, rect.y, - rect.width, rect.height); - } -} diff --git a/java/gjt/test/AttributesPanel.java b/java/gjt/test/AttributesPanel.java deleted file mode 100644 index 535a12edaeb..00000000000 --- a/java/gjt/test/AttributesPanel.java +++ /dev/null @@ -1,78 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import gjt.*; - -class AttributesPanel extends Panel { - private Applet applet; - private Box iconbox, labelbox, checkboxbox; - private Panel panelInLabelbox = new Panel(); - private Panel panelInCheckboxbox = new Panel(); - private ExclusiveImageButtonPanel panelInIconbox; - - public AttributesPanel(Applet applet) { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - - this.applet = applet; - panelInIconbox = new ExclusiveImageButtonPanel( - Orientation.HORIZONTAL); - - populateIconPanel (); - populateLabelPanel (); - populateCheckboxPanel(); - - iconbox = new Box(panelInIconbox, - "Meaningless Images"); - labelbox = new Box(panelInLabelbox, "Labels"); - checkboxbox = new Box(panelInCheckboxbox, "Fruits"); - iconbox.etchedOut(); - - setLayout(gbl); - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weighty = 0.50; - gbl.setConstraints(iconbox, gbc); - add(iconbox); - gbl.setConstraints(labelbox, gbc); - add(labelbox); - - gbc.anchor = GridBagConstraints.SOUTH; - gbc.weighty = 0; - gbl.setConstraints(panelInCheckboxbox, gbc); - add(checkboxbox); - } - private void populateIconPanel() { - Image ballot, film, ticket; - - ballot = applet.getImage(applet.getCodeBase(), - "gifs/ballot_box.gif"); - ticket = applet.getImage(applet.getCodeBase(), - "gifs/movie_ticket.gif"); - film = applet.getImage(applet.getCodeBase(), - "gifs/filmstrip.gif"); - - panelInIconbox.add(ballot); - panelInIconbox.add(ticket); - panelInIconbox.add(film); - } - private void populateLabelPanel() { - panelInLabelbox.add(new Label("Label One")); - panelInLabelbox.add(new Label("Label Two")); - panelInLabelbox.add(new Label("Label Three")); - panelInLabelbox.add(new Label("Label Four")); - panelInLabelbox.add(new Label("Label Five")); - } - private void populateCheckboxPanel() { - CheckboxGroup group = new CheckboxGroup(); - - panelInCheckboxbox.setLayout(new GridLayout(3,0)); - panelInCheckboxbox.add(new Checkbox("apples", - group, false)); - panelInCheckboxbox.add(new Checkbox("oranges", - group, false)); - panelInCheckboxbox.add(new Checkbox("pears", - group, true)); - } -} diff --git a/java/gjt/test/BargaugeTest.java b/java/gjt/test/BargaugeTest.java deleted file mode 100644 index 47733d6b0bf..00000000000 --- a/java/gjt/test/BargaugeTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package gjt.test; - -import java.awt.*; -import java.applet.*; -import gjt.Bargauge; - -/** - * An array of either horizontal or vertical animated bargauges. - * The orientation of the bargauges is controlled by a parameter - * passed into the applet.<p> - * - * <em> - * Warning: An AWT bug causes this test to be a gluttenous - * consumer of resources (especially under Win95). A mouse down - * will halt the animation thread along with its consumption of - * resources.<p> - * </em> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.Bargauge - */ -public class BargaugeTest extends UnitTest { - private Bargauge[] gauges = new Bargauge[10]; - private Thread animatorThread; - private boolean running; - - public String title() { - return "Bargauge Test"; - } - public Panel centerPanel() { - return new BargaugeTestPanel( - gauges, getParameter("orientation")); - } - public boolean mouseDown(Event event, int x, int y) { - if(running == true) { - animatorThread.suspend(); - running = false; - } - else { - animatorThread.resume (); - running = true; - } - return true; - } - public void start() { - super.start(); - animatorThread = new BargaugeAnimator(gauges); - animatorThread.start(); - running = true; - } - public void stop() { - super.stop(); - animatorThread.suspend(); - running = false; - } -} - -class BargaugeTestPanel extends Panel { - public BargaugeTestPanel(Bargauge[] gauges, String orient) { - Panel bargaugePanel = new Panel(); - - setLayout(new BorderLayout()); - add("North", - new Label("Mouse Down Starts/Stops",Label.CENTER)); - add("Center", bargaugePanel); - - bargaugePanel.add(new BargaugeGridPanel(gauges,orient)); - } -} - -class BargaugeGridPanel extends Panel { - private Dimension preferredSize = new Dimension(200, 250); - - public BargaugeGridPanel(Bargauge[] gauges, String orient) { - Bargauge nextGauge; - Color color = Color.gray; - - if("horizontal".equals(orient)) - setLayout(new GridLayout(gauges.length,0,5,5)); - else - setLayout(new GridLayout(0,gauges.length,5,5)); - - for(int i=0; i < gauges.length; ++i) { - switch(i) { - case 1: color = Color.darkGray; break; - case 2: color = Color.blue; break; - case 3: color = Color.magenta; break; - case 4: color = Color.yellow; break; - case 5: color = Color.green; break; - case 6: color = Color.cyan; break; - case 7: color = Color.orange; break; - case 8: color = Color.pink; break; - case 9: color = Color.red; break; - case 10: color = Color.yellow; break; - } - nextGauge = new Bargauge(color); - gauges[i] = nextGauge; - add(nextGauge); - } - } - public Dimension preferredSize() { return preferredSize; } - public Dimension minimumSize () { return preferredSize; } -} - -class BargaugeAnimator extends Thread { - private Bargauge[] gauges; - private boolean firstAnimation = true; - - public BargaugeAnimator(Bargauge[] gauges) { - this.gauges = gauges; - } - public void run() { - int count = gauges.length; - - while(true) { - try { Thread.currentThread().sleep(500,0); } - catch(InterruptedException e) { } - for(int i=0; i < count; ++i) { - gauges[i].setFillPercent(Math.random() * 100); - gauges[i].fill(); - - if(firstAnimation) - System.out.println(gauges[i].toString()); - } - firstAnimation = false; - } - } -} diff --git a/java/gjt/test/BleachImageFilterTest.java b/java/gjt/test/BleachImageFilterTest.java deleted file mode 100644 index 08fda725a08..00000000000 --- a/java/gjt/test/BleachImageFilterTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import java.awt.image.FilteredImageSource; - -import gjt.Util; -import gjt.image.BleachImageFilter; - -/** - * Initially displays an unbleached image. Subsequent mouse - * clicks in the canvas containing the image toggle between - * a bleached version of the image and an unbleached version.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.image.BleachImageFilter - */ -public class BleachImageFilterTest extends UnitTest { - public String title() { - return "BleachImageFilter Test " + - "(Click below to Bleach/Unbleach Picture)"; - } - public Panel centerPanel() { - return new BleachImageFilterTestPanel(this); - } -} - -class BleachImageFilterTestPanel extends Panel { - BleachImageFilterTestCanvas canvas; - - public BleachImageFilterTestPanel(Applet applet) { - add(canvas = new BleachImageFilterTestCanvas(applet)); - } - public boolean mouseDown(Event event, int x, int y) { - canvas.toggleBleaching(); - canvas.repaint(); - return true; - } -} - -class BleachImageFilterTestCanvas extends Canvas { - private Image im; - private Image bleached; - private boolean showingBleached = false; - - public BleachImageFilterTestCanvas(Applet applet) { - int bp; - String bleachPercent = - applet.getParameter("bleachPercent"); - - if(bleachPercent != null) - bp = new Integer(bleachPercent).intValue(); - else - bp = 50; - - im = applet.getImage(applet.getCodeBase(), - "gifs/saint.gif"); - Util.waitForImage(this, im); - - FilteredImageSource source = - new FilteredImageSource(im.getSource(), - new BleachImageFilter(bp)); - - bleached = createImage(source); - Util.waitForImage(this, bleached); - - showImageSize(); - } - public Dimension preferredSize() { - return new Dimension(im.getWidth(this), - im.getHeight(this)); - } - public void paint(Graphics g) { - if(showingBleached) g.drawImage(bleached,0,0,this); - else g.drawImage(im, 0,0,this); - } - public void toggleBleaching() { - showingBleached = showingBleached ? false : true; - } - private void showImageSize() { - System.out.print ("Image width=" + im.getWidth(this)); - System.out.println(" height=" + im.getHeight(this)); - } -} diff --git a/java/gjt/test/BorderTest.java b/java/gjt/test/BorderTest.java deleted file mode 100644 index 450b5ffc7ea..00000000000 --- a/java/gjt/test/BorderTest.java +++ /dev/null @@ -1,202 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import gjt.Border; -import gjt.Box; -import gjt.EtchedBorder; -import gjt.ImageButton; -import gjt.ThreeDBorder; - -/** - * Creates 10 bordered Components: - * <dl> - * <dd> A Canvas (click in canvas to depress/raise the border). - * <dd> A Label with an etched out border. - * <dd> A TextField with an inset 3D border. - * <dd> A CheckBox with a default border. - * <dd> A List with a raised 3D border. - * <dd> A Choice with an etched in border. - * <dd> A Box with a raised 3D border. - * <dd> An ImageButton with a thick, red border. - * <dd> An AWT Button with a cyan border. - * <dd> A TextArea with a blue default-width border. - * </dl> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.Border - * @see gjt.ThreeDBorder - * @see gjt.EtchedBorder - */ -public class BorderTest extends UnitTest { - public String title() { - return "Border Test"; - } - public Panel centerPanel() { - return new BorderTestPanel(this); - } -} - -class BorderTestPanel extends Panel { - TextField tf = new TextField( - "Inset TextField: border 5 pixels, gap 5 pixels "); - ThreeDBorder threeDBorder; - EtchedBorder etchedLabel; - Border border; - - public BorderTestPanel(Applet applet) { - setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); - - add(new BorderedCanvas()); - add(etchedLabel = - new EtchedBorder(new Label("Etched Label"))); - add(threeDBorder = new ThreeDBorder(tf, 5, 5)); - add(new Border(new Checkbox("Check Me Out"))); - add(makeThreeDBorderedList ()); - add(makeEtchedBorderedChoice ()); - add(makeThreeDBorderedCheckboxes()); - add(makeBorderedImageButton (applet)); - add(makeBorderedAWTButton ()); - add(makeBorderedTextArea ()); - - threeDBorder.inset(); - etchedLabel.etchedOut(); - } - private Border makeThreeDBorderedList() { - List list = new List(10, true); - - list.addItem("One"); - list.addItem("Two"); - list.addItem("Three"); - list.addItem("Four"); - list.addItem("Five"); - list.addItem("Six"); - list.addItem("Seven"); - list.addItem("Eight"); - list.addItem("Nine"); - list.addItem("Ten"); - list.addItem("Eleven"); - list.addItem("Twelve"); - list.addItem("Thirteen"); - list.addItem("Fourteen"); - list.addItem("Fiveteen"); - list.addItem("Sixteen"); - list.addItem("Seventeen"); - list.addItem("Eightteen"); - list.addItem("Nineteen"); - list.addItem("Twenty"); - - return new ThreeDBorder(list); - } - private Border makeEtchedBorderedChoice() { - Choice choice = new Choice(); - - choice.addItem("Toadies"); - choice.addItem("SilverChair"); - choice.addItem("Rug Burns"); - choice.addItem("Cracker"); - choice.addItem("Seven Mary Three"); - choice.addItem("Dishwalla"); - choice.addItem("Blues Traveler"); - choice.addItem("BottleRockets"); - choice.addItem("SpaceHog"); - - return new EtchedBorder(choice); - } - private Border makeBorderedImageButton(Applet applet) { - Image snail; - Border border; - - snail = applet.getImage(applet.getCodeBase(), - "gifs/snail.gif"); - border = new Border(new ImageButton(snail), 10); - border.setLineColor(Color.red); - - return border; - } - private Border makeBorderedAWTButton() { - Button button; - Border cyanBorder, blackBorder; - - button = new Button("Button Inside Two Borders"); - cyanBorder = new Border(button, 7); - cyanBorder.setLineColor(Color.cyan); - - blackBorder = new Border(cyanBorder); - - return blackBorder; - } - private Border makeThreeDBorderedCheckboxes() { - Panel panel = new Panel(); - Box box = new Box(panel, "Options"); - CheckboxGroup group = new CheckboxGroup(); - - panel.setLayout(new GridLayout(3,0)); - panel.add(new Checkbox("bordered", group, false)); - panel.add(new Checkbox("transparent", group, false)); - panel.add(new Checkbox("continuous", group, true)); - - return new ThreeDBorder(box, 4); - } - private Border makeBorderedTextArea() { - Border border; - - border = new Border( - new TextArea("Blue Bordered TextArea", 5, 30)); - border.setLineColor(Color.blue); - - return border; - } -} - -class BorderedCanvas extends ThreeDBorder { - public BorderedCanvas() { - super(new TestCanvas()); - } - public boolean mouseDown(Event event, int x, int y) { - if(isRaised()) paintInset (); - else paintRaised(); - return true; - } -} - -class TestCanvas extends Canvas { - private boolean centeredShowing = false; - private String centered = new String ("Red Centered Text"); - - public void paint(Graphics g) { - String canvas = "Canvas"; - String click = "Click Me"; - Dimension size = size(); - FontMetrics fm = g.getFontMetrics(); - - g.drawString(canvas, (size.width/2) - - (fm.stringWidth(canvas)/2), - fm.getHeight() - fm.getDescent()); - - g.drawString(click, (size.width/2) - - (fm.stringWidth(click)/2), - size.height - fm.getHeight() + - fm.getAscent()); - - if(centeredShowing == true) { - g.setColor(Color.red); - g.drawString(centered, - size.width/2-(fm.stringWidth(centered)/2), - size.height/2 - (fm.getHeight()/2) + - fm.getAscent()); - } - } - public Dimension preferredSize() { - FontMetrics fm = getGraphics().getFontMetrics(); - return new Dimension(fm.stringWidth(centered)+10, 100); - } - public boolean mouseUp(Event event, int x, int y) { - if(centeredShowing == false) centeredShowing = true; - else centeredShowing = false; - repaint(); - return true; - } -} diff --git a/java/gjt/test/BoxTest.java b/java/gjt/test/BoxTest.java deleted file mode 100644 index 24e3de9213e..00000000000 --- a/java/gjt/test/BoxTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import gjt.Box; -import gjt.ExclusiveImageButtonPanel; -import gjt.Orientation; - -/** - * Three Boxes, each of which surrounds either: ImageButtons, - * Labels or Checkboxes. The Box surrounding the ImageButtons - * is etched out, while the other two Boxes are etched in.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ImageButton - * @see gjt.Box - */ -public class BoxTest extends UnitTest { - public String title() { - return "Box Test"; - } - public Panel centerPanel() { - return new BoxTestPanel(this); - } -} - -class BoxTestPanel extends Panel { - private Applet applet; - private Box iconbox, labelbox, checkboxbox; - private Panel panelInLabelbox = new Panel(); - private Panel panelInCheckboxbox = new Panel(); - private ExclusiveImageButtonPanel panelInIconbox; - - public BoxTestPanel(Applet applet) { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - - this.applet = applet; - panelInIconbox = new ExclusiveImageButtonPanel( - Orientation.HORIZONTAL); - - populateIconPanel (); - populateLabelPanel (); - populateCheckboxPanel(); - - iconbox = new Box(panelInIconbox, - "Meaningless Images"); - labelbox = new Box(panelInLabelbox, "Labels"); - checkboxbox = new Box(panelInCheckboxbox, "Fruits"); - iconbox.etchedOut(); - - setLayout(gbl); - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weighty = 0.50; - gbl.setConstraints(iconbox, gbc); - add(iconbox); - gbl.setConstraints(labelbox, gbc); - add(labelbox); - - gbc.anchor = GridBagConstraints.SOUTH; - gbc.weighty = 0; - gbl.setConstraints(checkboxbox, gbc); - add(checkboxbox); - } - private void populateIconPanel() { - Image ballot, film, ticket; - - ballot = applet.getImage(applet.getCodeBase(), - "gifs/ballot_box.gif"); - ticket = applet.getImage(applet.getCodeBase(), - "gifs/movie_ticket.gif"); - film = applet.getImage(applet.getCodeBase(), - "gifs/filmstrip.gif"); - - panelInIconbox.add(ballot); - panelInIconbox.add(ticket); - panelInIconbox.add(film); - } - private void populateLabelPanel() { - panelInLabelbox.add(new Label("Label One")); - panelInLabelbox.add(new Label("Label Two")); - panelInLabelbox.add(new Label("Label Three")); - panelInLabelbox.add(new Label("Label Four")); - panelInLabelbox.add(new Label("Label Five")); - } - private void populateCheckboxPanel() { - CheckboxGroup group = new CheckboxGroup(); - - panelInCheckboxbox.setLayout(new GridLayout(3,0)); - panelInCheckboxbox.add(new Checkbox("apples", - group, false)); - panelInCheckboxbox.add(new Checkbox("oranges", - group, false)); - panelInCheckboxbox.add(new Checkbox("pears", - group, true)); - } -} diff --git a/java/gjt/test/BumpAnimationTest.java b/java/gjt/test/BumpAnimationTest.java deleted file mode 100644 index 81b6fb5ce8e..00000000000 --- a/java/gjt/test/BumpAnimationTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package gjt.test; - -import java.net.URL; -import java.applet.Applet; -import java.awt.*; - -import gjt.Util; -import gjt.Orientation; -import gjt.animation.*; - -/** - * A simple animation playfield with one sprite that bounces - * off the boundaries of the playfield.<p> - * - * When the sprite bounces off the left wall, it plays a - * bump sequence once; when it bounces off the right wall - * it plays the bump sequence twice.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.animation.Playfield - * @see gjt.animation.Sprite - */ -public class BumpAnimationTest extends UnitTest { - public String title() { - return "Bump Animation - Mouse Down Starts/Stops"; - } - public Panel centerPanel() { - return new BumpAnimationTestPanel(this); - } -} - -class BumpAnimationTestPanel extends Panel { - public BumpAnimationTestPanel(Applet applet) { - setLayout(new BorderLayout()); - add("Center", new BumpPlayfield(applet)); - } -} - -class BumpPlayfield extends Playfield { - private Applet applet; - private URL cb; - private Sprite javaDrinker; - private Sequence spinSequence, bumpSequence; - - public BumpPlayfield(Applet applet) { - this.applet = applet; - cb = applet.getCodeBase(); - makeSequencesAndSprites(); - } - public void paintBackground(Graphics g) { - Image bg = applet.getImage(cb, "gifs/background.gif"); - Util.wallPaper(this, g, bg); - } - public boolean mouseDown(Event event, int x, int y) { - if(running() == true) stop (); - else start(); - return true; - } - public void spriteCollision(Sprite sprite, Sprite sprite2) { - // Nothing to do: only 1 sprite! - } - public void edgeCollision(Sprite sprite, - Orientation orientation) { - if(orientation == Orientation.RIGHT || - orientation == Orientation.LEFT) { - if(sprite.getSequence() != bumpSequence) { - sprite.reverseX(); - - if(orientation == Orientation.RIGHT) - sprite.play(bumpSequence, 1); - else - sprite.play(bumpSequence, 2); - } - } - else - sprite.reverseY(); - } - private void makeSequencesAndSprites() { - String file; - Point startLoc = new Point(10, 10); - Image[] spinImages = new Image[19]; - Image[] bumpImages = new Image[6]; - - for(int i=0; i < spinImages.length; ++i) { - file = "gifs/spin"; - - if(i < 10) file += "0" + i + ".gif"; - else file += i + ".gif"; - - spinImages[i] = applet.getImage(cb, file); - } - for(int i=0; i < bumpImages.length; ++i) { - file = "gifs/bump0" + i + ".gif"; - bumpImages[i] = applet.getImage(cb, file); - } - spinSequence = new Sequence(this, spinImages); - bumpSequence = new Sequence(this, bumpImages); - javaDrinker = new Sprite(this, spinSequence, startLoc); - - spinSequence.setAdvanceInterval(100); - bumpSequence.setAdvanceInterval(200); - - javaDrinker.setMoveVector(new Point(2,2)); - addSprite(javaDrinker); - } -} diff --git a/java/gjt/test/ChoiceCardPanelTest.java b/java/gjt/test/ChoiceCardPanelTest.java deleted file mode 100644 index 4ec27ac8945..00000000000 --- a/java/gjt/test/ChoiceCardPanelTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import gjt.ChoiceCardPanel; - -/** - * A ChoiceCardPanel that controls three Panels.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ChoiceCardPanel - */ -public class ChoiceCardPanelTest extends UnitTest { - public String title() { return "Choice CardPanel Test"; } - public Panel centerPanel() { - return new ChoiceCardPanelTestPanel(this); - } -} - -class ChoiceCardPanelTestPanel extends Panel { - private ChoiceCardPanel mvp = new ChoiceCardPanel(); - - public ChoiceCardPanelTestPanel(Applet applet) { - setLayout(new BorderLayout()); - - mvp.addChoice("Attributes", - new AttributesPanel(applet)); - mvp.addChoice("Connections", new ConnectionsPanel()); - mvp.addChoice("Oracle", new OccupationOracle()); - add("Center", mvp); - } -} diff --git a/java/gjt/test/ColumnLayoutTest.java b/java/gjt/test/ColumnLayoutTest.java deleted file mode 100644 index fcef2151a25..00000000000 --- a/java/gjt/test/ColumnLayoutTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.net.URL; -import java.awt.*; -import gjt.*; - -/** - * Lays out 3 image buttons, and provides controls for setting - * orientations and gaps on the fly.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ImageButton - * @see gjt.Box - */ -public class ColumnLayoutTest extends UnitTest { - public String title() { - return "ColumnLayout Test"; - } - public Panel centerPanel() { - ColumnButtonPanel buttonPanel; - Panel panel = new Panel(); - - buttonPanel = new ColumnButtonPanel(this); - - panel.setLayout(new BorderLayout()); - panel.add("Center", buttonPanel); - panel.add("North", new Box(new ColumnPicker(buttonPanel), - "Column Layout Settings")); - return panel; - } -} - -class ColumnButtonPanel extends Panel implements DialogClient { - private ImageButton one, two, three; - private Panel panel = new Panel(); - private TenPixelBorder border = new TenPixelBorder(panel); - - public ColumnButtonPanel(Applet applet) { - URL cb = applet.getCodeBase(); - - one = new ImageButton(applet.getImage(cb, - "gifs/one.gif")); - two = new ImageButton(applet.getImage(cb, - "gifs/two.gif")); - three = new ImageButton(applet.getImage(cb, - "gifs/three.gif")); - - panel.setLayout(new ColumnLayout(0)); - panel.add(one); - panel.add(two); - panel.add(three); - - setLayout(new BorderLayout()); - add ("Center", border); - } - public void updateOrientations(Orientation horient, - Orientation vorient, - int gap) { - panel.setLayout(new ColumnLayout(horient, vorient, gap)); - border.validate(); - } - public void dialogDismissed(Dialog d) { } -} - -class ColumnPicker extends Panel { - private Label horientLabel = new Label("Horizontal:"); - private Label vorientLabel = new Label("Vertical:"); - private Label gapLabel = new Label("Gap:"); - - private Choice hchoice = new Choice(); - private Choice vchoice = new Choice(); - private Choice gapChoice = new Choice(); - - private ColumnButtonPanel buttonPanel; - - public ColumnPicker(ColumnButtonPanel buttonPanel) { - Panel orientations = new Panel(); - Panel gap = new Panel(); - - this.buttonPanel = buttonPanel; - hchoice.addItem("left"); - hchoice.addItem("center"); - hchoice.addItem("right"); - hchoice.select(1); - - vchoice.addItem("top"); - vchoice.addItem("center"); - vchoice.addItem("bottom"); - vchoice.select(1); - - gapChoice.addItem("0"); - gapChoice.addItem("5"); - gapChoice.addItem("10"); - gapChoice.addItem("15"); - gapChoice.addItem("20"); - - orientations.add(horientLabel); - orientations.add(hchoice); - orientations.add(vorientLabel); - orientations.add(vchoice); - - gap.add(gapLabel); - gap.add(gapChoice); - - add(new Box(orientations, "Orientations")); - add(new Box(gap, "Gap")); - } - public boolean action(Event event, Object what) { - String horient, vorient; - int gap; - - horient = hchoice.getSelectedItem(); - vorient = vchoice.getSelectedItem(); - gap = - (new Integer(gapChoice.getSelectedItem())).intValue(); - - buttonPanel.updateOrientations( - Orientation.fromString(horient), - Orientation.fromString(vorient), gap); - - return true; - } -} diff --git a/java/gjt/test/ComponentScrollerTest.java b/java/gjt/test/ComponentScrollerTest.java deleted file mode 100644 index 4f0e4a2ec70..00000000000 --- a/java/gjt/test/ComponentScrollerTest.java +++ /dev/null @@ -1,205 +0,0 @@ -package gjt.test; - -import java.awt.*; -import java.util.Vector; -import java.applet.Applet; -import java.net.URL; - -import gjt.Border; -import gjt.ButtonPanel; -import gjt.ColumnLayout; -import gjt.ComponentScroller; -import gjt.EtchedBorder; -import gjt.ImageButton; -import gjt.RowLayout; -import gjt.Separator; -import gjt.StickyImageButtonController; - -/** - * A phony image store, where you can purchase images.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see Border - * @see ButtonPanel - * @see ImageButton - * @see Separator - * @see StickyImageButtonController - * @see ComponentScroller - */ -public class ComponentScrollerTest extends UnitTest { - public String title() { - return "ComponentScroller Test"; - } - public Panel centerPanel() { - return new ComponentScrollerTestPanel(this); - } -} - -class ComponentScrollerTestPanel extends Panel { - private ComponentScroller scroller; - private Panel purchasePanel; - private ImageButtonRow nextRow; - private String[][] imageNames = { - { "gifs/ballot_box.gif", "gifs/filmstrip.gif", - "gifs/fly.gif", "gifs/eagle.gif", - "gifs/bullet_hole.gif" }, - { "gifs/mad_hacker.gif", "gifs/tricycle.gif", - "gifs/light_bulb1.gif", "gifs/scissors.gif", - "gifs/palette.gif" }, - { "gifs/frog.gif", "gifs/gear.gif", - "gifs/wrench.gif", "gifs/www.gif", - "gifs/Dining.gif" }, - { "gifs/ant.gif", "gifs/abomb.gif", - "gifs/basketball.gif", "gifs/soccer.gif", - "gifs/skelly.gif" }, - }; - public ComponentScrollerTestPanel(Applet applet) { - URL base = applet.getCodeBase(); - Image nextImage; - Border border, blackBorder; - - purchasePanel = new Panel(); - purchasePanel.setLayout(new ColumnLayout()); - - for(int r=0; r < imageNames.length; ++r) { - nextRow = new ImageButtonRow(); - nextRow.setLayout(new RowLayout()); - - for(int c=0; c < imageNames[r].length; ++c) { - nextImage = applet.getImage(base, - imageNames[r][c]); - nextRow.add(nextImage); - } - purchasePanel.add(nextRow); - } - purchasePanel.add(new ButtonPurchaseForm()); - - scroller = new ComponentScroller(); - border = new Border(purchasePanel, 3, 2); - blackBorder = new Border(border, 1, 0); - - border.setLineColor(Color.gray); - blackBorder.setLineColor(Color.black); - scroller.setComponent(blackBorder); - - setLayout(new BorderLayout()); - add("Center", scroller); - } -} - -class ButtonPurchaseForm extends Panel { - TextField nameField = new TextField(25); - TextField addressField = new TextField(25); - TextField cityField = new TextField(15); - TextField stateField = new TextField(2); - - Choice paymentChoice = new Choice(); - - Button paymentButton = new Button("Purchase"); - Button cancelButton = new Button("Cancel"); - - public ButtonPurchaseForm() { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - - Separator sep = new Separator(); - Label title = - new Label("Purchase A Fine Image Today"); - Label name = new Label("Name:"); - Label address = new Label("Address:"); - Label payment = new Label("Purchase Method:"); - Label phone = new Label("Phone:"); - Label city = new Label("City:"); - Label state = new Label("State:"); - - setLayout(gbl); - - paymentChoice.addItem("Visa"); - paymentChoice.addItem("MasterCard"); - paymentChoice.addItem("COD"); - - title.setFont(new Font("Times-Roman", - Font.BOLD + Font.ITALIC, - 16)); - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbl.setConstraints(title, gbc); - add(title); - - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(0,0,10,0); - gbl.setConstraints(sep, gbc); - add(sep); - - gbc.anchor = GridBagConstraints.WEST; - gbc.gridwidth = 1; - gbc.insets = new Insets(0,0,0,10); - gbl.setConstraints(name, gbc); - add(name); - - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbl.setConstraints(nameField, gbc); - add(nameField); - - gbc.gridwidth = 1; - gbl.setConstraints(address, gbc); - add(address); - - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(addressField, gbc); - add(addressField); - - gbc.gridwidth = 1; - gbl.setConstraints(city, gbc); - add(city); - - gbl.setConstraints(cityField, gbc); - add(cityField); - - gbl.setConstraints(state, gbc); - add(state); - - gbl.setConstraints(stateField, gbc); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbl.setConstraints(stateField, gbc); - add(stateField); - - gbc.gridwidth = 1; - gbl.setConstraints(payment, gbc); - gbc.insets = new Insets(5,0,5,0); - add(payment); - - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.NONE; - gbl.setConstraints(paymentChoice, gbc); - add(paymentChoice); - - ButtonPanel buttonPanel = new ButtonPanel(); - - buttonPanel.add(paymentButton); - buttonPanel.add(cancelButton); - - gbc.anchor = GridBagConstraints.SOUTH; - gbc.insets = new Insets(5,0,0,0); - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.gridwidth = 4; - gbl.setConstraints(buttonPanel, gbc); - add(buttonPanel); - } -} -class ImageButtonRow extends Panel { - public ImageButtonRow() { - setLayout(new RowLayout()); - } - public void add(Image image) { - ImageButton button = new ImageButton(image); - add(button); - button.setController( - new StickyImageButtonController(button)); - } -} diff --git a/java/gjt/test/ConnectionsPanel.java b/java/gjt/test/ConnectionsPanel.java deleted file mode 100644 index 7790d0709b1..00000000000 --- a/java/gjt/test/ConnectionsPanel.java +++ /dev/null @@ -1,9 +0,0 @@ -package gjt.test; - -import java.awt.*; - -class ConnectionsPanel extends Panel { - public ConnectionsPanel() { - add(new Label("Connections")); - } -} diff --git a/java/gjt/test/DialogTest.java b/java/gjt/test/DialogTest.java deleted file mode 100644 index f92069b7c49..00000000000 --- a/java/gjt/test/DialogTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package gjt.test; - -import java.awt.*; -import java.applet.Applet; - -import gjt.Util; -import gjt.DialogClient; -import gjt.MessageDialog; -import gjt.ProgressDialog; -import gjt.QuestionDialog; -import gjt.YesNoDialog; - -/** - * Tests 4 gjt custom dialogs: - * <dl> - * <dd> MessageDialog (a dialog which displays a message) - * <dd> QuestionDialog (a dialog which asks a question) - * <dd> YesNoDialog (a dialog with yes/no buttons) - * <dd> ProgressDialog (a dialog which records progress of task) - * </dl> - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.DialogClient - * @see gjt.MessageDialog - * @see gjt.ProgressDialog; - * @see gjt.QuestionDialog; - * @see gjt.YesNoDialog; - */ -public class DialogTest extends UnitTest { - public String title() { - return "Graphic Java Toolkit Dialog Test"; - } - public Panel centerPanel() { - return new DialogLauncher(); - } -} - -class DialogLauncher extends Panel implements DialogClient { - private MessageDialog messageDialog; - private QuestionDialog questionDialog; - private YesNoDialog yesNoDialog; - private ProgressDialog progressDialog; - - private Button messageDialogButton, questionDialogButton, - yesNoDialogButton, progressDialogButton; - - public DialogLauncher() { - setLayout(new GridLayout(0,1)); - - add(messageDialogButton = - new Button("Message Dialog")); - - add(questionDialogButton = - new Button("Question Dialog")); - - add(yesNoDialogButton = - new Button("YesNo Dialog")); - - add(progressDialogButton = - new Button("Progress Dialog")); - } - public boolean action(Event event, Object what) { - if(event.target == messageDialogButton) { - messageDialog = MessageDialog.getMessageDialog( - Util.getFrame(this), this, - "Example Message Dialog", - "This is an example of a message dialog."); - - messageDialog.show(); - } - else if(event.target == questionDialogButton) { - questionDialog = - new QuestionDialog(Util.getFrame(this), this, - "Example Question Dialog", - "Name: ", "Gumby", 45); - questionDialog.show(); - } - else if(event.target == yesNoDialogButton) { - yesNoDialog = - YesNoDialog.getYesNoDialog(Util.getFrame(this), - this, - "Example YesNo Dialog", - "Another cup of Java?"); - yesNoDialog.show(); - } - else if(event.target == progressDialogButton) { - progressDialog = - ProgressDialog.getProgressDialog( - Util.getFrame(this), - "Example Progress Dialog", - Color.blue); - - progressDialog.show(); - - ProgressThread thread = - new ProgressThread(progressDialog); - thread.start(); - } - - return true; - } - public void dialogDismissed(Dialog d) { - if(d == messageDialog) { - System.out.println("MessageDialog Down"); - } - if(d == questionDialog) { - if(questionDialog.wasCancelled()) - System.out.println("CANCELLED"); - else - System.out.println( - "Name: " + - questionDialog.getTextField().getText()); - } - if(d == yesNoDialog) { - if(yesNoDialog.answeredYes()) - System.out.println("YES"); - else - System.out.println("NO"); - } - } -} - -class ProgressThread extends Thread { - private ProgressDialog dialog; - private double percentComplete = 0; - - public ProgressThread(ProgressDialog dialog) { - this.dialog = dialog; - } - public void run() { - while(percentComplete <= 100) { - try { Thread.currentThread().sleep(500); } - catch(InterruptedException e) { } - - dialog.setPercentComplete(percentComplete); - percentComplete += 10; - } - } -} diff --git a/java/gjt/test/DrawnRectangleTest.java b/java/gjt/test/DrawnRectangleTest.java deleted file mode 100644 index 19e3c195f7c..00000000000 --- a/java/gjt/test/DrawnRectangleTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package gjt.test; - -import java.awt.*; -import gjt.DrawnRectangle; -import gjt.EtchedRectangle; -import gjt.ThreeDRectangle; - -/** - * 9 DrawnRectangles (some of which are EtchedRectangles - * and ThreeDRectangles) with varying characteristics such - * as line widths and colors.<p> - * - * A mouse down (any mouse button) in any of the rectangles - * causes information about the rectangle to be printed to - * System.out. (Output will go to Java Console in Netscape).<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.DrawnRectangle - * @see gjt.EtchedRectangle - * @see gjt.ThreeDRectangle - */ -public class DrawnRectangleTest extends UnitTest { - public String title() { - return "Drawn Rectangle Test"; - } - public Panel centerPanel() { - return new DrawnRectangleTestPanel(); - } -} - -class DrawnRectangleTestPanel extends Panel { - private DrawnRectangle drawnFilledOrange, - drawnFilledBlue, drawnBlue; - private EtchedRectangle etchedOut, - etchedIn, etchedFilledCyan; - private ThreeDRectangle thinRaised, - thinInset, thickRaised, thickInset; - - public DrawnRectangleTestPanel() { - drawnFilledOrange = - new DrawnRectangle (this, 10, 10, 100, 100); - drawnFilledBlue = - new DrawnRectangle (this, 135, 135, 100, 100); - drawnBlue = - new DrawnRectangle (this, 505, 135, 100, 100); - etchedFilledCyan = - new EtchedRectangle(this, 10, 135, 100, 100); - - etchedIn = new EtchedRectangle(this, 385, 10, 100, 100); - etchedOut= new EtchedRectangle(this, 505, 10, 100, 100); - - thinRaised = - new ThreeDRectangle(this, 135, 10, 100, 100); - thinInset = - new ThreeDRectangle(this, 260, 10, 100, 100); - thickRaised = - new ThreeDRectangle(this, 385, 135, 100, 100); - thickInset = - new ThreeDRectangle(this, 260, 135, 100, 100); - - drawnFilledOrange.setLineColor(Color.black); - - drawnFilledBlue.setLineColor(Color.yellow); - drawnFilledBlue.setThickness(3); - - drawnBlue.setLineColor(Color.blue); - drawnBlue.setThickness(5); - - thickRaised.setThickness(5); - thickInset.setThickness (5); - } - public Dimension preferredSize() { - return new Dimension(610, 270); - } - public void paint(Graphics g) { - drawnFilledOrange.paint(); - drawnFilledOrange.fill (Color.orange); - - drawnFilledBlue.paint (); - drawnFilledBlue.fill (Color.blue); - - drawnBlue.paint (); - - etchedIn.paintEtchedIn (); - etchedOut.paintEtchedOut(); - - etchedFilledCyan.paintEtchedIn(); - etchedFilledCyan.fill(Color.cyan); - - thinRaised.paintRaised (); - thinInset.paintInset (); - - thickRaised.paintRaised (); - - thickInset.paintInset (); - thickInset.fill (Color.red); - } - public boolean mouseDown(Event event, int x, int y) { - if(drawnFilledOrange.inside(x,y)) - show(drawnFilledOrange); - - if(drawnFilledBlue.inside(x,y)) show(drawnFilledBlue); - if(drawnBlue.inside(x,y)) show(drawnBlue); - if(etchedIn.inside(x,y)) show(etchedIn); - if(etchedOut.inside(x,y)) show(etchedOut); - if(etchedFilledCyan.inside(x,y)) show(etchedFilledCyan); - if(thinRaised.inside(x,y)) show(thinRaised); - if(thickRaised.inside(x,y)) show(thickRaised); - if(thinInset.inside(x,y)) show(thinInset); - if(thickInset.inside(x,y)) show(thickInset); - - return true; - } - private void show(DrawnRectangle drawnRectangle) { - System.out.println(drawnRectangle); - } -} diff --git a/java/gjt/test/FontDialogTest.java b/java/gjt/test/FontDialogTest.java deleted file mode 100644 index d0b535c27f9..00000000000 --- a/java/gjt/test/FontDialogTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package gjt.test; - -import java.awt.*; - -import gjt.FontDialog; -import gjt.DialogClient; -import gjt.Util; - -/** - * Activating the button causes the FontDialog to be displayed. - * Selecting a font from the FontDialog causes the button to - * use the selected font.<p> - * - * This unit test overrides FontDialog to reset the labels - * displayed in the buttons, and to reset the list of font - * sizes displayed. See FontDialog for a discussion of the - * overridden methods.<p> - * - *<em>Note: The FontDialog takes forever to come up in - * Netscape.</em> - * - * @version 1.0, Apr 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.Util - * @see gjt.FontDialog - * @see gjt.DialogClient - */ -class LotsOfSizesFontDialog extends FontDialog { - private static String _defaultSizes[] = - { "8", "10", "12", "14", "16", - "18", "20", "22", "24", - "26", "28", "30", "32", "34", - "36", "38", "40", "42", "44", - "46", "48", "50", "52", "54", - "56", "58", "60", "62", "64", - "66", "68", "70", "72", "74", - "76", "78", "80", "82", "84", - "86", "88", "90", "92", "94", - "96", "98", "100" }; - - public LotsOfSizesFontDialog(Frame frame, - DialogClient client, - Font font) { - super(frame, client, font, true); - } - public String getPreviewButtonLabel() { - return "Preview Selected Font"; - } - public String getOkButtonLabel () { - return "I'll Take It"; - } - public String getCancelButtonLabel () { - return "Nevermind"; - } - public String[] getFontSizes () { - return _defaultSizes; - } -} - -public class FontDialogTest extends UnitTest { - public String title() { return "Font Dialog Test"; } - public Panel centerPanel() { - return new FontDialogTestPanel(); - } -} - -class FontDialogTestPanel extends Panel - implements DialogClient { - private Button fontButton; - - public FontDialogTestPanel() { - setLayout(new BorderLayout()); - add("Center", fontButton = new Button("Fonts ...")); - } - public boolean handleEvent(Event event) { - if(event.id == Event.ACTION_EVENT) { - LotsOfSizesFontDialog d; - d = new LotsOfSizesFontDialog(Util.getFrame(this), - this, - fontButton.getFont()); - d.show(); - } - return true; - } - public void dialogDismissed(Dialog d) { - FontDialog fontDialog = (FontDialog)d; - Font fontSelected = fontDialog.getFontSelected(); - - if(fontSelected != null) - fontButton.setFont(fontSelected); - - fontButton.requestFocus(); - } -} diff --git a/java/gjt/test/IconCardPanelTest.java b/java/gjt/test/IconCardPanelTest.java deleted file mode 100644 index 33a65e1939c..00000000000 --- a/java/gjt/test/IconCardPanelTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import java.net.URL; -import gjt.IconCardPanel; - -/** - * A gjt.IconCardPanel that controls 3 Panels.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.IconCardPanel - */ -public class IconCardPanelTest extends UnitTest { - public String title() { return "IconCardPanel Test"; } - public Panel centerPanel() { - return new CardPanelTestPanel(this); - } -} -class CardPanelTestPanel extends Panel { - IconCardPanel mvp = new IconCardPanel(); - - public CardPanelTestPanel(Applet applet) { - URL cb = applet.getCodeBase(); - - setLayout(new BorderLayout()); - - Image folks = applet.getImage(cb,"gifs/cell_phone.gif"); - Image pencil = applet.getImage(cb,"gifs/clipboard.gif"); - Image library = - applet.getImage(cb, "gifs/mad_hacker.gif"); - - mvp.addImageButton(folks, - "Attributes", - new AttributesPanel(applet)); - mvp.addImageButton(pencil, - "Connections", - new ConnectionsPanel()); - mvp.addImageButton(library, - "Oracle", - new OccupationOracle()); - - add("Center", mvp); - } -} diff --git a/java/gjt/test/ImageButtonTest.java b/java/gjt/test/ImageButtonTest.java deleted file mode 100644 index 52df6efeba0..00000000000 --- a/java/gjt/test/ImageButtonTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import gjt.Box; -import gjt.ImageButton; -import gjt.ImageButtonEvent; -import gjt.SpringyImageButtonController; -import gjt.StickyImageButtonController; - -/** - * 2 ImageButtons, one springy and the other sticky, both - * crabby.<p> - * - * Both ImageButtons come with an awt.Button that is used to - * enable/disable the ImageButton it's associated with.<p> - * - * ImageButtonEvents, along with mouse enter and mouse exit - * events for the two image buttons are printed out.<p> - * - * @version 1.0, Apr 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ImageButton - * @see gjt.ImageButtonEvent - * @see gjt.SpringyImageButtonController - * @see gjt.StickyImageButtonController - */ -public class ImageButtonTest extends UnitTest { - public String title() { - return "ImageButton Test"; - } - public Panel centerPanel() { - return new ImageButtonTestPanel(this); - } -} - -class ImageButtonTestPanel extends Panel { - private ImageButton springyButton; - private Button springyButtonEnabler; - private ImageButton stickyButton; - private Button stickyButtonEnabler; - - public ImageButtonTestPanel(Applet applet) { - Image image; - Box springyBox, stickyBox; - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - - image = - applet.getImage(applet.getCodeBase(), "gifs/crab.gif"); - - springyButton = new ImageButton(image); - springyButtonEnabler = new Button ("Disable"); - stickyButton = new ImageButton(image); - stickyButtonEnabler = new Button ("Disable"); - - stickyButton.setController( - new StickyImageButtonController(stickyButton)); - - setLayout(gbl); - - gbc.anchor = GridBagConstraints.NORTH; - springyBox = new Box(springyButton, "Springy"); - gbc.insets = new Insets(10,0,0,0); - gbl.setConstraints(springyBox, gbc); add(springyBox); - - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.insets = new Insets(45,10,0,0); - gbl.setConstraints(springyButtonEnabler, gbc); - add(springyButtonEnabler); - - gbc.anchor = GridBagConstraints.NORTH; - gbc.gridwidth = 1; - stickyBox = new Box(stickyButton, "Sticky"); - gbc.insets = new Insets(10,0,0,0); - gbc.weighty = 1.0; - gbl.setConstraints(stickyBox, gbc); add(stickyBox); - - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.insets = new Insets(45,10,0,0); - gbl.setConstraints(stickyButtonEnabler, gbc); - add(stickyButtonEnabler); - } - public boolean action(Event event, Object what) { - Button button = (Button)event.target; - String label = (String)what; - - if(button == stickyButtonEnabler) { - if(label.equals("Disable")) stickyButton.disable(); - else stickyButton.enable(); - } - else { - if(label.equals("Disable")) springyButton.disable(); - else springyButton.enable(); - } - if(label.equals("Disable")) button.setLabel("Enable"); - else button.setLabel("Disable"); - - return true; - } - public boolean handleEvent(Event event) { - boolean eventHandled = false; - - if(event instanceof ImageButtonEvent) { - System.out.println("ImageButton " + event); - eventHandled = true; - } - if(event.id == Event.MOUSE_ENTER) { - if(event.target == stickyButton) - System.out.println("Sticky Button Entered"); - - else if(event.target == springyButton) - System.out.println("Springy Button Entered"); - - eventHandled = true; - } - if(event.id == Event.MOUSE_EXIT) { - if(event.target == stickyButton) - System.out.println("Sticky Button Exited"); - - else if(event.target == springyButton) - System.out.println("Springy Button Exited"); - - eventHandled = true; - } - if(eventHandled) return true; - else return super.handleEvent(event); - } -} diff --git a/java/gjt/test/ImageDissolverTest.java b/java/gjt/test/ImageDissolverTest.java deleted file mode 100644 index c157408d2af..00000000000 --- a/java/gjt/test/ImageDissolverTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import java.awt.image.FilteredImageSource; - -import gjt.Util; -import gjt.image.ImageDissolver; - -/** - * Initially displays an image. Subsequent mouse clicks in the - * canvas containing the image cause the image to fade in or - * fade out, depending upon it's current state.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.image.DissolveFilter - * @see gjt.image.ImageDissolver - */ -public class ImageDissolverTest extends UnitTest { - public String title() { - return "ImageDissolver Test " + - "(Click Below to Fade Picture In/Out)"; - } - public Panel centerPanel() { - return new ImageDissolverTestPanel(this); - } -} - -class ImageDissolverTestPanel extends Panel { - ImageDissolverTestCanvas canvas; - - public ImageDissolverTestPanel(Applet applet) { - add(canvas = new ImageDissolverTestCanvas(applet)); - } - public boolean mouseDown(Event event, int x, int y) { - canvas.doFade(); - return true; - } -} - -class ImageDissolverTestCanvas extends Canvas { - private boolean isFaded = false; - private Image image; - private ImageDissolver dissolver; - - public ImageDissolverTestCanvas(Applet applet) { - image = - applet.getImage(applet.getCodeBase(),"gifs/saint.gif"); - - Util.waitForImage(this, image); - dissolver = new ImageDissolver(this, image); - } - public void paint(Graphics g) { - if( ! isFaded) - g.drawImage(image, 0, 0, this); - } - public Dimension preferredSize() { - return new Dimension(image.getWidth(this), - image.getHeight(this)); - } - public void doFade() { - if(isFaded) dissolver.fadeIn (0,0); - else dissolver.fadeOut(0,0); - - isFaded = isFaded ? false : true; - } -} diff --git a/java/gjt/test/ImageScrollerTest.java b/java/gjt/test/ImageScrollerTest.java deleted file mode 100644 index 0476682eb6d..00000000000 --- a/java/gjt/test/ImageScrollerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package gjt.test; - -import java.awt.*; -import java.applet.Applet; -import java.net.URL; - -import gjt.ImageScroller; -import gjt.Util; - -/** - * Four images are loaded; subsequent mouse clicks cycle - * through the images, that are displayed in an ImageScroller. - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.Scroller - * @see gjt.ImageScroller - */ -public class ImageScrollerTest extends UnitTest { - public String title() { - return "ImageScroller Test"; - } - public Panel centerPanel() { - return new ImageScrollerTestPanel(this); - } -} - -class ImageScrollerTestPanel extends Panel { - private Image[] images = new Image[4]; - private int imageIndex = 0; - private ImageScroller scroller; - - public ImageScrollerTestPanel(Applet applet) { - URL cb = applet.getCodeBase(); - - images[0]=applet.getImage(cb,"gifs/ashleyAndRoy.gif"); - images[1]=applet.getImage(cb,"gifs/ashleyAndSabre.gif"); - images[2]=applet.getImage(cb,"gifs/anjinAndMariko.gif"); - images[3]=applet.getImage(cb,"gifs/ashleyAndAnjin.gif"); - - setLayout(new BorderLayout()); - add("Center", scroller = new ImageScroller(images[0])); - } - public boolean mouseUp(Event event, int x, int y) { - if(imageIndex == images.length-1) imageIndex = 0; - else imageIndex++; - - Util.setCursor(Frame.WAIT_CURSOR, this); - scroller.resetImage(images[imageIndex]); - Util.setCursor(Frame.DEFAULT_CURSOR, this); - - return true; - } -} diff --git a/java/gjt/test/LabelCanvasTest.java b/java/gjt/test/LabelCanvasTest.java deleted file mode 100644 index cb4c0a857ae..00000000000 --- a/java/gjt/test/LabelCanvasTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package gjt.test; -import java.applet.Applet; -import java.awt.Event; -import java.awt.Panel; -import java.awt.Insets; -import java.awt.Graphics; -import gjt.LabelCanvas; -import gjt.SelectionEvent; -import gjt.Util; - -/** - * Four LabelCanvases, each with different insets. The leftmost - * LabelCanvas has standard insets (2 all around), while the - * other three were constructed as follows: - * <pre> - * insetFive.setInsets (new Insets(5,5,5,5)); - * insetTen.setInsets (new Insets(10,10,10,10)); - * insetFifteen.setInsets(new Insets(15,15,15,15)); - * </pre><p> - * - * LabelCanvases generate SelectionEvents, that we watch - * for in our handleEvent() method, and print out.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.LabelCanvas - */ -public class LabelCanvasTest extends UnitTest { - public String title() { return "LabelCanvas Test"; } - public Panel centerPanel() { - return new LabelCanvasTestPanel(this); - } -} - -class LabelCanvasTestPanel extends Panel { - Applet applet; - public LabelCanvasTestPanel(Applet applet) { - this.applet = applet; - LabelCanvas standard = - new LabelCanvas("Standard Insets"); - LabelCanvas insetFive = - new LabelCanvas("Insets = Five"); - LabelCanvas insetTen = - new LabelCanvas("Insets = Ten"); - LabelCanvas insetFifteen = - new LabelCanvas("Insets = Fifteen"); - - insetFive.setInsets (new Insets(5,5,5,5)); - insetTen.setInsets (new Insets(10,10,10,10)); - insetFifteen.setInsets(new Insets(15,15,15,15)); - - add(standard); - add(insetFive); - add(insetTen); - add(insetFifteen); - } - public boolean handleEvent(Event event) { - if(event instanceof SelectionEvent) { - SelectionEvent sevent = (SelectionEvent)event; - LabelCanvas canvas = (LabelCanvas)event.target; - - if(sevent.isSelected()) - System.out.println("LabelCanvas " + - canvas.getLabel() + - " selected"); - else - System.out.println("LabelCanvas " + - canvas.getLabel() + - " deselected"); - return true; - } - return super.handleEvent(event); - } -} diff --git a/java/gjt/test/MessageDialogTest.java b/java/gjt/test/MessageDialogTest.java deleted file mode 100644 index 6efddd08cb4..00000000000 --- a/java/gjt/test/MessageDialogTest.java +++ /dev/null @@ -1,50 +0,0 @@ - -package gjt.test; - -import java.awt.*; -import java.applet.Applet; - -import gjt.MessageDialog; -import gjt.DialogClient; -import gjt.Util; - -/** - * Simple unit test that exercises gjt.MessageDialog. This - * unit test serves to illustrate the use of gjt.DialogClient. - * For a unit test which covers all of the gjt dialogs, - * see gjt.test.DialogTest. - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.DialogClient - * @see gjt.MessageDialog - */ -public class MessageDialogTest extends UnitTest { - public String title() { - return "Message Dialog Test"; - } - public Panel centerPanel() { - return new MessageDialogLauncher(); - } -} - -class MessageDialogLauncher extends Panel - implements DialogClient { - private MessageDialog messageDialog; - - public MessageDialogLauncher() { - add(new Button("Show Message Dialog")); - } - public boolean action(Event event, Object what) { - messageDialog = MessageDialog.getMessageDialog( - Util.getFrame(this), this, - "Example Message Dialog", - "This is an example of a message dialog."); - messageDialog.show(); - return true; - } - public void dialogDismissed(Dialog d) { - System.out.println("MessageDialog Down"); - } -} diff --git a/java/gjt/test/OccupationOracle.java b/java/gjt/test/OccupationOracle.java deleted file mode 100644 index a34c2ad2064..00000000000 --- a/java/gjt/test/OccupationOracle.java +++ /dev/null @@ -1,334 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; - -// The OccupationOracle class makes a guess at a person's occupation -// within an engineering organization based on a few "key" traits. -// Invalid entries in numeric fields result in an "Unknown" occupation. -// This applet uses the awt.GridBagLayout class to structure the -// occupation form. The awt.GridBagLayout class allows fields to -// be placed in rows and columns within a form. Each component -// is given a "display area" based on the constraints in effect -// when it is added to the layout. - -// Author: Jerry Jackson (thanks, sifu) - -public class OccupationOracle extends Panel { - - // Construct the form. Create each component of the form and - // add it to the layout. Initialize the occupation to "Unknown". - - public OccupationOracle() { - - // Use the GridBagLayout layout to construct rows and - // columns. - - GridBagLayout gridbag = new GridBagLayout(); - - // Create a new set of constraints to use when adding - // a component to the layout. The constraint values - // in effect when a component is added to the layout - // are cloned and stored in conjunction with the component - // by the layout. - - GridBagConstraints constraints = new GridBagConstraints(); - - // Set the font for the form. - - //setFont(new Font("TimesRoman", Font.BOLD, 12)); - - // Associate the GridBagLayout object with the applet. - - setLayout(gridbag); - - // The "anchor" constraint determines how a component - // is justified within its display area. - - constraints.anchor = GridBagConstraints.WEST; - - // Determines how much space should be given to this component. - // if left at 0.0, all components clump up in the middle as the - // padding is applied to the outside. - - constraints.weightx = 1.0; - - // Create a name label and text field. - - makeNameField(); - - // Setting the "gridwidth" constraint to 1 will - // cause the component to take up the minimum - // horizontal space in its row. - - constraints.gridwidth = 1; - - // "addFormComponent" will associate the current constraints - // with a component and add the component to the form. - - addFormComponent(gridbag, nameLabel, constraints); - - // Setting the "gridwidth" constraint to REMAINDER will - // cause the component to fill up the remainder of its row. - // i.e. it will be the last entry in the row. - - constraints.gridwidth = GridBagConstraints.REMAINDER; - - // The "fill" constraint tells what to do if the item is in - // a area larger than it is. In this case we want to fill - // any extra horizontal space. - - constraints.fill = GridBagConstraints.HORIZONTAL; - - addFormComponent(gridbag, nameField, constraints); - - // Create and add an age label and text field. - - makeAgeField(); - - constraints.gridwidth = 1; - constraints.fill = GridBagConstraints.NONE; - constraints.weightx = 0.0; - addFormComponent(gridbag, ageLabel, constraints); - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1.0; - addFormComponent(gridbag, ageField, constraints); - - // Create and add a world view label and a single checkbox - // for a true/false value. - - makeWorldViewField(); - - constraints.gridwidth = 1; - constraints.weightx = 0.0; - addFormComponent(gridbag, worldViewLabel, constraints); - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1.0; - addFormComponent(gridbag, worldViewField, constraints); - - - // Create and add a coffee consumption label and text field. - - makeCoffeeField(); - - constraints.gridwidth = 1; - constraints.weightx = 0.0; - addFormComponent(gridbag, coffeeLabel, constraints); - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1.0; - addFormComponent(gridbag, coffeeField, constraints); - - - // Create and add a fashion sense label and a checkbox - // group that has three mutually exclusive values. - - makeFashionField(); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0; - constraints.weighty = 0.0; - addFormComponent(gridbag, fashionLabel, constraints); - - // The three checkboxes that represent fashion sense. - - addFormComponent(gridbag, low, constraints); - addFormComponent(gridbag, medium, constraints); - addFormComponent(gridbag, high, constraints); - - // The Occupation field is output only. - - makeOccupationField(); - - constraints.gridwidth = 1; - constraints.weightx = 0.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.NONE; - addFormComponent(gridbag, occupationLabel, constraints); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1.0; - addFormComponent(gridbag, occupationField, constraints); - - // Display the initial "Unknown" occupation. - - recalculateOccupation(); - - resize(400, 250); - } - - // The paint() method for this applet just calls the paintComponents() - // method which is defined by the Container class. It causes all - // the components visible within the Container to get painted. - - public void paint(Graphics g) { - paintComponents(g); - } - - // When any action occurs within the form we do the same thing: - // recalculate the person's occupation. - - public boolean action(Event event, Object arg) { - recalculateOccupation(); - return true; - } - - // A helper function that associates constraints with a component - // and adds it to the form. - - private void addFormComponent(GridBagLayout grid, Component comp, - GridBagConstraints c) { - grid.setConstraints(comp, c); - add(comp); - } - - - // recalculateOccupation() fetches the values of each component - // and computes an occupation based on some truly stupid heuristics. - - private void recalculateOccupation() { - - // If we don't have a name yet we might incorrectly categorize - // the CEO! - - if (nameField.getText() == "") { - occupationField.setText("Unknown"); - } - - // Fetch other important values that we'll use in our - // calculations. - - int age; - int coffeeConsumption; - boolean binaryView = worldViewField.getState(); - - - // Try to fetch integer values for age and coffeeConsumption. - // If the values in the fields can't be parsed as integers, - // set the occupation to "Unknown". - - try { - age = Integer.parseInt(ageField.getText()); - coffeeConsumption = Integer.parseInt(coffeeField.getText()); - } catch (Exception e) { - occupationField.setText("Unknown"); - return; - } - - // Check for the CEO. - - String name = nameField.getText(); - - if (name.endsWith("II") || - name.endsWith("III") || - name.endsWith("IV")) { - - if (age < 35 || coffeeConsumption < 4) { - occupationField.setText("Junior Executive"); - } else { - occupationField.setText("CEO"); - } - - return; - } - - // Fashion sense is a critical piece of information. - // The getCurrent() method of CheckboxGroup returns whichever - // Checkbox in the group is currently selected. Only one - // can be selected at a time. - - Checkbox fashionValue = fashionGroup.getCurrent(); - - if (fashionValue == low || fashionValue == medium) { - - // There are two kinds of people in the world: those who - // divide people into two kinds and those who don't. - - if (binaryView && coffeeConsumption >= 4) { - occupationField.setText("Engineer"); - - } else if ((age > 40 && binaryView) || - (age < 40 && coffeeConsumption >= 4)) { - occupationField.setText("Engineering Manager"); - - } else { - occupationField.setText("Product Manager"); - } - - } else { - - // High fashion sense. Not an engineer! - - if (binaryView || coffeeConsumption >= 4) { - occupationField.setText("Vice President"); - - } else { - occupationField.setText("Product Marketing"); - } - } - } - - // Helper functions to create form components. - - private void makeNameField() { - nameLabel = new Label("Name: "); - nameField = new TextField(40); - } - - private void makeAgeField() { - ageLabel = new Label("Age: "); - ageField = new TextField(3); - } - - private void makeOccupationField() { - occupationLabel = new Label("Occupation: "); - occupationField = new TextField(40); - } - - private void makeWorldViewField() { - worldViewLabel = new Label("Binary World View: "); - worldViewField = new Checkbox(); - } - - private void makeCoffeeField() { - coffeeLabel = new Label("Coffee consumption: "); - coffeeField = new TextField(3); - } - - private void makeFashionField() { - fashionLabel = new Label("Fashion sense:"); - - fashionGroup = new CheckboxGroup(); - low = new Checkbox("Low ", fashionGroup, false); - medium = new Checkbox("Medium", fashionGroup, true); - high = new Checkbox("High ", fashionGroup, false); - } - - // Text fields. - - private TextField nameField; - private TextField ageField; - private TextField coffeeField; - private TextField occupationField; - - // Labels. - - private Label nameLabel; - private Label ageLabel; - private Label coffeeLabel; - private Label fashionLabel; - private Label worldViewLabel; - private Label occupationLabel; - - // Checkboxes. - - private Checkbox worldViewField; - private Checkbox low; - private Checkbox medium; - private Checkbox high; - - // The fashion sense checkbox group. - - private CheckboxGroup fashionGroup; -} - - diff --git a/java/gjt/test/RowLayoutTest.java b/java/gjt/test/RowLayoutTest.java deleted file mode 100644 index eb7b419ca17..00000000000 --- a/java/gjt/test/RowLayoutTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.net.URL; -import java.awt.*; -import gjt.*; - -/** - * Lays out 3 image buttons, and provides controls for setting - * orientations and gaps on the fly.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ImageButton - * @see gjt.Box - */ -public class RowLayoutTest extends UnitTest { - public String title() { - return "RowLayout Test"; - } - public Panel centerPanel() { - RowButtonPanel buttonPanel = new RowButtonPanel(this); - Panel panel = new Panel(); - - panel.setLayout(new BorderLayout()); - panel.add("Center", buttonPanel); - panel.add("North", new Box(new RowPicker(buttonPanel), - "Row Layout Settings")); - return panel; - } -} - -class RowButtonPanel extends Panel implements DialogClient { - private ImageButton one, two, three; - private Panel panel = new Panel(); - private TenPixelBorder border = new TenPixelBorder(panel); - - public RowButtonPanel(Applet applet) { - URL cb = applet.getCodeBase(); - - one = new ImageButton(applet.getImage(cb, - "gifs/one.gif")); - two = new ImageButton(applet.getImage(cb, - "gifs/two.gif")); - three = new ImageButton(applet.getImage(cb, - "gifs/three.gif")); - - panel.setLayout(new RowLayout(0)); - panel.add(one); - panel.add(two); - panel.add(three); - - setLayout(new BorderLayout()); - add ("Center", border); - } - public void updateOrientations(Orientation horient, - Orientation vorient, - int gap) { - panel.setLayout(new RowLayout(horient, vorient, gap)); - border.validate(); - } - public void dialogDismissed(Dialog d) { } -} - -class RowPicker extends Panel { - private Label horientLabel = new Label("Horizontal:"); - private Label vorientLabel = new Label("Vertical:"); - private Label gapLabel = new Label("Gap:"); - - private Choice hchoice = new Choice(); - private Choice vchoice = new Choice(); - private Choice gapChoice = new Choice(); - - private RowButtonPanel buttonPanel; - - public RowPicker(RowButtonPanel buttonPanel) { - Panel orientations = new Panel(); - Panel gap = new Panel(); - - this.buttonPanel = buttonPanel; - hchoice.addItem("left"); - hchoice.addItem("center"); - hchoice.addItem("right"); - hchoice.select(1); - - vchoice.addItem("top"); - vchoice.addItem("center"); - vchoice.addItem("bottom"); - vchoice.select(1); - - gapChoice.addItem("0"); - gapChoice.addItem("5"); - gapChoice.addItem("10"); - gapChoice.addItem("15"); - gapChoice.addItem("20"); - - orientations.add(horientLabel); - orientations.add(hchoice); - orientations.add(vorientLabel); - orientations.add(vchoice); - - gap.add(gapLabel); - gap.add(gapChoice); - - add(new Box(orientations, "Orientations")); - add(new Box(gap, "Gap")); - } - public boolean action(Event event, Object what) { - String horient, vorient; - int gap; - - horient = hchoice.getSelectedItem(); - vorient = vchoice.getSelectedItem(); - gap = - (new Integer(gapChoice.getSelectedItem())).intValue(); - - buttonPanel.updateOrientations( - Orientation.fromString(horient), - Orientation.fromString(vorient), gap); - - return true; - } -} diff --git a/java/gjt/test/RubberbandTest.java b/java/gjt/test/RubberbandTest.java deleted file mode 100644 index ae256fb2c3a..00000000000 --- a/java/gjt/test/RubberbandTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package gjt.test; - -import java.awt.*; -import gjt.DrawingPanel; -import gjt.Separator; -import gjt.RowLayout; -import gjt.rubberband.*; - -/** - * A simple drawing applet that demonstrates the utility of - * the gjt.rubberband package.<p> - * - * Note that this unit test also serves as the unit test for - * gjt.DrawingPanel.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.DrawingPanel - * @see gjt.rubberband.Rubberband - * @see gjt.rubberband.RubberbandLine - * @see gjt.rubberband.RubberbandRectangle - * @see gjt.rubberband.RubberbandEllipse - * @see gjt.rubberband.RubberbandPanel - */ -public class RubberbandTest extends UnitTest { - public String title() { - return "Rubberband Test"; - } - public Panel centerPanel() { - return new RubberbandTestPanel(); - } -} - -class RubberbandTestPanel extends Panel { - private DrawingPanel drawingPanel; - private ChoicePanel choicePanel; - - public RubberbandTestPanel() { - drawingPanel = new DrawingPanel(); - choicePanel = new ChoicePanel(drawingPanel); - - setLayout(new BorderLayout()); - add("North", choicePanel); - add("Center", drawingPanel); - } -} - -class ChoicePanel extends Panel { - private DrawingPanel drawingPanel; - private Color color; - private Checkbox fillCheckbox = new Checkbox(); - - public ChoicePanel(DrawingPanel drawingPanel) { - Panel choicePanel = new Panel(); - Choice geometricChoice = new Choice(); - Choice colorChoice = new Choice(); - - this.drawingPanel = drawingPanel; - - geometricChoice.addItem("Lines"); - geometricChoice.addItem("Rectangles"); - geometricChoice.addItem("Ellipses"); - - colorChoice.addItem("Black"); - colorChoice.addItem("Red"); - colorChoice.addItem("Blue"); - colorChoice.addItem("Gray"); - colorChoice.addItem("White"); - - choicePanel.setLayout(new RowLayout(10)); - choicePanel.add(new Label("Shape:")); - choicePanel.add(geometricChoice); - choicePanel.add(new Label("Color:")); - choicePanel.add(colorChoice); - choicePanel.add(new Label("Fill:")); - choicePanel.add(fillCheckbox); - - setLayout(new BorderLayout()); - add("Center", choicePanel); - add("South", new Separator()); - } - public boolean action(Event event, Object what) { - if(event.target instanceof Checkbox) { - drawingPanel.setFill(fillCheckbox.getState()); - } - else if(event.target instanceof Choice) { - if(((String)what).equals("Lines")) { - fillCheckbox.setState(false); - drawingPanel.drawLines(); - } - else if(((String)what).equals("Rectangles")) { - System.out.println("Rectangles"); - drawingPanel.drawRectangles(); - } - else if(((String)what).equals("Ellipses")) - drawingPanel.drawEllipses (); - else if(((String)what).equals("Black")) - drawingPanel.setColor(Color.black); - else if(((String)what).equals("Red")) - drawingPanel.setColor(Color.red); - else if(((String)what).equals("Blue")) - drawingPanel.setColor(Color.blue); - else if(((String)what).equals("Gray")) - drawingPanel.setColor(Color.gray); - else if(((String)what).equals("White")) - drawingPanel.setColor(Color.white); - } - return true; - } - public Insets insets() { return new Insets(5,0,5,0); } -} diff --git a/java/gjt/test/SeparatorTest.java b/java/gjt/test/SeparatorTest.java deleted file mode 100644 index 3dd80173ea3..00000000000 --- a/java/gjt/test/SeparatorTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package gjt.test; - -import java.awt.*; -import gjt.Etching; -import gjt.Separator; - -/** - * Two Separators, one horizontal and the other vertical, the - * former etched in, and the latter etched out are laid out with - * an adorning Label for each.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.UnitTest - * @see gjt.Separator - */ -public class SeparatorTest extends UnitTest { - public String title () { return "Separator Test"; } - public Panel centerPanel() { - return new SeparatorTestPanel(); - } -} - -class SeparatorTestPanel extends Panel { - public SeparatorTestPanel() { - setLayout(new BorderLayout()); - add("North", new SeparatorTestNorthPanel ()); - add("Center", new SeparatorTestCenterPanel()); - } -} - -class SeparatorTestNorthPanel extends Panel { - Separator separator = new Separator(); - - public SeparatorTestNorthPanel() { - setLayout(new BorderLayout()); - add("North", new Label("North Of Etched-In Separator")); - add("South", separator); - } -} - -class SeparatorTestCenterPanel extends Panel { - Separator separator = new Separator(Etching.OUT); - - public SeparatorTestCenterPanel() { - GridBagConstraints gbc = new GridBagConstraints(); - GridBagLayout gbl = new GridBagLayout(); - Label label = new Label("West Of Etched-Out Separator"); - - setLayout(gbl); - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(0,0,0,10); - gbl.setConstraints(label, gbc); - add(label); - - gbc.insets = new Insets(0,0,0,0); - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.VERTICAL; - gbl.setConstraints(separator, gbc); - add(separator); - - } -} diff --git a/java/gjt/test/SimpleAnimationTest.java b/java/gjt/test/SimpleAnimationTest.java deleted file mode 100644 index faf0c7c611c..00000000000 --- a/java/gjt/test/SimpleAnimationTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package gjt.test; - -import java.net.URL; -import java.applet.Applet; -import java.awt.*; - -import gjt.Util; -import gjt.Orientation; -import gjt.animation.*; - -/** - * An animation playfield containing a lone sprite that bounces - * off the boundaries of the playfield.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.test.AnimationTest - * @see gjt.animation.Playfield - * @see gjt.animation.Sprite - */ -public class SimpleAnimationTest extends UnitTest { - public String title() { - return "Simple Animation - Mouse Down Starts/Stops"; - } - public Panel centerPanel() { - return new SimpleAnimationTestPanel(this); - } -} - -class SimpleAnimationTestPanel extends Panel { - public SimpleAnimationTestPanel(Applet applet) { - setLayout(new BorderLayout()); - add("Center", new SimplePlayfield(applet)); - } -} - -class SimplePlayfield extends Playfield { - private Applet applet; - private URL cb; - private Sprite javaDrinker; - private Sequence spinSequence; - - public SimplePlayfield(Applet applet) { - this.applet = applet; - cb = applet.getCodeBase(); - makeSequencesAndSprites(); - } - public void paintBackground(Graphics g) { - Image bg = applet.getImage(cb, "gifs/background.gif"); - Util.wallPaper(this, g, bg); - } - public boolean mouseDown(Event event, int x, int y) { - if(running() == true) stop (); - else start(); - return true; - } - public void spriteCollision(Sprite sprite, Sprite sprite2) { - // Nothing to do: only 1 sprite! - } - public void edgeCollision(Sprite sprite, - Orientation orientation) { - if(orientation == Orientation.RIGHT || - orientation == Orientation.LEFT) - sprite.reverseX(); - else - sprite.reverseY(); - } - private void makeSequencesAndSprites() { - String file; - Point startLoc = new Point(10, 10); - Image[] spinImages = new Image[19]; - - for(int i=0; i < spinImages.length; ++i) { - file = "gifs/spin"; - - if(i < 10) file += "0" + i + ".gif"; - else file += i + ".gif"; - - spinImages[i] = applet.getImage(cb, file); - } - spinSequence = new Sequence(this, spinImages); - javaDrinker = new Sprite(this, spinSequence, startLoc); - - javaDrinker.setMoveVector(new Point(2,2)); - addSprite(javaDrinker); - } -} diff --git a/java/gjt/test/SimpleBargaugeTest.java b/java/gjt/test/SimpleBargaugeTest.java deleted file mode 100644 index 57eb464f4b1..00000000000 --- a/java/gjt/test/SimpleBargaugeTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package gjt.test; - -import java.awt.*; -import gjt.Bargauge; - -/** - * A lone Barguage which animates. This unit test is meant to - * illustrate that a Bargauge can cope with having its - * orientation chanaged from horizontal to vertical or - * vice-versa. This test is best run in appletviewer, so that - * the window may be resized such that the Bargauge changes its - * orientation.<p> - * - * <em> - * Warning: An AWT bug causes this test to be a gluttenous - * consumer of resources (especially under Win95). A mouse down - * will halt the animation thread along with its consumption of - * resources.<p> - * </em> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.Bargauge - */ -public class SimpleBargaugeTest extends UnitTest { - public String title() { - return "Simple Bargauge Test"; - } - public Panel centerPanel() { - return new SimpleBargaugeTestPanel(); - } -} - -class SimpleBargaugeTestPanel extends Panel implements Runnable { - private Bargauge gauge = new Bargauge(Color.blue); - private boolean running = true; - private Thread t; - - public SimpleBargaugeTestPanel() { - setLayout(new BorderLayout()); - add("Center", gauge); - - t = new Thread(this); - t.start(); - } - public void run() { - while(true) { - try { Thread.currentThread().sleep(500,0); } - catch(InterruptedException e) { } - - gauge.setFillPercent(Math.random() * 100); - gauge.fill(); - } - } - public boolean mouseDown(Event event, int x, int y) { - if(running) { t.suspend(); running = false; } - else { t.resume (); running = true; } - return true; - } -} diff --git a/java/gjt/test/StateButtonTest.java b/java/gjt/test/StateButtonTest.java deleted file mode 100644 index 508aee1682e..00000000000 --- a/java/gjt/test/StateButtonTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package gjt.test; - -import java.applet.Applet; -import java.awt.*; -import java.net.URL; -import gjt.StateButton; -import gjt.ImageButtonEvent; - -/** - * A StateButton which cycles through a fascinating series of - * Images.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.StateButton - */ -public class StateButtonTest extends UnitTest { - public String title () { return "StateButton Test"; } - public Panel centerPanel() { - return new StateButtonTestPanel(this); - } -} - -class StateButtonTestPanel extends Panel { - private URL codeBase; - private Image[] images; - private StateButton button; - - public StateButtonTestPanel(Applet applet) { - codeBase = applet.getCodeBase(); - images = new Image[3]; - images[0] = applet.getImage(codeBase, "gifs/fly.gif"); - images[1] = applet.getImage(codeBase, "gifs/frog.gif"); - images[2] = applet.getImage(codeBase, "gifs/eagle.gif"); - button = new StateButton(images); - - setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20)); - add (button); - } -} diff --git a/java/gjt/test/TenPixelBorder.java b/java/gjt/test/TenPixelBorder.java deleted file mode 100644 index bab694d0fb1..00000000000 --- a/java/gjt/test/TenPixelBorder.java +++ /dev/null @@ -1,44 +0,0 @@ -package gjt.test; - -import java.awt.*; - -public class TenPixelBorder extends Panel { - public TenPixelBorder(Component borderMe) { - setLayout(new BorderLayout()); - add("Center", borderMe); - } - public void paint(Graphics g) { - Dimension mySize = size(); - Insets myInsets = insets(); - - g.setColor(Color.gray); - - // Top Inset area - g.fillRect(0, - 0, - mySize.width, - myInsets.top); - - // Left Inset area - g.fillRect(0, - 0, - myInsets.left, - mySize.height); - - // Right Inset area - g.fillRect(mySize.width - myInsets.right, - 0, - myInsets.right, - mySize.height); - - // Bottom Inset area - g.fillRect(0, - mySize.height - myInsets.bottom, - mySize.width, - mySize.height); - } - public Insets insets() { - return new Insets(10,10,10,10); - } - -} diff --git a/java/gjt/test/TitledPanel.java b/java/gjt/test/TitledPanel.java deleted file mode 100644 index cb8d054e888..00000000000 --- a/java/gjt/test/TitledPanel.java +++ /dev/null @@ -1,22 +0,0 @@ -package gjt.test; - -import java.awt.BorderLayout; -import java.awt.Label; -import java.awt.Panel; -import gjt.Separator; - -/** - * A Panel fitted with a BorderLayout that contains a Label - * (title) in the North, and a Separator in the South. - * - * @version 1.0, Apr 2 1996 - * @author David Geary - */ - -public class TitledPanel extends Panel { - public TitledPanel(String title) { - setLayout(new BorderLayout()); - add("North", new Label(title, Label.CENTER)); - add("South", new Separator()); - } -} diff --git a/java/gjt/test/ToolbarTest.java b/java/gjt/test/ToolbarTest.java deleted file mode 100644 index f739ce96236..00000000000 --- a/java/gjt/test/ToolbarTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package gjt.test; - -import java.net.URL; -import java.awt.*; -import java.applet.Applet; -import gjt.ExclusiveImageButtonPanel; -import gjt.ImageButton; -import gjt.ImageButtonEvent; -import gjt.Orientation; -import gjt.Toolbar; -import gjt.Separator; - -/** - * A Toolbar to the north, and an ExclusiveImageButtonPanel on - * the west give this little applet its own unique charm. - * Owner is motivated.<p> - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see gjt.test.UnitTest - * @see gjt.ExclusiveImageButtonPanel - * @see gjt.ImageButton - * @see gjt.Toolbar - */ -public class ToolbarTest extends UnitTest { - public String title() { - return "Toolbar/ImageButtonPanel Test"; - } - public Panel centerPanel() { - return new ToolbarTestPanel(this); - } -} - -class ToolbarTestPanel extends Panel { - ImageButton newButton, openButton, diskButton, - printButton, cutButton, copyButton, - pasteButton; - - public ToolbarTestPanel(Applet app) { - setLayout(new BorderLayout()); - add("North", makeToolbar(app, app.getCodeBase())); - add("West", makePalette(app, app.getCodeBase())); - } - public boolean handleEvent(Event event) { - if(event instanceof ImageButtonEvent) { - ImageButtonEvent ibevent = (ImageButtonEvent)event; - - if(ibevent.isActivated()) { - if(event.target == newButton) - System.out.println("New Button Activated"); - if(event.target == openButton) - System.out.println("Open Button Activated"); - if(event.target == diskButton) - System.out.println("Disk Button Activated"); - if(event.target == printButton) - System.out.println("Print Button Activated"); - if(event.target == cutButton) - System.out.println("Cut Button Activated"); - if(event.target == copyButton) - System.out.println("Copy Button Activated"); - if(event.target == pasteButton) - System.out.println("Paste Button Activated"); - - return true; - } - } - - return super.handleEvent(event); - } - private Toolbar makeToolbar(Applet app, URL cb) { - Toolbar tb = new Toolbar(10, 0); - - newButton = tb.add(app.getImage(cb, "gifs/new.gif")); - openButton = tb.add(app.getImage(cb, "gifs/open.gif")); - diskButton = tb.add(app.getImage(cb, "gifs/disk.gif")); - - tb.addSpacer(newButton.preferredSize().width); - - printButton = tb.add(app.getImage(cb, "gifs/print.gif")); - - tb.addSpacer(newButton.preferredSize().width); - - cutButton = tb.add(app.getImage(cb, "gifs/cut.gif")); - copyButton = tb.add(app.getImage(cb, "gifs/copy.gif")); - pasteButton = tb.add(app.getImage(cb, "gifs/paste.gif")); - - return tb; - } - private Panel makePalette(Applet app, URL cb) { - ExclusiveImageButtonPanel iconPalette; - Panel iconPalettePanel = new Panel(); - - iconPalette = new ExclusiveImageButtonPanel( - Orientation.VERTICAL, - Orientation.CENTER, - Orientation.TOP, 10); - - iconPalette.add(app.getImage(cb,"gifs/ballot_box.gif")); - iconPalette.add(app.getImage(cb,"gifs/palette.gif")); - iconPalette.add(app.getImage(cb,"gifs/light_bulb1.gif")); - iconPalette.add(app.getImage(cb,"gifs/Dining.gif")); - iconPalette.add(app.getImage(cb,"gifs/scissors.gif")); - iconPalette.add(app.getImage(cb,"gifs/tricycle.gif")); - - iconPalettePanel = new Panel(); - iconPalettePanel.setLayout(new BorderLayout()); - iconPalettePanel.add ("Center", iconPalette); - iconPalettePanel.add ("East", new Separator()); - return iconPalettePanel; - } -} diff --git a/java/gjt/test/TwoDrinkersAnimationTest.java b/java/gjt/test/TwoDrinkersAnimationTest.java deleted file mode 100644 index ae4041b9eb6..00000000000 --- a/java/gjt/test/TwoDrinkersAnimationTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package gjt.test; - -import java.net.URL; -import java.applet.Applet; -import java.awt.*; -import java.awt.Panel; - -import gjt.Util; -import gjt.Orientation; -import gjt.animation.*; - -/** - * An animation playfield containing two "java drinkers", that - * both bounce off the sides of the playfield.<p> - * - * One of the java drinkers moves slow and spins fast, while - * the other java drinker moves fast and spins slow. When - * the two java drinkers collide, they both play a bump - * sequence - at different speeds.<p> - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see gjt.test.AnimationTest - * @see gjt.animation.Playfield - * @see gjt.animation.Sprite - */ -public class TwoDrinkersAnimationTest extends UnitTest { - public String title() { - return - "TwoDrinkers Animation - Mouse Down Starts/Stops"; - } - public Panel centerPanel() { - return new TwoDrinkersAnimationTestPanel(this); - } -} - -class TwoDrinkersAnimationTestPanel extends Panel { - public TwoDrinkersAnimationTestPanel(Applet applet) { - setLayout(new BorderLayout()); - add("Center", new TwoDrinkersPlayfield(applet)); - } -} - -class TwoDrinkersPlayfield extends Playfield { - private Applet applet; - private URL cb; - private Sprite moveFastSpinSlow, moveSlowSpinFast; - private Sequence fastSpinSequence, - slowSpinSequence, - fastBumpSequence, - slowBumpSequence; - - public TwoDrinkersPlayfield(Applet applet) { - this.applet = applet; - cb = applet.getCodeBase(); - makeSequencesAndSprites(); - } - public void paintBackground(Graphics g) { - Image bg = applet.getImage(cb, "gifs/background.gif"); - Util.wallPaper(this, g, bg); - } - public boolean mouseDown(Event event, int x, int y) { - if(running() == true) stop (); - else start(); - return true; - } - public void spriteCollision(Sprite sprite, Sprite sprite2) { - if(moveSlowSpinFast.getSequence() != fastBumpSequence) { - sprite.reverse(); - sprite2.reverse(); - - moveSlowSpinFast.play(fastBumpSequence, 3); - moveFastSpinSlow.play(slowBumpSequence, 3); - } - } - public void edgeCollision(Sprite sprite, - Orientation orientation) { - if(orientation == Orientation.RIGHT || - orientation == Orientation.LEFT) - sprite.reverseX(); - else - sprite.reverseY(); - } - private void makeSequencesAndSprites() { - String file; - Image[] spinImages = new Image[19]; - Image[] bumpImages = new Image[6]; - Image[] volleyball = new Image[4]; - - for(int i=0; i < spinImages.length; ++i) { - file = "gifs/spin"; - - if(i < 10) file += "0" + i + ".gif"; - else file += i + ".gif"; - - spinImages[i] = applet.getImage(cb, file); - } - for(int i=0; i < bumpImages.length; ++i) { - file = "gifs/bump0" + i + ".gif"; - bumpImages[i] = applet.getImage(cb, file); - } - fastSpinSequence = new Sequence(this, spinImages); - slowSpinSequence = new Sequence(this, spinImages); - - fastBumpSequence = new Sequence(this, bumpImages); - slowBumpSequence = new Sequence(this, bumpImages); - - moveFastSpinSlow = - new Sprite(this, - slowSpinSequence, new Point(25, 75)); - - moveSlowSpinFast = - new Sprite(this, - fastSpinSequence, new Point(250,250)); - - fastSpinSequence.setAdvanceInterval(50); - slowSpinSequence.setAdvanceInterval(300); - - fastBumpSequence.setAdvanceInterval(25); - slowBumpSequence.setAdvanceInterval(200); - - moveFastSpinSlow.setMoveVector(new Point(2,3)); - moveSlowSpinFast.setMoveVector(new Point(-1,-1)); - - moveSlowSpinFast.setMoveInterval(100); - - addSprite(moveFastSpinSlow); - addSprite(moveSlowSpinFast); - } -} diff --git a/java/gjt/test/UnitTest.java b/java/gjt/test/UnitTest.java deleted file mode 100644 index 1fa262d5629..00000000000 --- a/java/gjt/test/UnitTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package gjt.test; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.Panel; -import java.applet.Applet; -import gjt.*; - -/** - * An (abstract) Applet fitted with a BorderLayout that - * contains a TitledPanel in the North, and a Panel created by - * derived classes in the Center.<p> - * - * Since some Applets take awhile to load, UnitTest changes the - * cursor to a wait cursor in init(), changing it back to the - * default cursor in start(). Derived classes must be sure to - * call super.init() if they override init(); likewise for - * start().<p> - * - * Subclasses must implement: - * <dl> - * <dd>String title() - * <dd>Panel centerPanel() - * </dl> - * Subclasses should populate the Panel returned from - * centerPanel() with whatever makes sense for their unit test. - * - * @version 1.0, April 25, 1996 - * @author David Geary - * @see TitledPanel - */ -abstract public class UnitTest extends Applet { - abstract public String title(); - abstract public Panel centerPanel(); - - public void init() { - Util.getFrame(this).setCursor(Frame.WAIT_CURSOR); - Panel titledPanel = new TitledPanel(title()); - setLayout(new BorderLayout()); - add("North", titledPanel); - add("Center", centerPanel()); - } - public void start() { - Util.getFrame(this).setCursor(Frame.DEFAULT_CURSOR); - } -} diff --git a/java/src/ACE.java b/java/src/ACE.java deleted file mode 100644 index 8fa6e1823fa..00000000000 --- a/java/src/ACE.java +++ /dev/null @@ -1,164 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.OS - * - * = FILENAME - * JACE.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.OS; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - * <blockquote>Constants, utility "functions", etc.</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * Defines default constants for ACE. Many of these are used for the - * ACE tests and applications. You may want to change some of these to - * correspond to your environment. Also, routines for error handling, - * debugging and bit manipulation are included. - *</blockquote> - * - * <h2>NOTES</h2> - *<blockquote> - * This class is non-instantiable, and intended only to provide a constrained - * namespace. - *</blockquote> - */ -public abstract class ACE -{ - /** - * Default port on which a server listens for connections. - */ - public static final int DEFAULT_SERVER_PORT = 10002; - - /** - * Default name to use for a thread group. - */ - public static final String DEFAULT_THREAD_GROUP_NAME = "ace_thread_group"; - - /** - * Disable debugging. Once debugging is disabled, all ACE.DEBUG - * statements would be ignored. - */ - public static final void disableDebugging () - { - ACE.debug_ = false; - } - - /** - * Enable debugging. Once debugging is enabled, all ACE.DEBUG - * statements get printed. - */ - public static final void enableDebugging () - { - ACE.debug_ = true; - } - - /** - * Print the string representation of Java Exception. - *@param e Java exception - */ - public static final void ERROR (Exception e) - { - System.err.println (e); - } - - /** - * Print the string being passed in. - *@param s a Java String - */ - public static final void ERROR (String s) - { - System.err.println (s); - } - - /** - * Print the string being passed in. - *@param s A Java String - *@return Error value passed in - */ - public static final int ERROR_RETURN (String s, int errorVal) - { - System.err.println (s); - return errorVal; - } - - /** - * Print the string being passed in. Note the behavior will vary - * depending upon whether debugging is enabled or disabled. - *@param s a Java String - */ - public static final void DEBUG (String s) - { - if (ACE.debug_) - System.out.println (s); - } - - /** - * Flush out any data that may be buffered. - */ - public static final void FLUSH () - { - System.out.flush (); - } - - /** - * Set the bits of WORD using BITS as the mask. - *@param WORD the bits to be set. - *@param BITS the mask to use. - *@return The value obtained after setting the bits. - */ - public static final long SET_BITS (long WORD, long BITS) - { - return WORD | BITS; - } - - /** - * Clear the bits of WORD using BITS as the mask. - *@param WORD the bits to clear. - *@param BITS the mask to use. - *@return The value obtained after clearing the bits. - */ - public static final long CLR_BITS (long WORD, long BITS) - { - return WORD & ~BITS; - } - - /** - * Check if bits are enabled in WORD. - *@param WORD the bits to check. - *@param BIT the bit to check to see if it is enabled or not. - *@return true if bit is enabled, false otherwise. - */ - public static final boolean BIT_ENABLED (long WORD, long BIT) - { - return (WORD & BIT) != 0; - } - - /** - * Check if bits are disabled in WORD. - *@param WORD the bits to check. - *@param BIT the bit to check to see if it is disabled or not. - *@return true if bit is disabled, false otherwise. - */ - public static final boolean BIT_DISABLED (long WORD, long BIT) - { - return (WORD & BIT) == 0; - } - - // Debug flag (turn debugging on/off) - private static boolean debug_ = true; - - // Default private constructor to avoid instantiation - private ACE () - { - } -} - - diff --git a/java/src/AcceptStrategy.java b/java/src/AcceptStrategy.java deleted file mode 100644 index 7b48510840e..00000000000 --- a/java/src/AcceptStrategy.java +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * AcceptStrategy.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -import java.io.*; -import java.net.*; -import JACE.SOCK_SAP.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Interface for specifying a passive connection - * acceptance strategy for a - * <a href="ACE.Connection.SvcHandler.html"><tt>SvcHandler</tt></a> - * . - *</blockquote> - * - * <h2>DESCRIPTION</h2> - * - *<blockquote> - * This class provides a strategy that manages passive - * connection setup for an application, and can be extended - * to define new strategies. - *</blockquote> - * - * @see SvcHandler - * @see Acceptor - */ - -public class AcceptStrategy -{ - /** - * Create an instance of Accept Strategy. - *@param port port number where the server will listen for connections - *@exception IOException couldn't open port - */ - AcceptStrategy (int port) throws IOException - { - this.open (port); - } - - /** - * Initialize AcceptStrategy. - *@param port port number where the server will listen for connections - *@exception IOException couldn't open port - */ - public void open (int port) throws IOException - { - // Create a new SOCK_Acceptor to accept client connections - this.sockAcceptor_ = new SOCKAcceptor (port); - } - - /** - * Accept connections into the SvcHandler. Note that subclasses - * should overwrite this method to provide a different accept - * strategy. - *@param sh Svc Handler in which to accept the connection - *@exception SocketException - *@exception IOException - *@return 0 - */ - public int acceptSvcHandler (SvcHandler sh) throws - SocketException, IOException - { - // Create a new stream - SOCKStream sockStream = new SOCKStream (); - - // Block in accept. Returns when a connection shows up - this.sockAcceptor_.accept (sockStream); - - // Set the streams for the new handler - sh.setHandle (sockStream); - return 0; - } - - // Our connection acceptance factory - private SOCKAcceptor sockAcceptor_; - -} diff --git a/java/src/Acceptor.java b/java/src/Acceptor.java deleted file mode 100644 index 4a47d743e98..00000000000 --- a/java/src/Acceptor.java +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * Acceptor.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; -import JACE.ServiceConfigurator.*; - -/** - * <hr> - * <p><h2>SYNOPSIS</h2> - * - * <blockquote>Abstract factory for creating a service handler - * (<a href="ACE.Connection.SvcHandler.html"><tt>SvcHandler</tt></a>), - * accepting into the - * <a href="ACE.Connection.SvcHandler.html"><tt>SvcHandler</tt></a>, and activating the - * <a href="ACE.Connection.SvcHandler.html"><tt>SvcHandler</tt></a>.</blockquote> - * - * <p><h2>DESCRIPTION</h2> - * - * <blockquote>Implements the basic strategy for passively establishing - * connections with applications. The <tt>Acceptor</tt> - * is a factory for <tt>SvcHandler</tt> instances, and, by default - * generates a new <tt>SvcHandler</tt> instance for each connection - * esablished.</blockquote> - * - * <p> - * - * <blockquote> The user of this class <em>must</em> provide a - * reference to a handler factory prior to calling <a - * href="#accept()"><tt>accept</tt></a>, or an exception will be - * thrown. The handler factory is identified by the meta-class for - * the <tt>SvcHandler</tt>, and is typically obtained by calling <a - * href="java.lang.Class#classForName(java.lang.String)"><tt>Class.classForName("SvcHandler")</tt></a>. - * </blockquote> - * - * <p> - * - * <blockquote> TCP is the transport mechanism used, via - * <a href="ACE.SOCK_SAP.SOCKAcceptor.html#_top_"><tt>SOCKAcceptor</tt></a>, - * <em>et.al.</em> The SvcHandler is instantiated with a concrete type - * that performs the application-specific service. </blockquote> - * - * <h2>NOTES</h2> - * - * <blockquote> This class is not directly related to the - * <tt>AcceptorStrategy</tt> class.</blockquote> - * - * - * @see java.lang.Class,ACE.Connection.SvcHandler,ACE.SOCK_SAP.SOCKAcceptor */ -public class Acceptor extends ServiceObject -{ - /** - * Create an instance of Acceptor. Default constructor. Note that if - * an instance is created via this method, <tt>setHandlerFactory</tt> - * must be called prior to using <tt>accept</tt>. - * - * @see ACE.Connection.Acceptor.setHandlerFactory - */ - public Acceptor () - { - } - - /** - * Create an instance of Acceptor. - *@param handlerFactory meta-class reference used to create - * an instance of a SvcHandler when a connection is accepted - * (typically obtained by calling <tt>Class.classForName</tt>). - * - *@see java.lang.Class.classForName - */ - public Acceptor (Class handlerFactory) - { - this.handlerFactory_ = handlerFactory; - } - - /** - * Set the handler factory. This is provided to aid the default - * no-arg constructor. - *@param handlerFactory meta-class reference used to create - * an instance of a SvcHandler when a connection is accepted - * (typically obtained by calling <tt>Class.classForName</tt>). - * - *@see java.lang.Class.classForName - */ - public void setHandlerFactory (Class handlerFactory) - { - this.handlerFactory_ = handlerFactory; - } - - /** - * Initialize the Acceptor. - *@param port TCP port number where the Acceptor will listen for connections - *@exception IOException socket level exception - */ - public void open (int port) throws IOException - { - this.sockAcceptor_ = new SOCKAcceptor (port); - } - - /** - * Template method for accepting connections. Delegates operational - * activities to the following bridge methods: - * <ul> - * <li><tt>makeSvcHandler</tt></li> - * <li><tt>acceptSvcHandler</tt></li> - * <li><tt>activateSvcHandler</tt></li> - * </ul> - * - * <p> - * - * The method first obtains a <tt>SvcHandler</tt> via - * <tt>makeSvcHandler</tt>, accepts the connection <q>into</q> the - * handler using <tt>acceptSvcHandler</tt>, and finally turns over - * control to the handler with <tt>activateSvcHandler</tt>. - * - *@exception SocketException socket level error - *@exception InstantiationException <tt>makeSvcHandler</tt> failure - *@exception IllegalAccessException <tt>makeSvcHandler</tt> failure - *@exception IOException socket level error - */ - public void accept () throws SocketException, - InstantiationException, - IllegalAccessException, - IOException - { - - // Create a Svc_Handler using the appropriate Creation_Strategy - SvcHandler sh = this.makeSvcHandler (); - - // Accept a connection into the SvcHandler using the appropriate - // Accept_Strategy - this.acceptSvcHandler (sh); - - // Activate the SvcHandler using the appropriate ActivationStrategy - this.activateSvcHandler (sh); - } - - /** - * Bridge method for creating a <tt>SvcHandler</tt>. The default is to - * create a new <SvcHandler>. However, subclasses can override this - * policy to perform <SvcHandler> creation in any way that they like - * (such as creating subclass instances of <SvcHandler>, using a - * singleton, etc.) - *@return a new instance of the SvcHandler - *@exception InstantiationException could not create new SvcHandler - *@exception IllegalAccessException no SvcHandler factory provided - */ - protected SvcHandler makeSvcHandler () - throws InstantiationException, IllegalAccessException - { - // Create a new handler for the connection - return (SvcHandler) handlerFactory_.newInstance (); - } - - /** - * Bridge method for accepting the new connection into the - * <tt>SvcHandler</tt>. The default behavior delegates the work to - * <tt>SOCKAcceptor.accept</tt>. However, subclasses can override this - * strategy. - *@param sh SvcHandler in which to accept the connection - *@return 0 - *@exception SocketException socket level error - *@exception IOException socket level error - */ - protected int acceptSvcHandler (SvcHandler sh) - throws SocketException, IOException - { - // Create a new stream - SOCKStream sockStream = new SOCKStream (); - - // Block in accept. Returns when a connection shows up - this.sockAcceptor_.accept (sockStream); - - // Set the streams for the new handler - sh.setHandle (sockStream); - return 0; - } - - /** - * Bridge method for activating a <tt>SvcHandler</tt>. The default - * behavior of this method is to activate the <tt>SvcHandler</tt> by - * calling its open() method (which allows the <tt>SvcHandler</tt> to - * define its own concurrency strategy). However, subclasses can - * override this strategy to do more sophisticated concurrency - * activations. - *@param sh SvcHandler to activate - *@return 0 - */ - protected int activateSvcHandler (SvcHandler sh) - { - sh.open (null); - return 0; - } - - // Handler class that should be instantiated when a connection is - // made with a client - private Class handlerFactory_; - - // Our connection acceptance factory - private SOCKAcceptor sockAcceptor_; -} diff --git a/java/src/ActivateStrategy.java b/java/src/ActivateStrategy.java deleted file mode 100644 index 882203ad552..00000000000 --- a/java/src/ActivateStrategy.java +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * ActivateStrategy.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - - -/** - * <hr> - *<h2>SYNOPSIS</h2> - * Bridge supporting activation strategy used by - * <a href="ACE.Connection.StrategyAcceptor.html#_top_"><tt>StrategyAcceptor</tt></a> - * - *<h2>DESCRIPTION</h2> - * Subclass and overload - * <a href="#activateSvcHandler(ACE.Connection.SvcHandler)"><tt>activateSvcHandler</tt></a> - * in order change the activation strategy. Then, submit this subclass to - * <a href="ACE.Connection.StrategyAcceptor.html#_top_"><tt>StrategyAcceptor</tt></a> - * as the activation strategy. - * - *@see StrategyAcceptor - */ -public class ActivateStrategy -{ - /** - * Activate the Svc Handler. Note that subclasses should overwrite - * this method to provide a different Activate strategy. - *@param sh Svc Handler to activate - *@return zero if success, non-zero for failure - */ - public int activateSvcHandler (SvcHandler sh) - { - sh.open (null); - return 0; - } -} diff --git a/java/src/Condition.java b/java/src/Condition.java deleted file mode 100644 index 59a97c9a1a7..00000000000 --- a/java/src/Condition.java +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * Condition.java - * - *@author Irfan Pyarali - * - *************************************************/ -package JACE.Concurrency; - -import JACE.ASX.TimeoutException; -import JACE.ASX.TimeValue; - -/** - * <hr> - * <h2>TITLE</h2> - *<blockquote> - * Abstraction for <em>traditional</em> - * condition variable - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This condition variable allows the use of one - * mutex between multiple conditions. - * This implementation is based on the C++ version of ACE. - *</blockquote> - */ -public class Condition -{ - /** - * Default constructor - *@param Mutex for synchronization - */ - public Condition (Mutex mutex) - { - mutex_ = mutex; - } - - /** - * Wait for condition to become signaled. - *@exception InterruptedException exception during wait - */ - public void Wait () - throws InterruptedException - { - waiters_++; - - try - { - mutex_.release(); - semaphore_.acquire (); - mutex_.acquire (); - } - finally - { - waiters_--; - } - } - - /** - * TimedWait for condition to become signaled. - *@exception TimeoutException wait timed out exception - *@exception InterruptedException exception during wait - */ - public void Wait (TimeValue tv) - throws TimeoutException, InterruptedException - { - waiters_++; - - try - { - mutex_.release(); - - TimeValue start = TimeValue.getTimeOfDay (); - - semaphore_.acquire (tv); - - TimeValue now = TimeValue.getTimeOfDay (); - tv.minusEquals (TimeValue.minus (now, start)); - - mutex_.acquire (tv); - } - finally - { - waiters_--; - } - } - - /** - * Signal condition. Wake one waiter (if any). - */ - public void signal () - { - if (waiters_ > 0) - semaphore_.release (); - } - - /** - * Signal condition. Wake up all waiters (if any). - */ - public void broadcast () - { - for (int i = waiters_; i > 0; i--) - semaphore_.release (); - } - - /** - * Accessor to lock - *@return Mutex - */ - public Mutex mutex () - { - return mutex_; - } - - private int waiters_; - private Semaphore semaphore_ = new Semaphore (0); - private Mutex mutex_; - -} diff --git a/java/src/Connector.java b/java/src/Connector.java deleted file mode 100644 index 81b701e7b4d..00000000000 --- a/java/src/Connector.java +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * Connector.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; -import JACE.ServiceConfigurator.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Abstract factory for connecting a - * (<a href="ACE.Connection.SvcHandler.html"><tt>SvcHandler</tt></a>), - * to an application. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * Implements the basic strategy for actively establishing connections - * with applications. The <tt>Connector</tt> establishes the connection, - * passing it on to a <tt>SvcHandler</tt> instance, and handing over - * control to that instance. - *<p> - * TCP is the transport mechanism used, via - * <a href="ACE.SOCK_SAP.SOCKConnector.html#_top_"><tt>SOCKConnector</tt></a>. - *</blockquote> - * - *<h2>NOTES</h2> - *<blockquote> - * This class, as currently implemented, does not work like its C++ counterpart. - * Future versions are expected to rectify this discrepancy. - *</blockquote> - * - *@see SOCKConnector,SvcHandler - */ -public class Connector extends ServiceObject -{ - /** - * Create a Connector. Do nothing constructor. Allows user to - * call <a href="#open(java.lang.String)">open</a>() later. - */ - public Connector () - { - } - - /** - * Create a Connector passing in server hostname and port - * number, effectively shorthand for calling - * <a href="#open(java.lang.String)">open</a>(). - *@param hostname server hostname - *@param port server port number - */ - public Connector (String hostname, int port) - { - this.open (hostname, port); - } - - /** - * Initialize the Connector passing in server hostname and port - * number. Note that no connection attempt is made. - *@param hostname server hostname - *@param port server port number - */ - public void open (String hostname, int port) - { - this.hostname_ = hostname; - this.port_ = port; - } - - /** - * Connect to the server. - *@param sh Svc Handler to use to handle the connection - */ - public void connect (SvcHandler sh) throws UnknownHostException, - SocketException, - InstantiationException, - IllegalAccessException, - IOException - { - // Make a connection using the appropriate Connection_Strategy - this.connectSvcHandler (sh); - - // Activate the Svc_Handler using the appropriate Activation_Strategy - this.activateSvcHandler (sh); - } - - /** - * Bridge method for making a new connection. The default behavior - * creates a new SOCKConnector and then calls setHandle() on the - * <SvcHandler> that was passed in. Subclasses can override this - * strategy, if needed. - *@param sh Svc Handler to use to handle the connection - *@return 0 - */ - protected int connectSvcHandler (SvcHandler sh) throws - SocketException, IOException - { - // Create a new stream - SOCKStream sockStream = new SOCKStream (); - - // Create a SOCK_Connector (note the constructor does the connect for us) - this.sockConnector_ = new SOCKConnector (sockStream, - this.hostname_, - this.port_); - ACE.DEBUG ("Connected to " + - sockStream.socket ().getInetAddress ()); - - // Set the streams for the new handler - sh.setHandle (sockStream); - return 0; - } - - /** - * Bridge method for activating a <SvcHandler>. The default - * behavior of this method is to activate the <SvcHandler> by - * calling its open() method (which allows the SVC_HANDLER to define - * its own concurrency strategy). However, subclasses can override - * this strategy to do more sophisticated concurrency activations. - *@param sh Svc Handler to activate - *@return 0 - */ - protected int activateSvcHandler (SvcHandler sh) - { - sh.open (null); - return 0; - } - - - // Port server is listening on - private int port_; - - // Server hostname - private String hostname_; - - // Our connection factory - private SOCKConnector sockConnector_; -} diff --git a/java/src/CreationStrategy.java b/java/src/CreationStrategy.java deleted file mode 100644 index 219dc712668..00000000000 --- a/java/src/CreationStrategy.java +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * CreationStrategy.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Defines the interface for specifying a creation strategy for a - * <a href="ACE.Connection.SvcHandler.html#_top_"><tt>SvcHandler</tt></a> to the - * <a href="ACE.Connection.StrategyAcceptor.html#_top_"><tt>StrategyAcceptor</tt></a>. - *</blockquote> - * - * <p><b>DESCRIPTION</b><br> - *<blockquote> - * The default behavior is to make a new SvcHandler. However, - * subclasses can override this strategy to perform SvcHandler - * creation in any way that they like (such as creating subclass - * instances of SvcHandler, using a singleton, dynamically - * linking the handler, etc.). - *</blockquote> - * - *@see SvcHandler,StrategyAcceptor,AcceptStrategy,ActivateStrategy - */ -public class CreationStrategy -{ - /** - * Create an instance of Creation Strategy. - *@param handlerFactory Svc Handler factory that is used to create - * an instance of a Svc Handler - */ - public CreationStrategy (Class handlerFactory) - { - this.handlerFactory_ = handlerFactory; - } - - /** - * Create a new SvcHandler. Note that subclasses should override - * this method to provide a new creation strategy. - *@return reference to a new instance of the SvcHandler (or subclass) - *@exception InstantiationException Unable to instantiate. - *@exception IllegalAccessException No handler factory available. - */ - public SvcHandler makeSvcHandler () throws InstantiationException, - IllegalAccessException - { - // Create a new Svc_Handler - return (SvcHandler) handlerFactory_.newInstance (); - } - - private Class handlerFactory_; -} diff --git a/java/src/EventHandler.java b/java/src/EventHandler.java deleted file mode 100644 index 53a9974bf08..00000000000 --- a/java/src/EventHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Reactor - * - * = FILENAME - * EventHandler.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Reactor; - -import JACE.ASX.TimeValue; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Provides an abstract interface for handling timer events. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * Classes implementing this interface handle a timer's - * expiration. - *</blockquote> - * - * <h2>NOTES</h2> - *<blockquote> - * Users of C++ ACE will notice that this defines a substantially - * smaller interface than the C++ counterpart. Signal events are - * absent due to the complete absence of this feature from Java itself. - * Moreover, at this point - * there is still some question regarding whether or not the I/O - * portion will make any sense or fit into the Java model for I/O. - *</blockquote> - * - *@see TimerQueue,Reactor - */ -public interface EventHandler -{ - /** - * Called when timer expires. - *@param tv Time Value for which timer was set - *@param obj An arbitrary object that was passed to the Timer Queue - * (Asynchronous Completion Token) - */ - public int handleTimeout (TimeValue tv, Object obj); -} - -// Note that more methods will be added as needed diff --git a/java/src/GetOpt.java b/java/src/GetOpt.java deleted file mode 100644 index 2bf5d27c406..00000000000 --- a/java/src/GetOpt.java +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Misc - * - * = FILENAME - * GetOpt.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Misc; - -import java.io.*; -import java.util.Hashtable; -import java.util.StringTokenizer; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Iterator for parsing command-line arguments. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This version of `get_opt' appears to the caller like standard - * Unix `get_opt' but it behaves differently for the user, since - * it allows the user to intersperse the options with the other - * arguments. - * - * <p> As `get_opt' works, it permutes the elements of `argv' so that, - * when it is done, all the options precede everything else. Thus - * all application programs are extended to handle flexible argument - * order. - *</blockquote> - * - */ -public class GetOpt -{ - /** - * Constructor - *@param args command line arguments - *@param optstring string containing the legitimate option - * characters. A colon in optstring means that the previous character - * is an option that wants an argument which is then taken from the - * rest of the current args-element. Here is an example of what - * optstring might look like: "c:dP:p". - */ - public GetOpt (String[] args, String optstring) - { - // Cache the arguments - this.args_ = args; - this.hasArg_ = false; - - // Build the arg hashtable - this.buildArgTable (optstring); - } - - /** - * Scan elements specified in optstring for next option flag. - *@return The character corresponding to the next flag. - */ - public int next () - { - if (this.args_ == null) - return -1; - - if (this.index_ < this.args_.length) - { - String arg = this.args_[this.index_++]; - - // Make sure flag starts with "-" - if (!arg.startsWith ("-")) - return -1; - - // Check if there is more than one character specified as flag - if (arg.length () > 2) - return -1; - - // So far so good - // Check if the flag is in the arg_table and if it is get the - // associated binding. - Character c = (Character) this.argTable_.get (new Character (arg.charAt (1))); - if (c == null) - return -1; - - if (c.charValue () == '#') - { - this.hasArg_ = false; - return arg.charAt (1); - } - else if (c.charValue () == ':') - { - this.hasArg_ = true; - return arg.charAt (1); - } - else // This should not happen - return -1; - } - return -1; - } - - /** - * Get the argument (if any) associated with the flag. - *@return the argument associated with the flag. - */ - public String optarg () - { - if (this.hasArg_) - return this.args_[this.index_++]; - else - return null; - } - - // Build the argument table - private void buildArgTable (String s) - { - this.argTable_ = new Hashtable (); - StringTokenizer tokens = new StringTokenizer (s, ":"); - while (tokens.hasMoreTokens ()) - { - // Get the next token - String t = tokens.nextToken (); - - // First add all flags except the one with ":" after it - // Note "#" is an arbitrary character we use to distinguish - // the two cases - for (int i = 0; i < t.length () - 1; i++) - this.argTable_.put (new Character (t.charAt (i)), - new Character ('#')); - - // Now Add the flag just before ":" to the arg_table - this.argTable_.put (new Character (t.charAt (t.length () - 1)), - new Character (':')); - } - } - - private String [] args_; - // Copy of the args passed in - - private boolean hasArg_; - // Indicator that the flag has an argument following it - - private int index_; - // Index into the array of arguments - - private Hashtable argTable_; - // Table of flags that take arguments after them -} diff --git a/java/src/INETAddr.java b/java/src/INETAddr.java deleted file mode 100644 index 8d16c46c6b3..00000000000 --- a/java/src/INETAddr.java +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.SOCK_SAP - * - * = FILENAME - * INETAddr.java - * - *@author Chris Cleeland - * - *************************************************/ -package JACE.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; - -/** - * <hr> - * <p><b>TITLE</b><br> - * Defines an endpoint of a connection, encapsulating host and port. - * This is only a part-way implementation of C++ ACE's ACE_INET_Addr. - * - * <p><b>LIMITATIONS</b><br> - * Currently the class is very limited in its capabilities; it will - * be expanded in future revisions of ACE. - */ -public class INETAddr // extends Addr -{ - private InetAddress addr_; - private int port_ = 0; - /** - */ - public INETAddr () - { - // Do nothing constructor - } - - /** - * Create an INETAddr from a port/hostname - *@param port port number to connect with server at - *@param hostname hostname of the server - */ - public INETAddr (int port, String hostname) throws UnknownHostException - { - super(); - port_ = port; - addr_ = InetAddress.getByName(hostname); - // Should really use getAllByName(), - // but I don't think we do that in - // C++ ACE, even. - } - - /** - * Create an INETAddr from an address. - * @param address an address in the form "ip-number:port-number", <em>e.g.</em> <pre>tango.cs.wustl.edu:1234</pre> or <pre>128.252.166.57:1234</pre>; if no ':' is present address is assumed to be <b>INADDR_ANY</b> and address contains only the port number - * @throws UnknownHostException - */ - public INETAddr (String address) throws UnknownHostException - { - int colon = address.indexOf(':'); - if (colon != 0) - { - addr_ = InetAddress.getByName(address.substring(0, colon)); - address = address.substring(colon+1); - } - - port_ = Integer.parseInt(address); - } - - /** - * Return the name of the host. - */ - public String getHostName() - { - return addr_.getHostName(); - } - - /** - * Return the dotted Internet address. - */ - public String getHostAddr() - { - return addr_.toString(); - } - - /** - * Return the port number. - */ - public int getPortNumber() - { - return port_; - } - - public String toString() - { - return getHostAddr() + Integer.toString(port_); - } -} diff --git a/java/src/IOCntlCmds.java b/java/src/IOCntlCmds.java deleted file mode 100644 index 2469428a3a6..00000000000 --- a/java/src/IOCntlCmds.java +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * TaskFlags.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -public abstract class IOCntlCmds -{ - /** Set the low water mark. */ - public static final int SET_LWM = 1; - - /** Get the low water mark. */ - public static final int GET_LWM = 2; - - /** Set the high water mark. */ - public static final int SET_HWM = 3; - - /** Get the high water mark. */ - public static final int GET_HWM = 4; - - /** Link modules */ - public static final int MOD_LINK = 5; - - /** Unlink modules */ - public static final int MOD_UNLINK = 6; - -} diff --git a/java/src/IOCntlMsg.java b/java/src/IOCntlMsg.java deleted file mode 100644 index 8b69310c4f7..00000000000 --- a/java/src/IOCntlMsg.java +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * IOCntlMsg.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Data format for IOCTL messages - *</blockquote> - */ -public class IOCntlMsg -{ - - // = Initialization method. - - /* - * Initialize the control message. - *@param c IOCntlCmd for the control message. Note that this should - * be of type IOCntlCmds - */ - public IOCntlMsg (int c) - { - this.cmd_ = c; - } - - // = Get/set methods - - /* - * Get the command. - *@return the command. - */ - public int cmd () - { - return this.cmd_; - } - - /* - * Set the command. - *@param c the command. - */ - public void cmd (int c) - { - this.cmd_ = c; - } - - /* - * Get the count. - *@return the count. - */ - public int count () - { - return this.count_; - } - - /* - * Set the count. - *@param c the count. - */ - public void count (int c) - { - this.count_ = c; - } - - /* - * Get the error. - *@return the error. - */ - public int error () - { - return this.error_; - } - - /* - * Set the error. - *@param e the error. - */ - public void error (int e) - { - this.error_ = e; - } - - /* - * Get the return value. - *@return the return value. - */ - public int rval () - { - return this.rval_; - } - - /* - * Set the return value. - *@param r the return value. - */ - public void rval (int r) - { - this.rval_ = r; - } - - public String toString () - { - return (new Integer (this.cmd_)).toString (); - } - - private int cmd_; - // Command. - - private int count_; - // Count. - - private int error_; - // Error. - - private int rval_; - // Return value -} diff --git a/java/src/Makefile b/java/src/Makefile deleted file mode 100644 index 8d2fab2f79b..00000000000 --- a/java/src/Makefile +++ /dev/null @@ -1,139 +0,0 @@ -# Makefile -# $Id$ - -.SUFFIXES: .java .class - -JACE_WRAPPER = .. -CLASSDIR = $(JACE_WRAPPER)/classes -DOCDIR = $(JACE_WRAPPER)/doc - -JC = javac_g -JCOPTS = -g -d $(CLASSDIR) -JD = javadoc -JDOPTS = -d $(DOCDIR) - -COMPILE.java = $(JC) $(JCOPTS) $(filter %.java,$?) - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: asx os concurrency connection timers misc reactor svcconfig socksap - -pkg_all = $(pkg_asx_timestuff) $(pkg_asx) $(pkg_os) $(pkg_concurrency) \ - $(pkg_connection) $(pkg_timers) $(pkg_misc) $(pkg_reactor) \ - $(pkg_socksap) $(pkg_svcconfig) - -doc: - $(JD) $(JDOPTS) $(addsuffix .java,$(pkg_all)) $(packages) - -clean: - find ${JACE_WRAPPER}/classes/JACE -name '*.class' -print | xargs ${RM} - -docclean: - find ${JACE_WRAPPER}/doc -name '*.html' -print | xargs ${RM} - -realclean: clean docclean - - -pkg_asx_timestuff = \ - TimeValue \ - TimeoutException \ - TimedWait - -asx_timestuff: $(addsuffix .java,$(pkg_asx_timestuff)) - $(COMPILE.java) - -pkg_asx = \ - IOCntlCmds \ - IOCntlMsg \ - Task \ - TaskFlags \ - ThruTask \ - Module \ - MessageType \ - MessageBlock \ - MessageQueue \ - StreamHead \ - StreamTail \ - Stream - -asx: os asx_timestuff reactor concurrency $(addsuffix .java,$(pkg_asx)) - $(COMPILE.java) - -pkg_os = \ - OS \ - ACE - -os: $(addsuffix .java,$(pkg_os)) - $(COMPILE.java) - -pkg_concurrency = \ - Condition \ - Mutex \ - RWMutex \ - Semaphore \ - ThreadManager \ - Token - -concurrency: $(addsuffix .java,$(pkg_concurrency)) asx_timestuff os - $(COMPILE.java) - -pkg_connection = \ - SvcHandler \ - Acceptor \ - Connector \ - AcceptStrategy \ - ActivateStrategy \ - CreationStrategy \ - StrategyAcceptor - -connection: os socksap svcconfig $(addsuffix .java,$(pkg_connection)) - $(COMPILE.java) - -pkg_timers = \ - ProfileTimer - -timers: $(addsuffix .java,$(pkg_timers)) - $(COMPILE.java) - -pkg_misc = \ - GetOpt - -misc: $(addsuffix .java,$(pkg_misc)) - $(COMPILE.java) - -pkg_reactor = \ - EventHandler \ - TimerQueue - -reactor: asx_timestuff $(addsuffix .java,$(pkg_reactor)) - $(COMPILE.java) - -pkg_socksap = \ - INETAddr \ - SOCKStream \ - SOCKAcceptor \ - SOCKConnector - -socksap: os $(addsuffix .java,$(pkg_socksap)) - $(COMPILE.java) - -pkg_svcconfig = \ - ServiceObject \ - ServiceConfig \ - ServiceRepository - -svcconfig: os reactor misc $(addsuffix .java,$(pkg_svcconfig)) - $(COMPILE.java) - -packages = JACE \ - JACE.ASX \ - JACE.Connection \ - JACE.Concurrency \ - JACE.Misc \ - JACE.OS \ - JACE.Reactor \ - JACE.SOCK_SAP \ - JACE.Service_Configurator \ - JACE.Timers - - diff --git a/java/src/MessageBlock.java b/java/src/MessageBlock.java deleted file mode 100644 index 1741f9bef80..00000000000 --- a/java/src/MessageBlock.java +++ /dev/null @@ -1,453 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * MessageBlock.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Object used to store messages in the ASX framework. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * <tt>MessageBlock</tt> is modeled after the message data structures - * used in System V STREAMS. A <tt>MessageBlock</tt> is composed of - * one or more <tt>MessageBlock</tt>s that are linked together by <em>PREV</em> - * and <em>NEXT</em> pointers. In addition, a <tt>MessageBlock</tt> may also be - * linked to a chain of other <tt>MessageBlock</tt>s. This structure - * enables efficient manipulation of arbitrarily-large messages - * <em>without</em> incurring memory copying overhead. - *</blockquote> - * - *@see MessageQueue - */ -public class MessageBlock -{ - /** - * Create an empty Message Block - */ - public MessageBlock () - { - this (0); - } - - /** - * Create an empty Message Block. - * Note that this assumes that type of MessageBlock is MB_DATA. - *@param size size of the Message Block to create. - */ - public MessageBlock (int size) - { - // Note the explicit cast toString() is needed. For some strange - // reason, it fails otherwise if size == 0. - this ((new StringBuffer (size)).toString ()); - } - - /** - * Create a Message Block. Note that this assumes that type of - * MessageBlock is MB_DATA. - *@param data initial data to create a Message Block with. - */ - public MessageBlock (String data) - { - this (MessageType.MB_DATA, - null, - data); - } - - /** - * Create a Message Block. - *@param type type of the Message Block (must be one of those - * specified in class Message Type) - *@param cont next block of data - *@param data initial data to create Message Block with - */ - public MessageBlock (int type, - MessageBlock cont, - String data) - { - this.flags_ = 0; - this.priority_ = 0; - this.next_ = null; - this.prev_ = null; - - this.init (type, cont, data); - } - - /** - * Create a Message Block. Note that this assumes that type of - * MessageBlock is MB_OBJECT. - *@param obj initial object to create a Message Block with. - */ - public MessageBlock (Object obj) - { - this (MessageType.MB_OBJECT, - null, - obj); - } - - /** - * Create a Message Block. - *@param type type of the Message Block (must be one of those - * specified in class Message Type) - *@param cont next block of data - *@param obj initial object to create Message Block with - */ - public MessageBlock (int type, - MessageBlock cont, - Object obj) - { - this.init (type, cont, obj); - } - - /* Initialize the Message Block - *@param data data to initialize Message Block with - */ - public void init (String data) - { - this.base_ = new StringBuffer (data); - } - - /** - * Initialize a Message Block. - *@param type type of the Message Block (must be one of those - * specified in class Message Type) - *@param cont next block of data - *@param data data to initialize Message Block with - */ - public void init (int msgType, - MessageBlock msgCont, - String data) - { - if (data.length () == 0) - this.base_ = new StringBuffer (0); - else - this.base_ = new StringBuffer (data); - this.type_ = msgType; - this.cont_ = msgCont; - } - - /** - * Initialize a Message Block. Note that this assumes that type of - * MessageBlock is MB_OBJECT. - *@param obj initial object to initialize a Message Block with. - */ - public void init (Object obj) - { - this.init (MessageType.MB_OBJECT, null, obj); - } - - /** - * Initialize a Message Block. - *@param type type of the Message Block (must be one of those - * specified in class Message Type) - *@param cont next block of data - *@param obj object to initialize Message Block with - */ - public void init (int msgType, - MessageBlock msgCont, - Object obj) - { - this.obj_ = obj; - this.type_ = msgType; - this.cont_ = msgCont; - this.flags_ = 0; - this.priority_ = 0; - this.next_ = null; - this.prev_ = null; - } - - /** - * Set message flags. Note that the flags will be set on top of - * already set flags. - *@param moreFlags flags to set for the Message Block. - */ - public long setFlags (long moreFlags) - { - // Later we might mask more_flags so that user can't change - // internal ones: more_flags &= ~(USER_FLAGS -1). - this.flags_ = ACE.SET_BITS (this.flags_, moreFlags); - return this.flags_; - } - - /** - * Unset message flags. - *@param lessFlags flags to unset for the Message Block. - */ - public long clrFlags (long lessFlags) - { - // Later we might mask more_flags so that user can't change - // internal ones: less_flags &= ~(USER_FLAGS -1). - this.flags_ = ACE.CLR_BITS (this.flags_, lessFlags); - return this.flags_; - } - - /** - * Get the message flags. - *@return Message flags - */ - public long flags () - { - return this.flags_; - } - - /** - * Get the type of the message. - *@return message type - */ - public int msgType () - { - return this.type_; - } - - /** - * Set the type of the message. - *@param t type of the message - */ - public void msgType (int t) - { - this.type_ = t; - } - - /** - * Get the class of the message. Note there are two classes, - * <normal> messages and <high-priority> messages. - *@return message class - */ - public int msgClass () - { - return this.msgType () >= MessageType.MB_PRIORITY - ? MessageType.MB_PRIORITY : MessageType.MB_NORMAL; - } - - /** - * Find out if the message is a data message. - *@return true if message is a data message, false otherwise - */ - public boolean isDataMsg () - { - int mt = this.msgType (); - return mt == MessageType.MB_DATA - || mt == MessageType.MB_PROTO - || mt == MessageType.MB_PCPROTO; - } - - /** - * Find out if the message is an object message. - *@return true if message is an object message, false otherwise - */ - public boolean isObjMsg () - { - int mt = this.msgType (); - return mt == MessageType.MB_OBJECT - || mt == MessageType.MB_PROTO - || mt == MessageType.MB_PCPROTO; - } - - /** - * Get the priority of the message. - *@return message priority - */ - public long msgPriority () - { - return this.priority_; - } - - /** - * Set the priority of the message. - *@param pri priority of the message - */ - public void msgPriority (long pri) - { - this.priority_ = pri; - } - - /** - * Get message data. This assumes that msgType is MB_DATA. - *@return message data - */ - public String base () - { - // Create a String object to return - char temp[] = new char [this.base_.length ()]; - this.base_.getChars (0, this.base_.length (), temp, 0); - return new String (temp); - } - - /** - * Set the message data. This assumes that msgType is MB_DATA. - *@param data message data - *@param msgFlags message flags - */ - public void base (String data, - long msgFlags) - { - this.base_ = new StringBuffer (data); - this.flags_ = msgFlags; - } - - /** - * Get message object. This assumes that msgType is MB_OBJECT. - *@return message object - */ - public Object obj () - { - return this.obj_; - } - - /** - * Set the message object. This assumes that msgType is MB_OBJECT. - *@param object message object - *@param msgFlags message flags - */ - public void obj (Object obj, - long msgFlags) - { - this.obj_ = obj; - this.flags_ = msgFlags; - } - - // = The following four methods only make sense if the Message_Block - // is of type MB_DATA and not MB_OBJECT. - - /** - * Get length of the message. This method only makes sense if the - * MessageBlock is of type MB_DATA and not MB_OBJECT. - *@return length of the message. - */ - public int length () - { - return this.base_.length (); - } - - /** - * Set the length of the message. This method only makes sense if the - * MessageBlock is of type MB_DATA and not MB_OBJECT. - *@param n message length - */ - public void length (int n) - { - this.base_.setLength (n); - } - - /** - * Get size of the allocated buffer for the message. This method - * only makes sense if the MessageBlock is of type MB_DATA and not - * MB_OBJECT. - *@return size of the message buffer - */ - public int size () - { - return this.base_.capacity (); - } - - /** - * Set the total size of the buffer. This method will grow the - * buffer if need be. Also, this method only makes sense if the - * MessageBlock is of type MB_DATA and not MB_OBJECT. - *@param n size of message buffer - */ - public void size (int n) - { - this.base_.ensureCapacity (n); - } - - - /** - * Get the continuation field. The coninuation field is used to - * chain together composite messages. - *@return the continuation field - */ - public MessageBlock cont () - { - return this.cont_; - } - - /** - * Set the continuation field. The coninuation field is used to - * chain together composite messages. - *@param msgCont continuation field - */ - void cont (MessageBlock msgCont) - { - this.cont_ = msgCont; - } - - /** - * Get link to next message. The next message points to the - * <MessageBlock> directly ahead in the MessageQueue. - *@return next message block - */ - MessageBlock next () - { - return this.next_; - } - - /** - * Set link to next message. The next message points to the - * <MessageBlock> directly ahead in the MessageQueue. - *@param msgBlock next message block - */ - void next (MessageBlock msgBlock) - { - this.next_ = msgBlock; - } - - /** - * Get link to previous message. The previous message points to the - * <MessageBlock> directly before in the MessageQueue. - *@return previous message block - */ - MessageBlock prev () - { - return this.prev_; - } - - /** - * Set link to previous message. The previous message points to the - * <MessageBlock> directly before in the MessageQueue. - *@param msgBlock previous message block - */ - void prev (MessageBlock msgBlock) - { - this.prev_ = msgBlock; - } - - private int type_; - // Type of message. - - private long flags_; - // Misc flags. - - private long priority_; - // Priority of message. - - private StringBuffer base_; - // String data of message block (initialized to null). - - private Object obj_; - // Object data of message block (initialized to null). - - private MessageBlock cont_; - // Next message block in the chain. - - private MessageBlock next_; - // Next message in the list. - - private MessageBlock prev_; - // Previous message in the list. - -} - diff --git a/java/src/MessageQueue.java b/java/src/MessageQueue.java deleted file mode 100644 index f71c91ca857..00000000000 --- a/java/src/MessageQueue.java +++ /dev/null @@ -1,626 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * MessageQueue.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import java.util.Date; -import JACE.OS.*; -import JACE.Reactor.*; - -class NotFullCondition extends TimedWait -{ - public NotFullCondition (MessageQueue mq) - { - super (mq); - this.mq_ = mq; - } - - public boolean condition () { - // Delegate to the appropriate conditional - // check on the MessageQueue. - return !this.mq_.isFull (); - } - private MessageQueue mq_; -} - -class NotEmptyCondition extends TimedWait -{ - public NotEmptyCondition (MessageQueue mq) - { - super (mq); - this.mq_ = mq; - } - - public boolean condition () { - // Delegate to the appropriate conditional - // check on the MessageQueue. - return !this.mq_.isEmpty (); - } - private MessageQueue mq_; -} - - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * A thread-safe message queueing facility, modeled after the - * queueing facilities in System V StreamS. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *</blockquote> - * <tt>MessageQueue</tt> is the central queueing facility for messages - * in the ASX framework. All operations are thread-safe, as it is intended - * to be used for inter-thread communication (<em>e.g.</em>, a producer and - * consumer thread joined by a <tt>MessageQueue</tt>). The queue - * consiste of <tt>MessageBlock</tt>s. - *</blockquote> - * - *@see MessageBlock,TimeValue - */ -public class MessageQueue -{ - /** - * Default constructor - */ - public MessageQueue () - { - this (DEFAULT_HWM, DEFAULT_LWM); - } - - /** - * Create a Message Queue with high and low water marks. - *@param hwm High water mark (max number of bytes allowed in the - * queue) - *@param lwm Low water mark (min number of bytes in the queue) - */ - public MessageQueue (int hwm, int lwm) - { - if (this.open (hwm, lwm) == -1) - ACE.ERROR ("open"); - } - - /** - * Initialize a Message Queue with high and low water marks. - *@param hwm High water mark (max number of bytes allowed in the - * queue) - *@param lwm Low water mark (min number of bytes in the queue) - */ - public synchronized int open (int hwm, int lwm) - { - this.highWaterMark_ = hwm; - this.lowWaterMark_ = lwm; - this.deactivated_ = false; - this.currentBytes_ = 0; - this.currentCount_ = 0; - this.tail_ = null; - this.head_ = null; - return 0; - } - - // = For enqueue, enqueueHead, enqueueTail, and dequeueHead if - // timeout is specified, the caller will wait for amount of time in - // tv. Calls will return, however, when queue is closed, - // deactivated, or if the time specified in tv elapses. - - /** - * Enqueue a <MessageBlock> into the <MessageQueue> in accordance - * with its <msgPriority> (0 is lowest priority). Note that the - * call will block (unless the queue has been deactivated). - *@param newItem item to enqueue onto the Message Queue - *@return -1 on failure, else the number of items still on the queue. - */ - public synchronized int enqueue (MessageBlock newItem) throws InterruptedException - { - return this.enqueue (newItem, null); - } - - /** - * Enqueue a <MessageBlock> into the <MessageQueue> in accordance - * with its <msgPriority> (0 is lowest priority). Note that the - * call will return if <timeout> amount of time expires or if the - * queue has been deactivated. - *@param newItem item to enqueue onto the Message Queue - *@param tv amount of time (TimeValue) to wait before returning - * (unless operation completes before) - *@return -1 on failure, else the number of items still on the - * queue. - */ - public synchronized int enqueue (MessageBlock newItem, - TimeValue tv) throws InterruptedException - { - int result = -1; - if (this.deactivated_) - return -1; - try - { - if (tv == null) // Need to do a blocking wait - notFullCondition_.timedWait (); - else // Need to do a timed wait - notFullCondition_.timedWait (tv); - } - catch (TimeoutException e) - { - return -1; - } - - // Check again if queue is still active - if (this.deactivated_) - return -1; - else - result = this.enqueueInternal (newItem); - - // Tell any blocked threads that the queue has a new item! - this.notEmptyCondition_.broadcast (); - return result; - } - - /** - * Enqueue a <MessageBlock> at the end of the <MessageQueue>. Note - * that the call will block (unless the queue has been deactivated). - *@param newItem item to enqueue onto the Message Queue - *@return -1 on failure, else the number of items still on the queue. - */ - public synchronized int enqueueTail (MessageBlock newItem) throws InterruptedException - { - return this.enqueueTail (newItem, null); - } - - /** - * Enqueue a <MessageBlock> at the end of the <MessageQueue>. Note - * that the call will return if <timeout> amount of time expires or - * if the queue has been deactivated. - *@param newItem item to enqueue onto the Message Queue - *@param tv amount of time (TimeValue) to wait before returning - * (unless operation completes before) - *@return -1 on failure, else the number of items still on the queue. - */ - public synchronized int enqueueTail (MessageBlock newItem, - TimeValue tv) throws InterruptedException - { - int result = -1; - if (this.deactivated_) - return -1; - try - { - if (tv == null) // Need to do a blocking wait - notFullCondition_.timedWait (); - else // Need to do a timed wait - notFullCondition_.timedWait (tv); - } - catch (TimeoutException e) - { - return -1; - } - - // Check again if queue is still active - if (this.deactivated_) - return -1; - else - result = this.enqueueTailInternal (newItem); - - // Tell any blocked threads that the queue has a new item! - this.notEmptyCondition_.broadcast (); - return result; - } - - /** - * Enqueue a <MessageBlock> at the head of the <MessageQueue>. Note - * that the call will block (unless the queue has been deactivated). - *@param newItem item to enqueue onto the Message Queue - *@return -1 on failure, else the number of items still on the queue. - */ - public synchronized int enqueueHead (MessageBlock newItem) throws InterruptedException - { - return this.enqueueHead (newItem, null); - } - - /** - * Enqueue a <MessageBlock> at the head of the <MessageQueue>. Note - * that the call will return if <timeout> amount of time expires or - * if the queue has been deactivated. - *@param newItem item to enqueue onto the Message Queue - *@param tv amount of time (TimeValue) to wait before returning - * (unless operation completes before) - *@return -1 on failure, else the number of items still on the queue. - */ - public synchronized int enqueueHead (MessageBlock newItem, - TimeValue tv) throws InterruptedException - { - int result = -1; - if (this.deactivated_) - return -1; - try - { - if (tv == null) // Need to do a blocking wait - notFullCondition_.timedWait (); - else // Need to do a timed wait - notFullCondition_.timedWait (tv); - } - catch (TimeoutException e) - { - return -1; - } - - // Check again if queue is still active - if (this.deactivated_) - return -1; - else - result = this.enqueueHeadInternal (newItem); - - // Tell any blocked threads that the queue has a new item! - this.notEmptyCondition_.broadcast (); - return result; - } - - /** - * Dequeue and return the <MessageBlock> at the head of the - * <MessageQueue>. Note that the call will block (unless the queue - * has been deactivated). - *@return null on failure, else the <MessageBlock> at the head of queue. - */ - public synchronized MessageBlock dequeueHead () throws InterruptedException - { - return this.dequeueHead (null); - } - - /** - * Dequeue and return the <MessageBlock> at the head of the - * <MessageQueue>. Note that the call will return if <timeout> - * amount of time expires or if the queue has been deactivated. - *@return null on failure, else the <MessageBlock> at the head of queue. - */ - public synchronized MessageBlock dequeueHead (TimeValue tv) throws InterruptedException - { - MessageBlock result = null; - if (this.deactivated_) - return null; - try - { - if (tv == null) // Need to do a blocking wait - notEmptyCondition_.timedWait (); - else // Need to do a timed wait - notEmptyCondition_.timedWait (tv); - } - catch (TimeoutException e) - { - return null; - } - - // Check again if queue is still active - if (this.deactivated_) - return null; - else - result = this.dequeueHeadInternal (); - - // Tell any blocked threads that the queue has room for an item! - this.notFullCondition_.broadcast (); - return result; - } - - /** - * Check if queue is full. - *@return true if queue is full, else false. - */ - public synchronized boolean isFull () - { - return this.isFullInternal (); - } - - /** - * Check if queue is empty. - *@return true if queue is empty, else false. - */ - public synchronized boolean isEmpty () - { - return this.isEmptyInternal (); - } - - /** - * Get total number of bytes on the queue. - *@return total number number of bytes on the queue - */ - public int messageBytes () - { - return this.currentBytes_; - } - - /** - * Get total number of messages on the queue. - *@return total number number of messages on the queue - */ - public int messageCount () - { - return this.currentCount_; - } - - // = Flow control routines - - /** - * Get high watermark. - *@return high watermark - */ - public int highWaterMark () - { - return this.highWaterMark_; - } - - /** - * Set high watermark. - *@param hwm high watermark - */ - public void highWaterMark (int hwm) - { - this.highWaterMark_ = hwm; - } - - /** - * Get low watermark. - *@return low watermark - */ - public int lowWaterMark () - { - return this.lowWaterMark_; - } - - /** - * Set low watermark. - *@param lwm low watermark - */ - public void lowWaterMark (int lwm) - { - this.lowWaterMark_ = lwm; - } - - // = Activation control methods. - - /** - * Deactivate the queue and wakeup all threads waiting on the queue - * so they can continue. No messages are removed from the queue, - * however. Any other operations called until the queue is - * activated again will immediately return -1. - *@return WAS_INACTIVE if queue was inactive before the call and - * WAS_ACTIVE if queue was active before the call. - */ - public synchronized int deactivate () - { - return this.deactivateInternal (); - } - - - /** - * Reactivate the queue so that threads can enqueue and dequeue - * messages again. - *@return WAS_INACTIVE if queue was inactive before the call and - * WAS_ACTIVE if queue was active before the call. - */ - public synchronized int activate () - { - return this.activateInternal (); - } - - protected boolean isEmptyInternal () - { - // Not sure about this one!!!! - return this.currentBytes_ <= this.lowWaterMark_ && this.currentCount_ <= 0; - } - - protected boolean isFullInternal () - { - return this.currentBytes_ > this.highWaterMark_; - } - - protected int deactivateInternal () - { - int currentStatus = - this.deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; - - this.notFullCondition_.broadcast (); - this.notEmptyCondition_.broadcast (); - - this.deactivated_ = true; - return currentStatus; - } - - protected int activateInternal () - { - int currentStatus = - this.deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; - this.deactivated_ = false; - - return currentStatus; - } - - protected int enqueueTailInternal (MessageBlock newItem) - { - if (newItem == null) - return -1; - - // List was empty, so build a new one. - if (this.tail_ == null) - { - this.head_ = newItem; - this.tail_ = newItem; - newItem.next (null); - newItem.prev (null); - } - // Link at the end. - else - { - newItem.next (null); - this.tail_.next (newItem); - newItem.prev (this.tail_); - this.tail_ = newItem; - } - - if (newItem.msgType() != MessageType.MB_OBJECT) - { - // Make sure to count *all* the bytes in a composite message!!! - for (MessageBlock temp = newItem; - temp != null; - temp = temp.cont ()) - this.currentBytes_ += temp.size (); - } - - this.currentCount_++; - return this.currentCount_; - } - - protected int enqueueHeadInternal (MessageBlock newItem) - { - if (newItem == null) - return -1; - - newItem.prev (null); - newItem.next (this.head_); - - if (this.head_ != null) - this.head_.prev (newItem); - else - this.tail_ = newItem; - - this.head_ = newItem; - - if (newItem.msgType() != MessageType.MB_OBJECT) - { - // Make sure to count *all* the bytes in a composite message!!! - for (MessageBlock temp = newItem; - temp != null; - temp = temp.cont ()) - this.currentBytes_ += temp.size (); - } - - this.currentCount_++; - - return this.currentCount_; - } - - protected int enqueueInternal (MessageBlock newItem) - { - if (newItem == null) - return -1; - - if (this.head_ == null) - // Check for simple case of an empty queue, where all we need to - // do is insert <newItem> into the head. - return this.enqueueHeadInternal (newItem); - else - { - MessageBlock temp; - - // Figure out where the new item goes relative to its priority. - - for (temp = this.head_; - temp != null; - temp = temp.next ()) - { - if (temp.msgPriority () <= newItem.msgPriority ()) - // Break out when we've located an item that has lower - // priority that <newItem>. - break; - } - - if (temp == null) - // Check for simple case of inserting at the end of the queue, - // where all we need to do is insert <newItem> after the - // current tail. - return this.enqueueTailInternal (newItem); - else if (temp.prev () == null) - // Check for simple case of inserting at the beginning of the - // queue, where all we need to do is insert <newItem> before - // the current head. - return this.enqueueHeadInternal (newItem); - else - { - // Insert the message right before the item of equal or lower - // priority. - newItem.next (temp); - newItem.prev (temp.prev ()); - temp.prev ().next (newItem); - temp.prev (newItem); - } - } - - if (newItem.msgType() != MessageType.MB_OBJECT) - { - // Make sure to count *all* the bytes in a composite message!!! - for (MessageBlock temp = newItem; - temp != null; - temp = temp.cont ()) - this.currentBytes_ += temp.size (); - } - - this.currentCount_++; - return this.currentCount_; - } - - protected MessageBlock dequeueHeadInternal () - { - MessageBlock firstItem = this.head_; - this.head_ = this.head_.next (); - - if (this.head_ == null) - this.tail_ = null; - - if (firstItem.msgType() != MessageType.MB_OBJECT) - { - // Make sure to subtract off all of the bytes associated with this - // message. - for (MessageBlock temp = firstItem; - temp != null; - temp = temp.cont ()) - this.currentBytes_ -= temp.size (); - } - - this.currentCount_--; - return firstItem; - } - - - /** Default high watermark (16 K). */ - public final static int DEFAULT_HWM = 16 * 1024; - - /** Default low watermark. */ - public final static int DEFAULT_LWM = 0; - - /** Message queue was active before activate() or deactivate(). */ - public final static int WAS_ACTIVE = 1; - - /** Message queue was inactive before activate() or deactivate(). */ - public final static int WAS_INACTIVE = 2; - - private int highWaterMark_; - // Greatest number of bytes before blocking. - - private int lowWaterMark_; - // Lowest number of bytes before unblocking occurs. - - private boolean deactivated_; - // Indicates that the queue is inactive. - - private int currentBytes_; - // Current number of bytes in the queue. - - private int currentCount_; - // Current number of messages in the queue. - - private MessageBlock head_; - // Head of Message_Block list. - - private MessageBlock tail_; - // Tail of Message_Block list. - - // The Delegated Notification mechanisms. - private NotFullCondition notFullCondition_ = new NotFullCondition (this); - private NotEmptyCondition notEmptyCondition_ = new NotEmptyCondition (this); - -} diff --git a/java/src/MessageType.java b/java/src/MessageType.java deleted file mode 100644 index 62c34455854..00000000000 --- a/java/src/MessageType.java +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * MessageType.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Message types used by ACE.MessageBlock. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * Defines bit masks used to identify various types of messages. - *</blockquote> - * - *<h2>NOTES</h2> - *<blockquote> - * This class is not intended to be instantiable. - *</blockquote> - */ -public class MessageType -{ - // = Data and protocol messages (regular and priority) - /** regular data */ - public static final int MB_DATA = 0x01; - - /** protocol control */ - public static final int MB_PROTO = 0x02; - - /** regular data */ - public static final int MB_OBJECT = 0x09; - - - // = Control messages (regular and priority) - /** line break */ - public static final int MB_BREAK = 0x03; - - /** pass file pointer */ - public static final int MB_PASSFP = 0x04; - - /** post an event to an event queue */ - public static final int MB_EVENT = 0x05; - - /** generate process signal */ - public static final int MB_SIG = 0x06; - - /** ioctl; set/get params */ - public static final int MB_IOCTL = 0x07; - - /** set various stream head options */ - public static final int MB_SETOPTS = 0x08; - - - // = Control messages (high priority; go to head of queue) - /** acknowledge ioctl */ - public static final int MB_IOCACK = 0x81; - - /** negative ioctl acknowledge */ - public static final int MB_IOCNAK = 0x82; - - /** priority proto message */ - public static final int MB_PCPROTO = 0x83; - - /** generate process signal */ - public static final int MB_PCSIG = 0x84; - - /** generate read notification */ - public static final int MB_READ = 0x85; - - /** flush your queues */ - public static final int MB_FLUSH = 0x86; - - /** stop transmission immediately */ - public static final int MB_STOP = 0x87; - - /** restart transmission after stop */ - public static final int MB_START = 0x88; - - /** line disconnect */ - public static final int MB_HANGUP = 0x89; - - /** fatal error used to set u.u_error */ - public static final int MB_ERROR = 0x8a; - - /** post an event to an event queue */ - public static final int MB_PCEVENT = 0x8b; - - - /** Normal priority messages */ - public static final int MB_NORMAL = 0x00; - - /** High priority control messages */ - public static final int MB_PRIORITY = 0x80; - - // Default private constructor to avoid instantiation - private MessageType () - { - } -} - diff --git a/java/src/Module.java b/java/src/Module.java deleted file mode 100644 index 6eb56bcbf43..00000000000 --- a/java/src/Module.java +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * Module.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Provides an abstraction for managing a bi-directional flow of - * messages. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This is based on the Module concept in System V Streams, - * which contains a pair of Tasks, one for handling upstream - * processing, one for handling downstream processing. - *</blockquote> - */ -public class Module -{ - // = Initialization and termination methods. - - /** - * Create an empty Module. - */ - public Module () - { - // Do nothing... - this.name ("<unknown>"); - } - - /* - * Create an initialized module. - *@param modName identity of the module. - *@param writerQ writer task of the module. - *@param readerQ reader task of the module. - *@param flags Module flags - */ - public Module (String modName, - Task writerQ, - Task readerQ, - Object flags) - { - this.open (modName, writerQ, readerQ, flags); - } - - /* - * Create an initialized module. - *@param modName identity of the module. - *@param writerQ writer task of the module. - *@param readerQ reader task of the module. - *@param flags Module flags - */ - public void open (String modName, - Task writerQ, - Task readerQ, - Object arg) - { - this.name (modName); - this.arg_ = arg; - - if (writerQ == null) - writerQ = new ThruTask (); - if (readerQ == null) - readerQ = new ThruTask (); - - this.reader (readerQ); - this.writer (writerQ); - - // Setup back pointers. - readerQ.module (this); - writerQ.module (this); - } - - - /* - * Set the writer task. - *@param q the writer task - */ - public void writer (Task q) - { - this.qPair_[1] = q; - if (q != null) - q.flags (ACE.CLR_BITS (q.flags (), TaskFlags.ACE_READER)); - } - - /* - * Set the reader task. - *@param q the reader task - */ - public void reader (Task q) - { - this.qPair_[0] = q; - if (q != null) - q.flags (ACE.SET_BITS (q.flags (), TaskFlags.ACE_READER)); - } - - /* - * Link this Module on top of Module. - *@param m the module to link this on top of. - */ - public void link (Module m) - { - this.next (m); - this.writer ().next (m.writer ()); - m.reader ().next (this.reader ()); - } - - /* - * Set and get pointer to sibling Task in Module. - *@param orig the task to get the sibling for - *@return the sibling of the task - */ - public Task sibling (Task orig) - { - if (this.qPair_[0] == orig) - return this.qPair_[1]; - else if (this.qPair_[1] == orig) - return this.qPair_[0]; - else - return null; - } - - /* - * Close down the module and its tasks. - *@param flags Module flags - *@return 0 on success, -1 on failure - */ - public int close (long flags) - { - Task readerQ = this.reader (); - Task writerQ = this.writer (); - int result = 0; - - if (readerQ != null) - { - if (readerQ.close (flags) == -1) - result = -1; - readerQ.flush (flags); - readerQ.next (null); - } - - if (writerQ != null) - { - if (writerQ.close (flags) == -1) - result = -1; - writerQ.flush (flags); - writerQ.next (null); - } - - return result; - } - - /* - * Get the argument passed to tasks. - *@return the argument passed to tasks. - */ - public Object arg () - { - return this.arg_; - } - - /* - * Set the argument to be passed to tasks. - *@param a the argument to be passed to tasks. - */ - public void arg (Object a) - { - this.arg_ = a; - } - - /* - * Get the name of the module. - *@return the name of the module. - */ - public String name () - { - return this.name_; - } - - /* - * Set the name of the module. - *@param n the name of the module. - */ - public void name (String n) - { - this.name_ = n; - } - - /* - * Get the writer task of the module. - *@return the writer task of the module. - */ - public Task writer () - { - return this.qPair_[1]; - } - - /* - * Get the reader task of the module. - *@return the reader task of the module. - */ - public Task reader () - { - return this.qPair_[0]; - } - - /* - * Get the next pointer to the module above in the stream. - *@return the next pointer to the module above in the stream. - */ - public Module next () - { - return this.next_; - } - - /* - * Set the next pointer to the module above in the stream. - *@param m the next pointer to the module above in the stream. - */ - public void next (Module m) - { - this.next_ = m; - } - - private Task qPair_[] = new Task[2]; - // Pair of Tasks that form the "read-side" and "write-side" of the - // ACE_Module partitioning. - - private String name_ = null; - // Name of the ACE_Module. - - private Module next_; - // Next ACE_Module in the stack. - - private Object arg_; - // Argument passed through to the reader and writer task when they - // are opened. - -} - diff --git a/java/src/Mutex.java b/java/src/Mutex.java deleted file mode 100644 index 8daab4ff9eb..00000000000 --- a/java/src/Mutex.java +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * Mutex.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Concurrency; - -import java.util.*; -import JACE.ASX.*; - -class TimedWaitMAdapter extends TimedWait -{ - TimedWaitMAdapter (Object obj) - { - super (obj); - } - - // Check to see if the lock is currently held or not. - public boolean condition () - { - return !this.inUse_; - } - - // Acquire/Release the lock - public void inUse (boolean c) - { - this.inUse_ = c; - } - - private boolean inUse_ = false; - // The actual lock -} - - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Value added abstraction for mutex variable creation. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * A timed mutex, <em>i.e.</em> a mutex whose operations do not - * block forever and can <q>time out</q>. - *</blockquote> - */ -public class Mutex -{ - /** - * Acquire the mutex. Note that this will block. - *@exception InterruptedException exception during wait - */ - public synchronized void acquire () throws InterruptedException - { - this.monitor_.timedWait (); - this.monitor_.inUse (true); - } - - /** - * Acquire the mutex. Note that the call will return if <timeout> - * amount of time expires. - *@param tv amount of time (TimeValue) to wait before returning - * (unless operation completes before) - *@exception TimeoutException wait timed out exception - *@exception InterruptedException exception during wait - */ - public synchronized void acquire (TimeValue tv) throws - TimeoutException, InterruptedException - { - this.monitor_.timedWait (tv); - this.monitor_.inUse (true); - } - - /** - * Release the mutex. - */ - public synchronized void release () - { - this.monitor_.inUse (false); - this.monitor_.signal (); - } - - private TimedWaitMAdapter monitor_ = new TimedWaitMAdapter (this); - // The monitor (adapter) to wait on -} diff --git a/java/src/OS.java b/java/src/OS.java deleted file mode 100644 index c17fd6d07f2..00000000000 --- a/java/src/OS.java +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.OS - * - * = FILENAME - * OS.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.OS; - -import java.util.StringTokenizer; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Methods to extend the capabilities of the Java runtime system. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This non-instantiable class contains little <q>utility functions</q> - * that should have been in Java to begin with :-) - *</blockquote> - */ -public class OS -{ - /** - * Create an array of Strings from a single String using <delim> as - * the delimiter. - *@param args the String to break up to make an array of Strings - *@param delim the delimeter to use to break the String up - *@return an array containing the original String broken up - */ - public static String [] createStringArray (String args, String delim) - { - // First determine the number of arguments - int count = 0; - StringTokenizer tokens = new StringTokenizer (args, delim); - while (tokens.hasMoreTokens ()) - { - tokens.nextToken (); - count++; - } - if (count == 0) - return null; - - // Create argument array - String [] argArray = new String [count]; - int index = 0; - tokens = new StringTokenizer (args, " "); - while (tokens.hasMoreTokens ()) - { - argArray [index] = tokens.nextToken (); - index++; - } - - // Assert index == count - if (index != count) - return null; - else - return argArray; - } - - // Default private constructor to avoid instantiation - private OS () - { - } -} diff --git a/java/src/ProfileTimer.java b/java/src/ProfileTimer.java deleted file mode 100644 index b7e9c908a13..00000000000 --- a/java/src/ProfileTimer.java +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Timers - * - * = FILENAME - * ProfileTimer.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Timers; - -/** - * <hr> - * <p><b>TITLE</b><br> - * A Java wrapper for interval timers. - */ -public class ProfileTimer -{ - /** - * Start the timer. - */ - public void start () - { - this.startTime_ = java.lang.System.currentTimeMillis (); - } - - /** - * Stop the timer. - */ - public void stop () - { - this.stopTime_ = java.lang.System.currentTimeMillis (); - } - - /** - * Determine elapsed time between start and stop. - *@return Total elapsed time (stop - start). - */ - public long elapsedTime () - { - return this.stopTime_ - this.startTime_; - } - - private long startTime_; - private long stopTime_; -} diff --git a/java/src/RWMutex.java b/java/src/RWMutex.java deleted file mode 100644 index 1161d9a8618..00000000000 --- a/java/src/RWMutex.java +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * RWMutex.java - * - *@author Ross Dargahi (rossd@krinfo.com), Prashant Jain, and Irfan Pyarali - * - *************************************************/ - -package JACE.Concurrency; - -import JACE.OS.*; - -/******************************************************************************* -* <HR> -* <B> Description </B> -* <BR> -* This class increments a read/write lock. A read/write lock allows multiple -* readers or a single writer to access the guarded element. -* This implementation is based on the C++ version of ACE. -* </PRE><P><HR> -* <B> Notes </B> -* <UL> -* <LI> This class does not support recursive semantics -* </UL> -*******************************************************************************/ -public class RWMutex -{ - /** - * Acquires the write lock - * @exception InterruptedException Lock acquisition interrupted - **/ - public void acquire() - throws InterruptedException - { - acquireWrite(); - } - - /** - * Acquires the read lock - * @exception InterruptedException Lock acquisition interrupted - **/ - public void acquireRead() - throws InterruptedException - { - // make sure we start with no exception - InterruptedException exception_ = null; - - // grab lock - lock_.acquire (); - - // Give preference to writers who are waiting. - while (referenceCount_ < 0 || numberOfWaitingWriters_ > 0) - { - numberOfWaitingReaders_++; - try - { - waitingReaders_.Wait (); - } - catch (InterruptedException exception) - { - // cache exception - exception_ = exception; - } - numberOfWaitingReaders_--; - } - - if (exception_ == null) - // No errors - referenceCount_++; - - // make sure this is released in all cases - lock_.release (); - - if (exception_ != null) - // error: propogate - throw exception_; - } - - /** - * Acquires the write lock - * @exception InterruptedException Lock acquisition interrupted - **/ - public void acquireWrite() - throws InterruptedException - { - // make sure we start with no exception - InterruptedException exception_ = null; - - // grab lock - lock_.acquire (); - - // Give preference to writers who are waiting. - while (referenceCount_ != 0) - { - numberOfWaitingWriters_++; - try - { - waitingWriters_.Wait (); - } - catch (InterruptedException exception) - { - // cache exception - exception_ = exception; - } - numberOfWaitingWriters_--; - } - - if (exception_ == null) - // No errors - referenceCount_ = -1; - - // make sure this is released in all cases - lock_.release (); - - if (exception_ != null) - // error: propogate - throw exception_; - } - - /** - * Release held lock - * @exception InterruptedException Lock acquisition interrupted - **/ - public void release() - throws InterruptedException - { - lock_.acquire (); - - // Releasing a reader. - if (referenceCount_ > 0) - referenceCount_--; - else - // Releasing a writer. - if (referenceCount_ == -1) - referenceCount_ = 0; - - // Give preference to writers over readers... - if (numberOfWaitingWriters_ > 0) - { - waitingWriters_.signal (); - } - else if (numberOfWaitingReaders_ > 0) - { - waitingReaders_.broadcast (); - } - - - lock_.release (); - } - - private Mutex lock_ = new Mutex (); - // Serialize access to internal state. - - private Condition waitingReaders_ = new Condition (lock_); - // Reader threads waiting to acquire the lock. - - private int numberOfWaitingReaders_; - // Number of waiting readers. - - private Condition waitingWriters_ = new Condition (lock_); - // Writer threads waiting to acquire the lock. - - private int numberOfWaitingWriters_ = 0; - // Number of waiting writers. - - private int referenceCount_ = 0; - // Value is -1 if writer has the lock, else this keeps track of the - // number of readers holding the lock. -} - diff --git a/java/src/Readme b/java/src/Readme deleted file mode 100644 index 73220d55de4..00000000000 --- a/java/src/Readme +++ /dev/null @@ -1,17 +0,0 @@ -Make sure to update the environment variable CLASSPATH to include the -path to where java/classes/ is located. The Java compiler uses this to -find classes when resolving dependencies. - -The Makefile has been worked over severely, and it now REQUIRES GNU -Make. The makefile is still a little rough, and will definitely -evolve. - -Suggestions are welcome at cleeland@cs.wustl.edu or pjain@cs.wustl.edu. - -Also, TimeValue moved from the ACE.Reactor to ACE.ASX package to break -up some circular dependency problems. - -The documentation for Java ACE has not been included in the release -but can be automatically generated by typing "make doc" in the src -directory. Note that the gif images needed by the documentaion ARE -included in the release. diff --git a/java/src/SOCKAcceptor.java b/java/src/SOCKAcceptor.java deleted file mode 100644 index aaca725426a..00000000000 --- a/java/src/SOCKAcceptor.java +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.SOCK_SAP - * - * = FILENAME - * SOCKAcceptor.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; - -/** - * <hr> - * <p><b>TITLE</b><br> - * Defines the format and interface for an ACE.SOCKAcceptor. - */ -public class SOCKAcceptor -{ - // = Initialization - - /** - * Create a SOCKAcceptor. Do nothing constructor. Allows user to - * call open() later and pass in the port number. - */ - public SOCKAcceptor () - { - } - - /** - * Create a SOCKAcceptor. - *@param port port number where the server will listen for connections - */ - public SOCKAcceptor (int port) throws IOException - { - this.open (port); - } - - /** - * Create socket to listen for connections on. - *@param port port number where the server will listen for connections - */ - public void open(int port) throws IOException - { - // Close old socket (if there is one) - this.close (); - - // Create a new server socket - this.listenSocket_ = new ServerSocket (port); - // ACE.DEBUG ("Server listening on port " + port); - } - - /** - * Close the socket and do any necessary cleanup. - */ - public void close () throws IOException - { - if (this.listenSocket_ != null) - { - this.listenSocket_.close (); - this.listenSocket_ = null; - } - } - - /** - * Accept a connection. The streams are set when the method returns. - *@param sockStream SOCK Stream to use for the connection - */ - public void accept (SOCKStream sockStream) throws SocketException, IOException - { - // Block in accept. Returns when a connection shows up and sets - // the streams - sockStream.socket (this.listenSocket_.accept ()); - ACE.DEBUG ("Accepted connection from " + - sockStream.socket ().getInetAddress ()); - } - - /** - * Get the underlying listen socket. - *@return the underlying listen socket - */ - public ServerSocket listenSocket () - { - return this.listenSocket_; - } - - /** - * Set the underlying listen socket. - *@param s the underlying listen socket - */ - public void listenSocket (ServerSocket s) - { - this.listenSocket_ = s; - } - - /** - * Clean up when the garbage collector gets run (if at all). Note - * that there is no guarantee that finalize () will get called. - */ - protected void finalize () throws Throwable - { - super.finalize (); - this.close (); - } - - // Socket on which listen for connections (by default initialized to - // null) - private ServerSocket listenSocket_; -} diff --git a/java/src/SOCKConnector.java b/java/src/SOCKConnector.java deleted file mode 100644 index 98dfcaf6b3d..00000000000 --- a/java/src/SOCKConnector.java +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.SOCK_SAP - * - * = FILENAME - * SOCKConnector.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; - -/** - * <hr> - * <p><b>TITLE</b><br> - * Defines an active connection factory for the socket wrappers. - */ -public class SOCKConnector -{ - // = Initialization - - /** - * Create a SOCKConnector. Do nothing constructor. Allows user to - * call connect() later. - */ - public SOCKConnector () - { - // Do nothing constructor - } - - /** - * Create a SOCKConnector and connect to the server. - *@param sockStream SOCK Stream to use for the connection - *@param hostname hostname of the server - *@param port port number to connect with server at - */ - public SOCKConnector (SOCKStream sockStream, - String hostname, - int port) throws SocketException, IOException - { - this.connect (sockStream, - hostname, - port); - } - - /** - * Connect to the server. - *@param sockStream SOCK Stream to use for the connection - *@param hostname hostname of the server - *@param port port number to connect with server at - */ - public void connect (SOCKStream sockStream, - String hostname, - int port) throws SocketException, IOException - { - sockStream.socket (new Socket (hostname, port)); - } - - /** - * Connect to the server. - *@param sockStream SOCK Stream to use for the connection - *@param addr INETAddr instance specifying host/port - */ - public void connect (SOCKStream sockStream, - INETAddr addr) throws SocketException, IOException - { - sockStream.socket (new Socket (addr.getHostName(), - addr.getPortNumber())); - } -} diff --git a/java/src/SOCKStream.java b/java/src/SOCKStream.java deleted file mode 100644 index 079dcb05c3c..00000000000 --- a/java/src/SOCKStream.java +++ /dev/null @@ -1,196 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.SOCK_SAP - * - * = FILENAME - * SOCKStream.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; - -/** - * <hr> - * <p><b>TITLE</b><br> - * Defines the methods in the ACE.SOCKStream abstraction. - * - * <p><b>DESCRIPTION</b><br> - * This adds additional wrapper methods atop the java Socket class. - */ -public class SOCKStream -{ - /** - * Create a default SOCK Stream. Do nothing constructor. - */ - public SOCKStream () - { - } - - /** - * Create a SOCK Stream. - *@param s Socket to initialize SOCK Stream with. - */ - public SOCKStream (Socket s) throws IOException - { - this.socket (s); - } - - /** - * Set the socket and the underlying streams. - *@param s Socket associated with the SOCK Stream. - */ - public void socket (Socket s) throws IOException - { - this.socket_ = s; - // Note that if s is not a valid socket or is null, the - // following calls will throw exceptions - this.iStream_ = new DataInputStream (s.getInputStream ()); - this.oStream_ = new PrintStream (s.getOutputStream ()); - } - - /* Get the underlying Socket. - *@return the underlying socket - */ - public Socket socket () - { - return this.socket_; - } - - /** - * Close the streams and the underlying socket. - */ - public void close () throws IOException - { - if (this.socket_ != null) - this.socket_.close (); - this.socket_ = null; - } - - // = The following send and recv methods are overloaded to provide a - // flexible interface - - /** - * Send a StringBuffer. Note that the method blocks. - *@param s the StringBuffer to send - *@return the length of the StringBuffer - */ - public int send (StringBuffer s) throws IOException - { - // Get the data out - String buf = s.toString (); - this.oStream_.print (buf); - this.oStream_.flush (); - return buf.length (); - } - - /** - * Send a String. Note that the method blocks. - *@param s the String to send - *@return the length of the String - */ - public int send (String s) throws IOException - { - this.oStream_.print (s); - this.oStream_.flush (); - return s.length (); - } - - /** - * Send an array of bytes. Note that the method blocks. - *@param b array of bytes to send - *@param offset offset into the byte array to start sending from - *@param length number of bytes to send - *@return number of bytes sent - */ - public int sendN (byte[] b, int offset, int length) throws IOException - { - this.oStream_.write (b, offset, length); - this.oStream_.flush (); - return length; - } - - /** - * Receive data and append it to the StringBuffer that was passed - * in. Note that the method blocks. - *@param s the StringBuffer to append the result of the recv to - *@return the length of the String received - */ - public int recv (StringBuffer s) throws IOException - { - String temp = this.iStream_.readLine (); - s.append (temp); - return temp.length (); - } - - /** - * Receive an array of characters. This method blocks until either - * all the bytes are read, the end of the stream is detected, or - * an exception is thrown. - *@param b byte array to receive the data in - *@param offset the start offset of the data in the byte array. - *@param n number of bytes to receive - *@return n - */ - public int recvN (byte[] b, int offset, int n) throws IOException - { - this.iStream_.readFully (b, offset, n); - return n; - } - - /** - * Set the underlying input stream. - *@param iStream the input stream - */ - public void inputStream (InputStream iStream) - { - this.iStream_ = new DataInputStream (iStream); - } - - /** - * Get the underlying input stream. - *@return the underlying input stream - */ - public InputStream inputStream () - { - return this.iStream_; - } - - /** - * Set the underlying output stream. - *@param iStream the output stream - */ - public void outputStream (OutputStream oStream) - { - this.oStream_ = new PrintStream (oStream); - } - - /** - * Get the underlying output stream. - *@return the underlying output stream - */ - public OutputStream outputStream () - { - return this.oStream_; - } - - /** - * Cleanup when the SOCK Stream is garbage collected. - */ - protected void finalize () throws Throwable - { - super.finalize (); - this.close (); - } - - private Socket socket_; - - // = The input and output streams (by default null) - private DataInputStream iStream_; - private PrintStream oStream_; -} diff --git a/java/src/Semaphore.java b/java/src/Semaphore.java deleted file mode 100644 index 4762712d722..00000000000 --- a/java/src/Semaphore.java +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * Semaphore.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Concurrency; - -import java.util.*; -import JACE.ASX.*; - -class TimedWaitSAdapter extends JACE.ASX.TimedWait -{ - TimedWaitSAdapter (Object obj) - { - super (obj); - } - - // Check to see if there are any semaphores available. - public boolean condition () - { - return this.count_ > 0; - } - - // Increment the count by one - public void increment () - { - this.count_++; - } - - // Decrement the count by one - public void decrement () - { - this.count_--; - } - - // Set the count - public void count (int c) - { - this.count_ = c; - } - - private int count_ = 0; -} - -/** - * <hr> - * <h2>SYNOPSIS</h2> - * Implementation of Dijkstra's counting semaphore in java. - */ -public class Semaphore -{ - /** - * Create a Semaphore. - *@param count semaphore count - */ - public Semaphore (int c) - { - this.monitor_.count (c); - } - - /** - * Acquire the Semaphore. Note that this will block. - *@exception InterruptedException exception during wait - */ - public synchronized void acquire () throws InterruptedException - { - this.monitor_.timedWait (); - this.monitor_.decrement (); - } - - /** - * Acquire the Semaphore. Note that the call will return if <timeout> - * amount of time expires. - *@param tv amount of time (TimeValue) to wait before returning - * (unless operation completes before) - *@exception TimeoutException wait timed out exception - *@exception InterruptedException exception during wait - */ - public synchronized void acquire (TimeValue tv) - throws JACE.ASX.TimeoutException, InterruptedException - { - this.monitor_.timedWait (tv); - this.monitor_.decrement (); - } - - /** - * Release the Semaphore. - */ - public synchronized void release () - { - this.monitor_.increment (); - this.monitor_.signal (); - } - - private TimedWaitSAdapter monitor_ = new TimedWaitSAdapter (this); - // The monitor (adapter) to wait on -} diff --git a/java/src/ServiceConfig.java b/java/src/ServiceConfig.java deleted file mode 100644 index 74e8523d8c1..00000000000 --- a/java/src/ServiceConfig.java +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ServiceConfigurator - * - * = FILENAME - * ServiceConfig.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ServiceConfigurator; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Misc.*; - -/** - * <hr> - * <p><b>TITLE</b><br> - * Provide the base class that supplies common server daemon - * operations. - */ -public class ServiceConfig -{ - public static int open (String [] args) throws - FileNotFoundException, IOException, ClassNotFoundException, - IllegalAccessException, InstantiationException - { - ServiceConfig.parseArgs (args); - if (ServiceConfig.svcRep_ == null) - ServiceConfig.svcRep_ = new ServiceRepository (); - return ServiceConfig.processDirectives (); - } - - protected static int processDirectives () throws - FileNotFoundException, IOException, ClassNotFoundException, - IllegalAccessException, InstantiationException - { - File configFile = new File (ServiceConfig.serviceConfigFile_); - - // Check if file exists and is a normal file - if (!configFile.exists () || !configFile.isFile ()) - throw new FileNotFoundException ("File " + ServiceConfig.serviceConfigFile_ + " not found"); - - // Check if the file is readable - if (!configFile.canRead ()) - throw new IOException ("File " + ServiceConfig.serviceConfigFile_ + " not readable"); - - // Set up the stream - FileInputStream fileIn = new FileInputStream (configFile); - - // Parse the file - StreamTokenizer in = new StreamTokenizer (fileIn); - - // Set '#' as comment character to be ignored and set '/' as - // ordinary character (was original comment character) - // in.commentChar ('#'); - in.ordinaryChar ('/'); - - // Set characters in ASCII range 33 to 47, ASCII range 91 to 96, - // and ASCII range 123 to 126 as ordinary characters - in.wordChars ('!', '/'); // ASCII range 33 to 47 - in.wordChars (':', '@'); // ASCII range 58 to 64 - in.wordChars ('[', '`'); // ASCII range 91 to 96 - in.wordChars ('{', '~'); // ASCII range 123 to 126 - - String className = null; - String classType = null; - String args = null; - // Create a state machine - int state = ServiceConfig.CLASS_NAME; - - while (in.nextToken () != StreamTokenizer.TT_EOF) - { - switch (state) - { - case ServiceConfig.CLASS_NAME: - if (in.ttype == StreamTokenizer.TT_WORD) - className = in.sval; - else - throw new IOException ("Illegal CLASS NAME argument in file " + ServiceConfig.serviceConfigFile_); - state = ServiceConfig.CLASS_TYPE; - break; - case ServiceConfig.CLASS_TYPE: - if (in.ttype == StreamTokenizer.TT_WORD) - classType = in.sval; - else - throw new IOException ("Illegal CLASS TYPE argument in file " + ServiceConfig.serviceConfigFile_); - state = ServiceConfig.ARGS; - // Set space to be an ordinary character to allow - // arguments to be parsed in - in.wordChars (' ', ' '); - break; - case ServiceConfig.ARGS: - if (in.ttype == StreamTokenizer.TT_WORD) - { - args = in.sval; - // Load the class - Class c = null; - - // First check if we need to load the class from the - // file system or from across the network. - if (className.lastIndexOf ("://") != -1) - { - // We need to get the bytes over the network since - // the name specified in the configuration file - // contains a protocol specification - c = ServiceConfig.svcRep_.load (new URL (className)); - } - else - { - c = ServiceConfig.svcRep_.load (className); - } - - // Note that c should be defined else an exception - // would have been thrown by now - - // Figure out the type of the class, create an - // instance and then invoke the initialization method - if (classType.equals ("ServiceObject")) - { - ServiceObject svcObj = (ServiceObject) c.newInstance (); - - // Create an array of String from args String - String [] argArray = OS.createStringArray (args, " "); - - // Call init on the Service Object passing in arguments - svcObj.init (argArray); - } - else - throw new IOException ("Illegal CLASS TYPE argument in file " + ServiceConfig.serviceConfigFile_); - } - else - throw new IOException ("Illegal ARGS argument in file " + ServiceConfig.serviceConfigFile_); - state = ServiceConfig.CLASS_NAME; - // Set space back to whitespace-character to extract the - // next token - in.whitespaceChars (' ', ' '); - break; - default: - throw new IOException ("Illegal argument in file " + ServiceConfig.serviceConfigFile_); - } - } - return 0; - } - - protected static void parseArgs (String [] args) - { - GetOpt getopt = new GetOpt (args, "bdnf:"); - for (int c; (c = getopt.next ()) != -1; ) - switch (c) - { - case 'b': - // Note: not supported yet! - ServiceConfig.beADaemon_ = true; - break; - case 'd': - ServiceConfig.debug_ = true; - break; - case 'n': - ServiceConfig.noDefaults_ = true; - break; - case 'f': - ServiceConfig.serviceConfigFile_ = getopt.optarg (); - break; - default: - ACE.ERROR ((char ) c + " is not a ServiceConfig option"); - break; - } - } - - // Set by command line options - private static boolean beADaemon_ = false; - private static boolean debug_ = false; - private static boolean noDefaults_ = false; - private static String serviceConfigFile_ = "svc.conf"; - private static ServiceRepository svcRep_ = null; - - // States for the state-machine used in parsing the config file - private final static int CLASS_NAME = 0; - private final static int CLASS_TYPE = 1; - private final static int ARGS = 2; -} diff --git a/java/src/ServiceObject.java b/java/src/ServiceObject.java deleted file mode 100644 index 56761f81267..00000000000 --- a/java/src/ServiceObject.java +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ServiceConfigurator - * - * = FILENAME - * ServiceObject.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ServiceConfigurator; - -import java.io.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class ServiceObject implements EventHandler -{ - /** - * Initialize object when dynamic loading occurs. Overwrite this - * method to do anything useful. - *@return -1 (default implementation) - */ - public int init (String [] args) - { - return -1; - } - - /** - * Terminate the object. Note that an object can not be explicitly - * unloaded. Overwrite this method to do anything useful. - *@return -1 (default implementation) - */ - public int fini () - { - return -1; - } - - /** - * Get information on an active object. Overwrite this method to do - * anything useful. - *@return null (default implementation) - */ - public String info () - { - return null; - } - - /** - * Called when timer expires. Overwrite this method to do - * anything useful. - *@param tv Time Value for which timer was set - *@param obj An arbitrary object that was passed to the Timer Queue - * (Asynchronous Completion Token) - *@return -1 - */ - public int handleTimeout (TimeValue tv, Object obj) - { - return -1; - } -} diff --git a/java/src/ServiceRepository.java b/java/src/ServiceRepository.java deleted file mode 100644 index de5e4384b7d..00000000000 --- a/java/src/ServiceRepository.java +++ /dev/null @@ -1,282 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ServiceConfigurator - * - * = FILENAME - * ServiceRepository.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ServiceConfigurator; - -import java.io.*; -import java.util.*; -import java.net.*; -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Provides a repository for loaded Java classes - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This class provides a means to load Java classes explicitly at - * runtime. Note that since the class makes use of the Java - * ClassLoader, this class can not be used in a Java applet. - *</blockquote> - */ -public class ServiceRepository -{ - /** - * Create a Service Repository. - */ - public ServiceRepository () - { - this.loader_ = new ServiceLoader (null); - } - - /** - * Create a Service Repository passing in the context. Note that - * this can cause problems for the default system loader since it will - * try to load all the system classes using the context specified. - *@param context Context to use when loading classes. - */ - public ServiceRepository (String context) - { - this.loader_ = new ServiceLoader (context); - } - - /** - * Set the context - *@param context Context to use when loading classes. - */ - public void context (String c) - { - this.loader_.context (c); - } - - /** - * Load a Java Class. This method first checks if the class is - * already in the repository. If it is not, it checks if the class - * is a system class and can be found on the local system. If both - * these fail, the method tries to load the bytes for the class and - * then create the Class from these bytes. - *@param name name of the class to find in the repository - *@return Class corresponding to name - */ - public Class load (String name) throws ClassNotFoundException - { - return this.loader_.loadClass (name, true); - } - - /** - * Load a Java Class across the network. The method tries to load - * the bytes for the class and then create the Class from these - * bytes. - *@param url URL of the class to load - *@return Class corresponding to the url - */ - public Class load (URL url) throws ClassNotFoundException - { - return this.loader_.loadClass (url, true); - } - - private ServiceLoader loader_; -} - -class ServiceLoader extends ClassLoader -{ - public ServiceLoader (String context) - { - super (); - if (context == null) - this.getClassPath (); - else - this.context_ = context; - } - - public void context (String c) - { - this.context_ = c; - } - - // Load a compiled class file into runtime - public Class loadClass (String name, boolean resolve) throws ClassNotFoundException - { - Class newClass; - if (this.context_ == null) - { - try - { - // Try to load it the class by reading in the bytes. - // Note that we are not catching ClassNotFoundException here - // since our caller will catch it. - try - { - byte[] buf = bytesForClass (name); - newClass = defineClass (buf, 0, buf.length); - // ACE.DEBUG ("Loaded class: "+ name); - - // Check if we need to load other classes referred to by this class. - if (resolve) - resolveClass (newClass); - } - catch (ClassNotFoundException e) - { - // ACE.DEBUG ("Using default loader for class: "+ name); - // Try default system loader - if ((newClass = findSystemClass (name)) != null) - return newClass; - else - throw (e); // Rethrow the exception - } - } - catch (IOException e) - { - throw new ClassNotFoundException (e.toString ()); - } - } - else - { - System.out.println ("Fetching over the net"); - System.out.println ("Context: " + this.context_); - // Try to load it the class by reading in the bytes. - // Note that we are not catching ClassNotFoundException here - // since our caller will catch it. - try - { - URL url = new URL (this.context_ + name); - URLConnection urlConnection = url.openConnection (); - - // Get the input stream associated with the URL connection and - // pipe it to a newly created DataInputStream - DataInputStream i = new DataInputStream (urlConnection.getInputStream ()); - - // Allocate a buffer big enough to hold the contents of the - // data we are about to read - byte [] buf = new byte [urlConnection.getContentLength ()]; - - // Now read all the data into the buffer - i.readFully (buf); - - newClass = defineClass (buf, 0, buf.length); - // ACE.DEBUG ("Loaded class: "+ name); - - // Check if we need to load other classes referred to by this class. - if (resolve) - resolveClass (newClass); - } - catch (IOException e) - { - throw new ClassNotFoundException (e.toString ()); - } - } - return newClass; - } - - // Load a compiled class file across the network - public Class loadClass (URL url, boolean resolve) throws ClassNotFoundException - { - Class newClass = null; - // Try to load it the class by reading in the bytes. - // Note that we are not catching ClassNotFoundException here - // since our caller will catch it. - try - { - URLConnection urlConnection = url.openConnection (); - - // Get the input stream associated with the URL connection and - // pipe it to a newly created DataInputStream - DataInputStream i = new DataInputStream (urlConnection.getInputStream ()); - - // Allocate a buffer big enough to hold the contents of the - // data we are about to read - byte [] buf = new byte [urlConnection.getContentLength ()]; - - // Now read all the data into the buffer - i.readFully (buf); - - newClass = defineClass (buf, 0, buf.length); - // ACE.DEBUG ("Loaded class: "+ name); - - // Check if we need to load other classes referred to by this class. - if (resolve) - resolveClass (newClass); - } - catch (IOException e) - { - throw new ClassNotFoundException (e.toString ()); - } - return newClass; - } - - private void getClassPath () - { - // Cache system properties that are needed when trying to find a - // class file - this.classPath_ = System.getProperty ("java.class.path", "."); - this.pathSeparator_ = System.getProperty ("path.separator", ":"); - this.fileSeparator_ = System.getProperty ("file.separator", "/"); - } - - // Read a file into a byte array - private byte[] bytesForClass (String name) throws IOException, ClassNotFoundException - { - // Break up the CLASSPATH to check for existence of file in each - // sub-path. Note that we use the path_separator to extract every - // sub-path and use that to check if the class file exists. - StringTokenizer tokens = new StringTokenizer (this.classPath_, - this.pathSeparator_); - while (tokens.hasMoreTokens ()) - { - // Create a File object which can then be used to see if the - // class file actually exists - File classFile = new File (tokens.nextToken () + - this.fileSeparator_ + - name + - ".class"); - - // Check if file exists, is a normal file and is readable - if (true) /*classFile.exists () && - classFile.isFile () && - classFile.canRead ()) */ - { - // Set up the stream - FileInputStream in = new FileInputStream (classFile); - - // Get byte count - int length = in.available (); - - if (length == 0) - throw new ClassNotFoundException (name); - - // Create an array of bytes to read the file in - byte[] buf = new byte[length]; - - // Read the file - in.read (buf); - - // Return byte array - return buf; - } - } - // File was not found so throw an exception. - throw new ClassNotFoundException ("Class file " + name + " not found"); - } - - private String classPath_; - // Class path that is loaded at construction - - private String pathSeparator_; - // Platform-dependent path separator (e.g., : or ;) - - private String fileSeparator_; - // Platform-dependent file separator (e.g., / or \) - - private String context_ = null; -} diff --git a/java/src/StrategyAcceptor.java b/java/src/StrategyAcceptor.java deleted file mode 100644 index 07f81a8ad63..00000000000 --- a/java/src/StrategyAcceptor.java +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * StrategyAcceptor.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; - -public class StrategyAcceptor -{ - /** - * Create an instance of StrategyAcceptor. - *@param handlerFactory Svc Handler factory that is used to create - * an instance of a Svc Handler when a connection is accepted. - */ - public StrategyAcceptor (Class handlerFactory) - { - this (handlerFactory, null, null, null); - } - - /** - * Create an instance of StrategyAcceptor. Use the creation - * strategy and the handlerFactory passed in to creae a new instance - * of the Svc Handler. - *@param handlerFactory Svc Handler factory that is used to create - * an instance of a Svc Handler when a connection is accepted. - *@param creStrategy Creation strategy to use to create a new - * instance of the Svc Handler. - *@param acceptStrategy Accept strategy to use to accept a new - * connection into the Svc Handler. - *@param activateStrategy Activate strategy to use to activate the - * instance of the Svc Handler. - */ - public StrategyAcceptor (Class handlerFactory, - CreationStrategy creStrategy, - AcceptStrategy acceptStrategy, - ActivateStrategy activateStrategy) - { - // Cache everything - this.handlerFactory_ = handlerFactory; - this.creStrategy_ = creStrategy; - this.acceptStrategy_ = acceptStrategy; - this.activateStrategy_ = activateStrategy; - } - - /** - * Initialize the Strategy Acceptor. The method creates the - * appropriate strategies as needed. - *@param port port number where the server will listen for connections - */ - public void open (int port) throws IOException - { - if (this.creStrategy_ == null) - this.creStrategy_ = new CreationStrategy (this.handlerFactory_); - if (this.acceptStrategy_ == null) - this.acceptStrategy_ = new AcceptStrategy (port); - else - this.acceptStrategy_.open (port); - if (this.activateStrategy_ == null) - this.activateStrategy_ = new ActivateStrategy (); - } - - /** - * Accept a connection using the appropriate strategies. - */ - public void accept () throws SocketException, - InstantiationException, - IllegalAccessException, - IOException - { - // Create a Svc_Handler using the appropriate Creation_Strategy - SvcHandler sh = this.makeSvcHandler (); - - // Accept a connection into the Svc_Handler - this.acceptSvcHandler (sh); - - // Activate the Svc_Handler - this.activateSvcHandler (sh); - } - - /** - * Bridge method for creating a SvcHandler. The strategy for - * creating a SvcHandler is configured into the Acceptor via it's - * creStrategy_. If no strategy is passed in, the default behavior - * of this method is to use the default CreationStrategy. - *@return a new instance of the Svc Handler - */ - protected SvcHandler makeSvcHandler () throws InstantiationException, - IllegalAccessException - { - // Create a new handler for the connection - return this.creStrategy_.makeSvcHandler (); - } - - - /** - * Bridge method for accepting the new connection into the - * <SvcHandler>. The strategy for accepting into a SvcHandler is - * configured into the Acceptor via it's acceptStrategy_. If no - * strategy is passed in, the default behavior of this method is to - * use the default AcceptStrategy. - *@param sh Svc Handler in which to accept the connection - *@return result of accepting a connection using the accept strategy - */ - protected int acceptSvcHandler (SvcHandler sh) throws - SocketException, IOException - { - // Delegate responsibility to the appropriate strategy - return this.acceptStrategy_.acceptSvcHandler (sh); - } - - /** - * Bridge method for activating a <SvcHandler>. The strategy for - * activating a SvcHandler is configured into the Acceptor via it's - * activateStrategy_. If no strategy is passed in, the default - * behavior of this method is to use the default ActivateStrategy. - *@param sh Svc Handler to activate - *@return result of activating the Svc Handler - */ - protected int activateSvcHandler (SvcHandler sh) - { - // Delegate responsibility to the appropriate strategy - return this.activateStrategy_.activateSvcHandler (sh); - } - - // Handler class that should be instantiated when a connection is - // made with a client - private Class handlerFactory_; - - // Creation Strategy - private CreationStrategy creStrategy_; - - // Accept Strategy - private AcceptStrategy acceptStrategy_; - - // Activation Strategy - private ActivateStrategy activateStrategy_; -} diff --git a/java/src/Stream.java b/java/src/Stream.java deleted file mode 100644 index 030114d092f..00000000000 --- a/java/src/Stream.java +++ /dev/null @@ -1,438 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * Stream.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * This class is the primary abstraction for the ASX framework. - * It is moduled after System V Stream. - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * A Stream consists of a stack of <Modules>, each of which - * contains two <Tasks>. - *</blockquote> - */ - -public class Stream -{ - - public Stream () - { - this (null, null, null); - } - - // Create a Stream consisting of <head> and <tail> as the Stream - // head and Stream tail, respectively. If these are 0 then the - // <ACE_Stream_Head> and <ACE_Stream_Tail> are used, respectively. - // <arg> is the value past in to the open() methods of the tasks. - - public Stream (Object a, - Module head, - Module tail) - { - this.linkedUs_ = null; - // this.final_close_ = this.lock_; - - if (this.open (a, head, tail) == -1) - ACE.ERROR ("open" + head.name () + " " + tail.name ()); - } - - public int push (Module newTop) - { - if (this.pushModule (newTop, - this.streamHead_.next (), - this.streamHead_) == -1) - return -1; - else - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - return this.streamHead_.writer ().put (mb, tv); - } - - public MessageBlock get (TimeValue tv) throws InterruptedException - { - return this.streamHead_.reader ().getq (tv); - } - -// Return the "top" ACE_Module in a ACE_Stream, skipping over the -// stream_head. - - public Module top () - { - if (this.streamHead_.next () == this.streamTail_) - return null; - else - return this.streamHead_.next (); - } - -// Remove the "top" ACE_Module in a ACE_Stream, skipping over the -// stream_head. - - public int pop (long flags) - { - if (this.streamHead_.next () == this.streamTail_) - return -1; - else - { - // Skip over the ACE_Stream head. - Module top = this.streamHead_.next (); - Module newTop = top.next (); - - this.streamHead_.next (newTop); - - // Close the top ACE_Module. - - top.close (flags); - - this.streamHead_.writer ().next (newTop.writer ()); - newTop.reader ().next (this.streamHead_.reader ()); - - return 0; - } - } - -// Remove a named ACE_Module from an arbitrary place in the -// ACE_Stream. - - public int remove (String name, long flags) - { - Module prev = null; - - for (Module mod = this.streamHead_; - mod != null; mod = mod.next ()) - if (name.compareTo (mod.name ()) == 0) - { - if (prev == null) // Deleting ACE_Stream Head - this.streamHead_.link (mod.next ()); - else - prev.link (mod.next ()); - - mod.close (flags); - return 0; - } - else - prev = mod; - - return -1; - } - - public Module find (String name) - { - for (Module mod = this.streamHead_; - mod != null; - mod = mod.next ()) - if (name.compareTo (mod.name ()) == 0) - return mod; - - return null; - } - -// Actually push a module onto the stack... - - private int pushModule (Module newTop, - Module currentTop, - Module head) - { - Task ntReader = newTop.reader (); - Task ntWriter = newTop.writer (); - Task ctReader = null; - Task ctWriter = null; - - if (currentTop != null) - { - ctReader = currentTop.reader (); - ctWriter = currentTop.writer (); - ctReader.next (ntReader); - } - - ntWriter.next (ctWriter); - - if (head != null) - { - if (head != newTop) - head.link (newTop); - } - else - ntReader.next (null); - - newTop.next (currentTop); - - if (ntReader.open (newTop.arg ()) == -1) - return -1; - - if (ntWriter.open (newTop.arg ()) == -1) - return -1; - return 0; - } - - public synchronized int open (Object a, - Module head, - Module tail) - { - Task h1 = null, h2 = null; - Task t1 = null, t2 = null; - - if (head == null) - { - h1 = new StreamHead (); - h2 = new StreamHead (); - head = new Module ("ACEStreamHead", h1, h2, a); - } - - if (tail == null) - { - t1 = new StreamTail (); - t2 = new StreamTail (); - tail = new Module ("ACEStreamTail", - t1, t2, a); - } - - // Make sure *all* the allocation succeeded! - if (h1 == null || h2 == null || head == null - || t1 == null || t2 == null || tail == null) - { - // Close up! - head.close (0); - tail.close (0); - return -1; - } - - this.streamHead_ = head; - this.streamTail_ = tail; - - if (this.pushModule (this.streamTail_, - null, null) == -1) - return -1; - else if (this.pushModule (this.streamHead_, - this.streamTail_, - this.streamHead_) == -1) - return -1; - else - return 0; - } - - public synchronized int close (long flags) - { - if (this.streamHead_ != null - && this.streamTail_ != null) - { - // Don't bother checking return value here. - this.unlinkInternal (); - - int result = 0; - - // Remove and cleanup all the intermediate modules. - - while (this.streamHead_.next () != this.streamTail_) - { - if (this.pop (flags) == -1) - result = -1; - } - - // Clean up the head and tail of the stream. - if (this.streamHead_.close (flags) == -1) - result = -1; - if (this.streamTail_.close (flags) == -1) - result = -1; - - this.streamHead_ = null; - this.streamTail_ = null; - - // Tell all threads waiting on the close that we are done. - // this.final_close_.broadcast (); - return result; - } - return 0; - } - - public int control (int cmd, Object a) throws InterruptedException - { - IOCntlMsg ioc = new IOCntlMsg (cmd); - - // Create a data block that contains the user-supplied data. - MessageBlock db = - new MessageBlock (MessageType.MB_IOCTL, - null, - a); - - // Create a control block that contains the control field and a - // pointer to the data block. - MessageBlock cb = - new MessageBlock (MessageType.MB_IOCTL, - db, - (Object) ioc); - - int result = 0; - - if (this.streamHead_.writer ().put (cb, new TimeValue ()) == -1) - result = -1; - else if ((cb = this.streamHead_.reader ().getq (new TimeValue ())) == null) - result = -1; - else - result = ((IOCntlMsg ) cb.obj ()).rval (); - - return result; - } - -// Link two streams together at their bottom-most Modules (i.e., the -// one just above the Stream tail). Note that all of this is premised -// on the fact that the Stream head and Stream tail are non-NULL... -// This must be called with locks held. - - private int linkInternal (Stream us) - { - this.linkedUs_ = us; - // Make sure the other side is also linked to us! - us.linkedUs_ = this; - - Module myTail = this.streamHead_; - - if (myTail == null) - return -1; - - // Locate the module just above our Stream tail. - while (myTail.next () != this.streamTail_) - myTail = myTail.next (); - - Module otherTail = us.streamHead_; - - if (otherTail == null) - return -1; - - // Locate the module just above the other Stream's tail. - while (otherTail.next () != us.streamTail_) - otherTail = otherTail.next (); - - // Reattach the pointers so that the two streams are linked! - myTail.writer ().next (otherTail.reader ()); - otherTail.writer ().next (myTail.reader ()); - return 0; - } - - public synchronized int link (Stream us) - { - return this.linkInternal (us); - } - -// Must be called with locks held... - - private int unlinkInternal () - { - // Only try to unlink if we are in fact still linked! - - if (this.linkedUs_ != null) - { - Module myTail = this.streamHead_; - - // Only relink if we still exist! - if (myTail != null) - { - // Find the module that's just before our stream tail. - while (myTail.next () != this.streamTail_) - myTail = myTail.next (); - - // Restore the writer's next() link to our tail. - myTail.writer ().next (this.streamTail_.writer ()); - } - - Module otherTail = this.linkedUs_.streamHead_; - - // Only fiddle with the other side if it in fact still remains. - if (otherTail != null) - { - while (otherTail.next () != this.linkedUs_.streamTail_) - otherTail = otherTail.next (); - - otherTail.writer ().next (this.linkedUs_.streamTail_.writer ()); - - } - - // Make sure the other side is also aware that it's been unlinked! - this.linkedUs_.linkedUs_ = null; - - this.linkedUs_ = null; - return 0; - } - else - return -1; - } - - public synchronized int unlink () - { - return this.unlinkInternal (); - } - - public void dump () - { - ACE.DEBUG ("-------- module links --------"); - - for (Module mp = this.streamHead_; ; mp = mp.next ()) - { - ACE.DEBUG ("module name = " + mp.name ()); - if (mp == this.streamTail_) - break; - } - - ACE.DEBUG ("-------- writer links --------"); - - Task tp; - - for (tp = this.streamHead_.writer (); ; tp = tp.next ()) - { - ACE.DEBUG ("writer queue name = " + tp.name ()); - tp.dump (); - ACE.DEBUG ("-------\n"); - if (tp == this.streamTail_.writer () - || (this.linkedUs_ != null && tp == this.linkedUs_.streamHead_.reader ())) - break; - } - - ACE.DEBUG ("-------- reader links --------\n"); - for (tp = this.streamTail_.reader (); ; tp = tp.next ()) - { - ACE.DEBUG ("reader queue name = " + tp.name ()); - tp.dump (); - ACE.DEBUG ("-------\n"); - if (tp == this.streamHead_.reader () - || (this.linkedUs_ != null && tp == this.linkedUs_.streamHead_.writer ())) - break; - } - } - - Module streamHead_ = null; - // Pointer to the head of the stream. - - Module streamTail_ = null; - // Pointer to the tail of the stream. - - Stream linkedUs_ = null; - // Pointer to an adjoining linked stream. - - // = Synchronization objects used for thread-safe streams. - // ACE_SYNCH_MUTEX lock_; - // Protect the stream against race conditions. - - // ACE_SYNCH_CONDITION final_close_; - // Use to tell all threads waiting on the close that we are done. - -} - - diff --git a/java/src/StreamHead.java b/java/src/StreamHead.java deleted file mode 100644 index 37d9c2af0c3..00000000000 --- a/java/src/StreamHead.java +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * StreamHead.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Standard module that acts as the head of a ustream. - *</blockquote> - */ - -public class StreamHead extends Task -{ - // Module that acts as the head of a Stream. - - public int open (Object obj) - { - return 0; - } - - public int close (long l) - { - return 0; - } - - public int svc () - { - return -1; - } - - private int control (MessageBlock mb) - { - - IOCntlMsg ioc = (IOCntlMsg) mb.obj (); - int cmd = ioc.cmd (); - - switch (cmd) - { - case IOCntlCmds.SET_LWM: - case IOCntlCmds.SET_HWM: - this.waterMarks (cmd, mb.cont ().length ()); - ioc.rval (0); - break; - default: - return 0; - } - return ioc.rval (); - } - - /* Performs canonical flushing at the ACE_Stream Head */ - - private int canonicalFlush (MessageBlock mb) - { - String s = mb.base (); - long f = (new Long (s)).longValue (); - - if ((f & TaskFlags.ACE_FLUSHR) != 0) - { - this.flush (TaskFlags.ACE_FLUSHALL); - f &= ~TaskFlags.ACE_FLUSHR; - } - if ((f & TaskFlags.ACE_FLUSHW) != 0) - return this.reply (mb, new TimeValue ()); - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - int res = 0; - if (mb.msgType () == MessageType.MB_IOCTL - && (res = this.control (mb)) == -1) - return res; - - if (this.isWriter ()) - { - return this.putNext (mb, tv); - } - else /* this.isReader () */ - { - switch (mb.msgType ()) - { - case MessageType.MB_FLUSH: - return this.canonicalFlush (mb); - default: - break; - } - - try - { - return this.putq (mb, tv); - } - catch (InterruptedException e) - { - return -1; - } - } - } - - public void dump () - { - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - -} diff --git a/java/src/StreamTail.java b/java/src/StreamTail.java deleted file mode 100644 index 44f9dde6634..00000000000 --- a/java/src/StreamTail.java +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * StreamTail.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Standard module that acts as the tail of a ustream. - *</blockquote> - */ - -public class StreamTail extends Task -{ - // Module that acts as the tail of a Stream. - - public int open (Object obj) - { - return 0; - } - - public int close (long l) - { - return 0; - } - - public int svc () - { - return -1; - } - - private int control (MessageBlock mb) - { - IOCntlMsg ioc = (IOCntlMsg) mb.obj (); - int cmd = ioc.cmd (); - - switch (cmd) - { - case IOCntlCmds.SET_LWM: - case IOCntlCmds.SET_HWM: - { - int size = mb.cont ().length (); - - this.waterMarks (cmd, size); - this.sibling ().waterMarks (cmd, size); - ioc.rval (0); - break; - } - default: - mb.msgType (MessageType.MB_IOCNAK); - } - return this.reply (mb, new TimeValue ()); - } - - // Perform flush algorithm as though we were the driver - private int canonicalFlush (MessageBlock mb) - { - String s = mb.base (); - long f = (new Long (s)).longValue (); - - if ((f & TaskFlags.ACE_FLUSHW) != 0) - { - this.flush (TaskFlags.ACE_FLUSHALL); - f &= ~TaskFlags.ACE_FLUSHW; - } - if ((f & TaskFlags.ACE_FLUSHR) != 0) - { - this.sibling ().flush (TaskFlags.ACE_FLUSHALL); - return this.reply (mb, new TimeValue ()); - } - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - if (this.isWriter ()) - { - switch (mb.msgType ()) - { - case MessageType.MB_IOCTL: - return this.control (mb); - /* NOTREACHED */ - default: - break; - } - } - - return -1; - } - - public void dump () - { - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - -} diff --git a/java/src/SvcHandler.java b/java/src/SvcHandler.java deleted file mode 100644 index 0ba7f671e0d..00000000000 --- a/java/src/SvcHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Connection - * - * = FILENAME - * SvcHandler.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Connection; - -import java.io.*; -import java.net.*; -import JACE.SOCK_SAP.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public abstract class SvcHandler extends Task -{ - - /** - * Do nothing constructor. - */ - public SvcHandler () - { - } - - /** - * Set the stream using the SOCKStream passed in. This sets the - * underlying peer - *@param s SOCK Stream to use for the connection - */ - public void setHandle (SOCKStream s) throws IOException - { - this.stream_ = s; - } - - /** - * Get the underlying peer - *@return the underlying peer - */ - public SOCKStream peer () - { - return this.stream_; - } - - /** - * Abstract method that subclasses must define to allow - * initialization to take place. - */ - public abstract int open (Object obj); - - /** - * Provide a default implementation to simplify ancestors. - *@return 0 - */ - public int close (long flags) - { - return 0; - } - - /** - * Provide a default implementation to simplify ancestors. - *@return -1 - */ - public int put (MessageBlock mb, TimeValue tv) - { - return -1; - } - - /** - * Provide a default implementation to simplify ancestors. - *@param tv Time Value for which timer was set - *@param obj An arbitrary object that was passed to the Timer Queue - * (Asynchronous Completion Token) - */ - public int handleTimeout (TimeValue tv, Object obj) - { - return -1; - } - - private SOCKStream stream_; -} diff --git a/java/src/Task.java b/java/src/Task.java deleted file mode 100644 index 065e7869fef..00000000000 --- a/java/src/Task.java +++ /dev/null @@ -1,415 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * Task.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -import JACE.OS.*; -import JACE.Reactor.*; -import JACE.Concurrency.*; - -public abstract class Task implements Runnable, EventHandler -{ - // = Initialization/termination methods. - - /** - * Initialize a Task. Note, we allocate a message queue ourselves. - */ - public Task () - { - this.msgQueue_ = new MessageQueue (); - this.thrMgr_ = null; - } - - /** - * Initialize a Task. Note, we use the message queue and thread - * manager supplied by the user. - *@param mq Message Queue to hold list of messages on the Task - *@param thrMgr Thread Manager that manages all the spawned threads - */ - public Task (MessageQueue mq, - ThreadManager thrMgr) - { - this.msgQueue_ = mq; - this.thrMgr_ = thrMgr; - } - - /** - * Not meant to be invoked by the user directly!. This needs to be - * in the public interface in order to get invoked by Thread - * class. - */ - public void run () - { - this.svc (); - } - - // = Initialization and termination hooks (note that these *must* be - // defined by subclasses). - - /** - * Hook called to open a Task. - *@param obj used to pass arbitrary information - */ - public abstract int open (Object obj); - - /** - * Hook called to close a Task. - */ - public abstract int close (long flags); - - // = Immediate and deferred processing methods, respectively. - - /** - * Transfer a message into the queue to handle immediate - * processing. - *@param mb Message Block to handle immediately - *@param tv amount of time to wait for - */ - public abstract int put (MessageBlock mb, TimeValue tv); - - /** - * Run by a daemon thread to handle deferred processing. Note, that - * to do anything useful, this method should be overriden by the - * subclass. - *@return default implementation always returns 0. - */ - public int svc () - { - return 0; - } - - /** - * Set the underlying Thread Manager. - *@param t Thread Manager to use - */ - public synchronized void thrMgr (ThreadManager t) - { - this.thrMgr_ = t; - } - - /** - * Get the Thread Manager. - *@return Underlying Thread Manager - */ - public synchronized ThreadManager thrMgr () - { - return this.thrMgr_; - } - - // = Active object method. - - /** - * Turn the task into an active object. That is, having <nThreads> - * separate threads of control that all invoke Task::svc. - *@param flags Task Flags - *@param nThreads number of threads to spawn - *@param forceActive whether to force creation of new threads or not - *@return -1 if failure occurs, 1 if Task is already an active - * object and <forceActive> is false (doesn't *not* create a new - * thread in this case), and 0 if Task was not already an active - * object and a thread is created successfully or thread is an active - * object and <forceActive> is true. - */ - public synchronized int activate (long flags, int nThreads, boolean forceActive) - { - // Create a Thread Manager if we do not already have one - if (this.thrMgr_ == null) - this.thrMgr_ = new ThreadManager (); - - if (this.thrCount () > 0 && forceActive == false) - return 1; // Already active. - this.flags_ = flags; - - if (ACE.BIT_ENABLED (flags, TaskFlags.THR_DAEMON)) - this.thrMgr_.spawnN (nThreads, this, true); // Spawn off all threads as daemon threads - else // Spawn off all threads as normal threads - this.thrMgr_.spawnN (nThreads, this, false); - - return 0; - } - - // = Suspend/resume a Task - - /** - * Suspend a task. - */ - public synchronized void suspend () - { - // Suspend all threads - if (this.thrMgr_ != null) - this.thrMgr_.thrGrp ().suspend (); - } - - /** - * Resume a suspended task. - */ - public synchronized void resume () - { - // Resume all threads - if (this.thrMgr_ != null) - this.thrMgr_.thrGrp ().resume (); - } - - /** - * Get the current group name. - *@return name of the current thread group - */ - public synchronized String grpName () - { - if (this.thrMgr_ != null) - return this.thrMgr_.thrGrp ().getName (); - else - return null; - } - - /** - * Get the message queue associated with this task. - *@return the message queue associated with this task. - */ - public MessageQueue msgQueue () - { - return this.msgQueue_; - } - - /** - * Set the message queue associated with this task. - *@param mq Message Queue to use with this Task. - */ - public void msgQueue (MessageQueue mq) - { - this.msgQueue_ = mq; - } - - /** - * Get the number of threads currently running within the Task. - *@return the number of threads currently running within the Task. - * 0 if we're a passive object, else > 0. - */ - public synchronized int thrCount () - { - if (this.thrMgr_ != null) - return this.thrMgr_.thrGrp ().activeCount (); - else - return 0; - } - - /** - * Set the Task flags - *@param flags Task Flags - */ - public synchronized void flags (long flags) - { - this.flags_ = flags; - } - - /** - * Get the Task flags - *@return Task Flags - */ - public synchronized long flags () - { - return this.flags_; - } - - // = Message queue manipulation methods. - - - /* - * Dump debug information. - */ - public void dump () - { - } - - /** - * Insert message into the message queue. - *@param mb Message Block to insert into the Message Queue - *@param tv amount of time to wait for - */ - protected int putq (MessageBlock mb, TimeValue tv) throws InterruptedException - { - return this.msgQueue_.enqueueTail (mb, tv); - } - - /** - * Extract the first message from the queue. Note that the call is blocking. - *@return the first Message Block from the Message Queue. - *@param tv amount of time to wait for - */ - protected MessageBlock getq (TimeValue tv) throws InterruptedException - { - return this.msgQueue_.dequeueHead (tv); - } - - /** - * Return a message back to the queue. - *@param mb Message Block to return back to the Message Queue - *@param tv amount of time to wait for - */ - protected int ungetq (MessageBlock mb, TimeValue tv) throws InterruptedException - { - return this.msgQueue_.enqueueHead (mb, tv); - } - - /** - * Transfer message to the adjacent ACETask in an ACEStream. - *@param mb Message Block to transfer to the adjacent Task - *@param tv amount of time to wait for - *@return -1 if there is no adjacent Task, else the return value of - * trying to put the Message Block on that Task's Message Queue. - */ - protected int putNext (MessageBlock mb, TimeValue tv) - { - return this.next_ == null ? -1 : this.next_.put (mb, tv); - } - - /** - * Turn the message back around. Puts the message in the sibling's - * Message Queue. - *@param mb Message Block to put into sibling's Message Queue - *@param tv amount of time to wait for - *@return -1 if there is no adjacent Task to the sibling, else the - * return value of trying to put the Message Block on sibling's - * Message Queue. - */ - protected int reply (MessageBlock mb, TimeValue tv) - { - return this.sibling ().putNext (mb, tv); - } - - // = ACE_Task utility routines to identify names et al. - - /** - * Get the name of the enclosing Module. - *@return the name of the enclosing Module if there's one associated - * with the Task, else null. - */ - protected String name () - { - if (this.mod_ == null) - return null; - else - return this.mod_.name (); - } - - /** - * Get the Task's sibling. - *@return the Task's sibling if there's one associated with the - * Task's Module, else null. - */ - protected Task sibling () - { - if (this.mod_ == null) - return null; - else - return this.mod_.sibling (this); - } - - /** - * Set the Task's module. - *@param mod the Task's Module. - */ - protected void module (Module mod) - { - this.mod_ = mod; - } - - /** - * Get the Task's module. - *@return the Task's Module if there is one, else null. - */ - protected Module module () - { - return this.mod_; - } - - /** - * Check if queue is a reader. - *@return true if queue is a reader, else false. - */ - protected boolean isReader () - { - return (ACE.BIT_ENABLED (this.flags_, TaskFlags.ACE_READER)); - } - - /** - * Check if queue is a writer. - *@return true if queue is a writer, else false. - */ - protected boolean isWriter () - { - return (ACE.BIT_DISABLED (this.flags_, TaskFlags.ACE_READER)); - } - - // = Pointers to next ACE_Queue (if ACE is part of an ACE_Stream). - - /** - * Get next Task pointer. - *@return pointer to the next Task - */ - protected Task next () - { - return this.next_; - } - - /** - * Set next Task pointer. - *@param task next task pointer - */ - protected void next (Task task) - { - this.next_ = task; - } - - // Special routines corresponding to certain message types. - - /** - * Flush the Message Queue - *@return 0 if Message Queue is null, 1 if flush succeeds, -1 if - * ACE_FLUSHALL bit is not enabled in flags. - */ - protected int flush (long flag) - { - if (ACE.BIT_ENABLED (flag, TaskFlags.ACE_FLUSHALL)) - return (this.msgQueue_ == null ? 0 : 1); - else - return -1; - } - - - /** - * Manipulate watermarks. - *@param cmd IOCntlCmd - *@param size watermark - */ - protected void waterMarks (int cmd, int size) - { - if (cmd == IOCntlCmds.SET_LWM) - this.msgQueue_.lowWaterMark (size); - else /* cmd == IOCntlMsg.SET_HWM */ - this.msgQueue_.highWaterMark (size); - } - - private ThreadManager thrMgr_ = null; - // Thread_Manager that manages all the spawned threads - - private long flags_; - // Task flags. - - private MessageQueue msgQueue_; - // List of messages on the Task.. - - private Task next_; - // Adjacent ACE_Task. - - private Module mod_; - // Back-pointer to the enclosing module. -} diff --git a/java/src/TaskFlags.java b/java/src/TaskFlags.java deleted file mode 100644 index 590e514b5e2..00000000000 --- a/java/src/TaskFlags.java +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * TaskFlags.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -public abstract class TaskFlags -{ - /** Identifies a Task as being the "reader" in a Module. */ - public static final int ACE_READER = 01; - - /** Just flush data messages in the queue. */ - public static final int ACE_FLUSHDATA = 02; - - /** Flush all messages in the Queue. */ - public static final int ACE_FLUSHALL = 04; - - /** Flush read queue */ - public static final int ACE_FLUSHR = 010; - - /** Flush write queue */ - public static final int ACE_FLUSHW = 020; - - /** Flush both queues */ - public static final int ACE_FLUSHRW = 030; - - /** Identifies a thread as suspended */ - public static final int THR_SUSPENDED = 0x00000080; - - /** Identifies a thread as a daemon thread */ - public static final int THR_DAEMON = 0x00000100; - - // Default private constructor to avoid instantiation - private TaskFlags () - { - } -} diff --git a/java/src/ThreadManager.java b/java/src/ThreadManager.java deleted file mode 100644 index 5043d26511e..00000000000 --- a/java/src/ThreadManager.java +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * ThreadManager.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Concurrency; - -import java.util.*; -import JACE.OS.*; - -public class ThreadManager -{ - /** - * Default constructor - */ - public ThreadManager () - { - this (ACE.DEFAULT_THREAD_GROUP_NAME); - } - - /** - * Create a Thread Manager. - *@param groupName name of the thread group that the Thread Manager - * will manage - */ - public ThreadManager (String groupName) - { - this.thrGrp_ = new ThreadGroup (groupName); - if (this.thrGrp_ == null) - ACE.ERROR ("Thread group create failed"); - } - - /** - * Create a new thread. - *@param thr the caller whose run method will be invoked when the - * thread has been spawned - *@param daemon flag indicating whether the thread should be - * spawned off as a daemon thread - */ - public void spawn (Runnable thr, - boolean daemon) - { - Thread t = new Thread (this.thrGrp_, thr); - if (daemon) // Set the thread to be a daemon thread - t.setDaemon (true); - t.start (); - } - - /** - * Create a new thread and also give it a name. - *@param thr the caller whose run method will be invoked when the - * thread has been spawned - *@param threadName the name of the new thread - *@param daemon flag indicating whether the thread should be - * spawned off as a daemon thread - */ - public void spawn (Runnable thr, - String threadName, - boolean daemon) - { - Thread t = new Thread (this.thrGrp_, thr, threadName); - if (daemon) // Set the thread to be a daemon thread - t.setDaemon (true); - t.start (); - } - - - /** - * Create <n> new threads. - *@param n the number of threads to spawn - *@param thr the caller whose run method will be invoked by each of - * the <n> threads - *@param daemon flag indicating whether the threads should be - * spawned off as daemon threads - */ - public void spawnN (int n, - Runnable thr, - boolean daemon) - { - // Spawn off all the threads. - for (int i = 0; i < n; i++) - { - this.spawn (thr, daemon); - } - } - - /** - * Get the thread group containing all the threads. Note that the - * thread group can be used to get information regarding number of - * active threads as well as to suspend/resume all the threads in - * the group. - *@return the thread group that contains all the threads managed by - * the Thread Manager - */ - public ThreadGroup thrGrp () - { - return this.thrGrp_; - } - - private ThreadGroup thrGrp_; - // Thread Group that contains all the spawned threads - -} diff --git a/java/src/ThruTask.java b/java/src/ThruTask.java deleted file mode 100644 index aebc8eb1f48..00000000000 --- a/java/src/ThruTask.java +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * ThruTask.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.ASX; - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Standard module that acts as a "no op", simply passing on all - * data to its adjacent neighbor. - *</blockquote> - */ -public class ThruTask extends Task -{ - public int open (Object obj) - { - return 0; - } - - public int close (long flags) - { - return 0; - } - - public int put (MessageBlock msg, TimeValue tv) - { - return this.putNext (msg, tv); - } - - public int svc () - { - return -1; - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } -} diff --git a/java/src/TimeValue.java b/java/src/TimeValue.java deleted file mode 100644 index 280f45ab0f1..00000000000 --- a/java/src/TimeValue.java +++ /dev/null @@ -1,256 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Reactor - * - * = FILENAME - * TimeValue.java - * - *@author Prashant Jain - * - *************************************************/ -//package JACE.Reactor; -package JACE.ASX; - -public class TimeValue -{ - public final static TimeValue zero = new TimeValue (0,0); - - /** - * Default constructor - */ - public TimeValue () - { - this (0, 0); - } - - /** - * Constructor - *@param sec seconds - */ - public TimeValue (long sec) - { - this (sec, 0); - } - - /** - * Constructor - *@param sec seconds - *@param nanos nanoseconds - */ - public TimeValue (long sec, int nanos) - { - this.set (sec, nanos); - } - - /** - * Sets the seconds and nanoseconds of Time Value - *@param sec seconds - *@param nanos nanoseconds - */ - public void set (long sec, int nanos) - { - this.millisec_ = sec * 1000; - this.nanos_ = nanos; - this.normalize (); - } - - /** - * Get seconds - *@return Seconds - */ - public long sec () - { - return this.millisec_/1000; - } - - /** - * Get nanoseconds - *@return Nanoseconds - */ - public int nanos () - { - return this.nanos_; - } - - /** - * Get time in milliseconds. - *@return time in milliseconds - */ - public long getMilliTime () - { - return this.millisec_; - } - - /** - * Get a String representation of the Time Value. - *@return String representation of the Time Value - */ - public String toString () - { - return (new Long (this.millisec_/1000)).toString () + ":" + - (new Integer (this.nanos_)).toString (); - } - - /** - * Get current time. - *@return the current system time - */ - public static TimeValue getTimeOfDay () - { - return new TimeValue (System.currentTimeMillis ()/1000); - } - - /** - * Compare two Time Values for equality. - *@param tv Time Value to compare with - *@return true if the two Time Values are equal, false otherwise - */ - public boolean equals (TimeValue tv) - { - return this.millisec_ == (tv.sec () * 1000) && this.nanos_ == tv.nanos (); - } - - /** - * Compare two Time Values for non-equality. - *@param tv Time Value to compare with - *@return true if the two Time Values are not equal, false otherwise - */ - public boolean notEquals (TimeValue tv) - { - return !this.equals (tv); - } - - /** - * Add two Time Values. - *@param tv1 The first Time Value - *@param tv2 The second Time Value - *@return sum of the two Time Values. - */ - public static TimeValue plus (TimeValue tv1, TimeValue tv2) - { - TimeValue tv = new TimeValue (tv1.sec () + tv2.sec (), - tv1.nanos () + tv2.nanos ()); - tv.normalize (); - return tv; - } - - /** - * Subtract two Time Values. - *@param tv1 The first Time Value - *@param tv2 The second Time Value - *@return difference of the two Time Values. - */ - public static TimeValue minus (TimeValue tv1, TimeValue tv2) - { - TimeValue tv = new TimeValue (tv1.sec () - tv2.sec (), - tv1.nanos () - tv2.nanos ()); - tv.normalize (); - return tv; - } - - /** - * Add Time Value to "this". - *@param tv The Time Value to add to this. - */ - public void plusEquals (TimeValue tv) - { - this.set (this.sec () + tv.sec (), - this.nanos () + tv.nanos ()); - this.normalize (); - } - - /** - * Subtract Time Value from "this". - *@param tv The Time Value to subtract from this. - */ - public void minusEquals (TimeValue tv) - { - this.set (this.sec () - tv.sec (), - this.nanos () - tv.nanos ()); - this.normalize (); - } - - /** - * Compare two Time Values for less than. - *@param tv Time Value to compare with - *@return true if "this" is less than tv, false otherwise - */ - public boolean lessThan (TimeValue tv) - { - return tv.greaterThan (this); - } - - /** - * Compare two Time Values for greater than. - *@param tv Time Value to compare with - *@return true if "this" is greater than tv, false otherwise - */ - public boolean greaterThan (TimeValue tv) - { - if (this.sec () > tv.sec ()) - return true; - else if (this.sec () == tv.sec () - && this.nanos () > tv.nanos ()) - return true; - else - return false; - } - - /** - * Compare two Time Values for <=. - *@param tv Time Value to compare with - *@return true if "this" <= tv, false otherwise - */ - public boolean lessThanEqual (TimeValue tv) - { - return tv.greaterThanEqual (this); - } - - /** - * Compare two Time Values for >=. - *@param tv Time Value to compare with - *@return true if "this" >= tv, false otherwise - */ - public boolean greaterThanEqual (TimeValue tv) - { - return this.sec () >= tv.sec () && this.nanos () >= tv.nanos (); - } - - private void normalize () - { - if (this.nanos_ >= ONE_MILLISECOND) - { - do - { - this.millisec_++; - this.nanos_ -= ONE_MILLISECOND; - } - while (this.nanos_ >= ONE_MILLISECOND); - } - else if (this.nanos_ <= -ONE_MILLISECOND) - { - do - { - this.millisec_--; - this.nanos_ += ONE_MILLISECOND; - } - while (this.nanos_ <= -ONE_MILLISECOND); - } - - if (this.millisec_ >= 1 && this.nanos_ < 0) - { - this.millisec_--; - this.nanos_ += ONE_MILLISECOND; - } - else if (this.millisec_ < 0 && this.nanos_ > 0) - { - this.millisec_++; - this.nanos_ -= ONE_MILLISECOND; - } - } - - private long millisec_; - private int nanos_; - private final static int ONE_MILLISECOND = 1000000; -} diff --git a/java/src/TimedWait.java b/java/src/TimedWait.java deleted file mode 100644 index acf771dfca1..00000000000 --- a/java/src/TimedWait.java +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * TimedWait.java - * - *@author Prashant Jain and Doug Schmidt - * - *************************************************/ -package JACE.ASX; - -public abstract class TimedWait -{ - /** - * Default Constructor. Sets "this" to be used for the delegation of - * the wait() call to. - */ - public TimedWait () - { - object_ = this; - } - - /** - * Constructor. Allows subclasses to supply us with an Object that - * is delegated the wait() call. - *@param obj The Object that is delegated the wait() call. - */ - public TimedWait (Object obj) - { - object_ = obj; - } - - /** - * Hook method that needs to be implemented by subclasses. - */ - public abstract boolean condition (); - - /** - * Wait until condition becomes true. Note that the method - * blocks. Also note that this method is final to ensure that no one - * overrides it. - * IMPORTANT: This method assumes it is called with the object_'s - * monitor lock already held. - */ - public final void timedWait () throws InterruptedException - { - // Acquire the monitor lock. - if (!condition ()) - { - // Only attempt to perform the wait if the condition isn't - // true initially. - for (;;) - { - // Wait until we are notified. - object_.wait (); - - // Recheck the condition. - if (condition ()) - break; // Condition became true. - // else we were falsely notified so go back into wait - } - } - } - - /** - * Template Method that implements the actual timed wait. Note that - * this method is final to ensure that no one overrides it. - * IMPORTANT: This method assumes it is called with the object_'s - * monitor lock already held. - *@param tv Amount of time to do wait for. - */ - public final void timedWait (TimeValue tv) - throws InterruptedException, - TimeoutException - { - // Acquire the monitor lock. - if (!condition ()) - { - // Only attempt to perform the timed wait if the condition isn't - // true initially. - long start = System.currentTimeMillis (); - long waitTime = tv.getMilliTime (); - - for (;;) { - // Wait until we are notified. - object_.wait (waitTime); - - // Recheck the condition. - if (!condition ()) { - long now = System.currentTimeMillis (); - long timeSoFar = now - start; - - // Timed out! - if (timeSoFar >= tv.getMilliTime ()) - throw new TimeoutException (); - else - // We still have some time left to wait, so adjust the - // wait_time. - waitTime = tv.getMilliTime () - timeSoFar; - } - else - break; // Condition became true. - } - } - } - - /** - * Notify any one thread waiting on the object_. - * IMPORTANT: This method assumes it is called with the object_'s - * monitor lock already held. - */ - public final void signal () { - object_.notify (); - } - - /** - * Notify all threads waiting on the object_. - * IMPORTANT: This method assumes it is called with the object_'s - * monitor lock already held. - */ - public final void broadcast () { - object_.notifyAll (); - } - - /** - * The object we delegate to. If a subclass gives us a particular - * object, we use that to delegate to, otherwise, we ``delegate'' - * to ourself (i.e., this). - */ - protected Object object_; - -} diff --git a/java/src/TimeoutException.java b/java/src/TimeoutException.java deleted file mode 100644 index b55549938dc..00000000000 --- a/java/src/TimeoutException.java +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.ASX - * - * = FILENAME - * TimeoutException.java - * - *@author Prashant Jain and Doug Schmidt - * - *************************************************/ -package JACE.ASX; - -public class TimeoutException extends Exception -{ - /** - * Default Constructor. - */ - public TimeoutException () - { - super ("Timed Out"); - } - - /** - * Constructor. - *@param timeout The timeout value which expired. - *@param desc Textual description of the exception - */ - public TimeoutException (TimeValue timeout, String desc) - { - super ("Timed Out in " + timeout + ": " + desc); - } - -} diff --git a/java/src/TimerQueue.java b/java/src/TimerQueue.java deleted file mode 100644 index 74bac5ec398..00000000000 --- a/java/src/TimerQueue.java +++ /dev/null @@ -1,421 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Reactor - * - * = FILENAME - * TimerQueue.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Reactor; - -import java.util.*; -import JACE.ASX.*; - -class TimerNode -{ - public TimerNode (EventHandler handler, - Object arg, - TimeValue timerValue, - TimeValue interval, - TimerNode next, - int timerId) - { - this.handler_ = handler; - this.arg_ = arg; - this.timerValue_ = timerValue; - this.interval_ = interval; - this.next_ = next; - this.timerId_ = timerId; - } - - public EventHandler handler_; - // Handler to invoke <handleTimeout> on when a timeout occurs. - - public Object arg_; - // Argument to pass to <handleTimeout>. - - public TimeValue timerValue_; - // Time until the timer expires. - - public TimeValue interval_; - // If this is a periodic timer this holds the time until the next - // timeout. - - public TimerNode next_; - // Pointer to next timer. - - public int timerId_; - // Id of this timer (used to cancel timers before they expire). -} - -class WaitObject extends TimedWait -{ - public boolean condition () - { - return this.condition_; - } - - public void condition (boolean c) - { - this.condition_ = c; - } - - private boolean condition_ = false; -} - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Class that provides an interface to timers. - * - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This is a simple implementation that keeps a linked list of - * absolute timers. It allows multiple timers to be scheduled - * and returns a timer id for each timer scheduled. In addition, - * it allows periodic timers to be scheduled. - *</blockquote> - */ -public class TimerQueue implements Runnable -{ - /** - * Constructor. - *@param createInternalThread flag specifying whether to create an - * internal thread that runs the event loop. If it is true, a thread - * is spawned and it runs the event loop, handling all timeout - * events. If it is false, the caller is then responsible for calling - * handleEvents () to run the event loop. - */ - public TimerQueue (boolean createInternalThread) - { - this.eventLoopRunning_ = false; - if (createInternalThread) - new Thread (this).start (); - } - - /** - * The thread run method. Do *NOT* call this method! It gets called - * automatically. - */ - public void run () - { - this.handleEvents (); - } - - /** - * Handle timeout events. This forms the event loop and takes care - * of all scheduling. This method should only be called if the Timer - * Queue was constructed with the value of createInternalThread as - * false. - */ - public void handleEvents () - { - if (!this.eventLoopRunning_) - { - // Set the flag indicating that the event loop is now running - this.eventLoopRunning_ = true; - - TimeValue timeout = null; - TimeValue earliest = null; - - for (;;) - { - synchronized (this.obj_) - { - earliest = this.earliestTime (); - if (earliest != null) - timeout = TimeValue.minus (earliest, TimeValue.getTimeOfDay ()); - else - timeout = new TimeValue (); - try - { - // Extract the earliest time from the queue and do a timed wait - this.obj_.timedWait (timeout); - - // We have been notified. Check to see if we need to - // restart the wait with a different timeout - if (this.reset_) - { - this.reset_ = false; - this.obj_.condition (false); - timeout = TimeValue.minus (this.earliestTime (), TimeValue.getTimeOfDay ()); - } - } - catch (TimeoutException e) - { - // Timeout occurred. Call handleTimeout on appropriate - // Event Handlers - this.dispatchHandlers (); - } - catch (InterruptedException e) - { - } - } - } - } - } - - /** - * Check if the queue is empty. - *@return true if queue is empty, else false. - */ - boolean isEmpty () - { - return this.head_ == null; - } - - /** - * Get the node of the earliest node in the TimerQueue. - *@return the time of the earlier node in the TimerQueue. - */ - TimeValue earliestTime () - { - synchronized (this.obj_) - { - if (!this.isEmpty ()) - return this.head_.timerValue_; - else - return null; - } - } - - /** - * Schedule an <EventHandler> that will expire after <delta> amount - * of time. If it expires then <obj> is passed in as the value to - * the <EventHandler>'s <handleTimeout> callback method. This method - * returns a timer id that uniquely identifies the timer and can be - * used to cancel the timer before it expires. - *@param handler Event Handler that is to be scheduled with the timer - *@param obj Object that is passed back to the Event Handler when - * timeout occurs (Asynchronous Completion Token) - *@param delta amount of time for which to schedule the timer - *@return id of the timer scheduled - */ - public int scheduleTimer (EventHandler handler, - Object obj, - TimeValue delta) - { - return this.scheduleTimer (handler, obj, delta, TimeValue.zero); - } - - /** - * Schedule an <EventHandler> that will expire after <delta> amount - * of time. If it expires then <obj> is passed in as the value to - * the <EventHandler>'s <handleTimeout> callback method. If - * <interval> is != to <TimeValue.zero> then it is used to - * reschedule the <EventHandler> automatically. This method - * returns a timer id that uniquely identifies the timer and can be - * used to cancel the timer before it expires. - *@param handler Event Handler that is to be scheduled with the timer - *@param arg Object that is passed back to the Event Handler when - * timeout occurs (Asynchronous Completion Token) - *@param timeout amount of time for which to schedule the timer - *@param interval amount of time to use to reschedule the timer - *@return id of the timer scheduled - */ - public int scheduleTimer (EventHandler handler, - Object arg, - TimeValue timeout, - TimeValue interval) - { - // Increment the sequence number (it will wrap around). - this.timerId_++; - TimeValue futureTime = TimeValue.plus (timeout, TimeValue.getTimeOfDay ()); - TimerNode node = new TimerNode (handler, - arg, - futureTime, - interval, - null, - this.timerId_); - synchronized (this.obj_) - { - // Check if event loop is running. If it is not, then we can - // just place it at the appropriate place in the queue and - // don't need to do any notification. If event loop is - // running, then check if the node is the first node in the - // queue (either because the queue is empty or because the - // time for the node is earlier than the currently scheduled - // timer node). - if (this.eventLoopRunning_ && - (this.isEmpty () || futureTime.lessThan (this.earliestTime ()))) - { - // Insert the node into (the beginning of) the queue to be - // scheduled. - this.reschedule (node); - - // Notify the waiting thread so that it can reschedule - // using the earliest timeout - this.obj_.notify (); - } - else // Place in the appropriate position in the queue. - { - this.reschedule (node); - } - } - return this.timerId_; - } - - - /** - * Cancel the single timer associated with <timerId>. - *@param timerId id of the timer that needs to be cancelled. - *@return Object that was passed in when timer was scheduled - * (Asynchronous Completion Token). - */ - public Object cancelTimer (int timerId) - { - TimerNode prev = null; - TimerNode curr = null; - - synchronized (this.obj_) - { - // Try to locate the TimerNode that matches the timerId. - for (curr = this.head_; - curr != null && curr.timerId_ != timerId; - curr = curr.next_) - prev = curr; - - if (curr != null) - { - if (prev == null) - this.head_ = curr.next_; - else - prev.next_ = curr.next_; - - return curr.arg_; - } - } - return null; - } - - /** - * Cancel all timers associated with <Event Handler>. - *@param handler Event Handler whose associated timers need to be cancelled. - */ - public void cancelTimer (EventHandler handler) - { - TimerNode prev = null; - TimerNode curr = this.head_; - - synchronized (this.obj_) - { - while (curr != null) - { - if (curr.handler_ == handler) - { - if (prev == null) - { - this.head_ = curr.next_; - curr = this.head_; - } - else - { - prev.next_ = curr.next_; - curr = prev.next_; - } - } - else - { - prev = curr; - curr = curr.next_; - } - } - } - } - - // Call handleTimeout() on all handlers whose timers have expired. - private void dispatchHandlers () - { - TimeValue currentTime = TimeValue.getTimeOfDay (); - - for (;;) - { - if (this.isEmpty () || this.earliestTime ().greaterThan (currentTime)) - break; // There aren't any more timers eligible to expire. - - TimerNode expired = this.head_; - EventHandler handler = expired.handler_; - Object arg = expired.arg_; - int result; - - this.head_ = this.head_.next_; - - // Check whether this is an interval timer. - if (expired.interval_.greaterThan (TimeValue.zero)) - { - // Make sure that we skip past values that have already - // "expired". - do - expired.timerValue_.plusEquals (expired.interval_); - while (expired.timerValue_.lessThanEqual (currentTime)); - - // Since this is an interval timer, we need to reschedule - // it. - this.reschedule (expired); - } - - // Perform the callback. - result = handler.handleTimeout (currentTime, arg); - - if (result == -1) - this.cancelTimer (handler); - } - } - - // Reschedule a TimerNode by inserting it at the appropriate - // position in the queue. - private void reschedule (TimerNode expired) - { - if (this.isEmpty () || - expired.timerValue_.lessThan (this.earliestTime ())) - { - expired.next_ = this.head_; - this.head_ = expired; - // Set the condition to true so that the waiting thread can be - // notified and it can reschedule. - this.obj_.condition (true); - this.reset_ = true; - } - else - { - TimerNode prev = this.head_; - TimerNode after = this.head_.next_; - - // Locate the proper position in the queue. - - while (after != null - && expired.timerValue_.greaterThan (after.timerValue_)) - { - prev = after; - after = after.next_; - } - - expired.next_ = after; - prev.next_ = expired; - } - } - - private WaitObject obj_ = new WaitObject (); - // Synchronization object (as well as object to use to do wait on) - - private TimerNode head_; - // Pointer to linked list of TimerHandles. - - private int timerId_; - // Keeps track of the timer id that uniquely identifies each timer. - // This id can be used to cancel a timer via the <cancel (int)> - // method. - - private boolean reset_; - // Flag indicating whether to start the wait again - - private boolean eventLoopRunning_; - // Flag indicating whether the event loop is running or not -} - diff --git a/java/src/Token.java b/java/src/Token.java deleted file mode 100644 index a17be013ad5..00000000000 --- a/java/src/Token.java +++ /dev/null @@ -1,298 +0,0 @@ -/************************************************* - * - * = PACKAGE - * JACE.Concurrency - * - * = FILENAME - * Token.java - * - *@author Prashant Jain - * - *************************************************/ -package JACE.Concurrency; - -import java.util.*; -import JACE.ASX.*; - -class WaitObject extends TimedWait -{ - public boolean condition () - { - return this.condition_; - } - - public void condition (boolean c) - { - this.condition_ = c; - } - - private boolean condition_ = false; -} - -/** - * <hr> - * <h2>SYNOPSIS</h2> - *<blockquote> - * Class that acquires, renews, and releases a synchronization - * token that is serviced in strict FIFO ordering. - * - *</blockquote> - * - * <h2>DESCRIPTION</h2> - *<blockquote> - * This is a general-purpose synchronization mechanism that offers - * several benefits. For example, it implements "recursive mutex" - * semantics, where a thread that owns the token can reacquire it - * without deadlocking. In addition, threads that are blocked - * awaiting the token are serviced in strict FIFO order as other - * threads release the token. The solution makes use of the - * Specific Notification pattern presented by Tom Cargill in - * "Specific Notification for Java Thread Synchronization," PLoP96. - *</blockquote> - */ -public class Token -{ - /** - * Acquire the token. Note that this will block. The method uses - * synchronized blocks internally to avoid race conditions. - *@return 0 if acquires without calling <sleepHook> - * 1 if <sleepHook> is called. - * -1 if failure occurs - *@exception InterruptedException exception during wait - */ - public int acquire () throws InterruptedException - { - try - { - return this.acquire (new TimeValue ()); - } - catch (TimeoutException e) - { - // This really shouldn't happen since we are supposed to - // block. - return -1; - } - } - - /** - * Acquire the token. Wait for timeout amount of time. The method - * uses synchronized blocks internally to avoid race conditions. - *@param timeout Amount of time to wait for in trying to acquire the - * token. - *@return 0 if acquires without calling <sleepHook> - * 1 if <sleepHook> is called. - * -1 if failure occurs - *@exception TimeoutException exception if timeout occurs - *@exception InterruptedException exception during wait - */ - public int acquire (TimeValue timeout) throws InterruptedException, TimeoutException - { - int result = 0; - WaitObject snl = new WaitObject (); - boolean mustWait; - synchronized (snl) - { - synchronized (this) - { - mustWait = !this.snq_.isEmpty (); - if (mustWait && - Thread.currentThread ().toString ().compareTo (this.owner_) == 0) - { - // I am the one who has the token. So just increment - // the nesting level - this.nestingLevel_++; - return result; - } - // Add local lock to the queue - this.snq_.addElement (snl); - } - if (mustWait) - { - result = 1; - // Call sleep hook - sleepHook (); - snl.timedWait (timeout); // Do a blocking wait - } - // Set the owner of the token - this.owner_ = Thread.currentThread ().toString (); - } - return result; - } - - /** - * Try to acquire the token. Implements a non-blocking acquire. - *@return 0 if acquires without calling <sleepHook> - * 1 if <sleepHook> is called. - * -1 if failure occurs - */ - public synchronized int tryAcquire () - { - int result = 0; - if (!this.snq_.isEmpty ()) - { - // No one has the token, so acquire it - this.snq_.addElement (new WaitObject ()); - } - // Check if I am the one holding the token. - else if (Thread.currentThread ().toString ().compareTo (this.owner_) == 0) - { - this.nestingLevel_++; - } - // Someone else has the token. - else - { - // Will have to block to acquire the token, so call - // sleepHook and return - sleepHook (); - result = 1; - } - return result; - } - - /** - * Method that is called before a thread goes to sleep in an - * acquire(). This should be overridden by a subclass to define - * the appropriate behavior before acquire() goes to sleep. - * By default, this is a no-op. - */ - public void sleepHook () - { - } - - /** - * An optimized method that efficiently reacquires the token if no - * other threads are waiting. This is useful for situations where - * you don't want to degrade the quality of service if there are - * other threads waiting to get the token. - *@param requeuePosition Position in the queue where to insert the - * lock. If requeuePosition == -1 and there are other threads - * waiting to obtain the token we are queued at the end of the list - * of waiters. If requeuePosition > -1 then it indicates how many - * entries to skip over before inserting our thread into the list of - * waiters (e.g.,requeuePosition == 0 means "insert at front of the - * queue"). - *@exception InterruptedException exception during wait - */ - public void renew (int requeuePosition) throws InterruptedException - { - try - { - this.renew (requeuePosition, new TimeValue ()); - } - catch (TimeoutException e) - { - // This really shouldn't happen since we are supposed to - // block. - } - } - - /** - * An optimized method that efficiently reacquires the token if no - * other threads are waiting. This is useful for situations where - * you don't want to degrade the quality of service if there are - * other threads waiting to get the token. - *@param requeuePosition Position in the queue where to insert the - * lock. If requeuePosition == -1 and there are other threads - * waiting to obtain the token we are queued at the end of the list - * of waiters. If requeuePosition > -1 then it indicates how many - * entries to skip over before inserting our thread into the list of - * waiters (e.g.,requeuePosition == 0 means "insert at front of the - * queue"). - *@param timeout Amount of time to wait for in trying to acquire the - * token. - *@exception TimeoutException exception if timeout occurs - *@exception InterruptedException exception during wait - */ - public void renew (int requeuePosition, TimeValue timeout) - throws InterruptedException, TimeoutException - { - WaitObject snl = null; - int saveNestingLevel = 0; - - synchronized (this) - { - // Check if there is a thread waiting to acquire the token. If - // not or if requeuePosition == 0, then we don't do anything - // and we simply keep the token. - if (this.snq_.size () > 1 && requeuePosition != 0) - { - // Save the nesting level - saveNestingLevel = this.nestingLevel_; - this.nestingLevel_ = 0; - - // Reinsert ourselves at requeuePosition in the queue - snl = (WaitObject) this.snq_.firstElement (); - this.snq_.removeElementAt (0); - - if (requeuePosition < 0) - this.snq_.addElement (snl); // Insert at end - else - this.snq_.insertElementAt (snl, requeuePosition); - - synchronized (this.snq_.firstElement ()) - { - // Notify the first waiting thread in the queue - WaitObject obj = (WaitObject) this.snq_.firstElement (); - // Set its condition to be true so that it falls out - // of the for loop - obj.condition (true); - // Now signal the thread - obj.signal (); - } - } - } - - // Check if we reinserted the lock in the queue and therefore need - // to do a wait - if (snl != null) - { - synchronized (snl) - { - // Set the condition to be false so that we can begin the - // wait - snl.condition (false); - // Do a blocking wait - snl.timedWait (timeout); - } - // Restore the nesting level and current owner of the lock - this.nestingLevel_ = saveNestingLevel; - this.owner_ = Thread.currentThread ().toString (); - } - } - - /** - * Release the token. - */ - public synchronized void release () - { - // Check if nestingLevel > 0 and if so, decrement it - if (this.nestingLevel_ > 0) - this.nestingLevel_--; - else - { - this.snq_.removeElementAt (0); - if (!this.snq_.isEmpty ()) - { - synchronized (this.snq_.firstElement ()) - { - // Notify the first waiting thread in the queue - WaitObject obj = (WaitObject) this.snq_.firstElement (); - // Set its condition to be true so that it falls out - // of the for loop - obj.condition (true); - // Now signal the thread - obj.signal (); - } - } - } - } - - private Vector snq_ = new Vector (); - // Vector of lock objects - - private int nestingLevel_ = 0; - // Current Nesting Level - - private String owner_ = null; - // Current owner of the token. -} diff --git a/java/tests/ASX/BufferStreamTest.java b/java/tests/ASX/BufferStreamTest.java deleted file mode 100644 index 9a696497562..00000000000 --- a/java/tests/ASX/BufferStreamTest.java +++ /dev/null @@ -1,184 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// BufferStreamTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -// This short program copies stdin to stdout via the use of an ASX -// STREAM. It illustrates an implementation of the classic "bounded -// buffer" program using an ASX STREAM containing two Modules. Each -// Module contains two Tasks. - -class CommonTask extends Task -{ - // ACE_Task hooks - public int open (Object obj) - { - if (this.activate (0, 1, false) == -1) - ACE.ERROR ("spawn"); - return 0; - } - - public int close (long exitStatus) - { - ACE.DEBUG (Thread.currentThread () + " thread is exiting with status " + - exitStatus + " in module " + this.name () + "\n"); - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - return 0; - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } -} - -// Define the Producer interface. - -class Producer extends CommonTask -{ - // Read data from stdin and pass to consumer. - // The Consumer reads data from the stdin stream, creates a message, - // and then queues the message in the message list, where it is - // removed by the consumer thread. A 0-sized message is enqueued when - // there is no more data to read. The consumer uses this as a flag to - // know when to exit. - - public int svc () - { - // Keep reading stdin, until we reach EOF. - - DataInputStream in = new DataInputStream (System.in); - String msg = null; - try - { - while (true) - { - System.out.print ("Enter input: "); - System.out.flush (); - msg = in.readLine (); - if (msg == null) - { - // Send a shutdown message to the other thread and exit. - if (this.putNext (new MessageBlock (0), new TimeValue ()) == -1) - ACE.ERROR ("putNext"); - break; - } - else - { - // Send the message to the other thread. - if (this.putNext (new MessageBlock (msg), new TimeValue ()) == -1) - ACE.ERROR ("putNext"); - } - } - } - catch (IOException e) - { - } - return 0; - } -} - -class Consumer extends CommonTask - // = TITLE - // Define the Consumer interface. -{ - // Enqueue the message on the MessageQueue for subsequent - // handling in the svc() method. - public int put (MessageBlock mb, TimeValue tv) - { - try - { - return this.putq (mb, tv); - } - catch (InterruptedException e) - { - } - return 0; - } - - // The consumer dequeues a message from the ACE_Message_Queue, writes - // the message to the stderr stream, and deletes the message. The - // Consumer sends a 0-sized message to inform the consumer to stop - // reading and exit. - - public int svc () - { - MessageBlock mb = null; - - // Keep looping, reading a message out of the queue, until we - // timeout or get a message with a length == 0, which signals us to - // quit. - try - { - while (true) - { - // Wait for upto 4 seconds - mb = this.getq (new TimeValue (4)); - - if (mb == null) - break; - - int length = mb.length (); - - if (length > 0) - System.out.println ("\n" + mb.base ()); - - if (length == 0) - break; - } - } - catch (InterruptedException e) - { - } - if (mb == null) - { - ACE.ERROR ("timed out waiting for message"); - System.exit (1); - } - return 0; - } -} - -// Spawn off a new thread. - -public class BufferStreamTest -{ - public static void main (String args[]) - { - // Control hierachically-related active objects - Stream stream = new Stream (); - Module pm = new Module ("Consumer", new Consumer (), null, null); - Module cm = new Module ("Producer", new Producer (), null, null); - - // Create Producer and Consumer Modules and push them onto the - // STREAM. All processing is performed in the STREAM. - - if (stream.push (pm) == -1) - { - ACE.ERROR ("push"); - return; - } - else if (stream.push (cm) == -1) - { - ACE.ERROR ("push"); - return; - } - } -} diff --git a/java/tests/ASX/Makefile b/java/tests/ASX/Makefile deleted file mode 100644 index d097cbb0850..00000000000 --- a/java/tests/ASX/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = MessageQueueTest.java \ - TaskTest.java \ - PriorityBufferTest.java \ - ThreadPoolTest.java \ - BufferStreamTest.java - -packages = tests.ASX - -realclean: - find ${JACE_WRAPPER}/classes/tests/ASX -name '*.class' -print | xargs ${RM} - diff --git a/java/tests/ASX/MessageQueueTest.java b/java/tests/ASX/MessageQueueTest.java deleted file mode 100644 index c22d2cf041d..00000000000 --- a/java/tests/ASX/MessageQueueTest.java +++ /dev/null @@ -1,50 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// MessageQueueTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -public class MessageQueueTest -{ - public static void main (String args[]) - { - try - { - MessageBlock conMb; - MessageQueue msgQueue = new MessageQueue (); - MessageBlock mb1 = new MessageBlock ("hello"); - MessageBlock mb2 = new MessageBlock ("world"); - mb1.msgPriority (5); - mb2.msgPriority (7); - - // Enqueue in priority order. - if (msgQueue.enqueue (mb1) == -1) - ACE.ERROR ("put_next"); - - if (msgQueue.enqueue (mb2) == -1) - ACE.ERROR ("put_next"); - - // Now try to dequeue - if ((conMb = msgQueue.dequeueHead ()) == null) - ACE.ERROR ("dequeueHead"); - else - ACE.DEBUG ("Consumer: removed item " + conMb.base () + " of priority " + conMb.msgPriority ()); - } - catch (InterruptedException e) - { - } - } -} - diff --git a/java/tests/ASX/PriorityBufferTest.java b/java/tests/ASX/PriorityBufferTest.java deleted file mode 100644 index 5cce32fa3b1..00000000000 --- a/java/tests/ASX/PriorityBufferTest.java +++ /dev/null @@ -1,116 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// PriorityBufferTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -class consumer extends Thread -{ - public void run () - { - MessageBlock mb = null; - long curPriority = 0; - int length = 0; - - try - { - // Keep looping, reading a message out of the queue, until we - // get a message with a length == 0, which signals us to quit. - for (;;) - { - if ((mb = PriorityBufferTest.msgQueue.dequeueHead ()) == null) - break; - - length = mb.length (); - curPriority = mb.msgPriority (); - - if (length > 0) - ACE.DEBUG ("Consumer: removed item \"" + mb.base () + "\" of priority: " + curPriority); - - if (length == 0) - break; - } - } - catch (InterruptedException e) - { - } - } -} - -class producer extends Thread -{ - producer (int delay) - { - this.delay_ = delay; - } - - public void run () - { - try - { - long count = 0; - for (char c = 'a'; c <= 'z'; c++) - { - count++; - // Allocate a new message - MessageBlock mb = new MessageBlock (new Character (c).toString ()); - // Set the priority - mb.msgPriority (count); - - // Enqueue in priority order. - if (PriorityBufferTest.msgQueue.enqueue (mb) == -1) - ACE.ERROR ("put_next"); - else - { - ACE.DEBUG ("Producer: inserted item \"" + mb.base () + "\" of priority: " + count); - if (this.delay_ > 0) - this.sleep (this.delay_); - } - } - - // Now send a 0-sized shutdown message to the other thread - if (PriorityBufferTest.msgQueue.enqueueTail (new MessageBlock (0)) == -1) - ACE.ERROR ("put_next"); - } - catch (InterruptedException e) - { - } - } - - private int delay_; -} - -public class PriorityBufferTest -{ - public static MessageQueue msgQueue = new MessageQueue (); - - public static void main (String args[]) - { - int delay = 0; - if (args.length == 1) - { - try - { - delay = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - } - new producer (delay).start (); - new consumer ().start (); - } -} diff --git a/java/tests/ASX/TaskTest.java b/java/tests/ASX/TaskTest.java deleted file mode 100644 index b26b48ea148..00000000000 --- a/java/tests/ASX/TaskTest.java +++ /dev/null @@ -1,86 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// TaskTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class TaskTest extends Task -{ - int nThreads_; - int nIterations_; - - public TaskTest (int nThreads, int nIterations) - { - this.nIterations_ = nIterations; - this.nThreads_ = nThreads; - if (this.activate (0, nThreads, true) == -1) - ACE.ERROR ("activate failed"); - } - - public int open (Object obj) - { - return 0; - } - - public int close (long flags) - { - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - return 0; - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - - public int svc () - { - for (int i = 1; i <= this.nIterations_; i++) - { - ACE.DEBUG (Thread.currentThread ().toString () + " in iteration " + i); - // Allow other threads to run - Thread.yield (); - } - return 0; - } - - public static void main (String args[]) - { - int nThreads = 1; - int nIterations = 1; - try - { - if (args.length == 2) - { - nThreads = Integer.parseInt (args[0]); - nIterations = Integer.parseInt (args[1]); - } - else if (args.length == 1) - { - nThreads = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - TaskTest tt = new TaskTest (nThreads, nIterations); - } -} diff --git a/java/tests/ASX/ThreadPoolTest.java b/java/tests/ASX/ThreadPoolTest.java deleted file mode 100644 index cfb20f87adb..00000000000 --- a/java/tests/ASX/ThreadPoolTest.java +++ /dev/null @@ -1,185 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// ThreadPoolTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class ThreadPoolTest extends Task -{ - int nThreads_; - int nIterations_; - - public static int MAX_MB_SIZE = 1024; - - public ThreadPoolTest (int nThreads, int nIterations) - { - this.nIterations_ = nIterations; - this.nThreads_ = nThreads; - if (this.activate (0, nThreads, true) == -1) - ACE.ERROR ("activate failed"); - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - - public int open (Object obj) - { - return 0; - } - - public int close (long flags) - { - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - try - { - return this.putq (mb, tv); - } - catch (InterruptedException e) - { - } - return 0; - } - - public int svc () - { - int result = 0; - int count = 1; - - // Keep looping, reading a message out of the queue, until we get a - // message with a length == 0, which signals us to quit. - try - { - for (;; count++) - { - MessageBlock mb = this.getq (new TimeValue ()); - if (mb == null) - { - ACE.ERROR (Thread.currentThread ().toString () + " in iteration " + count + ", got result -1, exiting"); - break; - } - int length = mb.length (); - - if (length > 0) - ACE.DEBUG (Thread.currentThread ().toString () + - " in iteration " + count + ", length = " + - length + ", text = \"" + mb.base () + "\""); - - if (length == 0) - { - ACE.DEBUG (Thread.currentThread ().toString () + - " in iteration " + count + - ", got NULL message, exiting"); - break; - } - Thread.yield (); - } - } - catch (InterruptedException e) - { - } - return 0; - } - - public static void produce (ThreadPoolTest threadPool, int nIterations) - { - int count = 0; - for (int n = 0;;) - { - // Allocate a new message. - MessageBlock mb = new MessageBlock (new Integer (count).toString ()); - - if (count == nIterations) - n = 1; // Indicate that we need to shut down. - else - count++; - - if (count == 0 || (count % 20 == 0)) - { - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - } - if (n != 1) - { - ACE.DEBUG ("Producing..."); - // Pass the message to the Thread_Pool. - if (threadPool.put (mb, new TimeValue ()) == -1) - ACE.ERROR ("put"); - } - else - { - // Send a shutdown message to the waiting threads and exit. - ACE.DEBUG ("start loop, dump of task"); - - for (int i = threadPool.thrCount (); i > 0; i--) - { - ACE.DEBUG (Thread.currentThread ().toString () + - "EOF, enqueueing NULL block for thread " + i); - - // Enqueue a NULL message to flag each consumer to - // shutdown. - if (threadPool.put (new MessageBlock (0), new TimeValue ()) == -1) - ACE.ERROR ("put"); - } - - break; - } - } - } - - public static void main (String args[]) - { - int nThreads = 1; - int nIterations = 100; - try - { - if (args.length == 2) - { - nThreads = Integer.parseInt (args[0]); - nIterations = Integer.parseInt (args[1]); - } - else if (args.length == 1) - { - nThreads = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - ACE.DEBUG ("Threads = " + nThreads + " Iterations = " + nIterations); - - // Create the worker tasks. - ThreadPoolTest threadPool = new ThreadPoolTest (nThreads, - nIterations); - - // Create work for the worker tasks to process in their own threads. - produce (threadPool, nIterations); - ACE.DEBUG ("exiting..."); - } -} - - diff --git a/java/tests/Concurrency/Condition/Consumer.java b/java/tests/Concurrency/Condition/Consumer.java deleted file mode 100644 index ff4f5ff4a4b..00000000000 --- a/java/tests/Concurrency/Condition/Consumer.java +++ /dev/null @@ -1,73 +0,0 @@ -//File: Consumer.java -//Seth Widoff 8/8/96 -//This class attempts at random intervals to dequeue random elements -//from a queue. If the queue is empty the thread waits until an element -//has been enqueued and another thread has invoked the notify() method. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; -import java.util.Random; - -public class Consumer implements Runnable -{ - //Maximum pause between dequeues (in milliseconds) - private static final int MAX_PAUSE = 1000; - - private SimpleMessageQueue queue_; - private boolean stop_requested_ = false; - private String name_; - private int iterations_; - private TimeValue timeout_; - - public Consumer(String name, - SimpleMessageQueue queue, - int iterations, - TimeValue timeout) - { - name_ = "Consumer " + name; - queue_ = queue; - iterations_ = iterations; - timeout_ = timeout; - } - - public void run() - { - //Set the random number generator seed to the current time in - //milliseconds. - - Random random = new Random(System.currentTimeMillis()); - Integer element; - - for (int i = 0; i < iterations_; ) - { - try - { - element = (Integer)queue_.dequeue(timeout_); - if (element != null) - { - - System.out.print("Consumer::run() " + name_ + " dequeued " + element.toString()); - System.out.println(" Queue size: " + queue_.size()); - - Thread.sleep(random.nextLong() % MAX_PAUSE); - } - else - { - System.out.println ("Null"); - } - i++; - } - catch(Exception excp) - { - System.out.print ("Consumer::run() Exception: "); - System.out.println(excp); - } - } - } - - public void requestStop() - { - stop_requested_ = true; - } -} diff --git a/java/tests/Concurrency/Condition/JoinableThreadGroup.java b/java/tests/Concurrency/Condition/JoinableThreadGroup.java deleted file mode 100644 index c878eb026d3..00000000000 --- a/java/tests/Concurrency/Condition/JoinableThreadGroup.java +++ /dev/null @@ -1,24 +0,0 @@ -package tests.Concurrency.Condition; - -public class JoinableThreadGroup extends ThreadGroup -{ - public JoinableThreadGroup(String name) - { - super(name); - } - - public JoinableThreadGroup(ThreadGroup parent, String name) - { - super(parent, name); - } - - public void join() throws InterruptedException - { - Thread list[] = new Thread[activeCount()]; - - enumerate(list, true); - - for (int i = 0; i < list.length; i++) - list[i].join(); - } -} diff --git a/java/tests/Concurrency/Condition/Makefile b/java/tests/Concurrency/Condition/Makefile deleted file mode 100644 index fd1e6a93677..00000000000 --- a/java/tests/Concurrency/Condition/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - -files = \ - QueueTest.java \ - JoinableThreadGroup.java \ - SimpleMessageQueue.java \ - Producer.java \ - Consumer.java - -packages = tests.Concurrency.Condition; - -realclean: - find ${JACE_WRAPPER}/classes/tests/Concurrency/Condition -name '*.class' -print | xargs ${RM} diff --git a/java/tests/Concurrency/Condition/Producer.java b/java/tests/Concurrency/Condition/Producer.java deleted file mode 100644 index ed6da2251ba..00000000000 --- a/java/tests/Concurrency/Condition/Producer.java +++ /dev/null @@ -1,67 +0,0 @@ -//File: Producer.java -//Seth Widoff 8/8/96 -//This class attempts at random intervals to enqueue random elements -//into a queue. If the queue is full the thread waits until an element -//has been dequeued and another thread has invoked the notify() method. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; -import java.util.Random; - -public class Producer implements Runnable -{ - //Maximum pause between enqueues (in milliseconds) - private static final int MAX_PAUSE = 1000; - - private SimpleMessageQueue queue_; - private boolean stop_requested_ = false; - private String name_; - private int iterations_; - private TimeValue timeout_; - - public Producer(String name, - SimpleMessageQueue queue, - int iterations, - TimeValue timeout) - { - name_ = "Producer " + name; - queue_ = queue; - iterations_ = iterations; - timeout_ = timeout; - } - - public void run() - { - //Set the random number generator seed to the current time in milliseconds. - Random random = new Random(System.currentTimeMillis()); - int element = 1; - - for (int i = 0; i < iterations_; ) - { - try - { - // element = random.nextInt(); - - queue_.enqueue((Object)new Integer(element), timeout_); - System.out.print("Producer::run() " + name_ + " enqueued " + element); - System.out.println(" Queue size: " + queue_.size()); - - Thread.sleep(random.nextLong() % MAX_PAUSE); - i++; - element++; - } - catch(Exception excp) - { - System.out.print("Producer::run() Exception: "); - System.out.println(excp); - } - } - } - - public void requestStop() - { - stop_requested_ = true; - } -} - diff --git a/java/tests/Concurrency/Condition/QueueTest.java b/java/tests/Concurrency/Condition/QueueTest.java deleted file mode 100644 index 87e7d57bbbd..00000000000 --- a/java/tests/Concurrency/Condition/QueueTest.java +++ /dev/null @@ -1,64 +0,0 @@ -//File: QueueTest.java -//Seth Widoff, 8/8/96 -//This class is a test method for the Producer and Consumer classes. -//The main method takes as arguments the number of producers, the -//number of consumers and the number of elements in the queue. It then -//spawn the specified threads and starts them. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; - -public class QueueTest -{ - public static void main(String[] args) - { - if (args.length < 5) - { - System.out.println("Usage: java QueueTest <# producers> <# consumers> <# elements> <#iterations> <#timeout secs> <#timeout nano secs>"); - System.exit(1); - } - - int num_producers = Integer.parseInt(args[0]), - num_consumers = Integer.parseInt(args[1]), - num_elements = Integer.parseInt(args[2]), - num_iterations = Integer.parseInt(args[3]), - num_timeout_secs = Integer.parseInt(args[4]), - num_timeout_nano_secs = Integer.parseInt(args[5]); - - if (num_elements < 1 - || num_consumers < 1 - || num_producers < 1) - { - System.out.println("All the parameters must be larger than zero."); - System.exit(1); - } - - SimpleMessageQueue queue = new SimpleMessageQueue(num_elements); - Consumer[] consumers = new Consumer[num_consumers]; - Producer[] producers = new Producer[num_producers]; - JoinableThreadGroup thread_group = new JoinableThreadGroup("Producer Consumer"); - - for (int i = 0; i < num_producers; i++) - { - producers[i] = new Producer("Number " + (i + 1), queue, num_iterations, new TimeValue (num_timeout_secs, num_timeout_nano_secs)); - new Thread(thread_group, producers[i]).start(); - } - - for (int i = 0; i < num_consumers; i++) - { - consumers[i] = new Consumer("Number " + (i + 1), queue, num_iterations, new TimeValue (num_timeout_secs, num_timeout_nano_secs)); - new Thread(thread_group, consumers[i]).start(); - } - - try - { - thread_group.join(); - } - catch(InterruptedException excp) - { - System.out.println("QueueTest::main"); - System.out.println(excp); - } - } -} diff --git a/java/tests/Concurrency/Condition/SimpleMessageQueue.java b/java/tests/Concurrency/Condition/SimpleMessageQueue.java deleted file mode 100644 index bb703516858..00000000000 --- a/java/tests/Concurrency/Condition/SimpleMessageQueue.java +++ /dev/null @@ -1,86 +0,0 @@ -package tests.Concurrency.Condition; - -import JACE.ASX.TimeoutException; -import JACE.ASX.TimeValue; -import JACE.Concurrency.*; - -public class SimpleMessageQueue -{ - private int num_items_ = 0; - private int head_ = 0, tail_ = 0; - private Object[] queue_; - - private Mutex lock_ = new Mutex (); - private Condition notFull_ = new Condition (lock_); - private Condition notEmpty_ = new Condition (lock_); - - public SimpleMessageQueue(int size) - { - queue_ = new Object[size]; - } - - public void enqueue(Object element, TimeValue timeout) - throws TimeoutException, InterruptedException - { - try - { - lock_.acquire (); - while (this.isFull ()) - notFull_.Wait (timeout); - - if (tail_ == queue_.length) - tail_ = 0; - queue_[tail_] = element; - tail_++; - - num_items_++; - notEmpty_.signal (); - } - finally - { - lock_.release (); - } - } - - public Object dequeue (TimeValue timeout) - throws TimeoutException, InterruptedException - { - Object return_value = null; - - try - { - lock_.acquire (); - while (this.isEmpty ()) - notEmpty_.Wait (timeout); - - return_value = queue_[head_]; - head_++; - if (head_ == queue_.length) - head_ = 0; - - num_items_--; - notFull_.signal (); - } - finally - { - lock_.release (); - } - return return_value; - } - - public boolean isEmpty() - { - return num_items_ == 0; - } - - public boolean isFull() - { - return num_items_ == queue_.length; - } - - public int size() - { - return num_items_; - } -} - diff --git a/java/tests/Concurrency/Makefile b/java/tests/Concurrency/Makefile deleted file mode 100644 index f967dffb92f..00000000000 --- a/java/tests/Concurrency/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - -files = MutexTest.java \ - SemaphoreTest.java \ - RWMutexTest.java \ - TokenTest.java - -packages = tests.Concurrency - -realclean: - find ${JACE_WRAPPER}/classes/tests/Concurrency -name '*.class' -print | xargs ${RM} diff --git a/java/tests/Concurrency/MutexTest.java b/java/tests/Concurrency/MutexTest.java deleted file mode 100644 index 680266ef071..00000000000 --- a/java/tests/Concurrency/MutexTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * MutexTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class MutexReader extends Thread -{ - MutexReader (int nIterations, Mutex mutex) - { - this.nIterations_ = nIterations; - this.mutex_ = mutex; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the mutex (will block until it gets it) - try - { - this.mutex_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - MutexTest.count++; - ACE.DEBUG (Thread.currentThread ().toString () + - " reader acquired mutex in iteration " + i + - ", count = " + MutexTest.count); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - // Release the mutex - this.mutex_.release (); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Mutex mutex_; -} - -class MutexWriter extends Thread -{ - MutexWriter (int nIterations, Mutex mutex) - { - this.nIterations_ = nIterations; - this.mutex_ = mutex; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the mutex (will block until it gets it) - try - { - this.mutex_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - MutexTest.count++; - ACE.DEBUG (Thread.currentThread ().toString () + - " writer acquired mutex in iteration " + i + - ", count = " + MutexTest.count); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - // Release the mutex - this.mutex_.release (); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Mutex mutex_; -} - -public class MutexTest -{ - public static void main (String args[]) - { - int nReaders = 1; - int nWriters = 1; - int nIterations = 100; - int i; - try - { - if (args.length == 3) - { - nReaders = Integer.parseInt (args[0]); - nWriters = Integer.parseInt (args[1]); - nIterations = Integer.parseInt (args[2]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Create a lock - Mutex mutex = new Mutex (); - - // Now spawn off the readers and writers - for (i = 0; i < nReaders; i++) - new MutexReader (nIterations, mutex).start (); - - for (i = 0; i < nWriters; i++) - new MutexWriter (nIterations, mutex).start (); - } - public static int count; -} diff --git a/java/tests/Concurrency/RWMutexTest.java b/java/tests/Concurrency/RWMutexTest.java deleted file mode 100644 index ab28c9a83fd..00000000000 --- a/java/tests/Concurrency/RWMutexTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * RWMutexTest.java - * - *@author Ross Dargahi (rossd@krinfo.com) - * - *************************************************/ -package tests.Concurrency; - -import JACE.OS.*; -import JACE.Concurrency.*; - -class TestThread extends Thread -{ - TestThread(String name, - boolean writer, - RWMutex lock) - { - super (name); - mWriter = writer; - mLock = lock; - } - - public void run() - { - for (int i = 0; i < 10; i++) - { - try - { - if (!mWriter) - { - mLock.acquireRead(); - ACE.DEBUG (getName() + ": Acquired Read Lock"); - - int sleepTime = i * 100; - sleep (sleepTime); - - mLock.release (); - ACE.DEBUG (getName () + ": Released Read Lock"); - } - else - { - mLock.acquireWrite (); - ACE.DEBUG (getName () + ": Acquired Write Lock"); - - int sleepTime = i * 100; - sleep (sleepTime); - - mLock.release (); - ACE.DEBUG (getName () + ": Released Write Lock"); - } - } - catch (InterruptedException ex) - { - ACE.ERROR ("InterruptedException"); - } - } - } - - RWMutex mLock; - boolean mWriter; -} - -public class RWMutexTest -{ - public static void main(String [] args) - { - RWMutex lock = new RWMutex(); - - TestThread t1 = new TestThread ("1", false, lock); - TestThread t2 = new TestThread ("2", false, lock); - TestThread t3 = new TestThread ("3", false, lock); - TestThread t4 = new TestThread ("4", true, lock); - TestThread t5 = new TestThread ("5", false, lock); - TestThread t6 = new TestThread ("6", false, lock); - TestThread t7 = new TestThread ("7", false, lock); - TestThread t8 = new TestThread ("8", true, lock); - - t1.start (); - t2.start (); - t3.start (); - t4.start (); - t5.start (); - t6.start (); - t7.start (); - t8.start (); - } -} - diff --git a/java/tests/Concurrency/SemaphoreTest.java b/java/tests/Concurrency/SemaphoreTest.java deleted file mode 100644 index b45929daa55..00000000000 --- a/java/tests/Concurrency/SemaphoreTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * SemaphoreTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class SemaphoreWriter extends Thread -{ - SemaphoreWriter (int nIterations, Semaphore s) - { - this.nIterations_ = nIterations; - this.s_ = s; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the semaphore (will block until it gets it) - try - { - this.s_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - SemaphoreTest.counter++; - ACE.DEBUG (Thread.currentThread ().toString () + - " acquired semaphore in iteration " + i + - ", counter = " + SemaphoreTest.counter); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - // Release the semaphore - this.s_.release (); - ACE.DEBUG (Thread.currentThread ().toString () + - " released semaphore in iteration " + i); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Semaphore s_; -} - -public class SemaphoreTest -{ - public static void main (String args[]) - { - int nThreads = 1; - int count = 1; - int nIterations = 100; - int i; - try - { - if (args.length == 3) - { - nThreads = Integer.parseInt (args[0]); - count = Integer.parseInt (args[1]); - nIterations = Integer.parseInt (args[2]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Create a lock - Semaphore s = new Semaphore (count); - - // Spawn off n_threads - for (i = 0; i < nThreads; i++) - new SemaphoreWriter (nIterations, s).start (); - } - public static int counter; -} diff --git a/java/tests/Concurrency/TokenTest.java b/java/tests/Concurrency/TokenTest.java deleted file mode 100644 index ededed9fed9..00000000000 --- a/java/tests/Concurrency/TokenTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * TokenTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class MyToken extends Token -{ - public void sleepHook () - { - ACE.DEBUG (Thread.currentThread () + " blocking, sleepHook called"); - } -} - -public class TokenTest implements Runnable -{ - public void run () - { - try - { - this.token_.acquire (); - ACE.DEBUG (Thread.currentThread () + " acquired token"); - this.token_.acquire (); - ACE.DEBUG (Thread.currentThread () + " acquired token"); - Thread.sleep (100); - - this.token_.renew (1); - - this.token_.release (); - ACE.DEBUG (Thread.currentThread () + " released token"); - this.token_.release (); - ACE.DEBUG (Thread.currentThread () + " released token"); - } - catch (InterruptedException e) - { - this.token_.release (); - } - } - - public static void main (String args []) - { - ThreadManager tm = new ThreadManager (); - int n = 1; - try - { - if (args.length == 1) - { - n = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - tm.spawnN (n, - new TokenTest (), - false); - } - - private MyToken token_ = new MyToken (); -} diff --git a/java/tests/Connection/AcceptorTest.java b/java/tests/Connection/AcceptorTest.java deleted file mode 100644 index 0f8877f52d9..00000000000 --- a/java/tests/Connection/AcceptorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// AcceptorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class AcceptorTest -{ - void print_usage_and_die () - { - System.out.println ("Usage: test_server [<port>]"); - System.exit (0); - } - - public void init (int port) - { - try - { - Acceptor acceptor = new Acceptor (Class.forName ("tests.Connection.ServerHandler")); - acceptor.open (port); - while (true) - { - acceptor.accept (); - } - } - catch (ClassNotFoundException e) - { - ACE.ERROR (e); - } - catch (SocketException e) - { - ACE.ERROR ("Socket Exception: " + e); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - catch (IllegalAccessException e) - { - ACE.ERROR ("Dang!" + e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - AcceptorTest acceptorTest = new AcceptorTest (); - - if (args.length == 1) - { - try - { - port = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - acceptorTest.print_usage_and_die (); - } - } - acceptorTest.init (port); - } -} diff --git a/java/tests/Connection/ClientHandler.java b/java/tests/Connection/ClientHandler.java deleted file mode 100644 index 702c633ceca..00000000000 --- a/java/tests/Connection/ClientHandler.java +++ /dev/null @@ -1,76 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ClientHandler.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ClientHandler extends SvcHandler -{ - public ClientHandler () - { - } - - public int open (Object obj) - { - new Thread (this).start (); - return 0; - } - - public void run () - { - DataInputStream in = new DataInputStream (System.in); - String msg; - StringBuffer ack = new StringBuffer (); - int ack_len; - try - { - while (true) - { - System.out.print ("Enter input: "); - System.out.flush (); - msg = in.readLine (); - if (msg == null) - break; - this.peer ().send (new StringBuffer (msg)); - System.out.println ("Waiting for ack..."); - ack_len = this.peer ().recv (ack); - if (ack_len == 0) - break; - else - System.out.println (ack); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.peer ().close (); - } - catch (IOException e) - { - } - } - - } -} diff --git a/java/tests/Connection/ConnectorTest.java b/java/tests/Connection/ConnectorTest.java deleted file mode 100644 index 605d5e7a400..00000000000 --- a/java/tests/Connection/ConnectorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ConnectorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ConnectorTest -{ - void print_usage_and_die () - { - System.out.println ("Usage: test_Connector <hostname> [<port>]"); - System.exit (0); - } - - public void init (String hostname, int port) - { - try - { - Connector connector = new Connector (); - connector.open (hostname, port); - connector.connect (new ClientHandler ()); - } - catch (UnknownHostException e) - { - ACE.ERROR (e); - } - catch (SocketException e) - { - ACE.ERROR ("Connection refused"); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - catch (IllegalAccessException e) - { - ACE.ERROR (e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - ConnectorTest connectorTest = new ConnectorTest (); - - if (args.length == 2) - { - try - { - port = Integer.parseInt (args[1]); - } - catch (NumberFormatException e) - { - connectorTest.print_usage_and_die (); - } - } - connectorTest.init (args[0], port); - } -} diff --git a/java/tests/Connection/Makefile b/java/tests/Connection/Makefile deleted file mode 100644 index de076f71237..00000000000 --- a/java/tests/Connection/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = ServerHandler.java \ - ClientHandler.java \ - ConnectorTest.java \ - AcceptorTest.java - -packages = tests.Connection - -realclean: - find ${JACE_WRAPPER}/classes/tests/Connection -name '*.class' -print | xargs ${RM} diff --git a/java/tests/Connection/ServerHandler.java b/java/tests/Connection/ServerHandler.java deleted file mode 100644 index 7cdd50d7d37..00000000000 --- a/java/tests/Connection/ServerHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ServerHandler.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ServerHandler extends SvcHandler -{ - public ServerHandler () - { - } - - public int open (Object obj) - { - new Thread (this).start (); - return 0; - } - - public void run () - { - int msg_len; - System.out.println ("Waiting for messages..."); - try - { - while (true) - { - StringBuffer msg = new StringBuffer (); - msg_len = this.peer ().recv (msg); - if (msg_len == 0) - break; - System.out.println ("Received: " + msg); - this.peer ().send (new StringBuffer ("Got it!")); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.peer ().close (); - } - catch (IOException e) - { - } - } - - } -} diff --git a/java/tests/Misc/Makefile b/java/tests/Misc/Makefile deleted file mode 100644 index 2ea3d10fba5..00000000000 --- a/java/tests/Misc/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = ParseArgsTest.java - -packages = tests.Misc - -realclean: - find ${JACE_WRAPPER}/classes/tests/Misc -name '*.class' -print | xargs ${RM} diff --git a/java/tests/Misc/ParseArgsTest.java b/java/tests/Misc/ParseArgsTest.java deleted file mode 100644 index 5baddd2745d..00000000000 --- a/java/tests/Misc/ParseArgsTest.java +++ /dev/null @@ -1,45 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Misc -// -// = FILENAME -// ParseArgsTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Misc; - -import JACE.OS.*; -import JACE.Misc.*; - -public class ParseArgsTest -{ - public static void main (String args[]) - { - String s; - GetOpt opt = new GetOpt (args, "p:rs:"); - for (int c; (c = opt.next ()) != -1; ) - { - switch (c) - { - case 'p': - s = opt.optarg (); - ACE.DEBUG ("Option <p> selected with argument " + s); - break; - case 'r': - ACE.DEBUG ("Option <r> selected"); - break; - case 's': - s = opt.optarg (); - ACE.DEBUG ("Option <s> selected with argument " + s); - break; - default: - ACE.DEBUG ("Usage: java tests.Misc.ParseArgsTest [-p arg1] [-r] [-s arg2]"); - break; - } - } - } -} diff --git a/java/tests/Reactor/Makefile b/java/tests/Reactor/Makefile deleted file mode 100644 index f55573a89cb..00000000000 --- a/java/tests/Reactor/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = TimeValueTest.java \ - TimerQueueTest.java - -packages = tests.Reactor - -realclean: - find ${JACE_WRAPPER}/classes/tests/Reactor -name '*.class' -print | xargs ${RM} diff --git a/java/tests/Reactor/TimeValueTest.java b/java/tests/Reactor/TimeValueTest.java deleted file mode 100644 index b4f3e420ae1..00000000000 --- a/java/tests/Reactor/TimeValueTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************* - * - * = PACKAGE - * ACE.Reactor - * - * = FILENAME - * TimeValueTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Reactor; - -import JACE.OS.*; -import JACE.ASX.*; - -public class TimeValueTest -{ - public void ASSERT (boolean expression, int i) - { - if (!expression) - ACE.DEBUG ("ASSERT failed for " + i); - } - - public void runTest () - { - TimeValue tv1 = new TimeValue (); - TimeValue tv2 = new TimeValue (2); - TimeValue tv3 = new TimeValue (100); - TimeValue tv4 = new TimeValue (1, 1000000000); - TimeValue tv5 = new TimeValue (2); - TimeValue tv6 = new TimeValue (1, -1000000000); - - this.ASSERT (tv1.equals (new TimeValue (0)), 1); - this.ASSERT (tv2.lessThan (tv3), 2); - this.ASSERT (tv2.lessThanEqual (tv2), 3); - this.ASSERT (tv2.greaterThanEqual (tv4), 4); - this.ASSERT (tv5.greaterThanEqual (tv6), 5); - this.ASSERT (tv2.equals (new TimeValue (1, 1000000000)), 6); - this.ASSERT (tv5.equals (tv4), 7); - this.ASSERT (tv2.equals (tv4), 8); - this.ASSERT (tv1.notEquals (tv2), 9); - this.ASSERT (tv6.equals (tv1), 10); - } - - public static void main (String [] args) - { - new TimeValueTest ().runTest (); - } -} diff --git a/java/tests/Reactor/TimerQueueTest.java b/java/tests/Reactor/TimerQueueTest.java deleted file mode 100644 index d34439dcf9b..00000000000 --- a/java/tests/Reactor/TimerQueueTest.java +++ /dev/null @@ -1,80 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Reactor -// -// = FILENAME -// TimerQueueTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Reactor; - -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class TimerQueueTest implements EventHandler -{ - public int handleTimeout (TimeValue tv, Object obj) - { - ACE.DEBUG ("handleTimeout: " + tv.toString () + " " + (String) obj); - return 0; - } - - public static void main (String args []) - { - TimerQueue tq = new TimerQueue (true); - TimerQueueTest th1 = new TimerQueueTest (); - int n = 5; - - try - { - if (args.length == 1) - { - n = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Set a periodic timer - int id= tq.scheduleTimer (th1, - "periodic", - new TimeValue (2), - new TimeValue (3)); - - int i; - // Set a bunch of single timers - for (i=1; i <= n; i++) - { - tq.scheduleTimer (th1, - "A-timer-" + new Integer (i), - new TimeValue (i*2)); - } - - TimerQueueTest th2 = new TimerQueueTest (); - for (i=1; i <= n; i++) - { - tq.scheduleTimer (th2, - "B-timer-" + new Integer (i), - new TimeValue (i*3)); - } - // Cancel all timers associated with this handler - tq.cancelTimer (th2); - - try - { - Thread.sleep (30000); - } - catch (InterruptedException e) - { - } - tq.cancelTimer (id); - System.exit (0); - } -} diff --git a/java/tests/SOCK_SAP/Makefile b/java/tests/SOCK_SAP/Makefile deleted file mode 100644 index 1481d8e566f..00000000000 --- a/java/tests/SOCK_SAP/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = SOCKConnectorTest.java \ - SOCKAcceptorTest.java - -packages = tests.SOCK_SAP - -realclean: - find ${JACE_WRAPPER}/classes/tests/SOCK_SAP -name '*.class' -print | xargs ${RM} diff --git a/java/tests/SOCK_SAP/SOCKAcceptorTest.java b/java/tests/SOCK_SAP/SOCKAcceptorTest.java deleted file mode 100644 index 34ab8ecb6c9..00000000000 --- a/java/tests/SOCK_SAP/SOCKAcceptorTest.java +++ /dev/null @@ -1,108 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.SOCK_SAP -// -// = FILENAME -// SOCKAcceptorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; - -class TestHandler extends Thread -{ - public TestHandler (SOCKStream stream) - { - this.stream_ = stream; - this.start (); - } - - public void run () - { - int msgLen; - System.out.println ("Waiting for messages..."); - try - { - while (true) - { - StringBuffer msg = new StringBuffer (); - msgLen = this.stream_.recv (msg); - if (msgLen == 0) - break; - ACE.DEBUG ("Received: " + msg); - this.stream_.send ("Got it!"); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.stream_.close (); - } - catch (IOException e) - { - } - } - } - SOCKStream stream_; -} - -public class SOCKAcceptorTest -{ - void print_usage_and_die () - { - ACE.DEBUG ("Usage: SOCKAcceptorTest [<port>]"); - System.exit (0); - } - - public void init (int port) - { - try - { - SOCKAcceptor acceptor = new SOCKAcceptor (port); - while (true) - { - SOCKStream stream = new SOCKStream (); - acceptor.accept (stream); - TestHandler handler = new TestHandler (stream); - } - } - catch (IOException e) - { - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - SOCKAcceptorTest server = new SOCKAcceptorTest (); - if (args.length == 1) - { - try - { - port = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - server.print_usage_and_die (); - } - } - server.init (port); - } -} diff --git a/java/tests/SOCK_SAP/SOCKConnectorTest.java b/java/tests/SOCK_SAP/SOCKConnectorTest.java deleted file mode 100644 index 6af4fd5cba6..00000000000 --- a/java/tests/SOCK_SAP/SOCKConnectorTest.java +++ /dev/null @@ -1,86 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.SOCK_SAP -// -// = FILENAME -// SOCKConnectorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; - -public class SOCKConnectorTest -{ - void print_usage_and_die () - { - System.out.println ("Usage: SOCKConnectorTest <hostname> [<port>]"); - System.exit (0); - } - - void processRequests (SOCKStream stream) throws IOException - { - DataInputStream in = new DataInputStream (System.in); - String msg; - int ack_len; - - while (true) - { - StringBuffer ack = new StringBuffer (); - ACE.DEBUG ("Enter input: "); - ACE.FLUSH (); - msg = in.readLine (); - if (msg == null) - break; - stream.send (msg); - ACE.DEBUG ("Waiting for ack..."); - ack_len = stream.recv (ack); - if (ack_len == 0) - break; - else - ACE.DEBUG (ack.toString ()); - } - } - - public void init (String host, int port) - { - SOCKStream stream = new SOCKStream (); - SOCKConnector connector = new SOCKConnector (); - try - { - connector.connect (stream, - host, - port); - processRequests (stream); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - SOCKConnectorTest client = new SOCKConnectorTest (); - if (args.length == 2) - { - try - { - port = Integer.parseInt (args[1]); - } - catch (NumberFormatException e) - { - client.print_usage_and_die (); - } - } - client.init (args[0], port); - } -} diff --git a/java/tests/ServiceConfigurator/Makefile b/java/tests/ServiceConfigurator/Makefile deleted file mode 100644 index 32b949ef298..00000000000 --- a/java/tests/ServiceConfigurator/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Makefile - -.SUFFIXES: .java .class - -JACE_WRAPPER = ../.. -CLASSDIR = $(JACE_WRAPPER)/classes - -CLASSPATH := $(CLASSDIR):$(CLASSPATH) - -all: - javac -d ${JACE_WRAPPER}/classes $(files) -doc: - javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages) - - -files = TestService.java \ - mainTest.java - -packages = tests.Service_Configurator - -realclean: - find ${JACE_WRAPPER}/classes/tests/ServiceConfigurator -name '*.class' -print | xargs ${RM} - - diff --git a/java/tests/ServiceConfigurator/TestService.java b/java/tests/ServiceConfigurator/TestService.java deleted file mode 100644 index 66eb04619c5..00000000000 --- a/java/tests/ServiceConfigurator/TestService.java +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.ServiceConfigurator - * - * = FILENAME - * TestService.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.ServiceConfigurator; - -import JACE.ServiceConfigurator.*; -import JACE.OS.*; - -public class TestService extends ServiceObject -{ - public int init (String [] args) - { - ACE.DEBUG ("In Test_Service::init() with arguments: " + - args[0] + args[1]); - - //ACE.DEBUG ("In new Test_Service::init() with arguments: " + - // args[0] + args[1]); - return 0; - } - -} - diff --git a/java/tests/ServiceConfigurator/mainTest.java b/java/tests/ServiceConfigurator/mainTest.java deleted file mode 100644 index 2f87c57330e..00000000000 --- a/java/tests/ServiceConfigurator/mainTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.ServiceConfigurator - * - * = FILENAME - * mainTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.ServiceConfigurator; - -import JACE.ServiceConfigurator.*; -import JACE.OS.*; -import java.io.*; - -public class mainTest -{ - - public static void main (String args []) - { - ServiceConfig daemon = new ServiceConfig (); - try - { - daemon.open (args); - Thread.sleep (10000); - daemon.open (args); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - catch (FileNotFoundException e) - { - ACE.ERROR (e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - catch (ClassNotFoundException e) - { - ACE.ERROR (e + "foo"); - } - catch (IllegalAccessException e) - { - ACE.ERROR (e); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - } - -} |