86 lines
6.2 KiB
HTML
Raw Normal View History

2023-09-01 00:14:38 -05:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>BarChart.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.literal {color: #cc7832}
.ST4 {font-family: monospace; font-weight: bold; font-style: italic}
.ST0 {color: #287bde}
.number {color: #6897bb}
.string {color: #6a8759}
.ST1 {color: #ffc66d}
.comment {color: #808080}
.whitespace {color: #505050}
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
.ST3 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/MP1_FX_CalebFontenot/src/mp1_fx_calebfontenot/BarChart.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> mp1_fx_calebfontenot;
<span class="literal">import</span> javafx.application.Application;
<span class="literal">import</span> javafx.scene.Scene;
<span class="literal">import</span> javafx.scene.layout.Pane;
<span class="literal">import</span> javafx.scene.paint.Color;
<span class="literal">import</span> javafx.scene.shape.Rectangle;
<span class="literal">import</span> javafx.scene.text.Text;
<span class="literal">import</span> javafx.stage.Stage;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> BarChart <span class="literal">extends</span> Application {
@Override
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">start</span>(Stage primaryStage) <span class="literal">throws</span> Exception {
Pane pane = <span class="literal">new</span> Pane();
<span class="literal">double</span> height = <span class="number">300</span>;
<span class="literal">double</span> panelHeight = <span class="number">150</span>;
Rectangle r1 = <span class="literal">new</span> Rectangle(<span class="number">1</span><span class="number">0</span>, panelHeight - height * <span class="number">0.2</span>, <span class="number">1</span><span class="number">00</span>, height * <span class="number">0.2</span>);
r1.setFill(Color.<span class="ST2">RED</span>);
Text text1 = <span class="literal">new</span> Text(<span class="number">1</span><span class="number">0</span>, panelHeight - height * <span class="number">0.2</span> - <span class="number">10</span>, <span class="string">&quot;</span><span class="string">Project -- 20%</span><span class="string">&quot;</span>);
Rectangle r2 = <span class="literal">new</span> Rectangle(<span class="number">10</span> + <span class="number">110</span>, panelHeight - height * <span class="number">0.1</span>, <span class="number">1</span><span class="number">00</span>, height * <span class="number">0.1</span>);
r2.setFill(Color.<span class="ST2">BLUE</span>);
Text text2 = <span class="literal">new</span> Text(<span class="number">10</span> + <span class="number">110</span>, panelHeight - height * <span class="number">0.1</span> - <span class="number">10</span>, <span class="string">&quot;</span><span class="string">Quiz -- 10%</span><span class="string">&quot;</span>);
Rectangle r3 = <span class="literal">new</span> Rectangle(<span class="number">10</span> + <span class="number">220</span>, panelHeight - height * <span class="number">0.3</span>, <span class="number">1</span><span class="number">00</span>, height * <span class="number">0.3</span>);
r3.setFill(Color.<span class="ST2">GREEN</span>);
Text text3 = <span class="literal">new</span> Text(<span class="number">10</span> + <span class="number">220</span>, panelHeight - height * <span class="number">0.3</span> - <span class="number">10</span>, <span class="string">&quot;</span><span class="string">Midterm -- 30%</span><span class="string">&quot;</span>);
Rectangle r4 = <span class="literal">new</span> Rectangle(<span class="number">10</span> + <span class="number">330</span>, panelHeight - height * <span class="number">0.4</span>, <span class="number">1</span><span class="number">00</span>, height * <span class="number">0.4</span>);
r4.setFill(Color.<span class="ST2">ORANGE</span>);
Text text4 = <span class="literal">new</span> Text(<span class="number">10</span> + <span class="number">330</span>, panelHeight - height * <span class="number">0.4</span> - <span class="number">10</span>, <span class="string">&quot;</span><span class="string">Final -- 40%</span><span class="string">&quot;</span>);
pane.getChildren().addAll(r1, text1, r2, text2, r3, text3, r4, text4);
<span class="comment">// Create a scene and place it in the stage</span>
Scene scene = <span class="literal">new</span> Scene(pane, <span class="number">5</span><span class="number">00</span>, panelHeight);
primaryStage.setTitle(<span class="string">&quot;</span><span class="string">Bar Chart</span><span class="string">&quot;</span>);
primaryStage.setScene(scene);
primaryStage.show();
}
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args) {
<span class="ST4">launch</span>(args);
}
}
</pre></body>
</html>