- Removed some default templates (eg: created by X) - Wrote JavaDoc for classes that had none - Made JavaDoc more clear for classes - Linked JavaDoc to other classes - Minor spelling errors fixed - BoatInRace and BoatInRaceTest commented out (to be removed) #story[1003]
56 lines
1.2 KiB
Java
56 lines
1.2 KiB
Java
package seng302.Model;
|
|
|
|
import javafx.scene.canvas.Canvas;
|
|
import javafx.scene.canvas.GraphicsContext;
|
|
|
|
/**
|
|
* The abstract class for the resizable race canvases.
|
|
*/
|
|
public abstract class ResizableCanvas extends Canvas {
|
|
protected final GraphicsContext gc;
|
|
|
|
public ResizableCanvas(){
|
|
this.gc = this.getGraphicsContext2D();
|
|
// Redraw canvas when size changes.
|
|
widthProperty().addListener(evt -> draw());
|
|
heightProperty().addListener(evt -> draw());
|
|
|
|
}
|
|
|
|
abstract void draw();
|
|
|
|
|
|
/**
|
|
* Set the Canvas to resizable.
|
|
*
|
|
* @return That the Canvas is resizable.
|
|
*/
|
|
@Override
|
|
public boolean isResizable() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Returns the preferred width of the Canvas
|
|
*
|
|
* @param width of canvas
|
|
* @return Returns the width of the Canvas
|
|
*/
|
|
@Override
|
|
public double prefWidth(double width) {
|
|
return getWidth();
|
|
}
|
|
|
|
/**
|
|
* Returns the preferred height of the Canvas
|
|
*
|
|
* @param height of canvas
|
|
* @return Returns the height of the Canvas
|
|
*/
|
|
@Override
|
|
public double prefHeight(double height) {
|
|
return getHeight();
|
|
}
|
|
|
|
}
|