Visual Paradigm Standard - TrickyJava JDK11 Lab 2 - Deque UML java util > Deque > Queue > Collection lang > Iterable datastructure deque -head : Node -tail : Node -size : int +offerFirst(e : E) :...

Copy and Paste Your Assignment Here231123123


Visual Paradigm Standard - TrickyJava JDK11 Lab 2 - Deque UML java util > Deque > Queue > Collection lang > Iterable datastructure deque -head : Node -tail : Node -size : int +offerFirst(e : E) : boolean +offerLast(e : E) : boolean +pollFirst() : E +pollLast() : E +peekFirst() : E +peekLast() : E +removeFirstOccurrence(o : Object) : boolean +removeLastOccurrence(o : Object) : boolean +contains(o : Object) : boolean +size() : int +isEmpty() : boolean +clear() : void LinkedListDeque AbstractDeque -value : R -next : Node -prev : Node -Node(value : R) -Node(next : Node, prev : Node) -Node(value : R, next : Node, prev : Node) +toString() : String Node E E E E E T R 2 -next-prev QuadTreeSimulator-Skeleton/.classpath QuadTreeSimulator-Skeleton/.project QuadTreeSimulator-Skeleton org.eclipse.jdt.core.javabuilder org.eclipse.m2e.core.maven2Builder org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature QuadTreeSimulator-Skeleton/pom.xml 4.0.0 college.cst8288 cst8288-QuadTreeSimulator-skeleton 1 QuadTreeSimulator a simple javafx application with quadtree to detect particles on screen lastname-firstname-labsection# quadtreesimulator.QuadTreeSimulator QuadTreeSimulator QuadTreeSimulator QuadTreeSimulator 5.6.2 11.0.2 UTF-8 org.junit.jupiter junit-jupiter ${junit.version} test org.openjfx javafx-base ${javafx.version} org.openjfx javafx-controls ${javafx.version} org.openjfx javafx-graphics ${javafx.version} org.openjfx javafx-fxml ${javafx.version} org.openjfx javafx-media ${javafx.version} org.openjfx javafx-swing ${javafx.version} org.openjfx javafx-web ${javafx.version} src test org.apache.maven.plugins maven-surefire-plugin 3.0.0-M4 **/Test*.java **/*Test.java true maven-compiler-plugin 3.8.1 11 org.openjfx javafx-maven-plugin 0.0.4 true 2 true true ${jlink.application.name} ${jlink.folder.name} ${jlink.zip.name} ${mainclass.path} org.apache.maven.plugins maven-jar-plugin 3.2.0 ${filename} false ${mainclass.path} org.apache.maven.plugins maven-assembly-plugin 3.3.0 src/assembly/zip.xml ${filename} package single QuadTreeSimulator-Skeleton/.settings/org.eclipse.core.resources.prefs eclipse.preferences.version=1 encoding/=UTF-8 encoding/src=UTF-8 QuadTreeSimulator-Skeleton/.settings/org.eclipse.jdt.core.prefs eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=11 QuadTreeSimulator-Skeleton/.settings/org.eclipse.m2e.core.prefs activeProfiles= eclipse.preferences.version=1 resolveWorkspaceProjects=true version=1 QuadTreeSimulator-Skeleton/src/assembly/zip.xml true src zip pom.xml src test QuadTreeSimulator-Skeleton/src/module-info.java QuadTreeSimulator-Skeleton/src/module-info.java module particlelocator {     exports quadtreesimulator;          requires transitive javafx.graphics;     requires transitive javafx.controls;     requires javafx.base; } QuadTreeSimulator-Skeleton/src/quadtreesimulator/QuadTreeSimulator.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/QuadTreeSimulator.java package quadtreesimulator; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.event.ActionEvent; import javafx.geometry.Orientation; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.CheckMenuItem; import javafx.scene.control.CustomMenuItem; import javafx.scene.control.Label; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.control.RadioMenuItem; import javafx.scene.control.SeparatorMenuItem; import javafx.scene.control.Slider; import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToolBar; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Region; import javafx.scene.paint.Color; import javafx.stage.Stage; import quadtreesimulator.animator.AbstractAnimator; import quadtreesimulator.animator.QuadTreeAnimator; import quadtreesimulator.scene.AbstractScene; import quadtreesimulator.scene.ColorDetectionScene; /**  * This is the start of JavaFX application. This class must extend {@link Application}.  *   * @author Shariar (Shawn) Emami  * @version Sep 21, 2020  */ public class QuadTreeSimulator extends Application {     /**      * size of the scene      */     private static final double WIDTH = 900, HEIGHT = 600;     /**      * title of application      */     private String title = "Quad Tree Simulator";     /**      * background color of application      */     private Color background = Color.LIGHTPINK;     /**      * {@link BorderPane} is a layout manager that manages all nodes in 5 areas as below:      *       *
     * -----------------------      * |        top          |      * -----------------------      * |    |          |     |      * |left|  center  |right|      * |    |          |     |      * -----------------------      * |       bottom        |      * -----------------------      *

*       * this object is passed to {@link Scene} object in {@link ParticleLocator#start(Stage)} method.      */     private BorderPane root;     /**      * this object represents the canvas (drawing area)      */     private Canvas canvas;     private AbstractAnimator animator;     private AbstractScene scene;     private Alert alert;     /**      * this method is called at the very beginning of the JavaFX application and can be used to initialize all      * components in the application. however, {@link Scene} and {@link Stage} must not be created in this method. this      * method does not run JavaFX thread.      */     @Override     public void init() throws Exception {         //TODO Complete     }     /**      *


* this method is called when JavaFX application is started and it is running on JavaFX thread. this method must at      * least create {@link Scene} and finish customizing {@link Stage}. these two objects must be on JavaFX thread when      * created.      *


*


* {@link Stage} represents the frame of your application, such as minimize, maximize and close buttons.      * {@link Scene} represents the holder of all your JavaFX {@link Node}s.      * {@link Node} is the super class of every javaFX class.      *


*       * @param primaryStage - primary stage of your application that will be rendered      */     @Override     public void start( Stage primaryStage) throws Exception {         // Alert is initialized in start because it must be created on JavaFX thread         alert = new Alert( AlertType.INFORMATION);         Scene scene = new Scene( root, WIDTH, HEIGHT, background);         primaryStage.setScene( scene);         primaryStage.setTitle( title);         // when escape key is pressed close the application         primaryStage.addEventHandler( KeyEvent.KEY_RELEASED, ( KeyEvent event) -> {             if ( KeyCode.ESCAPE == event.getCode()) {                 primaryStage.hide();             }         });         // display the JavaFX application         primaryStage.show();     }     /**      * this method is called at the very end when the application is about to exit. this method is used to stop or      * release any resources used during the application.      */     @Override     public void stop() throws Exception {         animator.stop();     }     /**      *       * @return      */     private Region createColorBar() {         //TODO Complete         return null;     }     /**      * create a {@link ToolBar} that represent the menu bar at the top of the application.      *       * @return customized {@link ToolBar}      */     public Region createOptionsBar() {         MenuItem start = new MenuItem( "Start");         start.setOnAction( ( ActionEvent e) -> animator.start());         MenuItem stop = new MenuItem( "Stop");         stop.setOnAction( ( ActionEvent e) -> animator.stop());         MenuItem clear = new MenuItem( "Clear");         clear.setOnAction( ( ActionEvent e) -> animator.clear());         MenuItem exit = new MenuItem( "Exit");         exit.setOnAction( ( ActionEvent e) -> Platform.exit());         Slider slider = new Slider( 0, 10, 7);         DoubleProperty depthOption = (DoubleProperty) scene.getOption( "quadTreeDepth");         depthOption.bind( slider.valueProperty());         CustomMenuItem ballLabel = new CustomMenuItem();         ballLabel.setContent( new Label( "QT Depth:"));         ballLabel.setHideOnClick( false);         CustomMenuItem ballCount = new CustomMenuItem();         ballCount.setContent( slider);         ballCount.setHideOnClick( false);         CheckMenuItem fps = new CheckMenuItem( "FPS");         BooleanProperty fpsOption = (BooleanProperty) scene.getOption( "displayFPS");         fpsOption.bind( fps.selectedProperty());         fps.setSelected( true);         CheckMenuItem displayGrid = new CheckMenuItem( "QuadTree");         BooleanProperty qtOption = (BooleanProperty) scene.getOption( "displayQuadTree");         qtOption.bind( displayGrid.selectedProperty());         displayGrid.setSelected( true);         RadioMenuItem baseScene = new RadioMenuItem( "Scene");         baseScene.setSelected( true);         ToggleGroup sceneToggleGroup = new ToggleGroup();         baseScene.setToggleGroup( sceneToggleGroup);         RadioMenuItem baseAnimator = new RadioMenuItem( "Animator");         baseAnimator.setSelected( true);         //      baseAnimator.setOnAction( e -> createScene.accept( null));         ToggleGroup animatorToggleGroup = new ToggleGroup();         baseAnimator.setToggleGroup( animatorToggleGroup);         MenuItem info = new MenuItem( "Info");         info.setOnAction( e -> {             alert.setTitle( "Information");             alert.setHeaderText( "Developer");             alert.setContentText( "Shawn E.\[email protected]");             alert.show();         });         Menu file = new Menu( "File");         file.getItems().addAll( start, stop, clear, new SeparatorMenuItem(), exit);         Menu option = new Menu( "Options");         option.getItems().addAll( ballLabel, ballCount, new SeparatorMenuItem(), fps, displayGrid);         Menu help = new Menu( "Help");         help.getItems().addAll( info);         MenuBar menuBar = new MenuBar();         menuBar.getMenus().addAll( file, option, help);         return menuBar;     }     /**      * create a {@link ToolBar} that will represent the status bar of the application.      *       * @return customized {@link ToolBar}      */     public Region createStatusBar() {         Label mouseCoordLabel = new Label( "(0,0)");         Label dragCoordLabel = new Label( "(0,0)");         canvas.addEventHandler( MouseEvent.MOUSE_MOVED,                 e -> mouseCoordLabel.setText( "(" + e.getX() + "," + e.getY() + ")"));         canvas.addEventHandler( MouseEvent.MOUSE_DRAGGED,                 e -> dragCoordLabel.setText( "(" + e.getX() + "," + e.getY() + ")"));         return new ToolBar( new Label( "Mouse: "), mouseCoordLabel, new Label( "Drag: "), dragCoordLabel);     }     /**      * main starting point of the application      *       * @param args - arguments provided through command line, if any      */     public static void main( String[] args) {         // this method start the javaFX application.         // some IDEs are capable of starting JavaFX without this method.         launch( args);     } } QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/FpsCounter.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/FpsCounter.java package quadtreesimulator.entity; import javafx.scene.canvas.GraphicsContext; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import quadtreesimulator.entity.property.Sprite; /**  *   *   * @author Shahriar (Shawn) Emami  * @version April 17, 2020  */ public class FpsCounter extends GenericEntity {     public static final double ONE_SECOND = 1000000000L;     public static final double HALF_SECOND = ONE_SECOND / 2F;     private Font fpsFont;     private String fpsDisplay;     private int frameCount;     private double lastTime;     private double xPos, yPos;     public FpsCounter( double x, double y) {         sprite = new Sprite() {             @Override             public void draw( GraphicsContext gc) {                 gc.save();                 Font temp = gc.getFont();                 gc.setFont( fpsFont);                 gc.setFill( getFill());                 gc.fillText( fpsDisplay, xPos, yPos);                 gc.setStroke( getStroke());                 gc.setLineWidth( getWidth());                 gc.strokeText( fpsDisplay, xPos, yPos);                 gc.setFont( temp);                 gc.restore();             }         };         setPos( x, y);         setFont( Font.font( Font.getDefault().getFamily(), FontWeight.BLACK, 24));     }     public void calculateFPS( long now) {         if ( now - lastTime >= HALF_SECOND) {             fpsDisplay = Integer.toString( frameCount * 2);             frameCount = 0;             lastTime = now;         }         frameCount++;     }     public FpsCounter setFont( Font font) {         fpsFont = font;         return this;     }     public FpsCounter setPos( double x, double y) {         xPos = x;         yPos = y;         return this;     } } QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/GenericEntity.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/GenericEntity.java package quadtreesimulator.entity; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import quadtreesimulator.entity.property.Entity; import quadtreesimulator.entity.property.Sprite; /**  *   * @author Shariar (Shawn) Emami  * @version Sep 22, 2020  */ public class GenericEntity implements Entity {     protected Sprite sprite;     private BooleanProperty drawable;     public GenericEntity() {         this( null);     }     public GenericEntity( Sprite sprite) {         this.sprite = sprite;         drawable = new SimpleBooleanProperty( sprite != null);     }     public void setSprite( Sprite sprite) {         this.sprite = sprite;         drawable.set( sprite != null);     }     public BooleanProperty drawableProperty() {         return drawable;     }     @Override     public void update() {         // TODO Auto-generated method stub       }     @Override     public Sprite getDrawable() {         return sprite;     }     @Override     public boolean isDrawable() {         return sprite != null && drawable.get();     } } QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Drawable.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Drawable.java package quadtreesimulator.entity.property; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.ImagePattern; import javafx.scene.paint.Paint; /**  * an interface used on drawable objects.  *   * @param  - the type of class which implements this interface.  * @author Shahriar (Shawn) Emami  * @version Jan 12, 2019  */ public interface Drawable{     /**      * set the {@link Paint} to be used when filling the shape      * @param paint - an object representing fill content like {@link Paint} or {@link ImagePattern} object      * @return the instance of current object      */     T setFill( Paint paint);          /**      * set the {@link Paint} to be used when stroking the shape      * @param paint - an object representing fill content like {@link Paint} or {@link ImagePattern} object      * @return the instance of current object      */     T setStroke( Paint paint);          /**      * set the stroke width to be used when stroking the shape      * @param width - stroke width      * @return the instance of current object      */     T setWidth( double width);          /**      * get the current fill {@link Color}      * @return {@link Paint}      */     Paint getFill();     /**      * get the current stroke {@link Color}      * @return {@link Paint}      */     Paint getStroke();     /**      * get the current stroke width      * @return stroke width      */     double getWidth();          /**      * draw the shape given the {@link GraphicsContext}      * @param gc - {@link GraphicsContext} object      */     void draw( GraphicsContext gc); } QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Entity.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Entity.java package quadtreesimulator.entity.property; public interface Entity{     void update();     boolean isDrawable();     Drawable< ?> getDrawable(); } QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Sprite.java QuadTreeSimulator-Skeleton/src/quadtreesimulator/entity/property/Sprite.java package quadtreesimulator.entity.property; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.ImagePattern; import javafx.scene.paint.Paint; /**  *


* Sprite represents what to be drawn during the canvas drawing stage. this class holds information such as  * {@link Sprite#fill}, {@link Sprite#stroke} and {@link Sprite#strokeWidth}. this class is abstract, meaning   * it must be inherited and draw method overridden.  * fill and stroke values in this class are of type {@link Paint}. this allows  the user to set any color to the sprite  * or using the {@link ImagePattern} class choose an image asset and set it as filling.  *


*   * ex: sprite for polyshape  *
    sprite = new Sprite(){         {             setFill( new ImagePattern( new Image( "file:assets/concrete/dsc_1621.png")));         }         public void draw( GraphicsContext gc){             gc.setLineWidth( getWidth());             if( getStroke() != null){                 gc.setStroke( getStroke());                 gc.strokePolygon( points[0], points[1], pointCount);             }             if( getFill() != null){                 gc.setFill( getFill());                 gc.fillPolygon( points[0], points[1], pointCount);             }         }     };  *


*   * @author Shahriar (Shawn) Emami  * @version Mar 11, 2019  */ public abstract class Sprite implements Drawable< sprite>{     private Paint fill, stroke;     private double strokeWidth;     /**      * set the {@link Paint} to be used when filling the shape      * @param paint - an object representing fill content like {@link Paint} or {@link ImagePattern} object      * @return the instance of current object      */     public Sprite setFill( Paint color){         fill = color;         return this;     }          /**      * set the {@link Paint} to be used when stroking the shape      * @param paint - an object representing fill content like {@link Paint} or {@link ImagePattern} object      * @return the instance of current object      */     public Sprite setStroke( Paint color){         stroke = color;         return this;     }          /**      * set the stroke width to be used when stroking the shape      * @param width - stroke width      * @return the instance of current object      */     public Sprite setWidth( double width){         this.strokeWidth = width;         return this;     }          /**      * get the current fill {@link Color}      * @return {@link Paint}      */     public Paint getFill(){         return fill;     }     /**      * get the current stroke {@link Color}      * @return {@link Paint}      */     public Paint getStroke(){         return stroke;     }     /**      * get the current stroke width      * @return stroke width      */     public double getWidth(){         return strokeWidth;     }          /**      * draw the shape given the {@link GraphicsContext}      * @param gc - {@link GraphicsContext} object      */     public abstract void draw( GraphicsContext gc); } QuadTreeSimulator-Skeleton/src/utility/QuadTree.java QuadTreeSimulator-Skeleton/src/utility/QuadTree.java package utility; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import quadtreesimulator.entity.GenericEntity; import quadtreesimulator.entity.property.Sprite; //TODO Complete public class QuadTree {     //TODO Complete     private QuadTree() {         sprite = new Sprite() {             @Override             public void draw( GraphicsContext gc) {                 gc.setLineWidth( 0.5);                 drawNode( head, gc);             }             private void drawNode( Node n, GraphicsContext gc) {                 if ( n.children == null || n.empty || n.depth >= maxDepth) {                     return;                 }                 gc.strokeLine( n.x + n.width / 2, n.y, n.x + n.width / 2, n.y + n.height);                 gc.strokeLine( n.x, n.y + n.height / 2, n.x + n.width, n.y + n.height / 2);                 for ( Node node : n.children) {                     drawNode( node, gc);                 }             }         };     } } Visual Paradigm Standard - QuadTreeSim QuadTree Sim quadtreesimulator utility -children : Node[] -depth : int -x : double -y : double -width : double -height : double -empty : boolean +Node(depth : int, x : double, y : double, width : double, height : double) +push(buffer : int[], rowSize : int, color : int) : void +clear() : void -divide() : void Node -head : Node -maxDepth : int -QuadTree() +QuadTree(depth : int, width : double, height : double) +push(buffer : int[], colSize : int, c : Color) : void +clear() : void QuadTree entity property GenericEntityFpsCounter Sprite +update() : void +isDrawable() : boolean +getDrawable() : Drawable > Entity +setFill(paint : Paint) : T +setStroke(paint : Paint) : T +setWidth(width : double) : T +getFill() : Paint +getStroke() : Paint +getWidth() : double +draw(gc : GraphicsContext) : void > Drawable animator scene -qt : QuadTree +createScene() : AbstractScene +getQuadTree() : QuadTree ColorDetectionScene #canvasNode : Canvas #options : Map +AbstractScene() +setCanvas(canvas : Canvas) : void +getCanvas() : Canvas +w() : double +h() : double +gc() : GraphicsContext +addOption(uniqueName : String, option : Object) : void +getOption(uniqueName : String) : Object +createScene() : AbstractScene AbstractScene -buffer : int[] -x : double -y : double -initilized : boolean -drawingCanvas : Canvas -qt : QuadTree +init() : void +clear() : void #handle(gc : GraphicsContext, now : long) : void QuadTreeAnimator javafx-isRunning : boolean #scene : AbstractScene -fps : FpsCounter +AbstractAnimator() +stop() : void +start() : void +isRunning() : boolean +clear() : void #clearAndFill(gc : GraphicsContext, background : Color) : void #clearAndFill(gc : GraphicsContext, background : Color, x : double, y : double, w : double, h : double) : void +handle(now : long) : void #handle(gc : GraphicsContext, now : long) : void AbstractAnimator application-WIDTH : double = 900 -HEIGHT : double = 600 -title : String = "Quad Tree Simulator" -background : Color = Color.LIGHTPINK -root : BorderPane -canvas : Canvas -animator : AbstractAnimator -scene : AbstractScene -alert : Alert +init() : void +start(primaryStage : Stage) : void +stop() : void -createColorBar() : Region +createOptionsBar() : Region +createStatusBar() : Region +main(args : String[]) : void QuadTreeSimulator Application animation AnimationTimer T : Sprite -children * #scene1 -qt 1 -qt 1 -fps 1 -animator1 #sprite 1 -scene 1 sd quadtreesimulator.animator.AbstractAnimator.handle(long) opt [drawFPS.get()] opt [drawFPS.get()] : AbstractAnimator scene : AbstractScene fps : FpsCounter gc : GraphicsContext s : Sprite 1.9: s : Sprite 1.3: drawFPS : BooleanProperty 1.11: 1.10: draw(gc : GraphicsContext = gc) : void 1.8: getDrawable() : Sprite 1.7: restore() 1.6: handle(gc : GraphicsContext
Oct 17, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here