ArrayListController.java - ArrayListController Class import import import import import import import import import javafx.event.ActionEvent

ArrayListController.java - ArrayListController Class import...

This preview shows page 1 - 3 out of 6 pages.

/* ArrayListController Class * */ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.scene.*; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.scene.paint.*; import javafx.animation.AnimationTimer; import java.util.*; public class ArrayListController { private ArrayList<Auto> carList; private AutoDrawing drawing; private int activity; @FXML private BorderPane bp; @FXML private Button fill; @FXML private Button print; @FXML private Button set; @FXML private Button count; @FXML private Button find; private Pane pane; private Canvas canvas; private GraphicsContext gc; private int result; private boolean animate; public void initialize( ) { carList = new ArrayList<Auto>( ); drawing = new AutoDrawing( carList ); pane = new Pane( ); bp.setCenter( pane ); canvas = new Canvas( Dimensions.APP_WIDTH - Dimensions.APP_PADDING, Dimensions.APP_HEIGHT - Dimensions.APP_PADDING ); pane.getChildren( ).add( canvas ); gc = canvas.getGraphicsContext2D( ); } @FXML protected void activity( ActionEvent event ) { if ( event.getSource( ) == fill ) { activity = 0; drawing.clearAutoStates( ); fillWithCars( ); animate = true; } else if ( event.getSource( ) == print ) { activity = 1; drawing.clearAutoStates( ); printAutoList( );
Image of page 1
animate = true; } else if ( event.getSource( ) == set ) { activity = 2; TextInputDialog dialog = new TextInputDialog( "" ); dialog.setTitle( "User Input" ); dialog.setHeaderText( "Changing the Model of All Cars" ); dialog.setContentText( "Enter a Model" ); Optional<String> result = dialog.showAndWait( ); String model = null; if ( result.isPresent( ) ) model = result.get( ); if ( model != null ) { drawing.clearAutoStates( ); drawing.setSearchModel( model ); setModelValues( model ); animate = true; } else animate = false; } else if ( event.getSource( ) == count ) { activity = 3;
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 6 pages?

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes