-
Notifications
You must be signed in to change notification settings - Fork 2
/
ArtistPage.java
336 lines (290 loc) · 12.8 KB
/
ArtistPage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
//ArtistID-tvoyrgpiw
//Password-kbmiaczcm
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ArtistPage extends Application {
int userID;
public ArtistPage(int id) {
userID = id;
}
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
GridPane grid = new GridPane();
grid.setPadding(new Insets(100,200,0,60));
grid.setVgap(20);
grid.setHgap(10);
String f="-fx-font-weight: bolder ; -fx-text-fill: white; -fx-font:20px sans-serif";
Label searchSong = new Label("Search Song");
searchSong.setStyle(f);
GridPane.setConstraints(searchSong,10,0);
final TextField search = new TextField();
search.setPromptText("Enter Song name");
GridPane.setConstraints(search,11,0);
Label lang=new Label("Language:");
lang.setStyle(f);
GridPane.setConstraints(lang,10,1);
final ChoiceBox<String> cb1=new ChoiceBox<String>();
cb1.getItems().addAll("English","Hindi","Punjabi","Korean","Gujrati","Any");
GridPane.setConstraints(cb1,11,1);
Label genre=new Label("Genre:");
genre.setStyle(f);
GridPane.setConstraints(genre,10,2);
final ChoiceBox<String> cb2=new ChoiceBox<String>();
cb2.getItems().addAll("Pop","Rock","Hip-Hop","R&B","Electronic","Classic","Country","Jazz","Romance","Any");
GridPane.setConstraints(cb2,11,2);
Label mood=new Label("Mood:");
mood.setStyle(f);
GridPane.setConstraints(mood,10,3);
final ChoiceBox<String> cb3=new ChoiceBox<String>();
cb3.getItems().addAll("Happy","Dance","Romantic","Meloncholy","Energetic","Romantic","Any");
GridPane.setConstraints(cb3,11,3);
Label filml = new Label("Film:");
filml.setStyle(f);
GridPane.setConstraints(filml,10,4);
final TextField film = new TextField();
film.setPromptText("Choose Film");
GridPane.setConstraints(film,11,4);
Label artistl = new Label("Artist:");
artistl.setStyle(f);
GridPane.setConstraints(artistl,10,5);
final TextField artist = new TextField();
artist.setPromptText("Choose Artist");
artist.setStyle("-fx-text-fill: #000000");
GridPane.setConstraints(artist,11,5);
Button searchButton=new Button();
searchButton.setText("Search");
searchButton.setStyle("-fx-text-fill: #0000ff; -fx-font: 17px Serif");
GridPane.setConstraints(searchButton,11,7);
Button back=new Button();
back.setText("Sign Out");
back.setStyle("-fx-text-fill: #0000ff; -fx-font: 17px Serif");
GridPane.setConstraints(back,11,8);
grid.getChildren().addAll(searchSong, lang, film, artist, mood, genre, search, cb1,cb2,cb3, filml, artistl, back, searchButton);
grid.setStyle("-fx-background-image: url('https://cdn.hipwallpaper.com/i/73/52/e0Q23r.jpg')");
EventHandler<ActionEvent> searchEvent=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try {
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Musify","root","sql@iiitdelhi");
Statement stmt=con.createStatement();
String query = "";
String language=cb1.getValue();
String genre=cb2.getValue();
String mood=cb3.getValue();
String f = film.getText();
String a = artist.getText();
String gID = "";
String mID = "";
String fID = "";
String aID = "";
String songName = search.getText();
if(film.getText() == null || film.getText().trim().isEmpty())
{
// f = "any(select distinct FilmName from FilmMakers)";
fID = "any(select distinct FilmID from FilmMakers)";
}
else
{
fID = "(select distinct FilmID from FilmMakers where FilmName = " +"\"" +f + "\")";
}
if(artist.getText() == null || artist.getText().trim().isEmpty())
{
aID = "any(select distinct ArtistID from Artist)";
}
else
{
aID = "(select distinct ArtistID from Artist where ArtistName = " +"\"" +a + "\")";
}
if(genre==null || genre.equals("Any"))
{
// genre = "any(select distinct GenreName from Genre)";
gID = "any(select distinct GenreID from Genre)";
}
else
{
gID = "(select distinct GenreID from Genre where GenreName = " + "\"" + genre + "\")";
}
if(mood == null || mood.equals("Any"))
{
// mood = "any(select distint MoodName from Mood";
mID = "any(select distinct MoodID from Mood)";
}
else
{
mID = "(select distinct MoodID from Mood where MoodName = " + "\"" + mood + "\")";
}
if(language==null || language.equals("Any"))
{
String [] languages = {"Hindi_Songs", "English_Songs", "Korean_Songs", "Punjabi_Songs", "Gujrati_Songs"};
String [] q = new String[5];
for(int i=0;i<5;i++)
{
if(search.getText() == null || search.getText().trim().isEmpty())
{
songName = "any(select distinct SongName from " + languages[i] +")";
}
else
{
songName = "\"" + songName +"\"";
}
q[i] = "select * from " +languages[i]+" where SongName = " + songName + " and ArtistID = " + aID + " and MoodID = " + mID + " and GenreID = "+ gID + " and FilmID = " + fID;
}
query = q[0] + " union " + q[1] + " union " +q[2]+" union "+q[3]+" union "+q[4]+";";
System.out.println(query);
}
else
{
if(search.getText() == null || search.getText().trim().isEmpty())
{
songName = "any(select distinct SongName from " + language + "_Songs)";
}
else
{
songName = "\"" + songName +"\"";
}
query = "select * from " +language + "_Songs"+" where SongName = " + songName + " and ArtistID = " + aID + " and MoodID = " + mID + " and GenreID = "+ gID + " and FilmID = " + fID +";" ;
System.out.println(query);
}
ResultSet rs=stmt.executeQuery(query);
new musiclibrary(rs, language, userID).start(primaryStage);
} catch (Exception w) {
System.out.println(w.toString());
}
}
};
searchButton.setOnAction(searchEvent);
EventHandler<ActionEvent> so = new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
new play().start(primaryStage);
}
};
back.setOnAction(so);
GridPane g2=new GridPane();
g2.setPadding(new Insets(80,200,0,50)); // top,right,bottom,left
g2.setVgap(20);
g2.setHgap(20);
Button profile=new Button();
profile.setText("My Profile");
profile.setMinSize(100,70);
GridPane.setConstraints(profile,0,0);
profile.setStyle("-fx-text-fill: #0000ff; -fx-font: 20px Serif");
EventHandler<ActionEvent> event1=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try
{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Musify","root","sql@iiitdelhi");
Statement sta=con.createStatement();
String q="select * from Artist where ArtistID = " + userID;
ResultSet rs=sta.executeQuery(q);
new ArtistProfile(rs).start(primaryStage);
//
}
catch (Exception w) {
System.out.println(w.toString());
}
}
};
profile.setOnAction(event1);
Button bio=new Button();
bio.setText("Change Bio");
bio.setMinSize(100,70);
GridPane.setConstraints(bio,0,2);
bio.setStyle("-fx-text-fill: #0000ff; -fx-font: 20px Serif");
EventHandler<ActionEvent> event2=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try {
new ArtistBio(userID).start(primaryStage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
//tvoyrgpiw
//kbmiaczcm
};
bio.setOnAction(event2);
Button mysong=new Button();
mysong.setText("My Songs");
mysong.setMinSize(100,70);
GridPane.setConstraints(mysong,0,4);
mysong.setStyle("-fx-text-fill: #0000ff; -fx-font: 20px Serif");
EventHandler<ActionEvent> event3=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try {
new ArtistSongs(userID).start(primaryStage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
};
mysong.setOnAction(event3);
Button payment=new Button();
payment.setText("Payment");
payment.setMinSize(100,70);
GridPane.setConstraints(payment,0,6);
payment.setStyle("-fx-text-fill: #0000ff; -fx-font: 20px Serif");
EventHandler<ActionEvent> event4=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try {
new ArtistPayment(userID).start(primaryStage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
//tvoyrgpiw
//kbmiaczcm
};
payment.setOnAction(event4);
Button addSong=new Button();
addSong.setText("Add Song");
addSong.setMinSize(100,70);
GridPane.setConstraints(addSong,0,7);
addSong.setStyle("-fx-text-fill: #0000ff; -fx-font: 20px Serif");
EventHandler<ActionEvent> addingSong=new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
try {
new ArtistSongAddition(userID).start(primaryStage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
//tvoyrgpiw
//kbmiaczcm
};
addSong.setOnAction(addingSong);
g2.setStyle("-fx-background-image: url('https://cdn.hipwallpaper.com/i/73/52/e0Q23r.jpg')");
g2.getChildren().addAll(profile,bio,mysong,payment, addSong);
HBox hBox=new HBox();
hBox.getChildren().addAll(g2, grid);
Scene scene=new Scene(hBox,1200,900);
primaryStage.setScene(scene);
primaryStage.show();
}
}