Skip to content

Commit

Permalink
Screenshots added and socket programming removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandesh-Sharma committed May 3, 2022
1 parent f59b8b5 commit c570a63
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 90 deletions.
Binary file added screenshots/kheladi1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/kheladi7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/main/java/com/javafinal/kheladi/DBUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ public static ArrayList<stockModel> getStocks(){
String name = resultSet.getString("Name");
int ltp = resultSet.getInt("LTP");
String sector = resultSet.getString("Type");
String priceChange = resultSet.getString("priceChange");

stocks.add(new stockModel(symbol,name,ltp,sector));
stocks.add(new stockModel(symbol,name,ltp,sector,priceChange));


}
Expand Down Expand Up @@ -276,8 +277,9 @@ public static ArrayList<stockModel> getMyStocks(String username){
String name = resultSet.getString("Name");
int ltp = resultSet.getInt("LTP");
String sector = resultSet.getString("Type");
String priceChange= resultSet.getString("priceChange");

myStocks.add(new stockModel(symbol,name,ltp,sector));
myStocks.add(new stockModel(symbol,name,ltp,sector,priceChange));
}
return myStocks;
}
Expand Down
86 changes: 85 additions & 1 deletion src/main/java/com/javafinal/kheladi/LoggedInController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javafx.fxml.Initializable;
import javafx.geometry.Bounds;
import javafx.geometry.Side;
import javafx.scene.chart.PieChart;
import javafx.scene.chart.*;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
Expand All @@ -31,6 +31,8 @@

public class LoggedInController implements Initializable {

ArrayList<stockModel> allStocks;

//Panes and different sections of application
@FXML private Pane pn_compare_stocks,pn_stock_news,pn_sectorwise;
@FXML private GridPane pn_my_stocks, pn_stocks;
Expand All @@ -55,6 +57,10 @@ public class LoggedInController implements Initializable {
@FXML private AnchorPane pn_profit_loss;
@FXML private VBox vbox_colour_change;

//lineGraph
@FXML private LineChart line_chart;
@FXML private ComboBox combo_company1, combo_company2;




Expand Down Expand Up @@ -123,9 +129,41 @@ public void initialize(URL location, ResourceBundle resources){
});


// line-Chart
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Month");


line_chart.setTitle("Stock Monitoring, 2022");

XYChart.Series series1 = new XYChart.Series();
series1.setName("NABIL");


series1.getData().add(new XYChart.Data("Jan", 23));
series1.getData().add(new XYChart.Data("Feb", 14));

series1.getData().add(new XYChart.Data("Sep", 43));
series1.getData().add(new XYChart.Data("Oct", 17));
series1.getData().add(new XYChart.Data("Nov", 29));
series1.getData().add(new XYChart.Data("Dec", 25));

XYChart.Series series2 = new XYChart.Series();
series2.setName("SWBBL");
series2.getData().add(new XYChart.Data("Jan", 33));
series2.getData().add(new XYChart.Data("Feb", 34));

series2.getData().add(new XYChart.Data("Sep", 48));
series2.getData().add(new XYChart.Data("Oct", 27));
series2.getData().add(new XYChart.Data("Nov", 37));
series2.getData().add(new XYChart.Data("Dec", 29));



line_chart.getData().addAll(series1, series2);





Expand All @@ -136,8 +174,37 @@ public void initialize(URL location, ResourceBundle resources){
public void handle(ActionEvent actionEvent) {
DBUtils.changeScene(actionEvent,"login-view.fxml","Login", null, null,null,null);


}});}

//After first company is choosen in the combo box.
@FXML
private void firstCompanyChoosen (){

if (combo_company1.getValue() != null){
ArrayList<stockModel> tempStocks= allStocks;
ArrayList<String> remainingStocksSymbol= new ArrayList<>();
combo_company2.setDisable(false);

for (stockModel s: allStocks
) {
tempStocks.removeIf(t->(t.getSymbol().equals( combo_company1.getValue().toString())));}

for (stockModel stock:tempStocks
) {

remainingStocksSymbol.add(stock.getSymbol());

}
combo_company1.setItems(FXCollections.observableArrayList(remainingStocksSymbol));

}





}

// handle clicks of category items
@FXML
Expand Down Expand Up @@ -200,6 +267,11 @@ else if(event.getSource()==btn_stocks){
}


}

@FXML private void handleCompare(){


}


Expand Down Expand Up @@ -239,6 +311,7 @@ else if (profitLossCalculator.calculateNetGain()==0){

// Dashboard welcome and type label
public void setUserInformation(String username, String type, ArrayList<stockModel> stocks, ArrayList<stockModel> myStocks){
allStocks = stocks;
label_welcome.setText(username);
label_kheladi_type.setText(type);
for (int i=0; i<stocks.size();i++) {
Expand All @@ -255,6 +328,7 @@ public void setUserInformation(String username, String type, ArrayList<stockMode
// Find out remaining stock which is not in my stocks for adding it to combobox.
ArrayList<stockModel> tempStocks = stocks;
ArrayList<String> remainingStocksSymbol = new ArrayList();
ArrayList<String> allStocksSymbol = new ArrayList<>();
for (stockModel s: myStocks
) {
tempStocks.removeIf(t->(t.getSymbol().equals( s.getSymbol())));}
Expand All @@ -264,7 +338,17 @@ public void setUserInformation(String username, String type, ArrayList<stockMode

remainingStocksSymbol.add(stock.getSymbol());

}
for (stockModel stock:stocks
) {

allStocksSymbol.add(stock.getSymbol());

}
combo_stocks.setItems(FXCollections.observableArrayList(remainingStocksSymbol));
combo_company1.setItems(FXCollections.observableArrayList(allStocksSymbol));



}
}
15 changes: 14 additions & 1 deletion src/main/java/com/javafinal/kheladi/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Main extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("login-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 700, 500);
stage.setResizable(false);
stage.setTitle("Hello!");
stage.initStyle(StageStyle.UNDECORATED);
stage.setTitle("Kheladi");
stage.setScene(scene);
stage.show();



}

public static void main(String[] args) {
launch();

}
}
7 changes: 4 additions & 3 deletions src/main/java/com/javafinal/kheladi/stockModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ public class stockModel {
private String name;
private int ltp;
private String sector;
private String priceChange;

public stockModel(String symbol, String name, int ltp, String sector){
public stockModel(String symbol, String name, int ltp, String sector,String priceChange){
this.name = name;
this.symbol = symbol;
this.ltp = ltp;
this.sector = sector;
this.priceChange= priceChange;
}
public String getSymbol(){return symbol;}
public String getName(){return name;}
public int getLtp(){return ltp;}
public String getSector(){return sector; }


public String getPriceChange(){return priceChange;}

}
71 changes: 38 additions & 33 deletions src/main/resources/com/javafinal/kheladi/logged-in.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<AnchorPane prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.javafinal.kheladi.LoggedInController">
<children>
<Label fx:id="label_kheladi_type" layoutX="316.0" layoutY="4.0" text="Kheladi_ type" />
<Label fx:id="label_kheladi_type" layoutX="316.0" layoutY="4.0" text="Kheladi_ type" underline="true" />
<VBox prefHeight="500.0" prefWidth="228.0" style="-fx-background-color: #001029;">
<children>
<ImageView fitHeight="186.0" fitWidth="199.0" pickOnBounds="true" preserveRatio="true">
Expand All @@ -27,60 +27,50 @@
</font>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding></Button>
</VBox.margin></Button>
<Button fx:id="btn_stocks" graphicTextGap="10.0" layoutX="15.0" layoutY="274.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="All Stocks" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding>
</Button>
<Button fx:id="btn_my_stocks" graphicTextGap="10.0" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="My Stocks" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding></Button>
</VBox.margin></Button>
<Button fx:id="btn_compare_stocks" graphicTextGap="10.0" layoutX="10.0" layoutY="48.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="Compare Stocks" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding></Button>
</VBox.margin></Button>
<Button fx:id="btn_sectorwise" graphicTextGap="10.0" layoutX="10.0" layoutY="125.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="SectorWise" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding></Button>
</VBox.margin></Button>
<Button fx:id="btn_stock_news" graphicTextGap="10.0" layoutX="10.0" layoutY="87.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="Profit/Loss Calculator" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding></Button>
</VBox.margin></Button>
<Button fx:id="btn_stock_news1" graphicTextGap="10.0" layoutX="15.0" layoutY="442.0" mnemonicParsing="false" onAction="#handleClicks" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" prefHeight="38.0" prefWidth="230.0" style="-fx-background-color: #1d0024;" text="Nepse News" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font>
</Button>
</children></VBox>
<Label fx:id="label_welcome" layoutX="240.0" layoutY="4.0" text="Welcome" />
<Label fx:id="label_welcome" layoutX="240.0" layoutY="4.0" style="-fx-border-color: #102900;" text="Welcome">
<font>
<Font name="Arial Rounded MT Bold" size="13.0" />
</font></Label>
<Button fx:id="button_logout" layoutX="623.0" layoutY="8.0" mnemonicParsing="false" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" style="-fx-background-color: #001029;" text="Logout" textFill="WHITE">
<font>
<Font name="Arial Rounded MT Bold" size="14.0" />
Expand Down Expand Up @@ -289,26 +279,41 @@
</VBox>
</children>
</Pane>
<WebView fx:id="myWebView" prefHeight="364.0" prefWidth="470.0">
<StackPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</StackPane.margin></WebView>
<Pane fx:id="pn_compare_stocks" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: white;">
<Pane fx:id="pn_compare_stocks" prefHeight="352.0" prefWidth="461.0" style="-fx-background-color: white;">
<StackPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</StackPane.margin>
<children>
<ComboBox layoutX="20.0" layoutY="30.0" prefWidth="150.0" />
<ComboBox layoutX="297.0" layoutY="30.0" prefWidth="150.0" />
<LineChart layoutX="20.0" layoutY="74.0" prefHeight="268.0" prefWidth="228.0">
<LineChart fx:id="line_chart" layoutX="1.0" layoutY="62.0" prefHeight="273.0" prefWidth="461.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
<HBox alignment="CENTER" layoutY="12.0" prefHeight="46.0" prefWidth="460.0">
<children>
<ComboBox fx:id="combo_company1" onAction="#firstCompanyChoosen" prefHeight="26.0" prefWidth="139.0" promptText="Choose first stock" style="-fx-border-color: #102900;" />
<Button fx:id="btn_compare" mnemonicParsing="false" onAction="#handleCompare" onMouseEntered="#mouseEnter" onMouseExited="#mouseExit" style="-fx-background-color: #102900;" text="Compare Now" textFill="WHITE">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<HBox.margin>
<Insets bottom="5.0" left="20.0" right="20.0" top="5.0" />
</HBox.margin>
<font>
<Font name="Arial Rounded MT Bold" size="12.0" />
</font>
</Button>
<ComboBox fx:id="combo_company2" disable="true" prefHeight="26.0" prefWidth="139.0" promptText="Choose second stock" style="-fx-border-color: #102900;" />
</children>
</HBox>
</children></Pane>
<WebView fx:id="myWebView" prefHeight="364.0" prefWidth="470.0">
<StackPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</StackPane.margin></WebView>
</children>
</StackPane>
<Pane layoutX="227.0" layoutY="47.0" prefHeight="70.0" prefWidth="477.0" style="-fx-background-color: #102900;">
Expand Down
Loading

0 comments on commit c570a63

Please sign in to comment.