aboutsummaryrefslogtreecommitdiffstats
path: root/ajde/testdata/examples
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 17:58:19 +0000
committerwisberg <wisberg>2002-12-16 17:58:19 +0000
commitd842c4f1139629c1f062b74ba818d233b2c31043 (patch)
tree842d3871620bc0eb60edcd95e55804d67e0f61fa /ajde/testdata/examples
parent3ce247199704eae6b2c92c6e38c69584e3250c52 (diff)
downloadaspectj-d842c4f1139629c1f062b74ba818d233b2c31043.tar.gz
aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.zip
initial version
Diffstat (limited to 'ajde/testdata/examples')
-rw-r--r--ajde/testdata/examples/configs/.cvsignore1
-rw-r--r--ajde/testdata/examples/figures-coverage/.cvsignore1
-rw-r--r--ajde/testdata/examples/figures-coverage/editor/Editor.java4
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/.cvsignore8
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/Debug.java7
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/Figure.java88
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/FigureElement.java9
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/Main.java54
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore3
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/composites/Line.java6
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/composites/Square.java6
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore4
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/primitives/planar/Point.java73
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore1
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/primitives/solid/SolidPoint.java24
-rw-r--r--ajde/testdata/examples/figures-demo/.cvsignore1
-rw-r--r--ajde/testdata/examples/figures-demo/figures/Box.java55
-rw-r--r--ajde/testdata/examples/figures-demo/figures/Canvas.java11
-rw-r--r--ajde/testdata/examples/figures-demo/figures/ColorControl.java20
-rw-r--r--ajde/testdata/examples/figures-demo/figures/FigureElement.java21
-rw-r--r--ajde/testdata/examples/figures-demo/figures/Group.java88
-rw-r--r--ajde/testdata/examples/figures-demo/figures/Line.java73
-rw-r--r--ajde/testdata/examples/figures-demo/figures/Point.java59
-rw-r--r--ajde/testdata/examples/figures-demo/figures/ShapeFigureElement.java38
-rw-r--r--ajde/testdata/examples/figures-demo/figures/SlothfulPoint.java42
-rw-r--r--ajde/testdata/examples/figures-demo/figures/gui/FigurePanel.java172
-rw-r--r--ajde/testdata/examples/figures-demo/figures/gui/LogAdapter.java16
-rw-r--r--ajde/testdata/examples/figures-demo/figures/gui/Main.java26
-rw-r--r--ajde/testdata/examples/figures-demo/figures/support/Enforcement.java67
-rw-r--r--ajde/testdata/examples/figures-demo/figures/support/Log.java36
-rw-r--r--ajde/testdata/examples/inheritance/.cvsignore1
-rw-r--r--ajde/testdata/examples/inheritance/A.java22
-rw-r--r--ajde/testdata/examples/plainJava/apples/Apple.java115
-rw-r--r--ajde/testdata/examples/plainJava/apples/AppleCrate.java54
-rw-r--r--ajde/testdata/examples/plainJava/apples/BigRigAspect.java17
-rw-r--r--ajde/testdata/examples/plainJava/apples/TransportAspect.java26
36 files changed, 1249 insertions, 0 deletions
diff --git a/ajde/testdata/examples/configs/.cvsignore b/ajde/testdata/examples/configs/.cvsignore
new file mode 100644
index 000000000..bd4e1a00b
--- /dev/null
+++ b/ajde/testdata/examples/configs/.cvsignore
@@ -0,0 +1 @@
+configs.ajsym
diff --git a/ajde/testdata/examples/figures-coverage/.cvsignore b/ajde/testdata/examples/figures-coverage/.cvsignore
new file mode 100644
index 000000000..c6495af69
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/.cvsignore
@@ -0,0 +1 @@
+all.ajsym
diff --git a/ajde/testdata/examples/figures-coverage/editor/Editor.java b/ajde/testdata/examples/figures-coverage/editor/Editor.java
new file mode 100644
index 000000000..99e2b5d5b
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/editor/Editor.java
@@ -0,0 +1,4 @@
+
+package editor;
+
+class Editor { }
diff --git a/ajde/testdata/examples/figures-coverage/figures/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/.cvsignore
new file mode 100644
index 000000000..9a2b438e3
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/.cvsignore
@@ -0,0 +1,8 @@
+Checks.class
+Debug.class
+Element.class
+Figure.class
+FigureElement.class
+Main.class
+Main$TestGUI.class
+Test.class
diff --git a/ajde/testdata/examples/figures-coverage/figures/Debug.java b/ajde/testdata/examples/figures-coverage/figures/Debug.java
new file mode 100644
index 000000000..01e895abc
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/Debug.java
@@ -0,0 +1,7 @@
+
+package figures;
+
+aspect Debug {
+
+}
+
diff --git a/ajde/testdata/examples/figures-coverage/figures/Figure.java b/ajde/testdata/examples/figures-coverage/figures/Figure.java
new file mode 100644
index 000000000..9bf5e0f8b
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/Figure.java
@@ -0,0 +1,88 @@
+
+package figures;
+
+//import figures.primitives.planar.Point;
+
+import java.awt.Canvas;
+
+aspect Figure {
+ //pointcut sendSuccess(): cflow(setX()) && !handler(Exception);
+
+ public String Point.getName() {
+ return Point.name;
+ }
+
+ public int figures.primitives.planar.Point.DEFAULT_X = 0;
+
+ public pointcut constructions(): call(Point.new(int, int)) || call(SolidPoint.new(int, int, int));
+
+ public pointcut moves(FigureElement fe): target(fe) &&
+ (call(String Point.getName()) ||
+ call(void FigureElement.incrXY(int, int)) ||
+ call(void Point.setX(int)) ||
+ call(void Point.setY(int)) ||
+ call(void SolidPoint.setZ(int)));
+
+ pointcut mainExecution():
+ execution(int main(*));
+
+ pointcut runtimeHandlers(): mainExecution()
+ || handler(RuntimeException);
+
+ public pointcut mumble(): runtimeHandlers();
+
+ before(int newValue): set(int *.*) && args(newValue) { }
+
+ before(): get(int *.*) { }
+
+ before(): constructions() {
+ System.out.println("> before construction, jp: " + thisJoinPoint.getSignature());
+ }
+
+ before(FigureElement fe): moves(fe) {
+ System.out.println("> about to move FigureElement at X-coord: ");
+ }
+
+ after(): initialization(Point.new(..)) || staticinitialization(Point) {
+ System.out.println("> Point initialized");
+ }
+
+ // should be around
+ after(): mumble() {
+ System.err.println(">> in after advice...");
+ //proceed();
+ }
+
+ after(FigureElement fe): target(fe) &&
+ (call(void FigureElement.incrXY(int, int)) ||
+ call(void Point.setX(int)) ||
+ call(void Point.setY(int)) ||
+ call(void SolidPoint.setZ(int))) {
+ System.out.println("> yo.");
+ }
+
+ after(FigureElement fe):
+ target(fe) &&
+ (call(void FigureElement.incrXY(int, int)) ||
+ call(void Line.setP1(Point)) ||
+ call(void Line.setP2(Point)) ||
+ call(void Point.setX(int)) ||
+ call(void Point.setY(int))) { }
+
+ declare parents: Point extends java.io.Serializable;
+
+ declare parents: Point implements java.util.Observable;
+
+ declare soft: Point: call(* *(..));
+}
+
+aspect Checks {
+ pointcut illegalNewFigElt(): call(FigureElement+.new(..)) &&
+ !withincode(* Main.main(..));
+
+ declare error: illegalNewFigElt():
+ "Illegal figure element constructor call.";
+
+ declare warning: illegalNewFigElt():
+ "Illegal figure element constructor call.";
+}
diff --git a/ajde/testdata/examples/figures-coverage/figures/FigureElement.java b/ajde/testdata/examples/figures-coverage/figures/FigureElement.java
new file mode 100644
index 000000000..d2ce9eb82
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/FigureElement.java
@@ -0,0 +1,9 @@
+
+package figures;
+
+public interface FigureElement extends Element {
+
+ public void incrXY(int dx, int dy);
+}
+
+interface Element { }
diff --git a/ajde/testdata/examples/figures-coverage/figures/Main.java b/ajde/testdata/examples/figures-coverage/figures/Main.java
new file mode 100644
index 000000000..bbb2869b7
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/Main.java
@@ -0,0 +1,54 @@
+
+package figures;
+
+import figures.primitives.planar.Point;
+import figures.primitives.solid.SolidPoint;
+
+class Main {
+
+ private static Point startPoint;
+
+ public static void main(String[] args) {
+ try {
+ System.out.println("> starting...");
+
+ startPoint = makeStartPoint();
+ //startPoint.setX(3); new Point(0, 0);
+// SolidPoint sp1 = new SolidPoint(1, 3, 3);
+
+// sp1.setZ(1);
+// p1.incrXY(3, 3);
+ } catch (RuntimeException re) {
+ re.printStackTrace();
+ }
+ System.out.println("> finished.");
+ }
+
+ /** @deprecated use something else */
+ public static Point makeStartPoint() {
+ //return new Point(1, 2);
+ return null;
+ }
+
+ /** This should produce a deprecation warning with JDK > 1.2 */
+ static class TestGUI extends javax.swing.JFrame {
+ TestGUI() {
+ this.disable();
+ }
+ }
+
+ /** This should produce a porting-deprecation warning. */
+ //static pointcut mainExecution(): execution(void main(*));
+}
+
+privileged aspect Test {
+ before(Point p, int newval): target(p) && set(int Point.xx) && args(newval) {
+ System.err.println("> new value of x is: " + p.x + ", setting to: " + newval);
+ }
+
+ before(int newValue): set(int Point.*) && args(newValue) {
+ if (newValue < 0) {
+ throw new IllegalArgumentException("too small");
+ }
+ }
+}
diff --git a/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore
new file mode 100644
index 000000000..d9011a888
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore
@@ -0,0 +1,3 @@
+BoundedLine.class
+Line.class
+Square.class
diff --git a/ajde/testdata/examples/figures-coverage/figures/composites/Line.java b/ajde/testdata/examples/figures-coverage/figures/composites/Line.java
new file mode 100644
index 000000000..1f7ee5dc8
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/composites/Line.java
@@ -0,0 +1,6 @@
+
+package figures.composites;
+
+class Line { }
+
+class BoundedLine extends Line { }
diff --git a/ajde/testdata/examples/figures-coverage/figures/composites/Square.java b/ajde/testdata/examples/figures-coverage/figures/composites/Square.java
new file mode 100644
index 000000000..8ba3825d6
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/composites/Square.java
@@ -0,0 +1,6 @@
+
+package figures.composites;
+
+class Square {
+ private String name = "Square";
+}
diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore
new file mode 100644
index 000000000..1dd78c3c0
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore
@@ -0,0 +1,4 @@
+StrictlyBoundedPoint.class
+PointBoundsException.class
+Point.class
+BoundedPoint.class
diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/planar/Point.java b/ajde/testdata/examples/figures-coverage/figures/primitives/planar/Point.java
new file mode 100644
index 000000000..d389be386
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/primitives/planar/Point.java
@@ -0,0 +1,73 @@
+
+package figures.primitives.planar;
+
+import figures.*;
+import java.util.Collection;
+
+public class Point implements FigureElement {
+
+ static int xx = -1;
+ private int x;
+ private int y;
+ transient int currVal = 0;
+ public static String name;
+
+ {
+ y = -1;
+ }
+
+ static {
+ xx = -10;
+ }
+
+ int c; int b; int a;
+ {
+ x = 0;
+ y = 0;
+ }
+
+ static {
+ Point.name = "2-Dimensional Point";
+ }
+
+ public Point(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ int getCurrVal() {
+ return currVal;
+ }
+
+ /**
+ * @see Figure#moves
+ */
+ public int getX() { return x; }
+
+ public int getY() { return y; }
+
+ public void setX(int x) { this.x = x; }
+
+ public void setY(int x) { this.y = x; }
+
+ public void incrXY(int dx, int dy) {
+ setX(getX() + dx);
+ setY(getY() + dy);
+ }
+ public void check(int dx, int dy)
+ throws ArithmeticException, PointBoundsException {
+ if (dx < 0 || dy < 0) throw new PointBoundsException();
+ }
+}
+
+class PointBoundsException extends Exception { }
+
+class BoundedPoint extends Point {
+ public BoundedPoint(int x, int y) { super(x, y); }
+}
+
+class StrictlyBoundedPoint extends BoundedPoint {
+ public StrictlyBoundedPoint(int x, int y) { super(x, y); }
+}
+
+
diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore
new file mode 100644
index 000000000..fd0572c5e
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore
@@ -0,0 +1 @@
+SolidPoint.class
diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/solid/SolidPoint.java b/ajde/testdata/examples/figures-coverage/figures/primitives/solid/SolidPoint.java
new file mode 100644
index 000000000..80c1fc1ca
--- /dev/null
+++ b/ajde/testdata/examples/figures-coverage/figures/primitives/solid/SolidPoint.java
@@ -0,0 +1,24 @@
+
+package figures.primitives.solid;
+
+import java.util.Collection;
+import java.lang.String;
+import figures.primitives.planar.*;
+
+public class SolidPoint extends Point {
+ private int z;
+
+ public SolidPoint(int x, int y, int z) {
+ super(x, y);
+ this.z = z;
+ }
+
+ public int getZ() { return z; }
+
+ public void setZ(int z) { this.z = z; }
+
+ public void incrXY(int dx, int dy) {
+ super.incrXY(dx, dy);
+ setZ(getZ() + dx + dy);
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/.cvsignore b/ajde/testdata/examples/figures-demo/.cvsignore
new file mode 100644
index 000000000..ad69a1aa9
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/.cvsignore
@@ -0,0 +1 @@
+figures-demo-all.ajsym
diff --git a/ajde/testdata/examples/figures-demo/figures/Box.java b/ajde/testdata/examples/figures-demo/figures/Box.java
new file mode 100644
index 000000000..4db7f439d
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/Box.java
@@ -0,0 +1,55 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public class Box extends ShapeFigureElement {
+ private Point _p0;
+ private Point _p1;
+ private Point _p2;
+ private Point _p3;
+
+ public Box(int x0, int y0, int width, int height) {
+ _p0 = new Point(x0, y0);
+ _p1 = new Point(x0+width, y0);
+ _p2 = new Point(x0+width, y0+height);
+ _p3 = new Point(x0, y0+height);
+ }
+
+ public Point getP0() { return _p0; }
+ public Point getP1() { return _p1; }
+ public Point getP2() { return _p2; }
+ public Point getP3() { return _p3; }
+
+ public void move(int dx, int dy) {
+ _p0.move(dx, dy);
+ _p1.move(dx, dy);
+ _p2.move(dx, dy);
+ _p3.move(dx, dy);
+ }
+
+ public void checkBoxness() {
+ if ((_p0.getX() == _p3.getX()) &&
+ (_p1.getX() == _p2.getX()) &&
+ (_p0.getY() == _p1.getY()) &&
+ (_p2.getY() == _p3.getY()))
+ return;
+ throw new IllegalStateException("This is not a square.");
+ }
+
+ public String toString() {
+ return "Box(" + _p0 + ", " + _p1 + ", " + _p2 + ", " + _p3 + ")";
+ }
+
+ public Shape getShape() {
+ return new Rectangle(getP1().getX(),
+ getP1().getY(),
+ getP3().getX() - getP1().getX(),
+ getP3().getY() - getP1().getY());
+ }
+}
+
diff --git a/ajde/testdata/examples/figures-demo/figures/Canvas.java b/ajde/testdata/examples/figures-demo/figures/Canvas.java
new file mode 100644
index 000000000..e5491d7cb
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/Canvas.java
@@ -0,0 +1,11 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+public class Canvas {
+ public static void updateHistory() {
+ // not implemented
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/ColorControl.java b/ajde/testdata/examples/figures-demo/figures/ColorControl.java
new file mode 100644
index 000000000..46d1ba428
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/ColorControl.java
@@ -0,0 +1,20 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.Color;
+import figures.FigureElement;
+
+public aspect ColorControl {
+ public static void setFillColor(FigureElement fe, Color color) {
+ // fill in here
+ }
+
+ public static void setLineColor(FigureElement fe, Color color) {
+ // fill in here
+ }
+
+ // fill in here
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/FigureElement.java b/ajde/testdata/examples/figures-demo/figures/FigureElement.java
new file mode 100644
index 000000000..ae06c132b
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/FigureElement.java
@@ -0,0 +1,21 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public interface FigureElement {
+ public static final int MIN_VALUE = 0;
+ public static final int MAX_VALUE = 500;
+
+ public abstract void move(int dx, int dy);
+
+ public abstract Rectangle getBounds();
+
+ public abstract boolean contains(Point2D p);
+
+ public abstract void paint(Graphics2D g2);
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/Group.java b/ajde/testdata/examples/figures-demo/figures/Group.java
new file mode 100644
index 000000000..59c1a17cf
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/Group.java
@@ -0,0 +1,88 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.geom.*;
+
+public class Group implements FigureElement {
+ private Collection _members;
+ private String _identifier;
+
+ public Group(FigureElement first) {
+ this._members = new ArrayList();
+ add(first);
+ }
+
+ public void add(FigureElement fe) {
+ _members.add(fe);
+ }
+
+ public Iterator members() {
+ return _members.iterator();
+ }
+
+ public void move(int dx, int dy) {
+ for (Iterator i = _members.iterator(); i.hasNext(); ) {
+ FigureElement fe = (FigureElement)i.next();
+ fe.move(dx, dy);
+ }
+ }
+
+ public void resetIdentifier(String identifier) {
+ resetIdentifier(identifier);
+ }
+
+ public String toString() {
+ if (_identifier != null) {
+ return _identifier;
+ }
+
+ StringBuffer buf = new StringBuffer("Group(");
+ for (Iterator i = _members.iterator(); i.hasNext(); ) {
+ buf.append(i.next().toString());
+ if (i.hasNext()) {
+ buf.append(", ");
+ }
+ }
+ buf.append(")");
+ return buf.toString();
+ }
+
+ public Rectangle getBounds() {
+ Rectangle previous = null;
+ for (Iterator i = _members.iterator(); i.hasNext(); ) {
+ FigureElement fe = (FigureElement)i.next();
+ Rectangle rect = fe.getBounds();
+ if (previous != null) {
+ previous = previous.union(rect);
+ } else {
+ previous = rect;
+ }
+ }
+ return previous;
+ }
+
+ public boolean contains(Point2D p) {
+ for (Iterator i = _members.iterator(); i.hasNext(); ) {
+ FigureElement fe = (FigureElement)i.next();
+ if (fe.contains(p)) return true;
+ }
+ return false;
+ }
+
+ public void paint(Graphics2D g2) {
+ for (Iterator i = _members.iterator(); i.hasNext(); ) {
+ FigureElement fe = (FigureElement)i.next();
+ fe.paint(g2);
+ }
+ }
+
+ public int size() {
+ return _members.size();
+ }
+}
+
diff --git a/ajde/testdata/examples/figures-demo/figures/Line.java b/ajde/testdata/examples/figures-demo/figures/Line.java
new file mode 100644
index 000000000..45324646e
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/Line.java
@@ -0,0 +1,73 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public class Line extends ShapeFigureElement {
+ private Point _p1;
+ private Point _p2;
+
+ public Line(Point p1, Point p2) {
+ _p1 = p1;
+ _p2 = p2;
+ }
+
+ public Point getP1() {
+ return _p1;
+ }
+
+ public void setP1(Point p1) {
+ _p1 = p1;
+ Canvas.updateHistory();
+ }
+
+ public Point getP2() {
+ return _p2;
+ }
+
+ public void setP2(Point p2) {
+ _p2 = p2;
+ Canvas.updateHistory();
+ }
+
+ public void move(int dx, int dy) {
+ //_x = dx;
+ //_y = dy;
+
+ //_p1.move(dx, dy);
+ //_p2.move(dx, dy);
+ }
+
+ public String toString() {
+ return "Line(" + _p1 + ", " + _p2 + ")";
+ }
+
+ /**
+ * Used to determine if this line {@link contains(Point2D)} a point.
+ */
+ final static int THRESHHOLD = 5;
+
+ /**
+ * Returns <code>true</code> if the point segment distance is less than
+ * {@link THRESHHOLD}.
+ */
+ public boolean contains(Point2D p) {
+ return getLine2D().ptLineDist(p) < THRESHHOLD;
+ }
+
+ private Line2D getLine2D() {
+ return new Line2D.Float((float)getP1().getX(),
+ (float)getP1().getY(),
+ (float)getP2().getX(),
+ (float)getP2().getY());
+ }
+
+ public Shape getShape() {
+ return getLine2D();
+ }
+}
+
diff --git a/ajde/testdata/examples/figures-demo/figures/Point.java b/ajde/testdata/examples/figures-demo/figures/Point.java
new file mode 100644
index 000000000..e8783a560
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/Point.java
@@ -0,0 +1,59 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public class Point extends ShapeFigureElement {
+ private int _x;
+ private int _y;
+
+ public Point(int x, int y) {
+ _x = x;
+ _y = y;
+ }
+
+ public int getX() {
+ return _x;
+ }
+
+ public void setX(int x) {
+ _x = x;
+ //Canvas.updateHistory();
+ }
+
+ public int getY() {
+ return _y;
+ }
+
+ public void setY(int y) {
+ _y = y;
+ //Canvas.updateHistory();
+ }
+
+ public void move(int dx, int dy) {
+ setX(_x + dx);
+ setY(_y + dy);
+ }
+
+ public String toString() {
+ return "Point(" + _x + ", " + _y + ")";
+ }
+
+ /** The height of displayed {@link Point}s. */
+ private final static int HEIGHT = 10;
+
+ /** The width of displayed {@link Point}s. -- same as {@link HEIGHT}. */
+ private final static int WIDTH = Point.HEIGHT;
+
+ public Shape getShape() {
+ return new Ellipse2D.Float((float)getX()-Point.WIDTH/2,
+ (float)getY()-Point.HEIGHT/2,
+ (float)Point.HEIGHT,
+ (float)Point.WIDTH);
+ }
+}
+
diff --git a/ajde/testdata/examples/figures-demo/figures/ShapeFigureElement.java b/ajde/testdata/examples/figures-demo/figures/ShapeFigureElement.java
new file mode 100644
index 000000000..29a4a89ad
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/ShapeFigureElement.java
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public abstract class ShapeFigureElement implements FigureElement {
+ public abstract void move(int dx, int dy);
+
+ public abstract Shape getShape();
+
+ public Rectangle getBounds() {
+ return getShape().getBounds();
+ }
+
+ public boolean contains(Point2D p) {
+ return getShape().contains(p);
+ }
+
+ public Color getLineColor() {
+ return Color.black;
+ }
+
+ public Color getFillColor() {
+ return Color.red;
+ }
+
+ public final void paint(Graphics2D g2) {
+ Shape shape = getShape();
+ g2.setPaint(getFillColor());
+ g2.fill(shape);
+ g2.setPaint(getLineColor());
+ g2.draw(shape);
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/SlothfulPoint.java b/ajde/testdata/examples/figures-demo/figures/SlothfulPoint.java
new file mode 100644
index 000000000..35c8fb635
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/SlothfulPoint.java
@@ -0,0 +1,42 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+/**
+ * This class makes mistakes to be caught by invariant checkers.
+ */
+public class SlothfulPoint extends ShapeFigureElement {
+ private int _x;
+ private int _y;
+
+ public SlothfulPoint(int x, int y) {
+ }
+
+ public void setX(int x) {
+ _x = x;
+ }
+
+ public void setY(int y) {
+ _y = y;
+ }
+
+ public void move(int dx, int dy) {
+ //_x += dx;
+ //_y += dy;
+ }
+
+ public String toString() {
+ return "SlothfulPoint";
+ }
+
+ public Shape getShape() {
+ return new Ellipse2D.Float((float)_x,
+ (float)_y, 1.0f, 1.0f);
+ }
+}
+
diff --git a/ajde/testdata/examples/figures-demo/figures/gui/FigurePanel.java b/ajde/testdata/examples/figures-demo/figures/gui/FigurePanel.java
new file mode 100644
index 000000000..8e777c3df
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/gui/FigurePanel.java
@@ -0,0 +1,172 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures.gui;
+
+import figures.Point;
+import figures.Line;
+import figures.FigureElement;
+import figures.Group;
+
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import javax.swing.border.*;
+
+public class FigurePanel extends JComponent {
+
+ ButtonsPanel bp = new ButtonsPanel();
+ FigureSurface fs = new FigureSurface();
+ ConsolePanel cp = new ConsolePanel();
+
+
+ public FigurePanel() {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+ panel.add(fs);
+ panel.add(bp);
+ JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, cp);
+ sp.setPreferredSize(new Dimension(500, 400));
+ sp.setDividerLocation(250);
+ add(BorderLayout.CENTER, sp);
+ }
+
+ class ButtonsPanel extends JPanel {
+ private JLabel msgs = new JLabel("click to add a point or line");
+ public ButtonsPanel() {
+ setLayout(new FlowLayout(FlowLayout.LEFT));
+ add(new JButton(new AbstractAction("Main") {
+ public void actionPerformed(ActionEvent e) {
+ Main.main(new String[]{});
+ fs.repaint();
+ }
+ }));
+ add(msgs);
+ }
+
+ public void log(String msg) {
+ msgs.setText(msg);
+ }
+ }
+
+ static class ConsolePanel extends JPanel {
+
+ JTextArea text = new JTextArea();
+
+ public ConsolePanel() {
+ super(new BorderLayout());
+ text.setFont(StyleContext.getDefaultStyleContext().getFont("SansSerif", Font.PLAIN, 10));
+ JScrollPane scroller = new JScrollPane(text);
+ scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ add(BorderLayout.CENTER, scroller);
+ }
+
+ public void println(String msg) {
+ text.append(msg + '\n');
+ }
+ }
+
+ final static Color BACKGROUND = Color.white;
+
+ static class FigureSurface extends JPanel implements MouseListener, MouseMotionListener {
+ private Group canvas;
+
+ public FigureSurface() {
+ canvas = new Group(new Point(250, 250));
+ addMouseMotionListener(this);
+ addMouseListener(this);
+ setPreferredSize(new Dimension(500,500));
+ }
+
+ private Point addPoint(int x, int y) {
+ Point p = new Point(x, y);
+ canvas.add(p);
+ repaint();
+ return p;
+ }
+
+ private Line addLine(Point p1, Point p2) {
+ if (Math.abs(p1.getX()-p2.getX()) < 5 ||
+ Math.abs(p1.getY()-p2.getY()) < 5) {
+ return null;
+ }
+
+ Line line = null;
+ if (p1 != null && p2 != null) {
+ line = new Line(p1, p2);
+ canvas.add(line);
+ }
+ repaint();
+ return line;
+ }
+
+ public void paint(Graphics g) {
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setPaint(BACKGROUND);
+ g2.fill(new Rectangle2D.Float(0f, 0f, (float)g2.getClipBounds().width, (float)g2.getClipBounds().height));
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ canvas.paint(g2);
+ }
+
+
+ int lastX, lastY;
+ int pressX, pressY;
+
+ FigureElement first = null;
+ Point point1 = null;
+
+ public void mousePressed(MouseEvent e){
+ int x = e.getX(), y = e.getY();
+ pressX = lastX = x; pressY = lastY = y;
+ first = findFigureElement(x, y);
+ if (first == null) {
+ point1 = addPoint(x, y);
+ }
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX(), y = e.getY(), dx = lastX-x, dy = lastY-y;
+ lastX = x;
+ lastY = y;
+ if (first == null) {
+ Line line = addLine(point1, new Point(x, y));
+ if (line != null) {
+ canvas.add(line.getP2());
+ first = line.getP2();
+ canvas.add(line);
+ }
+ } else {
+ first.move(-dx, -dy);
+ }
+ repaint();
+ }
+
+ public void mouseReleased(MouseEvent e){
+ mouseDragged(e);
+ first = null;
+ point1 = null;
+ }
+
+
+ public void mouseMoved(MouseEvent e){}
+ public void mouseClicked(MouseEvent e){}
+ public void mouseExited(MouseEvent e){}
+ public void mouseEntered(MouseEvent e){}
+
+ private FigureElement findFigureElement(int x, int y) {
+ Point2D p = new Point2D.Float((float)x, (float)y);
+ for (Iterator i = canvas.members(); i.hasNext(); ) {
+ FigureElement fe = (FigureElement)i.next();
+ if (fe.contains(p)) return fe;
+ }
+ return null;
+ }
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/gui/LogAdapter.java b/ajde/testdata/examples/figures-demo/figures/gui/LogAdapter.java
new file mode 100644
index 000000000..078ab01cb
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/gui/LogAdapter.java
@@ -0,0 +1,16 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures.gui;
+
+import support.Log;
+
+aspect LogAdapter {
+
+ before(String s): call(void Log.log(String)) && args(s) {
+ if (Main.panel != null) {
+ Main.panel.cp.println(s);
+ }
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/gui/Main.java b/ajde/testdata/examples/figures-demo/figures/gui/Main.java
new file mode 100644
index 000000000..15fac91a0
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/gui/Main.java
@@ -0,0 +1,26 @@
+/*
+Copyright (c) 2001-2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package figures.gui;
+
+import javax.swing.*;
+import support.Log;
+import figures.Point;
+
+public class Main {
+ static FigurePanel panel;
+
+ public static void main(String[] args) {
+ JFrame figureFrame = new JFrame("Figure Editor");
+ panel = new FigurePanel();
+ figureFrame.setContentPane(panel);
+ figureFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ figureFrame.pack();
+ figureFrame.setVisible(true);
+
+ // for testing--remove!
+ //Point p = new Point(0, 0);
+ //p.setX(-10);
+ }
+}
diff --git a/ajde/testdata/examples/figures-demo/figures/support/Enforcement.java b/ajde/testdata/examples/figures-demo/figures/support/Enforcement.java
new file mode 100644
index 000000000..a7c806ac6
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/support/Enforcement.java
@@ -0,0 +1,67 @@
+/*
+ * (c) Copyright 2001 MyCorporation.
+ * All Rights Reserved.
+ */
+
+package figures.support;
+
+import figures.*;
+
+public aspect Enforcement {
+
+ before(int newValue): set(int Point.*) && args(newValue) {
+ if (newValue < 0) {
+ throw new IllegalArgumentException("> val: " + newValue + " is too small");
+ }
+ }
+
+ declare warning: call(void Canvas.updateHistory(..)) && !within(Enforcement): "";
+
+ after() returning: call(void FigureElement+.set*(..)) {
+ //Canvas.updateHistory();
+ }
+
+ declare error:
+ set(private * FigureElement+.*) &&
+ !(withincode(* FigureElement+.set*(..)) || withincode(FigureElement+.new(..))):
+ "should only assign to fileds from set methods";
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// before(int newValue): set(int Point.*) && args(newValue) {
+// if (newValue < 0) {
+// throw new IllegalArgumentException("> value: " + newValue + " too small");
+// }
+// }
+//
+// declare warning: call(void Canvas.updateHistory(..)) && !within(Enforcement):
+// "found call";
+//
+// after() returning: call(void FigureElement+.set*(..)) {
+// Canvas.updateHistory();
+// }
+//
+// declare error:
+// set(private * FigureElement+.*) &&
+// !(withincode(* FigureElement+.set*(..)) || withincode(FigureElement+.new(..))):
+// "should only assign to fields from set methods";
diff --git a/ajde/testdata/examples/figures-demo/figures/support/Log.java b/ajde/testdata/examples/figures-demo/figures/support/Log.java
new file mode 100644
index 000000000..ed395696a
--- /dev/null
+++ b/ajde/testdata/examples/figures-demo/figures/support/Log.java
@@ -0,0 +1,36 @@
+/*
+Copyright (c) 2002 Palo Alto Research Center Incorporated. All Rights Reserved.
+ */
+
+package support;
+
+public class Log {
+ private static StringBuffer data = new StringBuffer();
+
+ public static void traceObject(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public static void log(String s) {
+ data.append(s);
+ data.append(';');
+ }
+
+ public static void logClassName(Class _class) {
+ String name = _class.getName();
+ int dot = name.lastIndexOf('.');
+ if (dot == -1) {
+ log(name);
+ } else {
+ log(name.substring(dot+1, name.length()));
+ }
+ }
+
+ public static String getString() {
+ return data.toString();
+ }
+
+ public static void clear() {
+ data.setLength(0);
+ }
+}
diff --git a/ajde/testdata/examples/inheritance/.cvsignore b/ajde/testdata/examples/inheritance/.cvsignore
new file mode 100644
index 000000000..a5f90a68e
--- /dev/null
+++ b/ajde/testdata/examples/inheritance/.cvsignore
@@ -0,0 +1 @@
+inheritance.ajsym
diff --git a/ajde/testdata/examples/inheritance/A.java b/ajde/testdata/examples/inheritance/A.java
new file mode 100644
index 000000000..899b409f0
--- /dev/null
+++ b/ajde/testdata/examples/inheritance/A.java
@@ -0,0 +1,22 @@
+
+package inheritance;
+
+public abstract class A {
+
+ public abstract void bar();
+
+ public void foo() { }
+
+ public String toString() {
+ // mumble
+
+ return "";
+ }
+}
+
+class B extends A {
+
+ public void bar() { }
+
+ public void foo() { }
+}
diff --git a/ajde/testdata/examples/plainJava/apples/Apple.java b/ajde/testdata/examples/plainJava/apples/Apple.java
new file mode 100644
index 000000000..725d7f4b1
--- /dev/null
+++ b/ajde/testdata/examples/plainJava/apples/Apple.java
@@ -0,0 +1,115 @@
+
+package apples;
+
+import java.io.Serializable;
+import java.io.IOException;
+
+/**
+ * This class represents an apple that has the following two attributes
+ * <UL>
+ * <LI>a variety (i.e. "Macintosh" or "Granny Smith")
+ * <LI>a brusing factor represnting how badly bruised the apple is
+ * </UL>
+ *
+ * @author Mik Kersten
+ * @version $Version$
+ */
+
+public class Apple implements Serializable
+{
+ private String variety = null;
+ private int bruising = 0;
+
+ /**
+ * Default constructor.
+ *
+ * @param newVariety the type of variety for this apple
+ */
+ public Apple( String newVariety )
+ {
+ variety = newVariety;
+ }
+
+ /**
+ * This inner class represents apple seeds.
+ */
+ public class AppleSeed {
+ private int weight = 0;
+ private SeedContents seedContents = null;
+
+ /**
+ * This is how you get poison from the apple.
+ */
+ public void getArsenic() {
+ System.out.println( ">> getting arsenic" );
+ }
+
+ /**
+ * Reperesents the contents of the seeds.
+ */
+ public class SeedContents {
+ public String core = null;
+ public String shell = null;
+ }
+ }
+
+ /**
+ * Sets the bruising factor of the apple.
+ *
+ * @param bruiseFactor the new bruising factor
+ */
+ public void bruise( int bruiseFactor )
+ {
+ bruising = bruising + bruiseFactor;
+
+ if ( bruising > 100 ) bruising = 100;
+ if ( bruising < 0 ) bruising = 0;
+ }
+
+ /**
+ * Returns the bruising factor.
+ *
+ * @return bruising the bruising factor associated with the apple
+ */
+ public int getBruising()
+ {
+ return bruising;
+ }
+
+
+ /**
+ * Serializes the apple object.
+ *
+ * @param oos stream that the object is written to
+ */
+ private void writeObject( java.io.ObjectOutputStream oos )
+ throws IOException
+ {
+ // TODO: implement
+ }
+
+
+ /**
+ * Reads in the apple object.
+ *
+ * @param ois stream that the object is read from
+ */
+ private void readObject( java.io.ObjectInputStream ois )
+ throws IOException, ClassNotFoundException
+ {
+ // TODO: implement
+ }
+}
+
+/**
+ * Stub class to represent apple peeling.
+ */
+class ApplePealer
+{
+ /**
+ * Stub for peeling the apple.
+ */
+ public void peelApple() {
+ System.out.println( ">> peeling the apple..." );
+ }
+}
diff --git a/ajde/testdata/examples/plainJava/apples/AppleCrate.java b/ajde/testdata/examples/plainJava/apples/AppleCrate.java
new file mode 100644
index 000000000..82a33b4ed
--- /dev/null
+++ b/ajde/testdata/examples/plainJava/apples/AppleCrate.java
@@ -0,0 +1,54 @@
+
+package apples;
+
+import java.io.Serializable;
+import java.io.IOException;
+
+/**
+ * This class represents an apple crate that is used for transporting apples.
+ * The apples are contained in an array of <CODE>Apple</CODE> objects.
+ *
+ * @author Mik Kersten
+ * @version $Version$
+ *
+ * @see Apple
+ */
+
+public class AppleCrate implements Serializable
+{
+ Apple[] crateContents = null;
+
+ /**
+ * Default constructor.
+ *
+ * @param newCrateContents an array of <CODE>Apple</CODE> objects
+ */
+ public AppleCrate( Apple[] newCrateContents )
+ {
+ crateContents = newCrateContents;
+ }
+
+ /**
+ * A crate is sellable if the apples are bruised 50% or less on average.
+ *
+ * @return <CODE>true</CODE> if the the apples can be sold
+ */
+ public boolean isSellable()
+ {
+ int bruising = 0;
+ for ( int i = 0; i < crateContents.length; i++ )
+ {
+ bruising = bruising + crateContents[i].getBruising();
+ }
+
+ if ( (bruising/crateContents.length) > 50 )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ajde/testdata/examples/plainJava/apples/BigRigAspect.java b/ajde/testdata/examples/plainJava/apples/BigRigAspect.java
new file mode 100644
index 000000000..a9c3a8db4
--- /dev/null
+++ b/ajde/testdata/examples/plainJava/apples/BigRigAspect.java
@@ -0,0 +1,17 @@
+
+package apples;
+
+/**
+ * This aspect represents upacking apples after an airplane trip.
+ *
+ * @author Mik Kersten
+ * @version $Version$
+ */
+
+public class BigRigAspect extends TransportAspect
+{
+ /**
+ * Default constructor
+ */
+ public BigRigAspect() {}
+}
diff --git a/ajde/testdata/examples/plainJava/apples/TransportAspect.java b/ajde/testdata/examples/plainJava/apples/TransportAspect.java
new file mode 100644
index 000000000..0649986a6
--- /dev/null
+++ b/ajde/testdata/examples/plainJava/apples/TransportAspect.java
@@ -0,0 +1,26 @@
+
+package apples;
+
+/**
+ * This aspect crosscuts the process of shipping apples.
+ *
+ * @author Mik Kersten
+ * @version $Version$
+ */
+
+public class TransportAspect
+{
+ private String crateName = "temp crate";
+
+ /**
+ * Bruises each apple in the crate according to the bruise facor. The bruise
+ * factor is an integer that is passed as a parameter.
+ */
+ private void bruiser( int bruiseFactor )
+ {
+ for ( int i = 0; i < 5; i++ )
+ {
+ System.out.println( "bruising" );
+ }
+ }
+}