Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAE2.01 - Developpement application
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIQUEREZ Corentin
SAE2.01 - Developpement application
Commits
6342ad2b
Commit
6342ad2b
authored
1 year ago
by
PIQUEREZ Corentin
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/main'
parents
699a4283
e2dd3bd9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shukan/ShukanController.java
+55
-8
55 additions, 8 deletions
shukan/ShukanController.java
with
55 additions
and
8 deletions
shukan/ShukanController.java
+
55
−
8
View file @
6342ad2b
...
@@ -2,6 +2,7 @@ package shukan;
...
@@ -2,6 +2,7 @@ package shukan;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.event.*
;
import
java.util.Stack
;
/**
/**
...
@@ -17,6 +18,7 @@ public class ShukanController
...
@@ -17,6 +18,7 @@ public class ShukanController
private
ShukanViewBar
bar
;
private
ShukanViewBar
bar
;
/** Controlled application data. */
/** Controlled application data. */
private
ShukanData
data
;
private
ShukanData
data
;
private
Stack
<
Integer
>
actionStack
;
/** Constructs a event handler.
/** Constructs a event handler.
* @param canvas display area.
* @param canvas display area.
...
@@ -25,6 +27,7 @@ public class ShukanController
...
@@ -25,6 +27,7 @@ public class ShukanController
this
.
canvas
=
canvas
;
this
.
canvas
=
canvas
;
this
.
bar
=
bar
;
this
.
bar
=
bar
;
this
.
data
=
data
;
this
.
data
=
data
;
this
.
actionStack
=
new
Stack
<>();
}
}
...
@@ -55,6 +58,13 @@ public class ShukanController
...
@@ -55,6 +58,13 @@ public class ShukanController
{
{
switch
(
e
.
getKeyCode
())
switch
(
e
.
getKeyCode
())
{
{
case
KeyEvent
.
VK_Z
:
if
(
pressed
&&
e
.
isControlDown
())
{
int
lastAction
=
actionStack
.
pop
();
revertAction
(
lastAction
);
}
break
;
case
KeyEvent
.
VK_Q
:
case
KeyEvent
.
VK_Q
:
case
KeyEvent
.
VK_ESCAPE
:
case
KeyEvent
.
VK_ESCAPE
:
if
(!
pressed
)
if
(!
pressed
)
...
@@ -92,7 +102,34 @@ public class ShukanController
...
@@ -92,7 +102,34 @@ public class ShukanController
}
}
}
}
private
void
revertAction
(
int
action
)
{
switch
(
action
)
{
case
0
:
canvas
.
deleteActivity
();
canvas
.
repaint
();
break
;
case
1
:
System
.
out
.
println
(
"revert delete activity"
);
break
;
case
2
:
data
.
followRight
();
canvas
.
repaint
();
break
;
case
3
:
data
.
followLeft
();
canvas
.
repaint
();
break
;
case
4
:
data
.
exchangeExtremes
();
canvas
.
repaint
();
break
;
case
5
:
data
.
toggleCursus
(
false
);
canvas
.
repaint
();
}
}
/** Invoked when a key has been typed.
/** Invoked when a key has been typed.
* Implementation from KeyListener.
* Implementation from KeyListener.
...
@@ -201,37 +238,47 @@ public class ShukanController
...
@@ -201,37 +238,47 @@ public class ShukanController
* @param e detected action event
* @param e detected action event
* */
* */
public
void
actionPerformed
(
ActionEvent
e
){
public
void
actionPerformed
(
ActionEvent
e
){
if
(
e
.
getSource
()==
bar
.
buttons
[
0
])
if
(
e
.
getSource
()==
bar
.
buttons
[
0
])
{
canvas
.
saveData
();
canvas
.
saveData
();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
1
])
}
System
.
out
.
println
(
"back"
);
else
if
(
e
.
getSource
()==
bar
.
buttons
[
1
])
{
int
lastAction
=
actionStack
.
pop
();
revertAction
(
lastAction
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
2
])
else
if
(
e
.
getSource
()==
bar
.
buttons
[
2
])
{
{
canvas
.
newActivity
();
canvas
.
newActivity
();
canvas
.
repaint
();
canvas
.
repaint
();
actionStack
.
push
(
0
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
3
])
{
canvas
.
deleteActivity
();
actionStack
.
push
(
1
);
}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
3
])
canvas
.
deleteActivity
();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
4
])
{
if
(
data
.
followLeft
())
canvas
.
repaint
();}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
4
])
{
if
(
data
.
followLeft
())
{
canvas
.
repaint
();
actionStack
.
push
(
2
);}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
5
])
{
if
(
data
.
followRight
())
canvas
.
repaint
();}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
5
])
{
if
(
data
.
followRight
())
{
canvas
.
repaint
();
actionStack
.
push
(
3
);}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
6
])
else
if
(
e
.
getSource
()==
bar
.
buttons
[
6
])
{
{
data
.
exchangeExtremes
();
data
.
exchangeExtremes
();
canvas
.
repaint
();
canvas
.
repaint
();
actionStack
.
push
(
4
);
}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
7
])
else
if
(
e
.
getSource
()==
bar
.
buttons
[
7
])
{
{
data
.
toggleCursus
(
false
);
data
.
toggleCursus
(
false
);
canvas
.
repaint
();
canvas
.
repaint
();
actionStack
.
push
(
5
);
}
}
//if (data.followRight ()) canvas.repaint ();
//if (data.followRight ()) canvas.repaint ();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
8
])
else
if
(
e
.
getSource
()==
bar
.
buttons
[
8
])
new
ShukanTex
(
data
);
new
ShukanTex
(
data
);
else
if
(
e
.
getSource
()==
bar
.
buttons
[
9
]){
else
if
(
e
.
getSource
()==
bar
.
buttons
[
9
]){
EventQueue
.
invokeLater
(()
->
{
EventQueue
.
invokeLater
(()
->
{
ShukanParameters
myParameters
=
new
ShukanParameters
(
"Changer de thème"
,
canvas
);
ShukanParameters
myParameters
=
new
ShukanParameters
(
"Changer de thème"
,
canvas
);
myParameters
.
setSize
(
300
,
300
);
myParameters
.
setSize
(
300
,
300
);
...
...
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