diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-02-01 08:57:52 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-02-01 08:58:28 +0700 |
commit | 983159c76ca8163b61f0d52c98522e8bc113f585 (patch) | |
tree | 3137bb04a0942b59d7b066912a2fa8fed5601373 /docs/modules/ROOT/pages/examples/observer | |
parent | c99b58736fd7f2952fe9bf787333631a762dcbeb (diff) | |
download | aspectj-antora.tar.gz aspectj-antora.zip |
Move source code examples to Antora examples directoryantora
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'docs/modules/ROOT/pages/examples/observer')
9 files changed, 0 insertions, 268 deletions
diff --git a/docs/modules/ROOT/pages/examples/observer/Button.java b/docs/modules/ROOT/pages/examples/observer/Button.java deleted file mode 100644 index 79b33caa9..000000000 --- a/docs/modules/ROOT/pages/examples/observer/Button.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - - -package observer; - -import java.awt.Color; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -class Button extends java.awt.Button { - - static final Color defaultBackgroundColor = Color.gray; - static final Color defaultForegroundColor = Color.black; - 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); - } - - public void click() {} -} diff --git a/docs/modules/ROOT/pages/examples/observer/ColorLabel.java b/docs/modules/ROOT/pages/examples/observer/ColorLabel.java deleted file mode 100644 index 5709545f2..000000000 --- a/docs/modules/ROOT/pages/examples/observer/ColorLabel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -package observer; -import java.awt.Color; -import java.awt.Label; - -class ColorLabel extends Label { - - ColorLabel(Display display) { - super(); - display.addToFrame(this); - } - - final static Color[] colors = {Color.red, Color.blue, - 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); - } -} diff --git a/docs/modules/ROOT/pages/examples/observer/Demo.java b/docs/modules/ROOT/pages/examples/observer/Demo.java deleted file mode 100644 index 03be6a614..000000000 --- a/docs/modules/ROOT/pages/examples/observer/Demo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -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); - - b1.addObserver(c1); - b1.addObserver(c2); - b2.addObserver(c3); - } -} diff --git a/docs/modules/ROOT/pages/examples/observer/Display.java b/docs/modules/ROOT/pages/examples/observer/Display.java deleted file mode 100644 index 67ed2cb5b..000000000 --- a/docs/modules/ROOT/pages/examples/observer/Display.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -package observer; -import java.awt.Frame; -import java.awt.Panel; -import java.awt.Container; -import java.awt.Component; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.BorderLayout; - -/* - * Display is the container class that holds all the views of the - * colored number. - * In this demo, it holds buttons. - */ - -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.add(this, BorderLayout.CENTER); - frame.pack(); - frame.setVisible(true); - } - - void addToFrame(Component c) { - add(c); - frame.pack(); - } -} diff --git a/docs/modules/ROOT/pages/examples/observer/Observer.java b/docs/modules/ROOT/pages/examples/observer/Observer.java deleted file mode 100644 index 2851ebe17..000000000 --- a/docs/modules/ROOT/pages/examples/observer/Observer.java +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ -package observer; - -interface Observer { - void setSubject(Subject s); - Subject getSubject(); - void update(); -} diff --git a/docs/modules/ROOT/pages/examples/observer/Subject.java b/docs/modules/ROOT/pages/examples/observer/Subject.java deleted file mode 100644 index d6c144e38..000000000 --- a/docs/modules/ROOT/pages/examples/observer/Subject.java +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -package observer; -import java.util.Vector; - -interface Subject { - void addObserver(Observer obs); - void removeObserver(Observer obs); - Vector getObservers(); - Object getData(); -} diff --git a/docs/modules/ROOT/pages/examples/observer/SubjectObserverProtocol.java b/docs/modules/ROOT/pages/examples/observer/SubjectObserverProtocol.java deleted file mode 100644 index 05e54d76c..000000000 --- a/docs/modules/ROOT/pages/examples/observer/SubjectObserverProtocol.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -package observer; - -import java.util.Vector; - -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(); - } - } - - private Vector Subject.observers = new Vector(); - 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 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/modules/ROOT/pages/examples/observer/SubjectObserverProtocolImpl.java b/docs/modules/ROOT/pages/examples/observer/SubjectObserverProtocolImpl.java deleted file mode 100644 index 2bc75918c..000000000 --- a/docs/modules/ROOT/pages/examples/observer/SubjectObserverProtocolImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (c) Xerox Corporation 1998-2002. All rights reserved. - -Use and copying of this software and preparation of derivative works based -upon this software are permitted. Any distribution of this software or -derivative works must comply with all applicable United States export control -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. -*/ - -package observer; - -import java.util.Vector; - -aspect SubjectObserverProtocolImpl extends SubjectObserverProtocol { - - declare parents: Button implements Subject; - public Object Button.getData() { return this; } - - declare parents: ColorLabel implements Observer; - public void ColorLabel.update() { - colorCycle(); - } - - pointcut stateChanges(Subject s): - target(s) && - call(void Button.click()); - -} diff --git a/docs/modules/ROOT/pages/examples/observer/files.lst b/docs/modules/ROOT/pages/examples/observer/files.lst deleted file mode 100644 index 9b800286e..000000000 --- a/docs/modules/ROOT/pages/examples/observer/files.lst +++ /dev/null @@ -1,8 +0,0 @@ -ColorLabel.java -Button.java -Display.java -Subject.java -Observer.java -SubjectObserverProtocol.java -SubjectObserverProtocolImpl.java -Demo.java |