Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tp-4
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirkl-poo-2018
tp-4
Commits
0d9e2b8c
Commit
0d9e2b8c
authored
6 years ago
by
Alexis Durgnat
Browse files
Options
Downloads
Patches
Plain Diff
image added to chat message
parent
1e218dce
No related branches found
No related tags found
1 merge request
!21
*poof* final version
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/ch/hepia/ui/MainWindowController.java
+21
-20
21 additions, 20 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
src/main/resources/img/bubble.png
+0
-0
0 additions, 0 deletions
src/main/resources/img/bubble.png
with
21 additions
and
20 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
+
21
−
20
View file @
0d9e2b8c
...
@@ -16,8 +16,10 @@ import javafx.fxml.FXML;
...
@@ -16,8 +16,10 @@ import javafx.fxml.FXML;
import
javafx.fxml.Initializable
;
import
javafx.fxml.Initializable
;
import
javafx.scene.Node
;
import
javafx.scene.Node
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.control.*
;
import
javafx.scene.control.*
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.input.KeyCode
;
import
javafx.scene.input.KeyCode
;
import
javafx.scene.layout.Background
;
import
javafx.scene.layout.Background
;
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Color
;
...
@@ -31,9 +33,7 @@ import java.text.ParseException;
...
@@ -31,9 +33,7 @@ import java.text.ParseException;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.ResourceBundle
;
import
java.util.ResourceBundle
;
import
javafx.scene.image.Image
;
import
javafx.scene.layout.Pane
;
import
javafx.scene.layout.Pane
;
import
javafx.scene.layout.StackPane
;
public
class
MainWindowController
implements
Initializable
{
public
class
MainWindowController
implements
Initializable
{
...
@@ -111,32 +111,33 @@ public class MainWindowController implements Initializable {
...
@@ -111,32 +111,33 @@ public class MainWindowController implements Initializable {
*/
*/
private
void
drawConnection
(
Connection
connection
,
int
x
,
int
y
){
private
void
drawConnection
(
Connection
connection
,
int
x
,
int
y
){
List
<
Section
>
sections
=
connection
.
getSections
();
List
<
Section
>
sections
=
connection
.
getSections
();
connectionCanvas
.
getGraphicsContext2D
().
setFill
(
Color
.
RED
);
GraphicsContext
gcx
=
connectionCanvas
.
getGraphicsContext2D
();
connectionCanvas
.
getGraphicsContext2D
().
fillText
(
sections
.
get
(
0
).
getDeparture
().
getLocation
().
getName
(),
x
,
y
-
20
);
gcx
.
setFill
(
Color
.
RED
);
connectionCanvas
.
getGraphicsContext2D
().
setFill
(
Color
.
BLACK
);
gcx
.
fillText
(
sections
.
get
(
0
).
getDeparture
().
getLocation
().
getName
(),
x
,
y
-
20
);
connectionCanvas
.
getGraphicsContext2D
().
fillText
(
sections
.
get
(
0
).
getDeparture
().
getDepartureTime
().
toString
(),
x
,
y
-
40
);
gcx
.
setFill
(
Color
.
BLACK
);
connectionCanvas
.
getGraphicsContext2D
().
setFill
(
Color
.
RED
);
gcx
.
fillText
(
sections
.
get
(
0
).
getDeparture
().
getDepartureTime
().
toString
(),
x
,
y
-
40
);
connectionCanvas
.
getGraphicsContext2D
().
fillOval
(
x
-
5
,
y
-
5
,
10
,
10
);
gcx
.
setFill
(
Color
.
RED
);
connectionCanvas
.
getGraphicsContext2D
().
strokeLine
(
x
,
y
,
x
+
622
/
(
sections
.
size
()
+
1
),
y
);
gcx
.
fillOval
(
x
-
5
,
y
-
5
,
10
,
10
);
gcx
.
strokeLine
(
x
,
y
,
x
+
622
/
(
sections
.
size
()
+
1
),
y
);
for
(
int
i
=
0
;
i
<
sections
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
sections
.
size
();
i
++){
connectionCanvas
.
getGraphicsContext2D
()
.
strokeLine
(
gcx
.
strokeLine
(
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
,
622
/
(
sections
.
size
()),
y
);
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
,
622
/
(
sections
.
size
()),
y
);
connectionCanvas
.
getGraphicsContext2D
()
.
setFill
(
Color
.
RED
);
gcx
.
setFill
(
Color
.
RED
);
connectionCanvas
.
getGraphicsContext2D
()
.
fillOval
(
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
)
-
5
,
y
-
5
,
10
,
10
);
gcx
.
fillOval
(
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
)
-
5
,
y
-
5
,
10
,
10
);
connectionCanvas
.
getGraphicsContext2D
()
.
fillText
(
sections
.
get
(
i
).
getArrival
().
getLocation
().
getName
(),
gcx
.
fillText
(
sections
.
get
(
i
).
getArrival
().
getLocation
().
getName
(),
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
-
20
);
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
-
20
);
connectionCanvas
.
getGraphicsContext2D
()
.
setFill
(
Color
.
BLACK
);
gcx
.
setFill
(
Color
.
BLACK
);
connectionCanvas
.
getGraphicsContext2D
()
.
fillText
(
sections
.
get
(
i
).
getArrival
().
getArrivalTime
().
toString
(),
gcx
.
fillText
(
sections
.
get
(
i
).
getArrival
().
getArrivalTime
().
toString
(),
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
-
40
);
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
+
1
),
y
-
40
);
Journey
jrn
=
sections
.
get
(
i
).
getJourney
();
Journey
jrn
=
sections
.
get
(
i
).
getJourney
();
String
transportType
=
"MARCHE"
;
String
transportType
=
"MARCHE"
;
if
(!(
jrn
instanceof
Journey
.
EmptyJourney
))
{
if
(!(
jrn
instanceof
Journey
.
EmptyJourney
))
{
transportType
=
jrn
.
getCategory
()
+
", "
+
jrn
.
getNumber
();
transportType
=
jrn
.
getCategory
()
+
", "
+
jrn
.
getNumber
();
}
}
connectionCanvas
.
getGraphicsContext2D
()
.
setFill
(
Color
.
BLUE
);
gcx
.
setFill
(
Color
.
BLUE
);
connectionCanvas
.
getGraphicsContext2D
()
.
fillText
(
transportType
,
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
),
y
-
55
);
gcx
.
fillText
(
transportType
,
x
+
(
622
/
(
sections
.
size
()
+
1
))
*
(
i
),
y
-
55
);
connectionCanvas
.
getGraphicsContext2D
()
.
setFill
(
Color
.
RED
);
gcx
.
setFill
(
Color
.
RED
);
}
}
}
}
...
@@ -147,13 +148,13 @@ public class MainWindowController implements Initializable {
...
@@ -147,13 +148,13 @@ public class MainWindowController implements Initializable {
private
void
drawMessage
(
User
user
,
String
message
){
private
void
drawMessage
(
User
user
,
String
message
){
Pane
p
=
new
Pane
();
Pane
p
=
new
Pane
();
p
.
setMaxWidth
(
326
);
p
.
setMaxWidth
(
326
);
Image
lblImg
=
new
Image
(
Main
.
class
.
getResourceAsStream
(
"/img/bubble.png"
));
Label
msg
=
new
Label
();
Label
msg
=
new
Label
();
msg
.
setWrapText
(
true
);
msg
.
setWrapText
(
true
);
msg
.
setStyle
(
"-fx-padding: 8px"
);
msg
.
setStyle
(
"-fx-padding: 8px"
);
msg
.
setText
(
message
);
msg
.
setText
(
message
);
msg
.
setMaxWidth
(
310
);
msg
.
setMaxWidth
(
310
);
msg
.
setGraphic
(
new
ImageView
(
lblImg
));
p
.
getChildren
().
add
(
msg
);
p
.
getChildren
().
add
(
msg
);
insertMessageIntoQueue
();
insertMessageIntoQueue
();
chatContainer
.
getChildren
().
add
(
p
);
chatContainer
.
getChildren
().
add
(
p
);
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/img/bubble.png
0 → 100644
+
0
−
0
View file @
0d9e2b8c
15.6 KiB
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