Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simulator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
letsgoING
ArduBlock Source
Simulator
Commits
48a33260
Commit
48a33260
authored
Feb 16, 2021
by
Leon Dieter
Browse files
Options
Downloads
Patches
Plain Diff
nullpointer exception problem/simulator problem when resized
parent
bb9cde2f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tec/letsgoing/ardublock/simulator/Simulator.java
+38
-1
38 additions, 1 deletion
src/tec/letsgoing/ardublock/simulator/Simulator.java
src/tec/letsgoing/ardublock/simulator/view/GUI.java
+42
-8
42 additions, 8 deletions
src/tec/letsgoing/ardublock/simulator/view/GUI.java
with
80 additions
and
9 deletions
src/tec/letsgoing/ardublock/simulator/Simulator.java
+
38
−
1
View file @
48a33260
...
@@ -104,7 +104,7 @@ public class Simulator implements Runnable, ActionListener{
...
@@ -104,7 +104,7 @@ public class Simulator implements Runnable, ActionListener{
}
}
/**
/**
* Startet de
n
Simulation<br>
* Startet d
i
e Simulation<br>
* Wird durch den Play-Button gestartet.
* Wird durch den Play-Button gestartet.
*/
*/
public
void
startSimu
()
{
public
void
startSimu
()
{
...
@@ -179,6 +179,42 @@ public class Simulator implements Runnable, ActionListener{
...
@@ -179,6 +179,42 @@ public class Simulator implements Runnable, ActionListener{
for
(
SimCodeFunction
function
:
functionsCode
)
{
for
(
SimCodeFunction
function
:
functionsCode
)
{
arduino
.
addFunction
(
function
);
arduino
.
addFunction
(
function
);
}
}
startSimu
();
return
true
;
}
public
boolean
reloadGUI
(
GUI
currentGUI
)
{
if
(
simuThread
instanceof
Thread
)
{
stopSimu
();
try
{
simuThread
.
join
();
}
catch
(
InterruptedException
e
)
{
// e.printStackTrace();
arduino
.
errorAbort
(
"Thread Überwachung gestört - Bitte Programm neustarten"
);
return
false
;
}
}
gui
.
stopThread
();
this
.
gui
=
currentGUI
;
arduino
=
new
Arduino
(
gui
);
gui
.
connectPins
(
arduino
);
guiThread
=
new
Thread
(
gui
);
guiThread
.
start
();
for
(
SimCodeFunction
function
:
functionsCode
)
{
arduino
.
addFunction
(
function
);
}
startSimu
();
return
true
;
return
true
;
}
}
...
@@ -196,6 +232,7 @@ public class Simulator implements Runnable, ActionListener{
...
@@ -196,6 +232,7 @@ public class Simulator implements Runnable, ActionListener{
}
}
}
}
startSimu
();
startSimu
();
//System.out.println("reset");
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/tec/letsgoing/ardublock/simulator/view/GUI.java
+
42
−
8
View file @
48a33260
...
@@ -53,8 +53,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -53,8 +53,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
private
Modul
[]
modules
=
new
Modul
[
4
];
private
Modul
[]
modules
=
new
Modul
[
4
];
private
volatile
boolean
stopFlag
=
false
;
private
volatile
boolean
stopFlag
=
false
;
private
JTextArea
serialLog
=
new
JTextArea
();
private
JTextArea
serialLog
=
new
JTextArea
();
private
static
int
xscale
=
720
;
private
static
int
xscale
=
1500
;
private
static
int
yscale
=
720
;
private
static
int
yscale
=
1000
;
private
JPanel
modulPanel
;
private
Container
mainPane
;
/**
/**
* Konstruktor der Klasse GUI
* Konstruktor der Klasse GUI
...
@@ -63,14 +65,29 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -63,14 +65,29 @@ public class GUI extends JFrame implements Runnable, ActionListener {
*/
*/
public
GUI
(
Simulator
simu
)
{
public
GUI
(
Simulator
simu
)
{
super
(
"ArduBlock Simulator"
);
super
(
"ArduBlock Simulator"
);
createGUI
(
simu
);
this
.
addComponentListener
(
new
ComponentListener
()
{
this
.
addComponentListener
(
new
ComponentListener
()
{
@Override
@Override
public
void
componentResized
(
ComponentEvent
e
)
{
public
void
componentResized
(
ComponentEvent
e
)
{
if
(!(
xscale
==
getWidth
()
&&
yscale
==
getHeight
()))
{
if
(
modulPanel
.
getWidth
()
<=
modulPanel
.
getHeight
())
{
xscale
=
getWidth
();
xscale
=
getWidth
();
yscale
=
getHeight
();
yscale
=
getHeight
();
}
else
{
xscale
=
getWidth
();
yscale
=
getHeight
();
}
updating
(
simu
);
System
.
out
.
println
(
"xScale: "
+
xscale
+
"\tyScale: "
+
yscale
);
System
.
out
.
println
(
"xScale: "
+
xscale
+
"\tyScale: "
+
yscale
);
}
}
}
@Override
@Override
public
void
componentMoved
(
ComponentEvent
e
)
{
public
void
componentMoved
(
ComponentEvent
e
)
{
...
@@ -92,6 +109,23 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -92,6 +109,23 @@ public class GUI extends JFrame implements Runnable, ActionListener {
});
});
}
public
void
updating
(
Simulator
simu
)
{
mainPane
.
removeAll
();
createGUI
(
simu
);
//simu.reloadGUI(this);
}
public
void
createGUI
(
Simulator
simu
)
{
// Konstruktor der Module
// Konstruktor der Module
modules
[
0
]
=
new
RGB
(
new
ImageIcon
(
getToolkit
()
modules
[
0
]
=
new
RGB
(
new
ImageIcon
(
getToolkit
()
.
getImage
(
GUI
.
class
.
getResource
(
"/tec/letsgoing/ardublock/simulator/img/PM31_RGB_LED.png"
))));
.
getImage
(
GUI
.
class
.
getResource
(
"/tec/letsgoing/ardublock/simulator/img/PM31_RGB_LED.png"
))));
...
@@ -114,10 +148,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -114,10 +148,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
this
.
setResizable
(
true
);
//TODO Muss in true ge�ndert werden wenn skalierbar
this
.
setResizable
(
true
);
//TODO Muss in true ge�ndert werden wenn skalierbar
Container
mainPane
=
this
.
getContentPane
();
mainPane
=
this
.
getContentPane
();
// Panel welches alle Module sowie die Verdrahtung enth�lt.
// Panel welches alle Module sowie die Verdrahtung enth�lt.
JPanel
modulPanel
=
new
JPanel
(
new
BorderLayout
())
{
modulPanel
=
new
JPanel
(
new
BorderLayout
())
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@Override
@Override
...
@@ -137,12 +171,12 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -137,12 +171,12 @@ public class GUI extends JFrame implements Runnable, ActionListener {
//Panel der Buttons auf der rechten Seite wird ausgeblendet
//Panel der Buttons auf der rechten Seite wird ausgeblendet
//mainPane.add(createControlPanel(simu), BorderLayout.LINE_END);
//mainPane.add(createControlPanel(simu), BorderLayout.LINE_END);
mainPane
.
add
(
createSerialLog
(),
BorderLayout
.
PAGE_END
);
mainPane
.
add
(
createSerialLog
(),
BorderLayout
.
PAGE_END
);
this
.
pack
();
this
.
setSize
(
xscale
,
yscale
);
// this.setLocation(-1300, 0); //M�glichkeit die Renderingposition festzulegen
//this.pack();
// this.setLocation(-1300, 0); //Mglichkeit die Renderingposition festzulegen
this
.
setVisible
(
true
);
this
.
setVisible
(
true
);
}
}
/**
/**
...
...
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
sign in
to comment