diff options
author | ehilsdal <ehilsdal> | 2003-04-08 21:59:39 +0000 |
---|---|---|
committer | ehilsdal <ehilsdal> | 2003-04-08 21:59:39 +0000 |
commit | e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556 (patch) | |
tree | a4e993a588298b0d6babdf643de8d35991a2ebd6 /docs/dist/doc/examples/observer | |
parent | f11709f8bc26a053ff573039cc0b5ee887c005ff (diff) | |
download | aspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.tar.gz aspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.zip |
folded in material from README-11.html
finally totally and completely stomped out "introduction"
minor formatting changes
generating better filenames for the progguide
added A4 version of quick reference
Diffstat (limited to 'docs/dist/doc/examples/observer')
-rw-r--r-- | docs/dist/doc/examples/observer/Button.java | 25 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/ColorLabel.java | 20 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/Demo.java | 23 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/Display.java | 24 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/Observer.java | 4 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/Subject.java | 5 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/SubjectObserverProtocol.java | 24 | ||||
-rw-r--r-- | docs/dist/doc/examples/observer/SubjectObserverProtocolImpl.java | 13 |
8 files changed, 49 insertions, 89 deletions
diff --git a/docs/dist/doc/examples/observer/Button.java b/docs/dist/doc/examples/observer/Button.java index 086a89e24..79b33caa9 100644 --- a/docs/dist/doc/examples/observer/Button.java +++ b/docs/dist/doc/examples/observer/Button.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -Button.java - */ @@ -28,18 +24,17 @@ class Button extends java.awt.Button { static final String defaultText = "cycle color"; Button(Display display) { - super(); - setLabel(defaultText); - setBackground(defaultBackgroundColor); - setForeground(defaultForegroundColor); - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Button.this.click(); - } - }); - display.addToFrame(this); + super(); + setLabel(defaultText); + setBackground(defaultBackgroundColor); + setForeground(defaultForegroundColor); + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Button.this.click(); + } + }); + display.addToFrame(this); } public void click() {} - } diff --git a/docs/dist/doc/examples/observer/ColorLabel.java b/docs/dist/doc/examples/observer/ColorLabel.java index 7b0c05fc9..5709545f2 100644 --- a/docs/dist/doc/examples/observer/ColorLabel.java +++ b/docs/dist/doc/examples/observer/ColorLabel.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -ColorLabel.java - */ package observer; @@ -21,20 +17,18 @@ import java.awt.Label; class ColorLabel extends Label { ColorLabel(Display display) { - super(); - display.addToFrame(this); + super(); + display.addToFrame(this); } final static Color[] colors = {Color.red, Color.blue, - Color.green, Color.magenta}; + Color.green, Color.magenta}; private int colorIndex = 0; private int cycleCount = 0; void colorCycle() { - cycleCount++; - colorIndex = (colorIndex + 1) % colors.length; - setBackground(colors[colorIndex]); - setText("" + cycleCount); + cycleCount++; + colorIndex = (colorIndex + 1) % colors.length; + setBackground(colors[colorIndex]); + setText("" + cycleCount); } } - - diff --git a/docs/dist/doc/examples/observer/Demo.java b/docs/dist/doc/examples/observer/Demo.java index b25552478..03be6a614 100644 --- a/docs/dist/doc/examples/observer/Demo.java +++ b/docs/dist/doc/examples/observer/Demo.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -Demo.java - */ package observer; @@ -19,16 +15,15 @@ package observer; public class Demo { public static void main(String[] args) { - Display display = new Display(); - Button b1 = new Button(display); - Button b2 = new Button(display); - ColorLabel c1 = new ColorLabel(display); - ColorLabel c2 = new ColorLabel(display); - ColorLabel c3 = new ColorLabel(display); + Display display = new Display(); + Button b1 = new Button(display); + Button b2 = new Button(display); + ColorLabel c1 = new ColorLabel(display); + ColorLabel c2 = new ColorLabel(display); + ColorLabel c3 = new ColorLabel(display); - b1.addObserver(c1); - b1.addObserver(c2); - b2.addObserver(c3); + b1.addObserver(c1); + b1.addObserver(c2); + b2.addObserver(c3); } } - diff --git a/docs/dist/doc/examples/observer/Display.java b/docs/dist/doc/examples/observer/Display.java index d7f4d479c..67ed2cb5b 100644 --- a/docs/dist/doc/examples/observer/Display.java +++ b/docs/dist/doc/examples/observer/Display.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -Display.java - */ package observer; @@ -34,19 +30,17 @@ class Display extends Panel { protected Frame frame = new Frame("Subject/Observer Demo"); Display() { - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) {System.exit(0);} - }); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) {System.exit(0);} + }); - frame.add(this, BorderLayout.CENTER); - frame.pack(); - frame.setVisible(true); + frame.add(this, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); } void addToFrame(Component c) { - add(c); - frame.pack(); - } + add(c); + frame.pack(); + } } - - diff --git a/docs/dist/doc/examples/observer/Observer.java b/docs/dist/doc/examples/observer/Observer.java index 58ae44916..2851ebe17 100644 --- a/docs/dist/doc/examples/observer/Observer.java +++ b/docs/dist/doc/examples/observer/Observer.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -Observer.java - */ package observer; diff --git a/docs/dist/doc/examples/observer/Subject.java b/docs/dist/doc/examples/observer/Subject.java index 5d80b1e09..d6c144e38 100644 --- a/docs/dist/doc/examples/observer/Subject.java +++ b/docs/dist/doc/examples/observer/Subject.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,10 +8,8 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -Subject.java - */ + package observer; import java.util.Vector; diff --git a/docs/dist/doc/examples/observer/SubjectObserverProtocol.java b/docs/dist/doc/examples/observer/SubjectObserverProtocol.java index 73f730e09..05e54d76c 100644 --- a/docs/dist/doc/examples/observer/SubjectObserverProtocol.java +++ b/docs/dist/doc/examples/observer/SubjectObserverProtocol.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -SubjectObserverProtocol.java - */ package observer; @@ -23,25 +19,23 @@ abstract aspect SubjectObserverProtocol { abstract pointcut stateChanges(Subject s); after(Subject s): stateChanges(s) { - for (int i = 0; i < s.getObservers().size(); i++) { - ((Observer)s.getObservers().elementAt(i)).update(); - } + for (int i = 0; i < s.getObservers().size(); i++) { + ((Observer)s.getObservers().elementAt(i)).update(); + } } private Vector Subject.observers = new Vector(); - public void Subject.addObserver(Observer obs) { - observers.addElement(obs); - obs.setSubject(this); + public void Subject.addObserver(Observer obs) { + observers.addElement(obs); + obs.setSubject(this); } - public void Subject.removeObserver(Observer obs) { - observers.removeElement(obs); - obs.setSubject(null); + public void Subject.removeObserver(Observer obs) { + observers.removeElement(obs); + obs.setSubject(null); } public Vector Subject.getObservers() { return observers; } private Subject Observer.subject = null; public void Observer.setSubject(Subject s) { subject = s; } public Subject Observer.getSubject() { return subject; } - } - diff --git a/docs/dist/doc/examples/observer/SubjectObserverProtocolImpl.java b/docs/dist/doc/examples/observer/SubjectObserverProtocolImpl.java index 01f0c38fc..2bc75918c 100644 --- a/docs/dist/doc/examples/observer/SubjectObserverProtocolImpl.java +++ b/docs/dist/doc/examples/observer/SubjectObserverProtocolImpl.java @@ -1,5 +1,4 @@ /* - Copyright (c) Xerox Corporation 1998-2002. All rights reserved. Use and copying of this software and preparation of derivative works based @@ -9,9 +8,6 @@ laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. - -SubjectObserverProtocolImpl.java - */ package observer; @@ -25,12 +21,11 @@ aspect SubjectObserverProtocolImpl extends SubjectObserverProtocol { declare parents: ColorLabel implements Observer; public void ColorLabel.update() { - colorCycle(); + colorCycle(); } - pointcut stateChanges(Subject s): - target(s) && - call(void Button.click()); + pointcut stateChanges(Subject s): + target(s) && + call(void Button.click()); } - |