package lectures.mvc.graphics;
import util.annotations.WebDocuments;
import java.awt.Component;
import java.awt.event.KeyListener;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import lectures.mvc.properties.AnObservablePlottedShuttle;
import lectures.mvc.properties.ObservablePlottedShuttle;
import bus.uigen.OEFrame;
import bus.uigen.ObjectEditor;
@WebDocuments({"Lectures/MvcGraphics.pptx", "Lectures/MvcGraphics.pdf", "Videos/MvcGraphics.avi"})
public class PlottedShuttleComposer {
static final int CUSTOM_FRAME_WIDTH = 400;
static final int CUSTOM_FRAME_HEIGHT = 300;
static final int OE_FRAME_WIDTH = 400;
static final int OE_FRAME_HEIGHT = 600;
static final int INIT_SHUTTLE_X = 25;
static final int INIT_SHUTTLE_Y = 50;
static final int FINAL_SHUTTLE_X = 50;
static final int FINAL_SHUTTLE_Y = 100;
public static void composeShuttleMVC(ObservablePlottedShuttle aPlottedShuttle) {
PropertyChangeListener view = new APlottedShuttleView(aPlottedShuttle);
aPlottedShuttle.addPropertyChangeListener(view);
MouseListener aMouseController = new APlottedShuttleMouseController(aPlottedShuttle, (Component) view);
KeyListener aKeyController = new APlottedShuttleKeyController(aPlottedShuttle, (Component) view);
JFrame aFrame = new JFrame("Plotted Shuttle");
aFrame.add((Component) view);
aFrame.setSize(CUSTOM_FRAME_WIDTH, CUSTOM_FRAME_HEIGHT);
aFrame.setVisible(true);
}
public static void main(String[] args) {
ObservablePlottedShuttle aPlottedShuttle = new AnObservablePlottedShuttle(INIT_SHUTTLE_X, INIT_SHUTTLE_Y);
composeShuttleMVC(aPlottedShuttle);
OEFrame anOEFrame = ObjectEditor.edit(aPlottedShuttle);
anOEFrame.setSize(OE_FRAME_WIDTH, OE_FRAME_HEIGHT);
aPlottedShuttle.setShuttleX(FINAL_SHUTTLE_X);
aPlottedShuttle.setShuttleY(FINAL_SHUTTLE_Y);
}
}