Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Team 14 - IDATT1002
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eirik Steira
Team 14 - IDATT1002
Commits
4a6490b9
Commit
4a6490b9
authored
5 years ago
by
Lars Brodin Østby
Committed by
Eirik Steira
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add singøe image upload
parent
f6523c6a
No related branches found
No related tags found
2 merge requests
!104
Weekly merge to Master
,
!75
Single photo upload
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
+129
-93
129 additions, 93 deletions
src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
with
129 additions
and
93 deletions
src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
+
129
−
93
View file @
4a6490b9
package
NTNU.IDATT1002.controllers
;
import
NTNU.IDATT1002.App
;
import
NTNU.IDATT1002.ApplicationState
;
import
NTNU.IDATT1002.models.Tag
;
import
NTNU.IDATT1002.models.User
;
import
NTNU.IDATT1002.service.ImageService
;
import
java.io.File
;
import
java.util.Arrays
;
import
java.util.List
;
import
javafx.event.ActionEvent
;
import
javafx.fxml.Initializable
;
import
javafx.scene.control.Button
;
...
...
@@ -17,103 +24,132 @@ import java.util.ResourceBundle;
/**
* Controls the buttons and changeable elements on upload_single.fxml,
* a page where you add descriptions to your selected image
*
* @version 1.0 22.03.2020
*/
public
class
UploadedSingle
implements
Initializable
{
public
ImageView
tbar_logo
;
public
TextField
tbar_search
;
public
Button
tbar_searchBtn
;
public
Button
tbar_explore
;
public
Button
tbar_map
;
public
Button
tbar_upload
;
public
TextField
photo_title
;
public
TextField
photo_tag
;
public
TextArea
photo_desc
;
public
ImageView
photo_image
;
public
Button
acceptBtn
;
public
Button
tbar_albums
;
/**
* Method that runs when the controller is loaded
* Sets the image url on the page to be the uploaded images url
* @param location
* @param resources
*/
public
void
initialize
(
URL
location
,
ResourceBundle
resources
)
{
photo_image
.
setImage
(
new
Image
(
App
.
ex
.
getUploadedFiles
().
get
(
0
).
toURI
().
toString
()));
}
/**
* Method that changes scene to Main page
* @param mouseEvent
* @throws IOException
*/
public
void
switchToMain
(
MouseEvent
mouseEvent
)
throws
IOException
{
App
.
setRoot
(
"main"
);
}
/**
* Method that changes scene to Search page. It reads the value of the search
* field and if not empty it is passed to dataexchange
* @param actionEvent
* @throws IOException
*/
public
void
switchToSearch
(
ActionEvent
actionEvent
)
throws
IOException
{
if
(!
tbar_search
.
getText
().
isEmpty
()){
App
.
ex
.
setSearchField
(
tbar_search
.
getText
());
}
App
.
setRoot
(
"search"
);
}
/**
* Method that changes scene to Explore page
* @param actionEvent
* @throws IOException
*/
public
void
switchToExplore
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"explore"
);
}
/**
* Method that changes scene to Albums page
* @param actionEvent
* @throws IOException
*/
public
void
switchToAlbums
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"explore_albums"
);
}
/**
* Method that changes scene to Map page
* @param actionEvent
* @throws IOException
*/
public
void
switchToMap
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"map"
);
}
/**
* Method that changes scene to Upload page
* @param actionEvent
* @throws IOException
*/
public
void
switchToUpload
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"upload"
);
}
/**
* Method for uploading image to database with title, tags and description
* Image itself is not stored but URL is
* @param actionEvent
* @throws IOException
*/
public
void
uploadSingle
(
ActionEvent
actionEvent
)
throws
IOException
{
//TODO: write method to accept and upload the photo with chosen settings, titles...
App
.
setRoot
(
"main"
);
ImageService
imageService
;
NTNU
.
IDATT1002
.
models
.
Image
image
;
ApplicationState
applicationState
;
public
ImageView
tbar_logo
;
public
TextField
tbar_search
;
public
Button
tbar_searchBtn
;
public
Button
tbar_explore
;
public
Button
tbar_map
;
public
Button
tbar_upload
;
public
TextField
photo_title
;
public
TextField
photo_tag
;
public
TextArea
photo_desc
;
public
ImageView
photo_image
;
public
Button
acceptBtn
;
public
Button
tbar_albums
;
/**
* Method that runs when the controller is loaded
* Sets the image url on the page to be the uploaded images url
*
* @param location
* @param resources
*/
public
void
initialize
(
URL
location
,
ResourceBundle
resources
)
{
photo_image
.
setImage
(
new
Image
(
App
.
ex
.
getUploadedFiles
().
get
(
0
).
toURI
().
toString
()));
}
/**
* Method that changes stage to Main page
*
* @param mouseEvent
* @throws IOException
*/
public
void
switchToMain
(
MouseEvent
mouseEvent
)
throws
IOException
{
App
.
setRoot
(
"main"
);
}
/**
* Method that changes stage to Search page. It reads the value of the search
* field and if not empty it is passed to dataexchange
*
* @param actionEvent
* @throws IOException
*/
public
void
switchToSearch
(
ActionEvent
actionEvent
)
throws
IOException
{
if
(!
tbar_search
.
getText
().
isEmpty
())
{
App
.
ex
.
setSearchField
(
tbar_search
.
getText
());
}
App
.
setRoot
(
"search"
);
}
/**
* Method that changes stage to Explore page
*
* @param actionEvent
* @throws IOException
*/
public
void
switchToExplore
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"explore"
);
}
/**
* Method that changes stage to Albums page
*
* @param actionEvent
* @throws IOException
*/
public
void
switchToAlbums
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"explore_albums"
);
}
/**
* Method that changes stage to Map page
*
* @param actionEvent
* @throws IOException
*/
public
void
switchToMap
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"map"
);
}
/**
* Method that changes stage to Upload page
*
* @param actionEvent
* @throws IOException
*/
public
void
switchToUpload
(
ActionEvent
actionEvent
)
throws
IOException
{
App
.
setRoot
(
"upload"
);
}
/**
* Method for uploading image to database with title, tags and description
* Image itself is not stored but URL is
*
* @param actionEvent
* @throws IOException
*/
public
void
uploadSingle
(
ActionEvent
actionEvent
)
throws
IOException
{
String
tagTekst
=
photo_tag
.
toString
();
List
<
File
>
list
=
App
.
ex
.
getUploadedFiles
();
list
.
stream
().
forEach
(
x
->
{
image
=
imageService
.
createImage
(
applicationState
.
getCurrentUser
(),
x
).
get
();
List
tags
=
chopChopStringiBoi
(
tagTekst
);
tags
.
stream
().
forEach
(
y
->
{
imageService
.
addTagToImage
(
image
,
new
Tag
((
Tag
)
y
));
});
});
App
.
setRoot
(
"main"
);
}
public
List
<
String
>
chopChopStringiBoi
(
String
tagTekst
)
{
List
<
String
>
tags
=
Arrays
.
asList
(
tagTekst
.
split
(
" #"
));
return
tags
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment