package lectures.mvc.properties.atomic;
import util.annotations.WebDocuments;
import java.awt.Color;
import lectures.graphics.Line;
import util.annotations.StructurePattern;
import util.annotations.StructurePatternNames;
import util.misc.ThreadSupport;
import bus.uigen.OEFrame;
import bus.uigen.ObjectEditor;
@StructurePattern(StructurePatternNames.LINE_PATTERN)
@WebDocuments({"Lectures/MvcPropertiesAtomic.pptx", "Lectures/MvcPropertiesAtomic.pdf", "Videos/MvcPropertiesAtomic.avi"})
public class ANonObservableLine implements Line {
int x, y, width, height;
public ANonObservableLine (int initX, int initY, int initWidth, int initHeight) {
x = initX;
y = initY;
width = initWidth;
height = initHeight;
}
public Color getColor() {
return Color.WHITE;
}
public int getX() {return x;}
public void setX(int newX) {x = newX;}
public int getY() { return y; }
public void setY(int newY) {y = newY;}
public int getWidth() {return width;}
public void setWidth(int newVal) {width = newVal;}
public int getHeight() {return height;}
public void setHeight(int newHeight) {height = newHeight;}
public boolean equals(Object otherVal) {
if (!(otherVal instanceof Line)) {
return false;
}
Line otherLine = (Line) otherVal;
return (x == otherLine.getX() && y == otherLine.getY() && width == otherLine.getWidth() && height == otherLine.getHeight());
}
protected static int NUM_STEPS = 10;
protected static long SLEEP_TIME = 500;
protected static int X_STEP = 10;
public static void animateLine (
Line aLine,
OEFrame editor1,
OEFrame editor2) {
for (int i = 0; i < NUM_STEPS; i++) {
int newX = aLine.getX() + X_STEP;
aLine.setX(newX);
ThreadSupport.sleep(SLEEP_TIME);
editor1.refresh();
editor2.refresh();
}
}
public static void main(String args[]) {
Line aLine = new ANonObservableLine(10, 10, 30, 30);
OEFrame editor1 = ObjectEditor.edit (aLine);
OEFrame editor2 = ObjectEditor.edit (aLine);
animateLine (aLine, editor1, editor2);
}
}