Question

In: Computer Science

The painter Mondrian is known for paintings that are made up of rectangles of different colors...

The painter Mondrian is known for paintings that are made up of rectangles of different colors arranged together in patterns like the one below. Write an application that displays a Mondrian-like picture in a window using JavaFX (you are not allowed to use panels or frames). There must be at least nine rectangles, and they must be aligned so that they fill the window without any gaps. There must be at least two different colors, one of them you have to create (using the Color class) and at least two different sizes of rectangles. Use Mondrian as the class name

Solutions

Expert Solution

Program

package mondrian;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;

/**
*
* @author
*/
public class Mondrian extends Application {
  
@Override
public void start(Stage stage) {
//Drawing a Rectangle
Rectangle r1 = new Rectangle(20,20, 520, 220);
r1.setStroke(Color.BLACK);
r1.setFill(Color.WHITE);
Rectangle r2 = new Rectangle(20, 20, 80, 85);
r2.setStroke(Color.BLUE);
r2.setFill(Color.WHITE);
Rectangle r3 = new Rectangle(20, 85, 80, 155);
r3.setStroke(Color.GREEN);
r3.setFill(Color.WHITE);
Rectangle r4 = new Rectangle(100, 20, 140, 150);
r4.setStroke(Color.ORANGE);
r4.setFill(Color.WHITE);
Rectangle r5 = new Rectangle(240, 20, 20, 150);
r5.setStroke(Color.RED);
r5.setFill(Color.WHITE);
Rectangle r6 = new Rectangle(260, 20, 280, 80);
r6.setStroke(Color.VIOLET);
r6.setFill(Color.WHITE);
Rectangle r7 = new Rectangle(260, 100, 140, 70);
r7.setStroke(Color.BROWN);
r7.setFill(Color.WHITE);
Rectangle r8 = new Rectangle(400, 100, 140, 70);
r8.setStroke(Color.CYAN);
r8.setFill(Color.WHITE);
Rectangle r9 = new Rectangle(100, 170, 240, 70);
r9.setStroke(Color.YELLOW);
r9.setFill(Color.WHITE);

//Creating a Group object
Group root = new Group();
  
root.getChildren().add(r1);
root.getChildren().add(r2);
root.getChildren().add(r3);
root.getChildren().add(r4);
root.getChildren().add(r5);
root.getChildren().add(r6);
root.getChildren().add(r7);
root.getChildren().add(r8);
root.getChildren().add(r9);
  
//Creating a scene object
Scene scene = new Scene(root, 650, 300);
  
//Setting title to the Stage
stage.setTitle("Mondrian");

//Adding scene to the stage
stage.setScene(scene);

//Displaying the contents of the stage
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
  
}

Output:


Related Solutions

What led Kenton Nelson to be a painter? How does Kenton Nelson work with commissioned paintings?...
What led Kenton Nelson to be a painter? How does Kenton Nelson work with commissioned paintings? What did you learn about his painting process? Identify something that is inspiring to you and your life from his presentation.
Color blindness is the decreased ability to see colors and clearly distinguish different colors of the...
Color blindness is the decreased ability to see colors and clearly distinguish different colors of the visible spectrum. It is known that color blindness affects 11% of the European population. A sample of 12 subjects is taken for research purposes by a team of optometrists. What is the probability that one subject is color blind? What is the probability that more than one subject is color blind? What is the probability that at most 3 subjects are color blind? What...
You have a portfolio made up of the following three assets with known means, standard deviations,...
You have a portfolio made up of the following three assets with known means, standard deviations, and correlations of monthly returns: monthly return Correlation Matrix Weight Asset mean std dev Asset Apple Amazon CVS 50% Apple 3.06% 8.1% Apple 1 30% Amazon 2.84% 7.9% Amazon 0.39 1 20% CVS 0.42% 8.4% CVS 0.03 0.31 1 What is the expected monthly return on this portfolio? What is the monthly portfolio standard deviation? What is the probability that this portfolio will have...
A researcher thinks the proportion of breakdowns for cars is different for different colors of cars....
A researcher thinks the proportion of breakdowns for cars is different for different colors of cars. In order to support his theory, He collects the following data from an auto repair shop: red white blue black metallic observed 19 21 25 18 27 expected Using a chi-square goodness of fit test, is this evidence significant at ? State hypotheses, report test statistic and p-value and a conclusion.
A prolific artist, Pablo Picasso (1881-1973) painted 1,000 paintings during what is known as his “Blue...
A prolific artist, Pablo Picasso (1881-1973) painted 1,000 paintings during what is known as his “Blue Period”, and all thousand paintings are on display and hanging in galleries throughout the world. a) Draw the supply curve for Picasso’s Blue period works. Why is this supply curve different from other ones you have seen that follow the Law of Supply? b) Given your answer to a), the price of a Blue Period painting will be entirely dependent on what factors? Draw...
why do we see different colors come out when all the colors of white light enter...
why do we see different colors come out when all the colors of white light enter the drop? explain not only what happens but why explain why there is a second rainbow further out from the primary rainbow how is the second rainbow different from the primary(other then its position in the sky what explains why the sky is darker between the primary and secondary rainbow than above the primary?
 You are putting together a portfolio made up of four different stocks. ​ However, you are...
 You are putting together a portfolio made up of four different stocks. ​ However, you are considering two possible​ weightings:  Portfolio Weightings Asset Beta First Portfolio Second Portfolio A 2.5 10% 40% B 1 10% 40% C 0.5 40% 10% D -1.5 40% 10% 1.  What is the beta on each​ portfolio? and which portfolio is​ riskier? 2.  If the​ risk-free rate of interest were 4 percent and the market risk premium were 5 percent​, what rate of return would...
Use the list below to answer this question. Wastewater is made up of many different constituents,...
Use the list below to answer this question. Wastewater is made up of many different constituents, which one in your opinion create the greatest risks to human habitation? Natural habitation? Which ones are reasonably inert? Is treatment the only way to prevent these elements from entering the wastewater stream? •water ( > 95%) which is often added during flushing to carry the waste down a drain •Pathogens such as bacteria, viruses, prions and parasitic worms. •Non-pathogenic bacteria(> 100,000 / ml...
Describe the poor laws of canada that were made up two different types of relief, the...
Describe the poor laws of canada that were made up two different types of relief, the indoor and outdoor
 You are putting together a portfolio made up of four different stocks. ​ However, you are...
 You are putting together a portfolio made up of four different stocks. ​ However, you are considering two possible​ weightings: CHART BELOW a.  What is the beta on each​ portfolio? b.  Which portfolio is​ riskier? c.  If the​ risk-free rate of interest were 5 percent and the market risk premium were 7.5 percent​, what rate of return would you expect to earn from each of the​ portfolios? Portfolio Weightings Asset Beta First Portfolio Second Portfolio A 2.40 12​% 38​% B...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT