package praxis.composite.objects_shapes.f15;
import util.annotations.WebDocuments;
import util.misc.ThreadSupport;
import lectures.composite.objects_shapes.ALineWithObjectProperty;
import lectures.composite.objects_shapes.CartesianPlane;
import lectures.composite.objects_shapes.LineWithObjectProperty;
import lectures.graphics.ACartesianPoint;
import lectures.graphics.ALine;
import lectures.graphics.AStringShape;
import lectures.graphics.Line;
import lectures.graphics.StringShape;
import bus.uigen.OEFrame;
import bus.uigen.ObjectEditor;
@WebDocuments({"Lectures/CompositeObjectsShapesF15.pptx", "Lectures/CompositeObjectsShapesF15.pdf", "Videos/CompositeObjectsShapesF15.avi"})
public class APraxisCartesianPlane implements PraxisCartesianPlane {
protected int originX, originY;
protected int axesLength;
protected LineWithObjectProperty xAxis;
protected Line yAxis;
protected StringShape xLabel;
protected StringShape yLabel;
public APraxisCartesianPlane (int theAxesLength, int theOriginX, int theOriginY ) {
axesLength = theAxesLength;
originY = theOriginY;
xAxis = new ALineWithObjectProperty(new ACartesianPoint(toXAxisX(), toXAxisY()), axesLength, 0);
yAxis = new ALine(toYAxisX(), toYAxisY(), 0, axesLength);
xLabel = new AStringShape ("X", toXLabelX(), toXLabelY());
yLabel = new AStringShape ("Y", toYLabelX(), toYLabelY());
}
public LineWithObjectProperty getXAxis() {
return xAxis;
}
public Line getYAxis() {
return yAxis;
}
public StringShape getXLabel() {
return xLabel;
}
public StringShape getYLabel() {
return yLabel;
}
public int getAxesLength() {
return axesLength;
}
public void setAxesLength(int anAxesLength) {
axesLength = anAxesLength;
}
protected void changeDependentProperties() {
xAxis.setWidth(axesLength);
yAxis.setHeight(axesLength);
xAxis.setLocation(new ACartesianPoint (toXAxisX(), toXAxisY()));
yAxis.setY(toYAxisY());
xLabel.setX(toXLabelX());
xLabel.setY(toXLabelY());
yLabel.setX(toYLabelX());
yLabel.setY(toYLabelY());
}
protected int toXAxisX() {
return originX - axesLength/2;
}
protected int toXAxisY() {
return originY;
}
protected int toYAxisX() {
return originX;
}
protected int toYAxisY() {
return originY - axesLength/2;
}
protected int toXLabelX() {
return originX + axesLength/2;
}
protected int toXLabelY() {
return originY;
}
protected int toYLabelX() {
return originX;
}
protected int toYLabelY() {
return originY - axesLength/2;
}
public static void main (String[] args) {
final int axesIncrement = 5;
final long initDelay = 1000;
final long sleepTime = 300;
PraxisCartesianPlane aCartesianPlane = new APraxisCartesianPlane(100, 125, 125);
OEFrame anEditor = ObjectEditor.edit(aCartesianPlane);
anEditor.showTreePanel();
anEditor.setSize(500, 600);
anEditor.setLocation(100, 200);
ThreadSupport.sleep(initDelay);
for (int i = 0; i < 10; i++) {
int newAxesLength = aCartesianPlane.getAxesLength() + axesIncrement;
aCartesianPlane.setAxesLength(newAxesLength);
ThreadSupport.sleep(sleepTime);
anEditor.refresh();
System.out.println (" XX:" + aCartesianPlane.getXAxis().getLocation().getRadius());
}
}
}